Skip to content

Commit

Permalink
Combined local-registry cleanup make target; Added support for contai…
Browse files Browse the repository at this point in the history
…ner runtime in consideration

Signed-off-by: jubittajohn <jujohn@redhat.com>
  • Loading branch information
jubittajohn committed Aug 10, 2023
1 parent 8011376 commit 9743766
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 11 additions & 5 deletions test/operator-framework-e2e/operator_framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9743766

Please sign in to comment.