-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
tests: environement setup and other refactorings #3550
Conversation
@vdemeester just ping me, when it's ready to run on s390x env :) |
f6739b8
to
49da777
Compare
Note on possible follow-up:
|
a43eef5
to
9ce12f8
Compare
Oups 😅 |
This update the e2e tests suite to use `TestMain` in order to set up a environment object for the whole test. This object is meant to store anything that could be useful for the test to gather information from it and act based on it (skipping, getting the right image, …) In addition, this extract the clients into their own package, as well as the log helpers. It also refactor a bit how multi-arch is handled, by porting most of the feature into the environment. Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
9ce12f8
to
7aac53b
Compare
It is ready for review @barthy1 |
@@ -42,13 +45,17 @@ var ( | |||
// TestHelmDeployPipelineRun is an integration test that will verify a pipeline build an image | |||
// and then using helm to deploy it | |||
func TestHelmDeployPipelineRun(t *testing.T) { | |||
if testEnv.Platform == "linux/s390x" { | |||
t.Skipf("skip for s390x architecture") | |||
} |
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.
May be it's better to have 1 entry point for different e2e tests to skip, which can be extended for other architectures? For instance in setupWithCleanup
?
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 want to make the skip
very explicit per tests. Aka, if a test needs to be skip for whatever reason, it needs to be known when reading the test. In docker/docker
we used the concept of requirements
(requirements.IsNetworkAvailable
, …)
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.
ok, I have to say I like to keep related things in one place, just not to spam the code with if
statements for different cases (and many archs in the future), however I'd like to believe that all tests will work for all archs 🤞 and there won't be many exclusions required..
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.
example in docker/docker
: https://github.com/moby/moby/blob/master/integration/container/create_test.go#L74
return &Execution{ | ||
Clients: c, | ||
Info: v, | ||
Platform: v.Platform, |
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 really like this option to get platform
from actual target k8s cluster, so no need any more to use TEST_RUNTIME_ARCH
, in case when tests are initiated on machine of one arch, but will be executed on k8s cluster with another arch 👍
Can you also remove mention about this env variable from doc ?
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.
we can yes 🙃
// koCreate wraps the ko binary and invokes `ko create` for input within | ||
// namespace | ||
func koCreate(input []byte, namespace string) ([]byte, error) { | ||
cmd := exec.Command("ko", "create", "--platform", "linux/"+getTestArch(), "-n", namespace, "-f", "-") | ||
cmd := exec.Command("ko", "create", "--platform", testEnv.Platform, "-n", namespace, "-f", "-") |
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.
After test case "initiate tests on amd64, execute on s390x", learnt that --kubeconfig
should be added here. However it probably can be separate PR, as this functionality is not available in the initial code.
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.
@barthy1 I am not sure I understand 🤔
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.
If go test
is running with --kubeconfig
, ko create
won't have knowledge about the special kubeconfig and will be targeted to default cluster. So kubeconfig should be propagated to ko create
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.
@barthy1 ahhh very good point ! Yeah this can be done in a follow-up or now, I'll see if I've got some time to fix
the e2e and examples tests passed for s390x. Provided just a few suggestions from my side. |
/cc @tektoncd/core-maintainers |
@vdemeester: PR needs rebase. 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. |
if configFilePath == "" { | ||
t.Skip("GCP_SERVICE_ACCOUNT_KEY_PATH variable is not set.") | ||
if !testEnv.IsRunningOnGCP() { | ||
t.Skip("This tests only runs on GCP.\n GCP_SERVICE_ACCOUNT_KEY_PATH variable is not 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.
Nit: we're refererring to GCP_SERVICE_ACCOUNT_KEY_PATH
here as well as in IsRunningOnGCP()
. Could IsRunningOnGCP
return an error of form errors.New("GCP_SERVICE_ACCOUNT_KEY_PATH variable not set")
instead and then this code could just do t.Skip(fmt.Sprintf("This test only runs on GCP.\n%v", err))
. This way the "knowledge" of GCP_SERVICE_ACCOUNT_KEY_PATH is kept entirely with the IsRunningOnGCP
func.
Might even be worth putting "GCP_SERVICE_ACCOUNT_KEY_PATH"
into a named constant in testEnv
or alternatively create a func that looks it up? Then we could use it on line 64?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbwsg 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 |
@vdemeester: The following tests failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
/close |
@vdemeester: Closed this PR. In response to this:
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. |
Changes
This update the e2e tests suite to use
TestMain
in order to set up aenvironment object for the whole test. This object is meant to store
anything that could be useful for the test to gather information from
it and act based on it (skipping, getting the right image, …)
In addition, this extract the clients into their own package, as well
as the log helpers.
It also refactor a bit how multi-arch is handled, by porting most of
the feature into the environment.
There is a more improvements to do based on this, but this is a first step.
/kind misc
/area testing
/cc @barthy1 @imjasonh @mattmoor
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes