Skip to content

Commit 8f141f7

Browse files
committed
Optimize tests to reduce cpu/mem usage
1 parent 4bb4f6d commit 8f141f7

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

test/functional/base_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,12 +1063,15 @@ func CreateNovaWithNCellsAndEnsureReady(cellNumber int, novaNames *NovaNames) {
10631063
DeferCleanup(keystone.DeleteKeystoneAPI, novaNames.KeystoneAPIName)
10641064

10651065
// Set region on KeystoneAPI to ensure GetRegion() returns a value
1066+
keystoneAPI := keystone.GetKeystoneAPI(novaNames.KeystoneAPIName)
1067+
keystoneAPI.Spec.Region = "regionOne"
1068+
Expect(k8sClient.Update(ctx, keystoneAPI)).To(Succeed())
1069+
1070+
// Update status separately after spec is applied
10661071
Eventually(func(g Gomega) {
1067-
keystoneAPI := keystone.GetKeystoneAPI(novaNames.KeystoneAPIName)
1068-
keystoneAPI.Spec.Region = "regionOne"
1069-
g.Expect(k8sClient.Update(ctx, keystoneAPI)).To(Succeed())
1070-
keystoneAPI.Status.Region = "regionOne"
1071-
g.Expect(k8sClient.Status().Update(ctx, keystoneAPI)).To(Succeed())
1072+
ks := keystone.GetKeystoneAPI(novaNames.KeystoneAPIName)
1073+
ks.Status.Region = "regionOne"
1074+
g.Expect(k8sClient.Status().Update(ctx, ks)).To(Succeed())
10721075
}, timeout, interval).Should(Succeed())
10731076

10741077
memcachedSpec := infra.GetDefaultMemcachedSpec()

test/functional/nova_controller_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,12 +1940,16 @@ var _ = Describe("Nova controller - region defaults", func() {
19401940
})
19411941

19421942
It("defaults the region to regionOne", func() {
1943+
// Clear region on KeystoneAPI spec first
1944+
keystoneAPI := keystone.GetKeystoneAPI(novaNames.KeystoneAPIName)
1945+
keystoneAPI.Spec.Region = ""
1946+
Expect(k8sClient.Update(ctx, keystoneAPI)).To(Succeed())
1947+
1948+
// Update status separately after spec is applied
19431949
Eventually(func(g Gomega) {
1944-
keystoneAPI := keystone.GetKeystoneAPI(novaNames.KeystoneAPIName)
1945-
keystoneAPI.Spec.Region = ""
1946-
g.Expect(k8sClient.Update(ctx, keystoneAPI)).To(Succeed())
1947-
keystoneAPI.Status.Region = ""
1948-
g.Expect(k8sClient.Status().Update(ctx, keystoneAPI)).To(Succeed())
1950+
ks := keystone.GetKeystoneAPI(novaNames.KeystoneAPIName)
1951+
ks.Status.Region = ""
1952+
g.Expect(k8sClient.Status().Update(ctx, ks)).To(Succeed())
19491953
}, timeout, interval).Should(Succeed())
19501954

19511955
Eventually(func(g Gomega) {

0 commit comments

Comments
 (0)