Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/e2e: Run in parallel #76

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

E2E_TEST_TIMEOUT ?= "1h"
E2E_TEST_ARGS ?= ""

.PHONY: all
all: build
Expand Down Expand Up @@ -73,12 +72,12 @@ test: manifests generate fmt vet envtest ## Run tests.

# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
test-e2e:
test-e2e: ginkgo
export KUBECONFIG=${KUBECONFIG} && \
export PATH=$$(pwd)/.output/ovn-kubernetes/bin:$${PATH} && \
export REPORT_PATH=$$(pwd)/.output/ && \
cd test/e2e && \
go test -test.v --ginkgo.v --test.timeout=${E2E_TEST_TIMEOUT} ${E2E_TEST_ARGS} --ginkgo.junit-report=$${REPORT_PATH}/test-e2e.junit.xml
$(GINKGO) -p -v --timeout=${E2E_TEST_TIMEOUT} --junit-report=$${REPORT_PATH}/test-e2e.junit.xml ${E2E_TEST_ARGS}

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter & yamllint
Expand Down Expand Up @@ -164,12 +163,14 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION)
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION)
ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
GINKGO = $(LOCALBIN)/ginkgo-$(GINKGO_VERSION)

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
ENVTEST_VERSION ?= latest
GOLANGCI_LINT_VERSION ?= v1.54.2
GINKGO_VERSION ?= v2.22.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand All @@ -191,6 +192,10 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})

.PHONY: ginkgo
ginkgo:
$(call go-install-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo,${GINKGO_VERSION})

.PHONY: cluster-up
cluster-up:
./hack/cluster.sh up
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func logCommand(args []string, topic string, failureCount int) {
return
}

fileName := fmt.Sprintf(logsDir+"/%d_%s.log", failureCount, topic)
fileName := fmt.Sprintf(logsDir+"/%d_%d_%s.log", GinkgoParallelProcess(), failureCount, topic)
file, err := os.Create(fileName)
if err != nil {
fmt.Printf("Error running command %v, err %v\n", args, err)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/persistentips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var _ = DescribeTableSubtree("Persistent IPs", func(params testParams) {
JustAfterEach(func() {
if CurrentSpecReport().Failed() {
failureCount++
By(fmt.Sprintf("Test failed, collecting logs and artifacts, failure count %d", failureCount))
By(fmt.Sprintf("Test failed, collecting logs and artifacts, failure count %d, process %d", failureCount, GinkgoParallelProcess()))

logCommand([]string{"get", "pods", "-A"}, "pods", failureCount)
logCommand([]string{"get", "vm", "-A", "-oyaml"}, "vms", failureCount)
Expand Down
5 changes: 4 additions & 1 deletion test/env/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package env

import (
"fmt"
"strings"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/utils/pointer"

nadv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
Expand All @@ -14,7 +16,8 @@ import (
)

func GenerateLayer2WithSubnetNAD(nadName, namespace, role string) *nadv1.NetworkAttachmentDefinition {
networkName := "l2"
const randCharacters = 5
networkName := strings.Join([]string{"l2", role, rand.String(randCharacters)}, "-")
maiqueb marked this conversation as resolved.
Show resolved Hide resolved
return &nadv1.NetworkAttachmentDefinition{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Expand Down
Loading