Skip to content

Commit 784de4e

Browse files
authored
CLOUDP-132962: Datadog integration is disabled in cloudgov (#1417)
* CLOUDP-132962: Datadog integration is disabled in cloudgov * Fix * fix integration test
1 parent fa442be commit 784de4e

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

test/e2e/atlas/helper_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ func integrationExists(name string, thirdPartyIntegrations mongodbatlas.ThirdPar
279279
return false
280280
}
281281

282+
func Gov() bool {
283+
return os.Getenv("MCLI_SERVICE") == "cloudgov"
284+
}
285+
282286
func createProject(projectName string) (string, error) {
283287
cliPath, err := e2e.AtlasCLIBin()
284288
if err != nil {
@@ -290,7 +294,7 @@ func createProject(projectName string) (string, error) {
290294
projectName,
291295
"-o=json",
292296
}
293-
if os.Getenv("MCLI_SERVICE") == "cloudgov" {
297+
if Gov() {
294298
args = append(args, "--govCloudRegionsOnly")
295299
}
296300
cmd := exec.Command(cliPath, args...)

test/e2e/atlas/integrations_test.go

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,29 @@ func TestIntegrations(t *testing.T) {
4848
cliPath, err := e2e.AtlasCLIBin()
4949
require.NoError(t, err)
5050

51-
t.Run("Create DATADOG", func(t *testing.T) {
52-
cmd := exec.Command(cliPath,
53-
integrationsEntity,
54-
"create",
55-
datadogEntity,
56-
"--apiKey",
57-
key,
58-
"--projectId",
59-
g.projectID,
60-
"-o=json")
61-
cmd.Env = os.Environ()
62-
resp, err := cmd.CombinedOutput()
63-
64-
a := assert.New(t)
65-
a.NoError(err, string(resp))
66-
67-
var thirdPartyIntegrations mongodbatlas.ThirdPartyIntegrations
68-
if err := json.Unmarshal(resp, &thirdPartyIntegrations); a.NoError(err) {
69-
a.True(integrationExists(datadogEntity, thirdPartyIntegrations))
70-
}
71-
})
51+
if !Gov() { // cloudgov does not have an available datadog region
52+
t.Run("Create DATADOG", func(t *testing.T) {
53+
cmd := exec.Command(cliPath,
54+
integrationsEntity,
55+
"create",
56+
datadogEntity,
57+
"--apiKey",
58+
key,
59+
"--projectId",
60+
g.projectID,
61+
"-o=json")
62+
cmd.Env = os.Environ()
63+
resp, err := cmd.CombinedOutput()
64+
65+
a := assert.New(t)
66+
a.NoError(err, string(resp))
67+
68+
var thirdPartyIntegrations mongodbatlas.ThirdPartyIntegrations
69+
if err := json.Unmarshal(resp, &thirdPartyIntegrations); a.NoError(err) {
70+
a.True(integrationExists(datadogEntity, thirdPartyIntegrations))
71+
}
72+
})
73+
}
7274

7375
t.Run("Create NEW_RELIC", func(t *testing.T) {
7476
cmd := exec.Command(cliPath,
@@ -212,7 +214,7 @@ func TestIntegrations(t *testing.T) {
212214
cmd := exec.Command(cliPath,
213215
integrationsEntity,
214216
"describe",
215-
datadogEntity,
217+
newRelicEntity,
216218
"--projectId",
217219
g.projectID,
218220
"-o=json")
@@ -223,15 +225,15 @@ func TestIntegrations(t *testing.T) {
223225
a.NoError(err, string(resp))
224226
var thirdPartyIntegration mongodbatlas.ThirdPartyIntegration
225227
if err := json.Unmarshal(resp, &thirdPartyIntegration); a.NoError(err) {
226-
a.Equal(datadogEntity, thirdPartyIntegration.Type)
228+
a.Equal(newRelicEntity, thirdPartyIntegration.Type)
227229
}
228230
})
229231

230232
t.Run("Delete", func(t *testing.T) {
231233
cmd := exec.Command(cliPath,
232234
integrationsEntity,
233235
"delete",
234-
datadogEntity,
236+
newRelicEntity,
235237
"--force",
236238
"--projectId",
237239
g.projectID)
@@ -241,7 +243,7 @@ func TestIntegrations(t *testing.T) {
241243
a := assert.New(t)
242244
a.NoError(err, string(resp))
243245

244-
expected := fmt.Sprintf("Integration '%s' deleted\n", datadogEntity)
246+
expected := fmt.Sprintf("Integration '%s' deleted\n", newRelicEntity)
245247
a.Equal(expected, string(resp))
246248
})
247249
}

0 commit comments

Comments
 (0)