Skip to content

Commit 20729e2

Browse files
committed
WIP: Added a functional test
1 parent 90ab8b8 commit 20729e2

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

test/functional/nova_multicell_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,3 +952,43 @@ var _ = Describe("Nova multi cell", func() {
952952
})
953953
})
954954
})
955+
956+
var _ = Describe("Nova multi cell deletion", func() {
957+
BeforeEach(func() {
958+
959+
CreateNovaWith3CellsAndEnsureReady(novaNames)
960+
961+
})
962+
963+
When("Nova CR instance is created with 4 cells", func() {
964+
It("delete cell2 and cell3, verify for cell3", func() {
965+
966+
nova := GetNova(novaNames.NovaName)
967+
Expect(nova.Status.RegisteredCells).To(HaveKey(cell0.CellCRName.Name), "cell0 is not in the RegisteredCells", nova.Status.RegisteredCells)
968+
Expect(nova.Status.RegisteredCells).To(HaveKey(cell1.CellCRName.Name), "cell1 is not in the RegisteredCells", nova.Status.RegisteredCells)
969+
Expect(nova.Status.RegisteredCells).To(HaveKey(cell2.CellCRName.Name), "cell2 is not in the RegisteredCells", nova.Status.RegisteredCells)
970+
Expect(nova.Status.RegisteredCells).To(HaveKey(cell3.CellCRName.Name), "cell3 is not in the RegisteredCells", nova.Status.RegisteredCells)
971+
972+
// manually delete DB for cell3, to reproduce the error in cell3 deletion
973+
Expect(k8sClient.Delete(ctx, mariadb.GetMariaDBDatabase(cell3.MariaDBDatabaseName))).To(Succeed())
974+
975+
Eventually(func(g Gomega) {
976+
nova := GetNova(novaNames.NovaName)
977+
// delete(nova.Spec.CellTemplates, "cell2")
978+
delete(nova.Spec.CellTemplates, "cell3")
979+
g.Expect(k8sClient.Update(ctx, nova)).To(Succeed())
980+
}, timeout, interval).Should(Succeed())
981+
982+
Eventually(func(g Gomega) {
983+
// test cell2 is not present in CR
984+
nova := GetNova(novaNames.NovaName)
985+
// g.Expect(nova.Status.RegisteredCells).NotTo(HaveKey(cell2.CellCRName.Name))
986+
g.Expect(nova.Status.RegisteredCells).NotTo(HaveKey(cell3.CellCRName.Name))
987+
}, timeout, interval).Should(Succeed())
988+
989+
NovaCellNotExists(cell3.CellCRName)
990+
// GetNovaCell(cell3.CellCRName)
991+
992+
})
993+
})
994+
})

