Improve running end-to-end tests locally#972
Improve running end-to-end tests locally#972NBardelot wants to merge 7 commits intokubernetes:masterfrom
Conversation
* Allow users to run end-to-end tests with a fully-qualified and/or private alpine image * Allow users to run end-to-end tests behind a proxy * Sort .gitgnore for convenience for future diffs * Add .idea/ to .gitignore
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: NBardelot The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Allow the user running end-to-end tests to override the repository's URL in order to use a mirror if need be.
Introduces a new LIST_OF_E2E_TESTS option in order to select end-to-end tests that will be executed when calling `make test`. It uses the tests script's arguments parsing that already exists.
This reverts commit 560274698e3b42eaad01648a1afa81bc8e91ea0a.
Introduces a new LIST_OF_E2E_TESTS option in order to select end-to-end tests that will be executed when calling `make test`. It uses the tests script's arguments parsing that already exists.
thockin
left a comment
There was a problem hiding this comment.
I appreciate the PR, but I don't think we want this. The argument to test_e2e.sh is a pattern, not just a list, and besides that, you can just run the script. It's easier than passing a named argument to make.
Cf. my comment in the Running a subset of tests directly from By the way, you might already know of |
|
Somehow I only saw part of this PR when I looked at it before. I learned of bats well after I did all the work, so didn't bother to convert it. |
| fi | ||
|
|
||
| # Build it | ||
| # NOTE: If you want to run the end-to-end tests locally and you need specific Makefile arguments |
There was a problem hiding this comment.
why not pass the important args?
There was a problem hiding this comment.
At first glance I was surpised that the script was running its prerequisites by calling the Makefile. And I ended up calling the given goals ahead of time myself, and finding it simpler. The alternative would be to map 1..1 every Makefile arg as an env variable in the script, which is possible but not very practical.
There was a problem hiding this comment.
How many would we actually need to pass? On one hand this doesn't affect me personally so I could just not care. OTOH it feels like leaving a trap for future contributors...
| /bin/sh -c " \ | ||
| ./build/test.sh ./... \ | ||
| " | ||
| @if [ -n "$(HTTP_PROXY)" ]; then \ |
There was a problem hiding this comment.
Does this do anything? Each of these blocks runs in its own shell, so export has no meaning:
thockin@thockin-glaptop4:/tmp/m$ cat Makefile
foo:
@export FOO=bar
@echo $$FOO
bar:
@export FOO=bar; \
echo $$FOO
thockin@thockin-glaptop4:/tmp/m$ make foo
thockin@thockin-glaptop4:/tmp/m$ make bar
bar
There was a problem hiding this comment.
My bad. Let me add a commit to fix this.
I think someone who uses a proxy will have all three variables already configured in a dotenv file or profile, expecting the NO_PROXY standard variable to be passed alongside the two others. It looks strange when this one is not. So the goal here was to be consistent (and not having to debug why something will be routed through the proxy when the user's config contains an exclusion, for example: the private/local images registries, or the github project's local mirror).
There was a problem hiding this comment.
I'm fine with setting the variables for subprocesses. I don't understand what this specific change is doing.
If I apply this delta:
diff --git Makefile Makefile
index 4b1a9c0..3348685 100644
--- Makefile
+++ Makefile
@@ -278,6 +278,9 @@ test: $(BUILD_DIRS)
fi
VERBOSE=1 ./test_e2e.sh $(LIST_OF_E2E_TESTS)
+foo:
+ echo $$HTTP_PROXY $$HTTPS_PROXY $$NO_PROXY
+
TEST_TOOLS := $(shell find _test_tools/* -type d -printf "%f ")
test-tools: $(foreach tool, $(TEST_TOOLS), .container-test_tool.$(tool))
Here's what I see:
$ HTTP_PROXY=123 HTTPS_PROXY=456 NO_PROXY=789 make foo
123 456 789
$ make foo HTTP_PROXY=123 HTTPS_PROXY=456 NO_PROXY=789
123 456 789
$ sh -c "export HTTP_PROXY=123; export HTTPS_PROXY=456; export NO_PROXY=789; make foo"
123 456 789
In all 3 cases the variable are already passed down. Moreover, if I copy this pattern you have:
diff --git Makefile Makefile
index 4b1a9c0..1212d2f 100644
--- Makefile
+++ Makefile
@@ -278,6 +278,18 @@ test: $(BUILD_DIRS)
fi
VERBOSE=1 ./test_e2e.sh $(LIST_OF_E2E_TESTS)
+foo:
+ @if [ -n "$(HTTP_PROXY)" ]; then \
+ export HTTP_PROXY="111 $(HTTP_PROXY)"; \
+ fi
+ @if [ -n "$(HTTPS_PROXY)" ]; then \
+ export HTTPS_PROXY="222 $(HTTPS_PROXY)"; \
+ fi
+ @if [ -n "$(NO_PROXY)" ]; then \
+ export NO_PROXY="333 $(NO_PROXY)"; \
+ fi
+ echo $$HTTP_PROXY $$HTTPS_PROXY $$NO_PROXY
+
TEST_TOOLS := $(shell find _test_tools/* -type d -printf "%f ")
test-tools: $(foreach tool, $(TEST_TOOLS), .container-test_tool.$(tool))
I get:
$ HTTP_PROXY=123 HTTPS_PROXY=456 NO_PROXY=789 make foo
123 456 789
$ HTTP_PROXY=123 HTTPS_PROXY=456 NO_PROXY=789 make foo
123 456 789
$ sh -c "export HTTP_PROXY=123; export HTTPS_PROXY=456; export NO_PROXY=789; make foo"
123 456 789
The change you made to this rule doesn't DO anything. What problem spurred you to make this specific piece of the change?
test_e2e.sh
Outdated
| GIT_SYNC \ | ||
| --one-time \ | ||
| --repo="https://github.com/kubernetes/git-sync" \ | ||
| --repo="${GIT_SYNC_REPOSITORY_URL:-https://github.com/kubernetes/git-sync}" \ |
There was a problem hiding this comment.
Can I get something like:
local default_repo="https://github.com/kubernetes/git-sync"
local repo="${REMOTE_TEST_REPO_URL:-$default_repo}"
Makefile
Outdated
| # Allow alpine to be pulled from a private registry when building the end-to-end tests images | ||
| ALPINE_REGISTRY_PREFIX ?= | ||
|
|
||
| # By default all end-to-end tests are executed, but this allows for a manual selection |
There was a problem hiding this comment.
clarify that the values here are regexes against the testcase names
| echo $(VERSION) | ||
|
|
||
| # Run the 'test' goal in a single shell | ||
| test: .SHELLFLAGS = -c |
| /bin/sh -c " \ | ||
| ./build/test.sh ./... \ | ||
| " | ||
| @if [ -n "$(HTTP_PROXY)" ]; then \ |
There was a problem hiding this comment.
I'm fine with setting the variables for subprocesses. I don't understand what this specific change is doing.
If I apply this delta:
diff --git Makefile Makefile
index 4b1a9c0..3348685 100644
--- Makefile
+++ Makefile
@@ -278,6 +278,9 @@ test: $(BUILD_DIRS)
fi
VERBOSE=1 ./test_e2e.sh $(LIST_OF_E2E_TESTS)
+foo:
+ echo $$HTTP_PROXY $$HTTPS_PROXY $$NO_PROXY
+
TEST_TOOLS := $(shell find _test_tools/* -type d -printf "%f ")
test-tools: $(foreach tool, $(TEST_TOOLS), .container-test_tool.$(tool))
Here's what I see:
$ HTTP_PROXY=123 HTTPS_PROXY=456 NO_PROXY=789 make foo
123 456 789
$ make foo HTTP_PROXY=123 HTTPS_PROXY=456 NO_PROXY=789
123 456 789
$ sh -c "export HTTP_PROXY=123; export HTTPS_PROXY=456; export NO_PROXY=789; make foo"
123 456 789
In all 3 cases the variable are already passed down. Moreover, if I copy this pattern you have:
diff --git Makefile Makefile
index 4b1a9c0..1212d2f 100644
--- Makefile
+++ Makefile
@@ -278,6 +278,18 @@ test: $(BUILD_DIRS)
fi
VERBOSE=1 ./test_e2e.sh $(LIST_OF_E2E_TESTS)
+foo:
+ @if [ -n "$(HTTP_PROXY)" ]; then \
+ export HTTP_PROXY="111 $(HTTP_PROXY)"; \
+ fi
+ @if [ -n "$(HTTPS_PROXY)" ]; then \
+ export HTTPS_PROXY="222 $(HTTPS_PROXY)"; \
+ fi
+ @if [ -n "$(NO_PROXY)" ]; then \
+ export NO_PROXY="333 $(NO_PROXY)"; \
+ fi
+ echo $$HTTP_PROXY $$HTTPS_PROXY $$NO_PROXY
+
TEST_TOOLS := $(shell find _test_tools/* -type d -printf "%f ")
test-tools: $(foreach tool, $(TEST_TOOLS), .container-test_tool.$(tool))
I get:
$ HTTP_PROXY=123 HTTPS_PROXY=456 NO_PROXY=789 make foo
123 456 789
$ HTTP_PROXY=123 HTTPS_PROXY=456 NO_PROXY=789 make foo
123 456 789
$ sh -c "export HTTP_PROXY=123; export HTTPS_PROXY=456; export NO_PROXY=789; make foo"
123 456 789
The change you made to this rule doesn't DO anything. What problem spurred you to make this specific piece of the change?
| fi | ||
|
|
||
| # Build it | ||
| # NOTE: If you want to run the end-to-end tests locally and you need specific Makefile arguments |
There was a problem hiding this comment.
How many would we actually need to pass? On one hand this doesn't affect me personally so I could just not care. OTOH it feels like leaving a trap for future contributors...
alpineimageNO_PROXYparameter in theMakefilethat is propagated alongsideHTTP_PROXYandHTTPS_PROXYLIST_OF_E2E_TESTSparameter in theMakefilethat drives the names of the tests passed to./test_e2e.shto run a selection of tests, running all tests by defaultGIT_SYNC_REPOSITORY_URLin their environment, in order to use a mirror if need be.gitgnorefor convenience for future diffs.idea/to.gitignoreNOTE : I propose this in parallel of the feature request #970 as I had to make some adaptations locally to be able to run the end-to-end tests and I think they could be used by others. It completes the PR #971 that has already been merged.
/kind feature