Skip to content

Commit

Permalink
Group docker e2e simple flow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
d8660091 committed Jun 17, 2024
1 parent f2629b8 commit 947f1ca
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
36 changes: 18 additions & 18 deletions cmd/integration_test/build/buildspecs/quick-test-eks-a-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
14 changes: 13 additions & 1 deletion internal/test/e2e/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {

Check failure on line 34 in internal/test/e2e/list.go

View workflow job for this annotation

GitHub Actions / govulncheck

undefined: e2etest.Suites

Check failure on line 34 in internal/test/e2e/list.go

View workflow job for this annotation

GitHub Actions / build

undefined: e2etest.Suites
if strings.HasSuffix(line, k) {
for _, st := range s {
tests = append(tests, line+"/"+st.GetName())
}
break
}
}
} else {
tests = append(tests, line)
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions internal/test/e2e/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,16 @@ 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 != "" {
command = fmt.Sprintf("%s -test.run \"^(%s)$\" -test.timeout %s", command, regex, e2eTimeout)
command = fmt.Sprintf("%s -test.run \"^%s$\" -test.timeout %s", command, regex, e2eTimeout)
}

command = e.commandWithEnvVars(command)

e.logger.V(1).Info("Running e2e tests", "regex", regex, "command", command)

opt := ssm.WithOutputToCloudwatch()

testCommandResult, err = ssm.RunCommand(
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
32 changes: 32 additions & 0 deletions test/e2e/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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})
}
}

0 comments on commit 947f1ca

Please sign in to comment.