Skip to content
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

Ensure the $ARTIFACT_DIR variable is respected #2721

Conversation

timflannagan
Copy link
Contributor

@timflannagan timflannagan commented Mar 29, 2022

Description of the change:
#2432 had initially added support for CI to gather testing artifacts when the $ARTIFACT_DIR (#2729 renamed this variable from $ARTIFACTS_DIR from the original implementation) was specified, and the kind provisioner was responsible for running a bash script that fired off a series of kubectl commands at the namespace level. This functionality works fine for CI environments that are configured to use the make e2e-local target, but this kind of functionality wasn't emulated to also work with the kubeconfig provisioner that's used under-the-hood when users run make e2e directly.

These changes aim to consolidate both of those provisioner implementations so that both of them gathering testing artifacts when that variable has been specified, and an individual test case has failed.

Motivation for the change:
Ensure both the kubeconfig and kind provisioner(s) are able to collecting testing artifacts.

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive
  • Tests marked as [FLAKE] are truly flaky
  • Tests that remove the [FLAKE] tag are no longer flaky

@openshift-ci
Copy link

openshift-ci bot commented Mar 29, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: timflannagan

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 29, 2022
@@ -116,8 +117,7 @@ func (ctx TestContext) DumpNamespaceArtifacts(namespace string) error {
"KUBECONFIG=" + kubeconfigPath,
}

// compiled test binary running e2e tests is run from the root ./bin directory
cmd := exec.Command("../test/e2e/collect-ci-artifacts.sh")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into a sourcing issue when running the make e2e command locally as it's working directory points to ./test/e2e, so there's some skew between the working directory when using the kind or kubeconfig provisioners.

Comment on lines 88 to 90
if collectArtifactsScriptPath != nil && *collectArtifactsScriptPath != "" {
os.Setenv("E2E_ARTIFACTS_SCRIPT", *collectArtifactsScriptPath)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: there wasn't any clear way of injecting global state to the ctx package, and there weren't any setter methods so I wanted to avoid introducing that pattern, so we're using an internal environment variable to basically act as a cross-package variable. This is admittedly a bit hacky of an implementation so I'm open to suggestions.

@@ -137,6 +137,17 @@ func setDerivedFields(ctx *TestContext) error {
return fmt.Errorf("nil RESTClient")
}

if ctx.artifactsDir == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be in the clear there as we're building up the junit reporter for ginkgo vs. telling either of the provisioner implementation where to dump testing artifacts when configured.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: we could bubble up that downstream-only change to make upstream backwards-compatible to eliminate any skew between implementations (which might be relevant for any effort around ginkgo v1 -> v2)?

@timflannagan
Copy link
Contributor Author

I'll try and come back to this at some point.

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 6, 2022
@timflannagan
Copy link
Contributor Author

Ran these changes locally after rebasing against master:

$ make e2e ARTIFACT_DIR=./tmp E2E_INSTALL_NS=olm TEST="Not found APIs"
...
$ tree test/e2e/tmp
test/e2e/tmp
├── deprecated-e2e-pvt9s
│   ├── get_catalogsources_-o_yaml
│   ├── get_clusterserviceversions_-o_yaml
│   ├── get_events_--sort-by_.lastTimestamp
│   ├── get_installplans_-o_yaml
│   ├── get_operatorgroups_-o_yaml
│   ├── get_pods_-o_wide
│   └── get_subscriptions_-o_yaml
└── junit
    └── junit_e2e_01.xml

And I had updated one of the test cases in the deprecated e2e suite that's being focused on in that example to purposely fail:

-                               Expect(ctx.Ctx().Client().Status().Update(context.Background(), ip)).To(Succeed(), "failed to update the resource")
+                               Expect(ctx.Ctx().Client().Status().Update(context.Background(), ip)).ToNot(Succeed(), "failed to update the resource")

Comment on lines +88 to 91
if collectArtifactsScriptPath != nil && *collectArtifactsScriptPath != "" {
os.Setenv("E2E_ARTIFACT_SCRIPT", *collectArtifactsScriptPath)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: just a hack to inject state so the ctx package can derive where to find the artifacts bash script path location.

@timflannagan
Copy link
Contributor Author

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 7, 2022
@dinhxuanvu
Copy link
Member

Can we correct the title, commit message and all references to ARTIFACT_DIR given we just merged a PR to correct that?

@timflannagan timflannagan changed the title Ensure the $ARTIFACTS_DIR variable is respected Ensure the $ARTIFACT_DIR variable is respected Apr 7, 2022
This directory is populating when the e2e suite is supplied with an output $ARTIFACT_DIR, and the script that's responsible for gathering CI testing artifacts when a test case fails.

Signed-off-by: timflannagan <timflannagan@gmail.com>
Signed-off-by: timflannagan <timflannagan@gmail.com>
Copy link
Member

@dinhxuanvu dinhxuanvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 7, 2022
@openshift-merge-robot openshift-merge-robot merged commit 3f07f21 into operator-framework:master Apr 7, 2022
@timflannagan timflannagan deleted the ci/respect-artifacts-dir branch April 7, 2022 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants