Skip to content

Commit

Permalink
feat: turn on parallelized integration testing
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneutt committed Aug 5, 2021
1 parent b0bbb3b commit b00580a
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ REPO_URL=github.com/kong/kubernetes-ingress-controller
IMGNAME?=kubernetes-ingress-controller
IMAGE = $(REGISTRY)/$(IMGNAME)
IMG ?= controller:latest
NCPU ?= $(shell getconf _NPROCESSORS_ONLN)

# ------------------------------------------------------------------------------
# Setup
Expand Down Expand Up @@ -176,14 +177,14 @@ test.integration.legacy: container
.PHONY: test.integration.dbless
test.integration.dbless:
@./scripts/check-container-environment.sh
@TEST_DATABASE_MODE="off" GOFLAGS="-tags=integration_tests" go test -timeout 15m -race -v -count=1 -covermode=atomic -coverpkg=$(PKG_LIST) -coverprofile=$(COVERAGE_PROFILE) ./test/integration/...
@TEST_DATABASE_MODE="off" GOFLAGS="-tags=integration_tests" go test -parallel $(NCPU) -timeout 15m -race -v -covermode=atomic -coverpkg=$(PKG_LIST) -coverprofile=$(COVERAGE_PROFILE) ./test/integration/...

# TODO: race checking has been temporarily turned off because of race conditions found with deck. This will be resolved in an upcoming Alpha release of KIC 2.0.
# See: https:/Kong/kubernetes-ingress-controller/issues/1324
.PHONY: test.integration.postgres
test.integration.postgres:
@./scripts/check-container-environment.sh
@TEST_DATABASE_MODE="postgres" GOFLAGS="-tags=integration_tests" go test -timeout 15m -v -count=1 -covermode=atomic -coverpkg=$(PKG_LIST) -coverprofile=$(COVERAGE_PROFILE) ./test/integration/...
@TEST_DATABASE_MODE="postgres" GOFLAGS="-tags=integration_tests" go test -parallel $(NCPU) -timeout 15m -v -covermode=atomic -coverpkg=$(PKG_LIST) -coverprofile=$(COVERAGE_PROFILE) ./test/integration/...

# ------------------------------------------------------------------------------
# Operations
Expand Down
3 changes: 2 additions & 1 deletion hack/e2e/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ function cleanup() {
}
trap cleanup EXIT SIGINT SIGQUIT

GOFLAGS="-tags=integration_tests" KONG_TEST_CLUSTER="gke:${CLUSTER_NAME}" go test -count 1 -timeout 45m -v ./test/integration/...
NCPU="$(getconf _NPROCESSORS_ONLN)"
GOFLAGS="-tags=integration_tests" KONG_TEST_CLUSTER="gke:${CLUSTER_NAME}" go test -parallel "${NCPU}" -timeout 30m -v ./test/integration/...
4 changes: 4 additions & 0 deletions test/integration/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
)

func TestHealthEndpoint(t *testing.T) {
t.Parallel()
assert.Eventually(t, func() bool {
healthzURL := fmt.Sprintf("http://localhost:%v/healthz", manager.HealthzPort)
resp, err := httpc.Get(healthzURL)
Expand All @@ -28,6 +29,7 @@ func TestHealthEndpoint(t *testing.T) {
}

func TestMetricsEndpoint(t *testing.T) {
t.Parallel()
assert.Eventually(t, func() bool {
metricsURL := fmt.Sprintf("http://localhost:%v/metrics", manager.MetricsPort)
resp, err := httpc.Get(metricsURL)
Expand Down Expand Up @@ -55,6 +57,7 @@ func TestMetricsEndpoint(t *testing.T) {
}

func TestProfilingEndpoint(t *testing.T) {
t.Parallel()
assert.Eventually(t, func() bool {
profilingURL := fmt.Sprintf("http://localhost:%v/debug/pprof/", manager.DiagnosticsPort)
resp, err := httpc.Get(profilingURL)
Expand All @@ -68,6 +71,7 @@ func TestProfilingEndpoint(t *testing.T) {
}

func TestConfigEndpoint(t *testing.T) {
t.Parallel()
assert.Eventually(t, func() bool {
successURL := fmt.Sprintf("http://localhost:%v/debug/config/successful", manager.DiagnosticsPort)
failURL := fmt.Sprintf("http://localhost:%v/debug/config/failed", manager.DiagnosticsPort)
Expand Down
2 changes: 2 additions & 0 deletions test/integration/ingress_https_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ QLAtVaZd9SSi4Z/RX6B4L3Rj0Mwfn+tbrtYO5Pyhi40hiXf4aMgbVDFYMR0MMmH0
)

func TestHTTPSRedirect(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down Expand Up @@ -192,6 +193,7 @@ func TestHTTPSRedirect(t *testing.T) {
}

func TestHTTPSIngress(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down
6 changes: 5 additions & 1 deletion test/integration/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
)

func TestIngressEssentials(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down Expand Up @@ -172,6 +173,7 @@ func TestIngressEssentials(t *testing.T) {
}

func TestIngressClassNameSpec(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down Expand Up @@ -319,7 +321,9 @@ func TestIngressClassNameSpec(t *testing.T) {
}

func TestIngressNamespaces(t *testing.T) {
// ensure the alternative namespace is created
t.Parallel()

t.Log("creating extra testing namespaces")
elsewhereNamespace := &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: elsewhere}}
nowhere := "nowhere"
nowhereNamespace := &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: nowhere}}
Expand Down
1 change: 1 addition & 0 deletions test/integration/knative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
)

func TestKnativeIngress(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down
1 change: 1 addition & 0 deletions test/integration/kongingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
)

func TestKongIngressEssentials(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down
1 change: 1 addition & 0 deletions test/integration/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
)

func TestPluginEssentials(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down
1 change: 1 addition & 0 deletions test/integration/tcpingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
)

func TestTCPIngressEssentials(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down
1 change: 1 addition & 0 deletions test/integration/udpingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
)

func TestUDPIngressEssentials(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down
1 change: 1 addition & 0 deletions test/integration/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
)

func TestValidationWebhook(t *testing.T) {
t.Parallel()
ns, cleanup := namespace(t)
defer cleanup()

Expand Down
1 change: 0 additions & 1 deletion test/performance/ingress_bulk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/kong/kubernetes-ingress-controller/internal/annotations"
)

// TestIngressBulk attempts to validate functionality at scale by rapidly deploying a large number of ingress resources.
func TestIngressBulk(t *testing.T) {
ctx := context.Background()
ns := corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: corev1.NamespaceDefault}}
Expand Down

0 comments on commit b00580a

Please sign in to comment.