-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the support to test against specified release of Knative serving #170
Add the support to test against specified release of Knative serving #170
Conversation
Hi @houshengbo. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks ! I have some suggestion to discuss wrt/ organizing the script.
test/e2e-tests.sh
Outdated
start_latest_knative_serving | ||
} | ||
export KNATIVE_SERVING_VERSION=latest | ||
source $(dirname $0)/e2e-common.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of sourcing the same file twice, could we put the actual test code into a reusable function which gets the target version as argument?
Its easier to maintain if you transport the input to a function with arguments and not global environment variables (which also avoid unwanted side effects because of this global state), and you can reuse it much easier e.g. when you want to add another version.
Therefore I would also roll up the code into a loop which makes it more concise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/e2e-common.sh
Outdated
|
||
initialize $@ | ||
|
||
header "Running tests" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we output the version to test again here, too ? Makes it easier to analyse test failures.
test/e2e-common.sh
Outdated
# Helper functions. | ||
|
||
function knative_setup() { | ||
start_release_knative_serving "$KNATIVE_SERVING_VERSION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this callback function is only easy to customize with an environment variable (as you can't change the signature). However, you could put this kind of implementation detail inside the function that is called from outside this script so that you can avoid to source this file twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function knative_setup
is called by source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.sh.
It has to be defined after source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.sh. Am I correct?
If it is defined in e2e-tests.sh with soucing github.com/knative/test-infra/scripts/e2e-tests.sh, I do not think it will be called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh, I don't think that e2e-tests.sh execute any codes, but only defines functions which can be called later. Otherwise knative_setup
would have to be defined before sourcing this file
As a rule of thumb: Any shell script which is source must only define functions or global environment variables (if they have to).
test/e2e-tests.sh
Outdated
./kn service delete hello || fail_test | ||
./kn service delete foo || fail_test | ||
success | ||
export KNATIVE_SERVING_VERSION=$PREVIOUS_RELEASE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more concrete, my suggestion would be something along those lines:
- e2e-tests.sh:
sourcce e2e-commons.sh
for version in latest $PREVIOUS_RELEASE; do
echon "===== Starting E2E tests for $version
run_tests $version
done
- e2e-common.sh:
run_tests() {
local $version=${1}
export KNATIVE_SERVING_VERSION=$version
initialize
header "[$version]: Running tests"
kn_tests
}
kn_tests() {
./kn service create hello --image gcr.io/knative-samples/helloworld-go -e TARGET=Knative || fail_test
sleep 5
./kn service get || fail_test
./kn service update hello --env TARGET=kn || fail_test
sleep 3
./kn revision get || fail_test
./kn service get || fail_test
./kn service create hello --force --image gcr.io/knative-samples/helloworld-go -e TARGET=Awesome || fail_test
./kn service create foo --force --image gcr.io/knative-samples/helloworld-go -e TARGET=foo || fail_testa
sleep 5
./kn revision get || fail_test
./kn service get || fail_test
./kn service describe hello || fail_test
./kn service delete hello || fail_test
./kn service delete foo || fail_test
success
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for putting the test code in functions. However, as mentioned in the review we must not couple ourselves to the internal functions of the e2e library.
I opened knative/test-infra#897 for updating the upstream script to allow a parameterization of the Knative installation against which we want to install.
test/e2e-common.sh
Outdated
# This method is copied from github.com/knative/test-infra/scripts/e2e-tests.sh, since the original var | ||
# $KNATIVE_SERVING_RELEASE is readonly. In order to make it changeable, we rewrite the method with another | ||
# variable $KNATIVE_SERVING_RELEASE_YAML. | ||
function start_release_knative_serving() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your motivation but we shouldn't do this, because:
- We don't benefit from changes in this method upstream
- When the overridden function gets renamed the script fails silently (because this method is just not called).
Instead we should push a change upstream to make the version to install parameterizable either via an argument or an environment variable.
Tbh I think its even a fault that this method can be overridden. This subtle coupling is really hard to debug.
Let me open an issue in the testing upstream repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it is good to see test-infra is able to support the installation of custom release number.
/ok-to-test |
/retest |
test/e2e-common.sh
Outdated
} | ||
|
||
echo "===== Starting E2E tests for Knative serving of the release $KNATIVE_SERVING_VERSION" | ||
run_tests $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the function call which will trigger everything. Up to this point, everything needs to be defined/sourced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I expect e22-common.sh to be a kind of library it should also only contain function definitions but must not call or execute any command when being included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you are heading in the right direction. However, you should take care to only call the final execution function run_tests
in the outermost script, not by calling or sourcing an external script. See the comments inline.
test/e2e-common.sh
Outdated
} | ||
|
||
echo "===== Starting E2E tests for Knative serving of the release $KNATIVE_SERVING_VERSION" | ||
run_tests $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I expect e22-common.sh to be a kind of library it should also only contain function definitions but must not call or execute any command when being included.
test/e2e-tests.sh
Outdated
success | ||
for version in "${listOfRelease[@]}"; do | ||
export KNATIVE_SERVING_VERSION=$version | ||
$(dirname $0)/e2e-common.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of calling out to e2e-commons.sh, call here run_tests $@
and source all function definitions before.
test/e2e-common.sh
Outdated
# Helper functions. | ||
|
||
function knative_setup() { | ||
start_release_knative_serving "$KNATIVE_SERVING_VERSION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh, I don't think that e2e-tests.sh execute any codes, but only defines functions which can be called later. Otherwise knative_setup
would have to be defined before sourcing this file
As a rule of thumb: Any shell script which is source must only define functions or global environment variables (if they have to).
The integration tests fails with a
(not sure where this comes from) and the client test fails because the deps have not been updated. @houshengbo could you please run a Let's hope that the integration test failure is just a flake. |
@rhuss Thanks for your comments. I am thinking of another way to fix this issue. |
yes, sounds good to me. Also if we could configure that as two different GitHub checks then it would be evident which one is failing. Also it helps in parallelizing the tests which should it make faster. |
@houshengbo There are some minor merge conflicts. Could you please fix them? I will review the PR in the meantime. Thanks ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments below.
And I would rename the variable to KNATIVE_SERVING_VERSION as it is really about installing Knative Serving (and we might want to have different numbers for Knative eventing when it enters the client)
test/e2e-tests.sh
Outdated
|
||
# Script entry point. | ||
|
||
initialize $@ | ||
|
||
header "Running tests" | ||
header "Running tests for Knative serving version of $KNATIVE_VERSION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Running tests for Knative serving $KNATIVE_VERSION"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -0,0 +1,21 @@ | |||
#!/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really get this file (but could be also my ignorance ;)
- Shouldn't it be called '...latest-release.sh' as it refers to the latest release whereas "latest" refers to HEAD of master (unreleased code). A bit confusing. Or maybe call it really with the version number ('presubmit-integration-tests-0.6.0.sh') and update the configuration that calls this file
- Who is calling this file ?
- Why it is calling presubmit checks and not the e2e tests like in e2e-tests.sh but with a environment variable set ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I would have expected something like
export KNATIVE_VERSION="0.6.0"
$(dirname $0)/e2e-tests.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked offline with @houshengbo . It's complicated (as the second job needs to be a custom job).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank @rhuss for his suggestion. We will use latest-release.
The repo test-infra defines four basic type of jobs, every PR can enable: integration-tests, build-tests, go-coverage, and unit-tests. We can only have four regular jobs, with one for each of them respectively. It means even if we would like to have a new INTEGRATION TEST, we need to go through CUSTOM TEST JOB in test-infra. We cannot use the existing presubmit-tests.sh --integration-tests
with more argument to specify the version or anything else, and we cannot use extra argument for command in CUSTOM TEST either. That was the reason we needed to have a separate script like this one, with the correct env var setting for a specific version, to launch separately with a CUSTOM TEST JOB in test-infra. BTW, another PR for test-infra related to this PR is knative/test-infra#954.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: houshengbo, rhuss The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks ! |
* Create a helper for running e2e go tests Let's hide the complexity of running e2e go tests in `e2e-tests.sh`. Bonus: move documentation to `README.md` to make it more visible. Part of knative#170. * Add kubectl call to example
This PR adds an environment variable $KNATIVE_VERSION for both e2e-tests.sh and presubmit-tests.sh, in order to specify the version of Knative serving to be installed.
Closes: #168