Skip to content

Commit

Permalink
Merge pull request #258 from jotak/e2e-podman
Browse files Browse the repository at this point in the history
Fix e2e tests with podman
  • Loading branch information
jotak authored Jul 19, 2022
2 parents a40c4c4 + e21da0c commit 8469fe0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CG_BIN_FILE=confgenerator
NETFLOW_GENERATOR=nflow-generator
CMD_DIR=./cmd/
FLP_CONF_FILE ?= contrib/kubernetes/flowlogs-pipeline.conf.yaml
KIND_CLUSTER_NAME ?= kind

BUILD_DATE := $(shell date +%Y-%m-%d\ %H:%M)
TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
Expand Down Expand Up @@ -221,24 +222,24 @@ undeploy-netflow-simulator: ## Undeploy netflow simulator

.PHONY: create-kind-cluster
create-kind-cluster: $(KIND) ## Create cluster
$(KIND) create cluster --config contrib/kubernetes/kind/kind.config.yaml
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config contrib/kubernetes/kind/kind.config.yaml
kubectl cluster-info --context kind-kind

.PHONY: delete-kind-cluster
delete-kind-cluster: $(KIND) ## Delete cluster
$(KIND) delete cluster
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)

.PHONY: kind-load-image
kind-load-image: ## Load image to kind
ifeq ($(OCI_RUNTIME),$(shell which docker))
# This is an optimization for docker provider. "kind load docker-image" can load an image directly from docker's
# local registry. For other providers (i.e. podman), we must use "kind load image-archive" instead.
$(KIND) load docker-image $(DOCKER_IMG):$(DOCKER_TAG)
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image $(DOCKER_IMG):$(DOCKER_TAG)
else
$(eval tmpfile="/tmp/flp.tar")
-rm $(tmpfile)
$(OCI_RUNTIME) save $(DOCKER_IMG):$(DOCKER_TAG) -o $(tmpfile)
$(KIND) load image-archive $(tmpfile)
$(KIND) load --name $(KIND_CLUSTER_NAME) image-archive $(tmpfile)
-rm $(tmpfile)
endif

Expand Down
15 changes: 3 additions & 12 deletions pkg/test/e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,18 @@ func e2eDeleteKindCluster(clusterName string) env.Func {
}
}

// NOTE: the e2e framework uses `kind load` command that forces usage of docker (and not podman)
// ref: https://github.com/kubernetes-sigs/kind/issues/2027
func e2eBuildAndLoadImageIntoKind(dockerImg, dockerTag, clusterName string) env.Func {
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
e := gexe.New()
fmt.Printf("====> building docker image - %s:%s\n", dockerImg, dockerTag)
p := e.RunProc(fmt.Sprintf(`/bin/sh -c "cd $(git rev-parse --show-toplevel); OCI_RUNTIME=docker DOCKER_IMG=%s DOCKER_TAG=%s make build-image"`,
dockerImg, dockerTag))
p := e.RunProc(fmt.Sprintf(`/bin/sh -c "cd $(git rev-parse --show-toplevel); DOCKER_IMG=%s DOCKER_TAG=%s KIND_CLUSTER_NAME=%s make build-image kind-load-image"`,
dockerImg, dockerTag, clusterName))
if p.Err() != nil || !p.IsSuccess() || p.ExitCode() != 0 {
return nil, fmt.Errorf("failed to building docker image err=%v result=%v", p.Err(), p.Result())
}
fmt.Printf("====> Done.\n")
fmt.Printf("====> Load image into kind \n")
p = e.RunProc(fmt.Sprintf("kind load --name %s docker-image %s:%s", clusterName, dockerImg, dockerTag))
if p.Err() != nil || !p.IsSuccess() || p.ExitCode() != 0 {
return nil, fmt.Errorf("failed to load image into kind err=%v result=%v", p.Err(), p.Result())
return nil, fmt.Errorf("failed to build or load docker image err=%v result=%v", p.Err(), p.Result())
}
fmt.Printf("====> Done.\n")
return ctx, nil
}

}

func e2eRecreateNamespace(name string) env.Func {
Expand Down

0 comments on commit 8469fe0

Please sign in to comment.