Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 37 additions & 25 deletions test/e2e/backuprestores/backup_restores_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,32 @@
g.GenerateProjectAndCluster("backupRestores")
require.NotEmpty(t, g.ClusterName)

g2 := internal.NewAtlasE2ETestGenerator(t, internal.WithSnapshot(), internal.WithBackup())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverts 2951dd7

g2.GenerateProjectAndCluster("backupRestores2")
require.NotEmpty(t, g2.ClusterName)
projectID := g.ProjectID
clusterName := g.ClusterName

t.Cleanup(func() {
internal.DeleteClusterForProject(projectID, clusterName)

Check failure on line 51 in test/e2e/backuprestores/backup_restores_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `internal.DeleteClusterForProject` is not checked (errcheck)
})

g.ProjectID = ""
g.ClusterName = ""

g.GenerateProjectAndCluster("backupRestores2")
require.NotEmpty(t, g.ClusterName)

projectID2 := g.ProjectID
clusterName2 := g.ClusterName

g.Run("Create snapshot", func(t *testing.T) { //nolint:thelper // g.Run replaces t.Run
cmd := exec.Command(cliPath,
backupsEntity,
snapshotsEntity,
"create",
g.ClusterName,
clusterName,
"--desc",
"test-snapshot",
"--projectId",
g.ProjectID,
projectID,
"-o=json")
cmd.Env = os.Environ()
resp, err := internal.RunAndGetStdOut(cmd)
Expand All @@ -77,9 +89,9 @@
"watch",
snapshotID,
"--clusterName",
g.ClusterName,
clusterName,
"--projectId",
g.ProjectID)
projectID)
cmd.Env = os.Environ()
resp, _ := internal.RunAndGetStdOut(cmd)
t.Log(string(resp))
Expand All @@ -92,15 +104,15 @@
"start",
"automated",
"--clusterName",
g.ClusterName,
clusterName,
"--snapshotId",
snapshotID,
"--projectId",
g.ProjectID,
projectID,
"--targetProjectId",
g2.ProjectID,
projectID2,
"--targetClusterName",
g2.ClusterName,
clusterName2,
"-o=json")
cmd.Env = os.Environ()
resp, err := internal.RunAndGetStdOut(cmd)
Expand All @@ -118,9 +130,9 @@
"watch",
restoreJobID,
"--clusterName",
g.ClusterName,
clusterName,
"--projectId",
g.ProjectID,
projectID,
"-o=json")
cmd.Env = os.Environ()
resp, err := internal.RunAndGetStdOut(cmd)
Expand All @@ -133,9 +145,9 @@
backupsEntity,
restoresEntity,
"list",
g.ClusterName,
clusterName,
"--projectId",
g.ProjectID,
projectID,
"-o=json")
cmd.Env = os.Environ()
resp, err := internal.RunAndGetStdOut(cmd)
Expand All @@ -153,9 +165,9 @@
"describe",
restoreJobID,
"--clusterName",
g.ClusterName,
clusterName,
"--projectId",
g.ProjectID,
projectID,
"-o=json")
cmd.Env = os.Environ()
resp, err := internal.RunAndGetStdOut(cmd)
Expand All @@ -174,11 +186,11 @@
"start",
"download",
"--clusterName",
g.ClusterName,
clusterName,
"--snapshotId",
snapshotID,
"--projectId",
g.ProjectID,
projectID,
"-o=json")
cmd.Env = os.Environ()
resp, err := internal.RunAndGetStdOut(cmd)
Expand All @@ -196,9 +208,9 @@
"watch",
restoreJobID,
"--clusterName",
g.ClusterName,
clusterName,
"--projectId",
g.ProjectID,
projectID,
"-o=json")
cmd.Env = os.Environ()
resp, err := internal.RunAndGetStdOut(cmd)
Expand All @@ -213,9 +225,9 @@
"delete",
snapshotID,
"--clusterName",
g.ClusterName,
clusterName,
"--projectId",
g.ProjectID,
projectID,
"--force")
cmd.Env = os.Environ()
resp, err := internal.RunAndGetStdOut(cmd)
Expand All @@ -233,9 +245,9 @@
"watch",
snapshotID,
"--clusterName",
g.ClusterName,
clusterName,
"--projectId",
g.ProjectID)
projectID)
cmd.Env = os.Environ()
resp, _ := internal.RunAndGetStdOut(cmd)
t.Log(string(resp))
Expand Down
2 changes: 1 addition & 1 deletion test/internal/atlas_e2e_test_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (g *AtlasE2ETestGenerator) GenerateCluster() {
g.generateClusterWithPrefix("cluster")
}

// GenerateProjectAndCluster calls both generateProject and generateCluster.
// generateProjectAndCluster calls both generateProject and generateCluster.
func (g *AtlasE2ETestGenerator) GenerateProjectAndCluster(prefix string) {
g.t.Helper()

Expand Down
9 changes: 9 additions & 0 deletions test/internal/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,18 @@ func removeTerminationProtectionFromCluster(projectID, clusterName string) error

func DeleteClusterForProject(projectID, clusterName string) error {
if err := internalDeleteClusterForProject(projectID, clusterName); err != nil {
if strings.Contains(err.Error(), "CLUSTER_NOT_FOUND") {
return nil
}

if strings.Contains(err.Error(), "GROUP_NOT_FOUND") {
return nil
}

if !strings.Contains(err.Error(), "CANNOT_TERMINATE_CLUSTER_WHEN_TERMINATION_PROTECTION_ENABLED") {
return err
}

if err := removeTerminationProtectionFromCluster(projectID, clusterName); err != nil {
return err
}
Expand Down
Loading