From 3f957658ad76d6319fda910517e715f380c1185a Mon Sep 17 00:00:00 2001 From: Filipe Menezes Date: Thu, 18 Aug 2022 11:41:41 +0100 Subject: [PATCH 1/3] CLOUDP-132962: Datadog integration is disabled in cloudgov --- test/e2e/atlas/helper_test.go | 6 +++- test/e2e/atlas/integrations_test.go | 44 +++++++++++++++-------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/test/e2e/atlas/helper_test.go b/test/e2e/atlas/helper_test.go index f39d745e87..994141feb8 100644 --- a/test/e2e/atlas/helper_test.go +++ b/test/e2e/atlas/helper_test.go @@ -279,6 +279,10 @@ func integrationExists(name string, thirdPartyIntegrations mongodbatlas.ThirdPar return false } +func Gov() bool { + return os.Getenv("MCLI_SERVICE") == "cloudgov" +} + func createProject(projectName string) (string, error) { cliPath, err := e2e.AtlasCLIBin() if err != nil { @@ -290,7 +294,7 @@ func createProject(projectName string) (string, error) { projectName, "-o=json", } - if os.Getenv("MCLI_SERVICE") == "cloudgov" { + if Gov() { args = append(args, "--govCloudRegionsOnly") } cmd := exec.Command(cliPath, args...) diff --git a/test/e2e/atlas/integrations_test.go b/test/e2e/atlas/integrations_test.go index 091c14d883..f1fc80f0d6 100644 --- a/test/e2e/atlas/integrations_test.go +++ b/test/e2e/atlas/integrations_test.go @@ -48,27 +48,29 @@ func TestIntegrations(t *testing.T) { cliPath, err := e2e.AtlasCLIBin() require.NoError(t, err) - t.Run("Create DATADOG", func(t *testing.T) { - cmd := exec.Command(cliPath, - integrationsEntity, - "create", - datadogEntity, - "--apiKey", - key, - "--projectId", - g.projectID, - "-o=json") - cmd.Env = os.Environ() - resp, err := cmd.CombinedOutput() - - a := assert.New(t) - a.NoError(err, string(resp)) - - var thirdPartyIntegrations mongodbatlas.ThirdPartyIntegrations - if err := json.Unmarshal(resp, &thirdPartyIntegrations); a.NoError(err) { - a.True(integrationExists(datadogEntity, thirdPartyIntegrations)) - } - }) + if Gov() { // cloudgov does not have an available datadog region + t.Run("Create DATADOG", func(t *testing.T) { + cmd := exec.Command(cliPath, + integrationsEntity, + "create", + datadogEntity, + "--apiKey", + key, + "--projectId", + g.projectID, + "-o=json") + cmd.Env = os.Environ() + resp, err := cmd.CombinedOutput() + + a := assert.New(t) + a.NoError(err, string(resp)) + + var thirdPartyIntegrations mongodbatlas.ThirdPartyIntegrations + if err := json.Unmarshal(resp, &thirdPartyIntegrations); a.NoError(err) { + a.True(integrationExists(datadogEntity, thirdPartyIntegrations)) + } + }) + } t.Run("Create NEW_RELIC", func(t *testing.T) { cmd := exec.Command(cliPath, From d89b891822dc18b94bcaa38e089647e5de18eaa1 Mon Sep 17 00:00:00 2001 From: Filipe Menezes Date: Thu, 18 Aug 2022 11:43:25 +0100 Subject: [PATCH 2/3] Fix --- test/e2e/atlas/integrations_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/atlas/integrations_test.go b/test/e2e/atlas/integrations_test.go index f1fc80f0d6..fa89161970 100644 --- a/test/e2e/atlas/integrations_test.go +++ b/test/e2e/atlas/integrations_test.go @@ -48,7 +48,7 @@ func TestIntegrations(t *testing.T) { cliPath, err := e2e.AtlasCLIBin() require.NoError(t, err) - if Gov() { // cloudgov does not have an available datadog region + if !Gov() { // cloudgov does not have an available datadog region t.Run("Create DATADOG", func(t *testing.T) { cmd := exec.Command(cliPath, integrationsEntity, From ab5fc300a4729a854051bed7890ce294abd2055d Mon Sep 17 00:00:00 2001 From: Filipe Menezes Date: Thu, 18 Aug 2022 11:56:18 +0100 Subject: [PATCH 3/3] fix integration test --- test/e2e/atlas/integrations_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/atlas/integrations_test.go b/test/e2e/atlas/integrations_test.go index fa89161970..6382db8eb8 100644 --- a/test/e2e/atlas/integrations_test.go +++ b/test/e2e/atlas/integrations_test.go @@ -214,7 +214,7 @@ func TestIntegrations(t *testing.T) { cmd := exec.Command(cliPath, integrationsEntity, "describe", - datadogEntity, + newRelicEntity, "--projectId", g.projectID, "-o=json") @@ -225,7 +225,7 @@ func TestIntegrations(t *testing.T) { a.NoError(err, string(resp)) var thirdPartyIntegration mongodbatlas.ThirdPartyIntegration if err := json.Unmarshal(resp, &thirdPartyIntegration); a.NoError(err) { - a.Equal(datadogEntity, thirdPartyIntegration.Type) + a.Equal(newRelicEntity, thirdPartyIntegration.Type) } }) @@ -233,7 +233,7 @@ func TestIntegrations(t *testing.T) { cmd := exec.Command(cliPath, integrationsEntity, "delete", - datadogEntity, + newRelicEntity, "--force", "--projectId", g.projectID) @@ -243,7 +243,7 @@ func TestIntegrations(t *testing.T) { a := assert.New(t) a.NoError(err, string(resp)) - expected := fmt.Sprintf("Integration '%s' deleted\n", datadogEntity) + expected := fmt.Sprintf("Integration '%s' deleted\n", newRelicEntity) a.Equal(expected, string(resp)) }) }