Skip to content

Commit efa6815

Browse files
timflannaganPer Goncalves da Silva
authored andcommitted
Ensure the $ARTIFACT_DIR variable is respected (#2721)
* .gitignore: Filter out the nested .kube cache 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 <[email protected]> * Makefile,test: Ensure that the $ARTIFACT_DIR is respected Signed-off-by: timflannagan <[email protected]> Upstream-repository: operator-lifecycle-manager Upstream-commit: 3f07f21154867a72009051ec3f4a831c4725050a
1 parent 21282cc commit efa6815

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

staging/operator-lifecycle-manager/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,5 +455,5 @@ apiserver.key
455455

456456
!vendor/**
457457
test/e2e-local.image.tar
458-
458+
test/e2e/.kube
459459
dist/

staging/operator-lifecycle-manager/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ E2E_TEST_NS ?= operators
139139
e2e:
140140
$(GINKGO) $(E2E_OPTS) $(or $(run), ./test/e2e) $< -- -namespace=$(E2E_TEST_NS) -olmNamespace=$(E2E_INSTALL_NS) -dummyImage=bitnami/nginx:latest $(or $(extra_args), -kubeconfig=${KUBECONFIG})
141141

142-
143142
# See workflows/e2e-tests.yml See test/e2e/README.md for details.
144143
.PHONY: e2e-local
145144
e2e-local: BUILD_TAGS="json1 experimental_metrics"
146-
e2e-local: extra_args=-kind.images=../test/e2e-local.image.tar -test-data-dir=../test/e2e/testdata
145+
e2e-local: extra_args=-kind.images=../test/e2e-local.image.tar -test-data-dir=../test/e2e/testdata -gather-artifacts-script-path=../test/e2e/collect-ci-artifacts.sh
147146
e2e-local: run=bin/e2e-local.test
148147
e2e-local: bin/e2e-local.test test/e2e-local.image.tar
149148
e2e-local: e2e

staging/operator-lifecycle-manager/test/e2e/ctx/ctx.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ type TestContext struct {
4242
e2eClient *util.E2EKubeClient
4343
ssaClient *controllerclient.ServerSideApplier
4444

45-
kubeconfigPath string
46-
artifactsDir string
45+
kubeconfigPath string
46+
artifactsDir string
47+
artifactsScriptPath string
4748

4849
scheme *runtime.Scheme
4950

@@ -132,8 +133,7 @@ func (ctx TestContext) DumpNamespaceArtifacts(namespace string) error {
132133
"KUBECONFIG=" + kubeconfigPath,
133134
}
134135

135-
// compiled test binary running e2e tests is run from the root ./bin directory
136-
cmd := exec.Command("../test/e2e/collect-ci-artifacts.sh")
136+
cmd := exec.Command(ctx.artifactsScriptPath)
137137
cmd.Env = append(cmd.Env, envvars...)
138138
cmd.Stdout = os.Stdout
139139
cmd.Stderr = os.Stderr
@@ -153,6 +153,17 @@ func setDerivedFields(ctx *TestContext) error {
153153
return fmt.Errorf("nil RESTClient")
154154
}
155155

156+
if ctx.artifactsDir == "" {
157+
if artifactsDir := os.Getenv("ARTIFACT_DIR"); artifactsDir != "" {
158+
ctx.artifactsDir = artifactsDir
159+
}
160+
}
161+
if ctx.artifactsScriptPath == "" {
162+
if scriptPath := os.Getenv("E2E_ARTIFACT_SCRIPT"); scriptPath != "" {
163+
ctx.artifactsScriptPath = scriptPath
164+
}
165+
}
166+
156167
kubeClient, err := operatorclient.NewClientFromRestConfig(ctx.restConfig)
157168
if err != nil {
158169
return err

staging/operator-lifecycle-manager/test/e2e/ctx/provisioner_kind.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build kind
12
// +build kind
23

34
package ctx
@@ -135,10 +136,6 @@ func Provision(ctx *TestContext) (func(), error) {
135136
return nil, fmt.Errorf("error loading kubeconfig: %s", err.Error())
136137
}
137138
ctx.restConfig = restConfig
138-
139-
if artifactsDir := os.Getenv("ARTIFACTS_DIR"); artifactsDir != "" {
140-
ctx.artifactsDir = artifactsDir
141-
}
142139
ctx.kubeconfigPath = kubeconfigPath
143140

144141
var once sync.Once

staging/operator-lifecycle-manager/test/e2e/e2e_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ var (
4242
"dummy image to treat as an operator in tests",
4343
)
4444

45+
collectArtifactsScriptPath = flag.String(
46+
"gather-artifacts-script-path",
47+
"./collect-ci-artifacts.sh",
48+
"configures the relative/absolute path to the script resposible for collecting CI artifacts",
49+
)
50+
4551
testdataPath = flag.String(
4652
"test-data-dir",
4753
"./testdata",
@@ -82,6 +88,9 @@ var _ = BeforeSuite(func() {
8288
// This flag can be deprecated in favor of the kubeconfig provisioner:
8389
os.Setenv("KUBECONFIG", *kubeConfigPath)
8490
}
91+
if collectArtifactsScriptPath != nil && *collectArtifactsScriptPath != "" {
92+
os.Setenv("E2E_ARTIFACT_SCRIPT", *collectArtifactsScriptPath)
93+
}
8594

8695
testNamespace = *namespace
8796
operatorNamespace = *olmNamespace

0 commit comments

Comments
 (0)