From 1c310945509fcca691a27cf7b641b3812b7c1fe0 Mon Sep 17 00:00:00 2001 From: Sarah Wang Date: Wed, 4 Dec 2024 17:13:34 -0500 Subject: [PATCH 1/6] make command for a specific e2e test --- Makefile | 8 ++++++++ test/e2e/tests/kind_test.go | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d36506393..9de0f9256 100644 --- a/Makefile +++ b/Makefile @@ -216,6 +216,14 @@ e2e-tests: manifests $(KUSTOMIZE) ## Run E2E tests and destroy environment stack e2e-tests-keep-stacks: manifests $(KUSTOMIZE) ## Run E2E tests and keep environment stacks running. To run locally, complete pre-reqs (see docs/how-to-contribute.md) and prepend command with `aws-vault exec sso-agent-sandbox-account-admin --`. E.g. `aws-vault exec sso-agent-sandbox-account-admin -- make e2e-tests-keep-stacks`. KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e --tags=e2e github.com/DataDog/datadog-operator/e2e -v -timeout 1h -coverprofile cover_e2e_keep_stacks.out -args -keep-stacks=true +.PHONY: e2e-test-specific +e2e-test-specific: + @if [ -z "$(filter-out e2e-test-specific,$(MAKECMDGOALS))" ]; then \ + echo "Usage: make e2e-specific "; \ + else \ + go test ./test/e2e/... -count=1 --tags=e2e -v -run '$(filter-out e2e-test-specific,$(MAKECMDGOALS))'; \ + fi + .PHONY: bundle bundle: bin/$(PLATFORM)/operator-sdk bin/$(PLATFORM)/yq $(KUSTOMIZE) manifests ## Generate bundle manifests and metadata, then validate generated files. bin/$(PLATFORM)/operator-sdk generate kustomize manifests --apis-dir ./api -q diff --git a/test/e2e/tests/kind_test.go b/test/e2e/tests/kind_test.go index 79384d2e4..39af86f2f 100644 --- a/test/e2e/tests/kind_test.go +++ b/test/e2e/tests/kind_test.go @@ -11,9 +11,6 @@ package e2e import ( "context" "fmt" - "github.com/DataDog/datadog-agent/test/fakeintake/aggregator" - "github.com/DataDog/datadog-agent/test/fakeintake/client" - "github.com/stretchr/testify/suite" "path/filepath" "regexp" "strconv" @@ -21,6 +18,10 @@ import ( "testing" "time" + "github.com/DataDog/datadog-agent/test/fakeintake/aggregator" + "github.com/DataDog/datadog-agent/test/fakeintake/client" + "github.com/stretchr/testify/suite" + "github.com/DataDog/datadog-operator/test/e2e/common" "github.com/DataDog/datadog-operator/test/e2e/provisioners" "github.com/DataDog/test-infra-definitions/components/datadog/agentwithoperatorparams" @@ -178,7 +179,7 @@ func (s *k8sSuite) TestGenericK8s() { }, 600*time.Second, 30*time.Second, "could not validate KSM (cluster check) metrics in time") }) - s.T().Run("KSM check works (cluster check runner)", func(t *testing.T) { + s.T().Run("KSM check works cluster check runner", func(t *testing.T) { // Update DDA ddaConfigPath, err = common.GetAbsPath(filepath.Join(common.ManifestsPath, "datadog-agent-ccr-enabled.yaml")) assert.NoError(t, err) From 1b1f1ebd09ef5b995391ec89ce035378585bb9dd Mon Sep 17 00:00:00 2001 From: Sarah Wang Date: Thu, 5 Dec 2024 15:06:15 -0500 Subject: [PATCH 2/6] update command to use env var --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9de0f9256..7347919f8 100644 --- a/Makefile +++ b/Makefile @@ -218,10 +218,11 @@ e2e-tests-keep-stacks: manifests $(KUSTOMIZE) ## Run E2E tests and keep environm .PHONY: e2e-test-specific e2e-test-specific: - @if [ -z "$(filter-out e2e-test-specific,$(MAKECMDGOALS))" ]; then \ - echo "Usage: make e2e-specific "; \ + @if [ -z "$(E2ETESTNAME)" ]; then \ + echo "The environment variable E2ETESTNAME is not set. Please set E2ETESTNAME to the name of the test you want to run."; \ + exit 1; \ else \ - go test ./test/e2e/... -count=1 --tags=e2e -v -run '$(filter-out e2e-test-specific,$(MAKECMDGOALS))'; \ + go test ./test/e2e/tests/... -count=1 --tags=e2e -v -run $(E2ETESTNAME); \ fi .PHONY: bundle From 0d30895c4931c1c21d41a8bb200a29985926c79b Mon Sep 17 00:00:00 2001 From: Sarah Wang Date: Fri, 3 Jan 2025 14:39:52 -0500 Subject: [PATCH 3/6] updated e2e specific test --- Makefile | 19 +++++++------------ test/e2e/tests/k8sSuite/k8sSuite_test.go | 13 +++++++------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index b49dce6c7..4bda55130 100644 --- a/Makefile +++ b/Makefile @@ -209,23 +209,18 @@ integration-tests-v2: $(ENVTEST) ## Run tests with reconciler V2 KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test --tags=integration_v2 github.com/DataDog/datadog-operator/internal/controller -coverprofile cover_integration_v2.out .PHONY: e2e-tests -e2e-tests: manifests $(KUSTOMIZE) ## Run E2E tests and destroy environment stacks after tests complete. To run locally, complete pre-reqs (see docs/how-to-contribute.md) and prepend command with `aws-vault exec sso-agent-sandbox-account-admin --`. E.g. `aws-vault exec sso-agent-sandbox-account-admin -- make e2e-tests`. - KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e ./... --tags=e2e -run TestLocalKindSuite -v -timeout 0s -coverprofile cover_e2e.out - +e2e-tests: ## Run E2E tests and destroy environment stacks after tests complete. To run locally, complete pre-reqs (see docs/how-to-contribute.md) and prepend command with `aws-vault exec sso-agent-sandbox-account-admin --`. E.g. `aws-vault exec sso-agent-sandbox-account-admin -- make e2e-tests`. + @if [ -z "$(E2E_RUN_REGEX)" ]; then \ + KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e/ ./... -count=1 --tags=e2e -v -run TestLocalKindSuite -timeout 0s -coverprofile cover_e2e.out; \ + else \ + echo "Running e2e test: $(E2E_RUN_REGEX)"; \ + KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e/ ./... -count=1 --tags=e2e -v -run $(E2E_RUN_REGEX) -timeout 0s -coverprofile cover_e2e.out; \ + fi .PHONY: e2e-tests-keep-stacks e2e-tests-keep-stacks: manifests $(KUSTOMIZE) ## Run E2E tests and keep environment stacks running. To run locally, complete pre-reqs (see docs/how-to-contribute.md) and prepend command with `aws-vault exec sso-agent-sandbox-account-admin --`. E.g. `aws-vault exec sso-agent-sandbox-account-admin -- make e2e-tests-keep-stacks`. KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e ./... --tags=e2e -run TestLocalKindSuite -v -timeout 0s -coverprofile cover_e2e_keep_stacks.out -args -keep-stacks=true -.PHONY: e2e-test-specific -e2e-test-specific: - @if [ -z "$(E2ETESTNAME)" ]; then \ - echo "The environment variable E2ETESTNAME is not set. Please set E2ETESTNAME to the name of the test you want to run."; \ - exit 1; \ - else \ - go test ./test/e2e/tests/... -count=1 --tags=e2e -v -run $(E2ETESTNAME); \ - fi - .PHONY: bundle bundle: bin/$(PLATFORM)/operator-sdk bin/$(PLATFORM)/yq $(KUSTOMIZE) manifests ## Generate bundle manifests and metadata, then validate generated files. bin/$(PLATFORM)/operator-sdk generate kustomize manifests --apis-dir ./api -q diff --git a/test/e2e/tests/k8sSuite/k8sSuite_test.go b/test/e2e/tests/k8sSuite/k8sSuite_test.go index 50aba1244..4d87ac6de 100644 --- a/test/e2e/tests/k8sSuite/k8sSuite_test.go +++ b/test/e2e/tests/k8sSuite/k8sSuite_test.go @@ -10,6 +10,12 @@ package e2e import ( "fmt" + "path/filepath" + "regexp" + "strings" + "testing" + "time" + "github.com/DataDog/datadog-agent/test/fakeintake/aggregator" "github.com/DataDog/datadog-agent/test/fakeintake/client" "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments" @@ -17,11 +23,6 @@ import ( "github.com/DataDog/datadog-operator/test/e2e/provisioners" "github.com/DataDog/datadog-operator/test/e2e/tests/utils" "github.com/stretchr/testify/suite" - "path/filepath" - "regexp" - "strings" - "testing" - "time" "github.com/DataDog/test-infra-definitions/components/datadog/agentwithoperatorparams" "github.com/DataDog/test-infra-definitions/components/datadog/operatorparams" @@ -147,7 +148,7 @@ func (s *k8sSuite) TestGenericK8s() { }, 120*time.Second, 15*time.Second, "could not validate KSM (cluster check) metrics in time") }) - s.T().Run("KSM check works (cluster check runner)", func(t *testing.T) { + s.T().Run("KSM check works cluster check runner", func(t *testing.T) { // Update DDA ddaConfigPath, err = common.GetAbsPath(filepath.Join(common.ManifestsPath, "datadog-agent-ccr-enabled.yaml")) assert.NoError(t, err) From 4d64621a47ee0347e49f2775d0ebe3a7a33988d1 Mon Sep 17 00:00:00 2001 From: Sarah Wang Date: Fri, 3 Jan 2025 14:58:48 -0500 Subject: [PATCH 4/6] remove parentheses from test headers --- test/e2e/tests/k8s_suite/k8s_suite_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/tests/k8s_suite/k8s_suite_test.go b/test/e2e/tests/k8s_suite/k8s_suite_test.go index 81aefbcaa..936c92cde 100644 --- a/test/e2e/tests/k8s_suite/k8s_suite_test.go +++ b/test/e2e/tests/k8s_suite/k8s_suite_test.go @@ -8,6 +8,7 @@ package k8ssuite import ( "context" "fmt" + "github.com/DataDog/datadog-agent/test/fakeintake/aggregator" "github.com/DataDog/datadog-agent/test/fakeintake/client" "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments" @@ -128,7 +129,7 @@ func (s *k8sSuite) TestGenericK8s() { }) - s.T().Run("KSM check works (cluster check runner)", func(t *testing.T) { + s.T().Run("KSM check works cluster check runner", func(t *testing.T) { ddaConfigPath, err := common.GetAbsPath(filepath.Join(common.ManifestsPath, "datadog-agent-ccr-enabled.yaml")) assert.NoError(s.T(), err) From d1b822d5c85fb245a560b9b700fc5f79f9195da9 Mon Sep 17 00:00:00 2001 From: Sarah Wang Date: Fri, 3 Jan 2025 15:26:32 -0500 Subject: [PATCH 5/6] update e2e-tests --- Makefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3a22aa434..f557e709d 100644 --- a/Makefile +++ b/Makefile @@ -210,14 +210,12 @@ integration-tests-v2: $(ENVTEST) ## Run tests with reconciler V2 .PHONY: e2e-tests e2e-tests: ## Run E2E tests and destroy environment stacks after tests complete. To run locally, complete pre-reqs (see docs/how-to-contribute.md) and prepend command with `aws-vault exec sso-agent-sandbox-account-admin --`. E.g. `aws-vault exec sso-agent-sandbox-account-admin -- make e2e-tests`. + cd test/e2e && go get github.com/DataDog/datadog-agent/test/new-e2e@9ebd4d1cebbe1c9141e3a6b54176fdea8a79dd91 + cd $(ROOT) @if [ -z "$(E2E_RUN_REGEX)" ]; then \ - cd test/e2e && go get github.com/DataDog/datadog-agent/test/new-e2e@9ebd4d1cebbe1c9141e3a6b54176fdea8a79dd91 - cd $(ROOT) - KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e/ ./... -count=1 --tags=e2e -v -run TestLocalKindSuite -timeout 0s -coverprofile cover_e2e.out; \ + KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e/ ./... -count=1 --tags=e2e -v -run TestAWS -timeout 0s -coverprofile cover_e2e.out; \ else \ echo "Running e2e test: $(E2E_RUN_REGEX)"; \ - cd test/e2e && go get github.com/DataDog/datadog-agent/test/new-e2e@9ebd4d1cebbe1c9141e3a6b54176fdea8a79dd91 - cd $(ROOT) KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e/ ./... -count=1 --tags=e2e -v -run $(E2E_RUN_REGEX) -timeout 0s -coverprofile cover_e2e.out; \ fi From a87e37b3b3914c78f453ff220cec8749a92f4aa0 Mon Sep 17 00:00:00 2001 From: Sarah Wang Date: Fri, 3 Jan 2025 15:36:48 -0500 Subject: [PATCH 6/6] nit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f557e709d..cd54d4b9e 100644 --- a/Makefile +++ b/Makefile @@ -213,7 +213,7 @@ e2e-tests: ## Run E2E tests and destroy environment stacks after tests complete. cd test/e2e && go get github.com/DataDog/datadog-agent/test/new-e2e@9ebd4d1cebbe1c9141e3a6b54176fdea8a79dd91 cd $(ROOT) @if [ -z "$(E2E_RUN_REGEX)" ]; then \ - KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e/ ./... -count=1 --tags=e2e -v -run TestAWS -timeout 0s -coverprofile cover_e2e.out; \ + KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e/ ./... -count=1 --tags=e2e -v -run TestAWSKindSuite -timeout 0s -coverprofile cover_e2e.out; \ else \ echo "Running e2e test: $(E2E_RUN_REGEX)"; \ KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test -C test/e2e/ ./... -count=1 --tags=e2e -v -run $(E2E_RUN_REGEX) -timeout 0s -coverprofile cover_e2e.out; \