Skip to content

Commit a2281f2

Browse files
Add Wait Logic to "Delete Cluster" E2E Tests
The "pgo delete cluster" E2E tests now include wait logic when verifying that the "pgo show" command no longer displays cluster information after the cluster has been deleted. This is done to accommodate the updated rmdata process, which now only deletes the pgcluster custom resource once all other resources for the cluster have been successfully deleted. [sc-13204]
1 parent 3854134 commit a2281f2

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

testing/pgo_cli/cluster_delete_test.go

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package pgo_cli_test
1616
*/
1717

1818
import (
19+
"strings"
1920
"testing"
2021
"time"
2122

@@ -46,9 +47,14 @@ func TestClusterDelete(t *testing.T) {
4647
requireWaitFor(t, gone, time.Minute, time.Second,
4748
"timeout waiting for data of %q in %q", cluster(), namespace())
4849

49-
output, err = pgo("show", "cluster", cluster(), "-n", namespace()).Exec(t)
50-
require.NoError(t, err)
51-
require.NotContains(t, output, cluster())
50+
emptyPGOShow := func() bool {
51+
output, err = pgo("show", "cluster", cluster(), "-n", namespace()).Exec(t)
52+
require.NoError(t, err)
53+
return !strings.Contains(output, cluster())
54+
}
55+
requireWaitFor(t, emptyPGOShow, time.Minute, time.Second,
56+
"timeout waiting for pgo show to no longer display information for cluster %s",
57+
cluster())
5258
})
5359
})
5460

@@ -72,9 +78,14 @@ func TestClusterDelete(t *testing.T) {
7278
require.NotEmpty(t, pvcs)
7379
require.Contains(t, pvcs[0].Name, "pgbr-repo")
7480

75-
output, err = pgo("show", "cluster", cluster(), "-n", namespace()).Exec(t)
76-
require.NoError(t, err)
77-
require.NotContains(t, output, cluster())
81+
emptyPGOShow := func() bool {
82+
output, err = pgo("show", "cluster", cluster(), "-n", namespace()).Exec(t)
83+
require.NoError(t, err)
84+
return !strings.Contains(output, cluster())
85+
}
86+
requireWaitFor(t, emptyPGOShow, time.Minute, time.Second,
87+
"timeout waiting for pgo show to no longer display information for cluster %s",
88+
cluster())
7889
})
7990
})
8091

@@ -97,6 +108,15 @@ func TestClusterDelete(t *testing.T) {
97108
pvcs := clusterPVCs(t, namespace(), cluster())
98109
require.NotEmpty(t, pvcs)
99110
require.Equal(t, cluster(), pvcs[0].Name)
111+
112+
emptyPGOShow := func() bool {
113+
output, err = pgo("show", "cluster", cluster(), "-n", namespace()).Exec(t)
114+
require.NoError(t, err)
115+
return !strings.Contains(output, cluster())
116+
}
117+
requireWaitFor(t, emptyPGOShow, time.Minute, time.Second,
118+
"timeout waiting for pgo show to no longer display information for cluster %s",
119+
cluster())
100120
})
101121
})
102122
})

0 commit comments

Comments
 (0)