Skip to content

Commit 06b234a

Browse files
committed
Makefile,test: Ensure that the $ARTIFACTS_DIR is respected
Signed-off-by: timflannagan <[email protected]>
1 parent 0cded8b commit 06b234a

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

Diff for: Makefile

+1-2
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

Diff for: test/e2e/ctx/ctx.go

+15-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ type TestContext struct {
3737
packageClient pversioned.Interface
3838
ssaClient *controllerclient.ServerSideApplier
3939

40-
kubeconfigPath string
41-
artifactsDir string
40+
kubeconfigPath string
41+
artifactsDir string
42+
artifactsScriptPath string
4243

4344
scheme *runtime.Scheme
4445

@@ -116,8 +117,7 @@ func (ctx TestContext) DumpNamespaceArtifacts(namespace string) error {
116117
"KUBECONFIG=" + kubeconfigPath,
117118
}
118119

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

140+
if ctx.artifactsDir == "" {
141+
if artifactsDir := os.Getenv("ARTIFACTS_DIR"); artifactsDir != "" {
142+
ctx.artifactsDir = artifactsDir
143+
}
144+
}
145+
if ctx.artifactsScriptPath == "" {
146+
if scriptPath := os.Getenv("E2E_ARTIFACTS_SCRIPT"); scriptPath != "" {
147+
ctx.artifactsScriptPath = scriptPath
148+
}
149+
}
150+
140151
kubeClient, err := operatorclient.NewClientFromRestConfig(ctx.restConfig)
141152
if err != nil {
142153
return err

Diff for: test/e2e/ctx/provisioner_kind.go

+1-4
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

Diff for: test/e2e/e2e_test.go

+10
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",
@@ -79,6 +85,9 @@ var _ = BeforeSuite(func() {
7985
// This flag can be deprecated in favor of the kubeconfig provisioner:
8086
os.Setenv("KUBECONFIG", *kubeConfigPath)
8187
}
88+
if collectArtifactsScriptPath != nil && *collectArtifactsScriptPath != "" {
89+
os.Setenv("E2E_ARTIFACTS_SCRIPT", *collectArtifactsScriptPath)
90+
}
8291

8392
testNamespace = *namespace
8493
operatorNamespace = *olmNamespace
@@ -114,6 +123,7 @@ var _ = BeforeSuite(func() {
114123
HaveLen(1),
115124
ContainElement(Not(BeZero())),
116125
))
126+
117127
_, err := fetchCatalogSourceOnStatus(ctx.Ctx().OperatorClient(), "operatorhubio-catalog", operatorNamespace, catalogSourceRegistryPodSynced)
118128
Expect(err).NotTo(HaveOccurred())
119129

0 commit comments

Comments
 (0)