From 45acfed9aa2d81eb577a08fb6d4fc1d26b72bf56 Mon Sep 17 00:00:00 2001 From: Xu Deng Date: Mon, 17 Jun 2024 15:24:17 +0000 Subject: [PATCH] Group docker e2e simple flow tests --- Makefile | 2 +- .../build/buildspecs/quick-test-eks-a-cli.yml | 36 +++++++++---------- internal/test/e2e/list.go | 14 +++++++- internal/test/e2e/run.go | 3 +- test/e2e/docker_test.go | 13 +++++++ test/e2e/suite.go | 32 +++++++++++++++++ 6 files changed, 79 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 820c8b6720ea7..f6b22c31b2670 100644 --- a/Makefile +++ b/Makefile @@ -684,7 +684,7 @@ e2e-tests-binary: .PHONY: build-integration-test-binary build-integration-test-binary: - GOOS=$(GO_OS) GOARCH=$(GO_ARCH) $(GO) build -o bin/test github.com/aws/eks-anywhere/cmd/integration_test + GOOS=$(GO_OS) GOARCH=$(GO_ARCH) $(GO) build -o bin/test -tags "$(E2E_TAGS)" github.com/aws/eks-anywhere/cmd/integration_test .PHONY: conformance conformance: diff --git a/cmd/integration_test/build/buildspecs/quick-test-eks-a-cli.yml b/cmd/integration_test/build/buildspecs/quick-test-eks-a-cli.yml index 46776a199820e..9c1d760ab5191 100644 --- a/cmd/integration_test/build/buildspecs/quick-test-eks-a-cli.yml +++ b/cmd/integration_test/build/buildspecs/quick-test-eks-a-cli.yml @@ -186,23 +186,23 @@ phases: - ${CODEBUILD_SRC_DIR}/cmd/integration_test/build/script/start_docker.sh - make eks-a-for-dev-e2e build-integration-test-binary e2e-tests-binary E2E_TAGS="e2e all_providers" E2E_OUTPUT_FILE=bin/e2e.test - export CLUSTER_NAME_PREFIX="${BRANCH_NAME//./-}" - - > - ./bin/test e2e cleanup vsphere - -n ${CLUSTER_NAME_PREFIX} - -v 4 - - > - ./bin/test e2e cleanup cloudstack - -n ${CLUSTER_NAME_PREFIX} - --delete-duplicate-networks - -v 6 - - > - ./bin/test e2e cleanup nutanix - -n ${CLUSTER_NAME_PREFIX} - -e ${T_NUTANIX_ENDPOINT} - -p ${T_NUTANIX_PORT} - --insecure - --ignoreErrors - -v 4 + # - > + # ./bin/test e2e cleanup vsphere + # -n ${CLUSTER_NAME_PREFIX} + # -v 4 + # - > + # ./bin/test e2e cleanup cloudstack + # -n ${CLUSTER_NAME_PREFIX} + # --delete-duplicate-networks + # -v 6 + # - > + # ./bin/test e2e cleanup nutanix + # -n ${CLUSTER_NAME_PREFIX} + # -e ${T_NUTANIX_ENDPOINT} + # -p ${T_NUTANIX_PORT} + # --insecure + # --ignoreErrors + # -v 4 build: commands: - export JOB_ID=$CODEBUILD_BUILD_ID @@ -224,7 +224,7 @@ phases: -i ${INTEGRATION_TEST_INSTANCE_PROFILE} -m ${INTEGRATION_TEST_MAX_EC2_COUNT} -p ${INTEGRATION_TEST_MAX_CONCURRENT_TEST_COUNT} - -r ${TESTS} + -r "TestDockerKubernetesSimpleFlowSuite" -v 4 --skip ${SKIPPED_TESTS} --bundles-override=${BUNDLES_OVERRIDE} diff --git a/internal/test/e2e/list.go b/internal/test/e2e/list.go index a209c80ce9c30..22cfb37389e45 100644 --- a/internal/test/e2e/list.go +++ b/internal/test/e2e/list.go @@ -9,6 +9,7 @@ import ( "github.com/aws/eks-anywhere/pkg/executables" "github.com/aws/eks-anywhere/pkg/types" + e2etest "github.com/aws/eks-anywhere/test/e2e" ) func listTests(regex string, testsToSkip []string) (tests, skippedTests []string, err error) { @@ -29,7 +30,18 @@ func listTests(regex string, testsToSkip []string) (tests, skippedTests []string } if strings.HasPrefix(line, "Test") { - tests = append(tests, line) + if strings.HasSuffix(line, "Suite") { + for k, s := range e2etest.Suites { + if strings.HasSuffix(line, k) { + for _, st := range s { + tests = append(tests, line+"/"+st.GetName()) + } + break + } + } + } else { + tests = append(tests, line) + } } } diff --git a/internal/test/e2e/run.go b/internal/test/e2e/run.go index e5b97abaa5b9c..b3d7d8342e1e3 100644 --- a/internal/test/e2e/run.go +++ b/internal/test/e2e/run.go @@ -281,7 +281,6 @@ func RunTests(conf instanceRunConf, inventoryCatalogue map[string]*hardwareCatal } func (e *E2ESession) runTests(regex string) (testCommandResult *testCommandResult, err error) { - e.logger.V(1).Info("Running e2e tests", "regex", regex) command := "GOVERSION=go1.16.6 gotestsum --junitfile=junit-testing.xml --raw-command --format=standard-verbose --hide-summary=all --ignore-non-json-output-lines -- test2json -t -p e2e ./bin/e2e.test -test.v" if regex != "" { @@ -290,6 +289,8 @@ func (e *E2ESession) runTests(regex string) (testCommandResult *testCommandResul command = e.commandWithEnvVars(command) + e.logger.V(1).Info("Running e2e tests", "regex", regex, "command", command) + opt := ssm.WithOutputToCloudwatch() testCommandResult, err = ssm.RunCommand( diff --git a/test/e2e/docker_test.go b/test/e2e/docker_test.go index fe9c915d4659a..41ebf93186364 100644 --- a/test/e2e/docker_test.go +++ b/test/e2e/docker_test.go @@ -1459,3 +1459,16 @@ func TestDockerKubernetes129to130EtcdScaleDown(t *testing.T) { ), ) } + +func TestDockerKubernetesSimpleFlowSuite(t *testing.T) { + for _, ts := range Suites[SimpleFlowSuite] { + t.Run(ts.GetName(), func(t *testing.T) { + test := framework.NewClusterE2ETest( + t, + framework.NewDocker(t), + framework.WithClusterFiller(api.WithKubernetesVersion(ts.(*SimpleFlowTest).KubeVersion)), + ) + runSimpleFlow(test) + }) + } +} diff --git a/test/e2e/suite.go b/test/e2e/suite.go index ade1f87d6b849..f65e8d5b78ba6 100644 --- a/test/e2e/suite.go +++ b/test/e2e/suite.go @@ -4,6 +4,7 @@ package e2e import ( + "github.com/aws/eks-anywhere/pkg/api/v1alpha1" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" ) @@ -16,3 +17,34 @@ func init() { // There might a better way for this, but this will do for now. ctrl.SetLogger(klog.Background()) } + +var kubeVersions = []v1alpha1.KubernetesVersion{v1alpha1.Kube128, v1alpha1.Kube129, v1alpha1.Kube130} + +// Subtest is an interface to represent a test case. +type Subtest interface { + GetName() string +} + +// SimpleFlowSuite is a suite name. +const SimpleFlowSuite = "SimpleFlowSuite" + +// Suites contain all test suites. The key is the suite suffix. +var Suites = map[string][]Subtest{ + SimpleFlowSuite: {}, +} + +// SimpleFlowTest is a struct to represent a simple flow test. +type SimpleFlowTest struct { + KubeVersion v1alpha1.KubernetesVersion +} + +// GetName return the test case name. +func (st *SimpleFlowTest) GetName() string { + return string(st.KubeVersion) +} + +func init() { + for _, k := range kubeVersions { + Suites[SimpleFlowSuite] = append(Suites[SimpleFlowSuite], &SimpleFlowTest{KubeVersion: k}) + } +}