test/functional/nova_reconfiguration_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ func CreateNovaWith3CellsAndEnsureReady(novaNames NovaNames) {
4343
cell0 := novaNames.Cells["cell0"]
4444
cell1 := novaNames.Cells["cell1"]
4545
cell2 := novaNames.Cells["cell2"]
46+
cell3 := novaNames.Cells["cell3"]
4647

4748
DeferCleanup(k8sClient.Delete, ctx, CreateNovaSecret(novaNames.NovaName.Namespace, SecretName))
4849
DeferCleanup(k8sClient.Delete, ctx, CreateNovaMessageBusSecret(cell0))
4950
DeferCleanup(k8sClient.Delete, ctx, CreateNovaMessageBusSecret(cell1))
5051
DeferCleanup(k8sClient.Delete, ctx, CreateNovaMessageBusSecret(cell2))
52+
DeferCleanup(k8sClient.Delete, ctx, CreateNovaMessageBusSecret(cell3))
5153

5254
serviceSpec := corev1.ServiceSpec{Ports: []corev1.ServicePort{{Port: 3306}}}
5355
DeferCleanup(
@@ -56,6 +58,7 @@ func CreateNovaWith3CellsAndEnsureReady(novaNames NovaNames) {
5658
DeferCleanup(mariadb.DeleteDBService, mariadb.CreateDBService(cell0.MariaDBDatabaseName.Namespace, cell0.MariaDBDatabaseName.Name, serviceSpec))
5759
DeferCleanup(mariadb.DeleteDBService, mariadb.CreateDBService(cell1.MariaDBDatabaseName.Namespace, cell1.MariaDBDatabaseName.Name, serviceSpec))
5860
DeferCleanup(mariadb.DeleteDBService, mariadb.CreateDBService(cell2.MariaDBDatabaseName.Namespace, cell2.MariaDBDatabaseName.Name, serviceSpec))
61+
DeferCleanup(mariadb.DeleteDBService, mariadb.CreateDBService(cell3.MariaDBDatabaseName.Namespace, cell3.MariaDBDatabaseName.Name, serviceSpec))
5962

6063
apiMariaDBAccount, apiMariaDBSecret := mariadb.CreateMariaDBAccountAndSecret(
6164
novaNames.APIMariaDBDatabaseAccount, mariadbv1.MariaDBAccountSpec{})
@@ -79,6 +82,12 @@ func CreateNovaWith3CellsAndEnsureReady(novaNames NovaNames) {
7982
DeferCleanup(k8sClient.Delete, ctx, cell2Account)
8083
DeferCleanup(k8sClient.Delete, ctx, cell2Secret)
8184

85+
cell3Account, cell3Secret := mariadb.CreateMariaDBAccountAndSecret(
86+
cell3.MariaDBAccountName, mariadbv1.MariaDBAccountSpec{})
87+
// DeferCleanup(k8sClient.Delete, ctx, cell3Account)
88+
// DeferCleanup(k8sClient.Delete, ctx, cell3Secret)
89+
logger.Info("Not Creating defercleanup for cell3 ...", " -- ", cell3Secret)
90+
8291
spec := GetDefaultNovaSpec()
8392
cell0Template := GetDefaultNovaCellTemplate()
8493
cell0Template["cellDatabaseInstance"] = cell0.MariaDBDatabaseName.Name
@@ -98,10 +107,17 @@ func CreateNovaWith3CellsAndEnsureReady(novaNames NovaNames) {
98107
cell2Template["cellMessageBusInstance"] = cell2.TransportURLName.Name
99108
cell2Template["hasAPIAccess"] = false
100109

110+
cell3Template := GetDefaultNovaCellTemplate()
111+
cell3Template["cellDatabaseInstance"] = cell3.MariaDBDatabaseName.Name
112+
cell3Template["cellDatabaseAccount"] = cell3Account.Name
113+
cell3Template["cellMessageBusInstance"] = cell3.TransportURLName.Name
114+
cell3Template["hasAPIAccess"] = false
115+
101116
spec["cellTemplates"] = map[string]interface{}{
102117
"cell0": cell0Template,
103118
"cell1": cell1Template,
104119
"cell2": cell2Template,
120+
"cell3": cell3Template,
105121
}
106122
spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name
107123
spec["apiMessageBusInstance"] = cell0.TransportURLName.Name
@@ -123,15 +139,18 @@ func CreateNovaWith3CellsAndEnsureReady(novaNames NovaNames) {
123139
mariadb.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
124140
mariadb.SimulateMariaDBDatabaseCompleted(cell1.MariaDBDatabaseName)
125141
mariadb.SimulateMariaDBDatabaseCompleted(cell2.MariaDBDatabaseName)
142+
mariadb.SimulateMariaDBDatabaseCompleted(cell3.MariaDBDatabaseName)
126143

127144
mariadb.SimulateMariaDBAccountCompleted(novaNames.APIMariaDBDatabaseAccount)
128145
mariadb.SimulateMariaDBAccountCompleted(cell0.MariaDBAccountName)
129146
mariadb.SimulateMariaDBAccountCompleted(cell1.MariaDBAccountName)
130147
mariadb.SimulateMariaDBAccountCompleted(cell2.MariaDBAccountName)
148+
mariadb.SimulateMariaDBAccountCompleted(cell3.MariaDBAccountName)
131149

132150
infra.SimulateTransportURLReady(cell0.TransportURLName)
133151
infra.SimulateTransportURLReady(cell1.TransportURLName)
134152
infra.SimulateTransportURLReady(cell2.TransportURLName)
153+
infra.SimulateTransportURLReady(cell3.TransportURLName)
135154

136155
th.SimulateJobSuccess(cell0.DBSyncJobName)
137156
th.SimulateStatefulSetReplicaReady(cell0.ConductorStatefulSetName)
@@ -149,6 +168,11 @@ func CreateNovaWith3CellsAndEnsureReady(novaNames NovaNames) {
149168
th.SimulateStatefulSetReplicaReady(cell2.ConductorStatefulSetName)
150169
th.SimulateJobSuccess(cell2.CellMappingJobName)
151170

171+
th.SimulateStatefulSetReplicaReady(cell3.NoVNCProxyStatefulSetName)
172+
th.SimulateJobSuccess(cell3.DBSyncJobName)
173+
th.SimulateStatefulSetReplicaReady(cell3.ConductorStatefulSetName)
174+
th.SimulateJobSuccess(cell3.CellMappingJobName)
175+
152176
th.ExpectCondition(
153177
novaNames.NovaName,
154178
ConditionGetterFunc(NovaConditionGetter),

test/functional/suite_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ var (
8383
cell0 CellNames
8484
cell1 CellNames
8585
cell2 CellNames
86+
cell3 CellNames
8687
)
8788

8889
func TestAPIs(t *testing.T) {
@@ -280,8 +281,9 @@ var _ = BeforeEach(func() {
280281
Name: uuid.New().String()[:25],
281282
}
282283

283-
novaNames = GetNovaNames(novaName, []string{"cell0", "cell1", "cell2"})
284+
novaNames = GetNovaNames(novaName, []string{"cell0", "cell1", "cell2", "cell3"})
284285
cell0 = novaNames.Cells["cell0"]
285286
cell1 = novaNames.Cells["cell1"]
286287
cell2 = novaNames.Cells["cell2"]
288+
cell3 = novaNames.Cells["cell3"]
287289
})

0 commit comments

Comments
 (0)