diff --git a/Makefile b/Makefile index 467e7ca21..993a2a45a 100644 --- a/Makefile +++ b/Makefile @@ -101,7 +101,7 @@ test-e2e: $(GINKGO) ## Run the e2e tests .PHONY: test-op-dev-e2e test-op-dev-e2e: $(GINKGO) ## Run operator create, upgrade and delete tests - $(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress $(FOCUS) test/operator-framework-e2e + CONTAINER_RUNTIME=$(CONTAINER_RUNTIME) $(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress $(FOCUS) test/operator-framework-e2e .PHONY: test-unit ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/') @@ -117,7 +117,7 @@ e2e: run kind-load-test-artifacts test-e2e e2e-coverage kind-cluster-cleanup ## .PHONY: operator-developer-e2e operator-developer-e2e: KIND_CLUSTER_NAME=operator-controller-op-dev-e2e ## Run operator-developer e2e on local kind cluster -operator-developer-e2e: run $(OPM) $(OPERATOR_SDK) $(KUSTOMIZE) deploy-local-registry test-op-dev-e2e stop-local-registry remove-local-registry kind-cluster-cleanup +operator-developer-e2e: run $(OPM) $(OPERATOR_SDK) $(KUSTOMIZE) deploy-local-registry test-op-dev-e2e cleanup-local-registry kind-cluster-cleanup .PHONY: e2e-coverage e2e-coverage: @@ -153,12 +153,9 @@ kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into deploy-local-registry: ## Deploy local docker registry $(CONTAINER_RUNTIME) run -d -p 5001:5000 --restart=always --name local-registry registry:2 -.PHONY: stop-local-registry -stop-local-registry: ## Stop local registry +.PHONY: cleanup-local-registry +cleanup-local-registry: ## Stop and remove local registry $(CONTAINER_RUNTIME) container stop local-registry - -.PHONY: remove-local-registry -remove-local-registry: ## Remove local registry $(CONTAINER_RUNTIME) container rm -v local-registry opm: $(OPM) diff --git a/test/operator-framework-e2e/operator_framework_test.go b/test/operator-framework-e2e/operator_framework_test.go index 7ea0d36cf..23696a15d 100644 --- a/test/operator-framework-e2e/operator_framework_test.go +++ b/test/operator-framework-e2e/operator_framework_test.go @@ -33,9 +33,10 @@ import ( ) var ( - cfg *rest.Config - c client.Client - ctx context.Context + cfg *rest.Config + c client.Client + ctx context.Context + containerRuntime string ) type BundleInfo struct { @@ -104,6 +105,11 @@ var _ = BeforeSuite(func() { ctx = context.Background() + containerRuntime = os.Getenv("CONTAINER_RUNTIME") + if containerRuntime == "" { + containerRuntime = "docker" + } + }) var _ = Describe("Operator Framework E2E for plain+v0 bundles", func() { @@ -557,14 +563,14 @@ func sdkBundleComplete(sdkInfo *SdkProjectInfo, rootBundlePath string, bundleDat // `dockerContext`: context directory containing the files and resources referenced by the Dockerfile. // `w`: Writer to which the standard output and standard error will be redirected. func buildPushLoadContainer(tag, dockerfilePath, dockerContext, kindServer string, w io.Writer) error { - cmd := exec.Command("docker", "build", "-t", tag, "-f", dockerfilePath, dockerContext) + cmd := exec.Command(containerRuntime, "build", "-t", tag, "-f", dockerfilePath, dockerContext) cmd.Stderr = w cmd.Stdout = w if err := cmd.Run(); err != nil { return fmt.Errorf("Error building Docker container image %s : %+v", tag, err) } - cmd = exec.Command("docker", "push", tag) + cmd = exec.Command(containerRuntime, "push", tag) cmd.Stderr = w cmd.Stdout = w if err := cmd.Run(); err != nil {