Skip to content

Commit ad497aa

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

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
@@ -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

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_ARTIFACT_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)