Skip to content

Commit ad444c4

Browse files
CLOUDP-309403: Flaky Test: mongodb-atlas-cli-master-github.com_mongodb_mongodb-atlas-cli_atlascli_test_e2e.TestRestores/atlas_backups_restores_e2e/e2e_atlas_backups (#3906)
1 parent 15865d9 commit ad444c4

File tree

2 files changed

+26
-34
lines changed

2 files changed

+26
-34
lines changed

test/e2e/backuprestores/backup_restores_test.go

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,20 @@ func TestRestores(t *testing.T) {
4444
g.GenerateProjectAndCluster("backupRestores")
4545
require.NotEmpty(t, g.ClusterName)
4646

47-
projectID := g.ProjectID
48-
clusterName := g.ClusterName
49-
50-
g.ProjectID = ""
51-
g.ClusterName = ""
52-
53-
g.GenerateProjectAndCluster("backupRestores2")
54-
require.NotEmpty(t, g.ClusterName)
55-
56-
projectID2 := g.ProjectID
57-
clusterName2 := g.ClusterName
47+
g2 := internal.NewAtlasE2ETestGenerator(t, internal.WithSnapshot(), internal.WithBackup())
48+
g2.GenerateProjectAndCluster("backupRestores2")
49+
require.NotEmpty(t, g2.ClusterName)
5850

5951
g.Run("Create snapshot", func(t *testing.T) { //nolint:thelper // g.Run replaces t.Run
6052
cmd := exec.Command(cliPath,
6153
backupsEntity,
6254
snapshotsEntity,
6355
"create",
64-
clusterName,
56+
g.ClusterName,
6557
"--desc",
6658
"test-snapshot",
6759
"--projectId",
68-
projectID,
60+
g.ProjectID,
6961
"-o=json")
7062
cmd.Env = os.Environ()
7163
resp, err := internal.RunAndGetStdOut(cmd)
@@ -85,9 +77,9 @@ func TestRestores(t *testing.T) {
8577
"watch",
8678
snapshotID,
8779
"--clusterName",
88-
clusterName,
80+
g.ClusterName,
8981
"--projectId",
90-
projectID)
82+
g.ProjectID)
9183
cmd.Env = os.Environ()
9284
resp, _ := internal.RunAndGetStdOut(cmd)
9385
t.Log(string(resp))
@@ -100,15 +92,15 @@ func TestRestores(t *testing.T) {
10092
"start",
10193
"automated",
10294
"--clusterName",
103-
clusterName,
95+
g.ClusterName,
10496
"--snapshotId",
10597
snapshotID,
10698
"--projectId",
107-
projectID,
99+
g.ProjectID,
108100
"--targetProjectId",
109-
projectID2,
101+
g2.ProjectID,
110102
"--targetClusterName",
111-
clusterName2,
103+
g2.ClusterName,
112104
"-o=json")
113105
cmd.Env = os.Environ()
114106
resp, err := internal.RunAndGetStdOut(cmd)
@@ -126,9 +118,9 @@ func TestRestores(t *testing.T) {
126118
"watch",
127119
restoreJobID,
128120
"--clusterName",
129-
clusterName,
121+
g.ClusterName,
130122
"--projectId",
131-
projectID,
123+
g.ProjectID,
132124
"-o=json")
133125
cmd.Env = os.Environ()
134126
resp, err := internal.RunAndGetStdOut(cmd)
@@ -141,9 +133,9 @@ func TestRestores(t *testing.T) {
141133
backupsEntity,
142134
restoresEntity,
143135
"list",
144-
clusterName,
136+
g.ClusterName,
145137
"--projectId",
146-
projectID,
138+
g.ProjectID,
147139
"-o=json")
148140
cmd.Env = os.Environ()
149141
resp, err := internal.RunAndGetStdOut(cmd)
@@ -161,9 +153,9 @@ func TestRestores(t *testing.T) {
161153
"describe",
162154
restoreJobID,
163155
"--clusterName",
164-
clusterName,
156+
g.ClusterName,
165157
"--projectId",
166-
projectID,
158+
g.ProjectID,
167159
"-o=json")
168160
cmd.Env = os.Environ()
169161
resp, err := internal.RunAndGetStdOut(cmd)
@@ -182,11 +174,11 @@ func TestRestores(t *testing.T) {
182174
"start",
183175
"download",
184176
"--clusterName",
185-
clusterName,
177+
g.ClusterName,
186178
"--snapshotId",
187179
snapshotID,
188180
"--projectId",
189-
projectID,
181+
g.ProjectID,
190182
"-o=json")
191183
cmd.Env = os.Environ()
192184
resp, err := internal.RunAndGetStdOut(cmd)
@@ -204,9 +196,9 @@ func TestRestores(t *testing.T) {
204196
"watch",
205197
restoreJobID,
206198
"--clusterName",
207-
clusterName,
199+
g.ClusterName,
208200
"--projectId",
209-
projectID,
201+
g.ProjectID,
210202
"-o=json")
211203
cmd.Env = os.Environ()
212204
resp, err := internal.RunAndGetStdOut(cmd)
@@ -221,9 +213,9 @@ func TestRestores(t *testing.T) {
221213
"delete",
222214
snapshotID,
223215
"--clusterName",
224-
clusterName,
216+
g.ClusterName,
225217
"--projectId",
226-
projectID,
218+
g.ProjectID,
227219
"--force")
228220
cmd.Env = os.Environ()
229221
resp, err := internal.RunAndGetStdOut(cmd)
@@ -241,9 +233,9 @@ func TestRestores(t *testing.T) {
241233
"watch",
242234
snapshotID,
243235
"--clusterName",
244-
clusterName,
236+
g.ClusterName,
245237
"--projectId",
246-
projectID)
238+
g.ProjectID)
247239
cmd.Env = os.Environ()
248240
resp, _ := internal.RunAndGetStdOut(cmd)
249241
t.Log(string(resp))

test/internal/atlas_e2e_test_generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func (g *AtlasE2ETestGenerator) GenerateCluster() {
345345
g.generateClusterWithPrefix("cluster")
346346
}
347347

348-
// generateProjectAndCluster calls both generateProject and generateCluster.
348+
// GenerateProjectAndCluster calls both generateProject and generateCluster.
349349
func (g *AtlasE2ETestGenerator) GenerateProjectAndCluster(prefix string) {
350350
g.t.Helper()
351351

0 commit comments

Comments
 (0)