Skip to content

Commit

Permalink
Run integration tests in parallel
Browse files Browse the repository at this point in the history
Execution time has cut down from 10 minutes to 1 minute and a few
seconds (!!!)

The solution is to start an API server for each parallel process,
listening on different ports. I tried to start only one API server and
share the API information among other parallel processes, but it was not
possible because the testEnv Environment does not implement any of the
marshall interfaces, so it is not possible to binary encode it. Binary
encoding is the method that Ginkgo uses to share information between
processes in the Synchronized Before/After suites.

Signed-off-by: Aitor Perez Cedres <acedres@vmware.com>
  • Loading branch information
Zerpet committed Dec 11, 2023
1 parent e2d091f commit 2f6e50e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ install-tools:
go install golang.org/x/vuln/cmd/govulncheck@latest

ENVTEST_K8S_VERSION = 1.26.1
ARCHITECTURE = amd64
ARCHITECTURE = $(shell go env GOARCH)
LOCAL_TESTBIN = $(CURDIR)/testbin

LOCAL_BIN := $(CURDIR)/bin
Expand Down Expand Up @@ -58,7 +58,7 @@ integration-tests: install-tools $(KUBEBUILDER_ASSETS) generate fmt vet manifest
ginkgo -r --randomize-all controllers/

just-integration-tests: $(KUBEBUILDER_ASSETS) vet
ginkgo --randomize-all -r controllers/
ginkgo --randomize-all -r -p controllers/

local-tests: unit-tests integration-tests ## Run all local tests (unit & integration)

Expand Down
4 changes: 4 additions & 0 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"fmt"
"go/build"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"path/filepath"
"testing"
"time"
Expand Down Expand Up @@ -101,6 +102,9 @@ var _ = BeforeSuite(func() {
filepath.Join(build.Default.GOPATH, "pkg", "mod", "github.com", "rabbitmq", "cluster-operator", "v2@v2.6.0", "config", "crd", "bases"),
},
ErrorIfCRDPathMissing: true,
Config: &rest.Config{
Host: fmt.Sprintf("localhost:818%d", GinkgoParallelProcess()),
},
}

cfg, err := testEnv.Start()
Expand Down

0 comments on commit 2f6e50e

Please sign in to comment.