Skip to content

Commit 939fdbb

Browse files
committed
Refactor e2e test for different log server per disk settings
1 parent db9e767 commit 939fdbb

File tree

2 files changed

+57
-75
lines changed

2 files changed

+57
-75
lines changed

e2e/fixtures/fdb_cluster.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,6 @@ func (fdbCluster *FdbCluster) GetStoragePods() *corev1.PodList {
581581
return fdbCluster.getPodsByProcessClass(fdbv1beta2.ProcessClassStorage)
582582
}
583583

584-
// GetTransactionPods returns all Pods of this cluster that have the process class transaction.
585-
func (fdbCluster *FdbCluster) GetTransactionPods() *corev1.PodList {
586-
return fdbCluster.getPodsByProcessClass(fdbv1beta2.ProcessClassTransaction)
587-
}
588-
589584
// GetPod returns the Pod with the given name that runs in the same namespace as the FoundationDBCluster.
590585
func (fdbCluster *FdbCluster) GetPod(name string) *corev1.Pod {
591586
pod := &corev1.Pod{}

e2e/test_operator/operator_test.go

Lines changed: 57 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ var _ = Describe("Operator", Label("e2e", "pr"), func() {
11491149
})
11501150

11511151
When("setting 2 logs per disk", func() {
1152-
var initialLogServerPerPod, expectedPodCnt, expectedLogProcessesCnt int
1152+
var initialLogServerPerPod, expectedPodCnt, expectedLogProcessesCnt, serverPerPod int
11531153

11541154
BeforeEach(func() {
11551155
initialLogServerPerPod = fdbCluster.GetLogServersPerPod()
@@ -1164,67 +1164,12 @@ var _ = Describe("Operator", Label("e2e", "pr"), func() {
11641164
Eventually(func() int {
11651165
return len(fdbCluster.GetLogPods().Items)
11661166
}).Should(BeNumerically("==", expectedPodCnt))
1167-
})
1168-
1169-
AfterEach(func() {
1170-
log.Printf("set log servers per Pod to %d", initialLogServerPerPod)
1171-
Expect(
1172-
fdbCluster.SetLogServersPerPod(initialLogServerPerPod, true),
1173-
).ShouldNot(HaveOccurred())
1174-
log.Printf(
1175-
"expectedPodCnt: %d, expectedProcessesCnt: %d",
1176-
expectedPodCnt,
1177-
expectedPodCnt*initialLogServerPerPod,
1178-
)
1179-
Eventually(func() int {
1180-
return len(fdbCluster.GetLogPods().Items)
1181-
}).Should(BeNumerically("==", expectedPodCnt))
1182-
})
1183-
1184-
It("should update the log servers to the expected amount", func() {
1185-
serverPerPod := initialLogServerPerPod * 2
1186-
log.Printf("set log servers per Pod to %d", initialLogServerPerPod)
1187-
Expect(fdbCluster.SetLogServersPerPod(serverPerPod, true)).ShouldNot(HaveOccurred())
1188-
log.Printf(
1189-
"expectedPodCnt: %d, expectedStorageProcessesCnt: %d",
1190-
expectedPodCnt,
1191-
expectedPodCnt*serverPerPod,
1192-
)
1193-
fdbCluster.ValidateProcessesCount(
1194-
fdbv1beta2.ProcessClassLog,
1195-
expectedPodCnt,
1196-
expectedPodCnt*serverPerPod,
1197-
)
1198-
})
1199-
})
1200-
1201-
When("setting 2 logs per disk to use transaction process", func() {
1202-
var initialLogServerPerPod, expectedPodCnt, expectedLogProcessesCnt int
12031167

1204-
BeforeEach(func() {
1205-
initialLogServerPerPod = fdbCluster.GetLogServersPerPod()
1206-
initialPods := fdbCluster.GetLogPods()
1207-
expectedPodCnt = len(initialPods.Items)
1208-
expectedLogProcessesCnt = expectedPodCnt * initialLogServerPerPod
1209-
log.Printf(
1210-
"expectedPodCnt: %d, expectedProcessesCnt: %d",
1211-
expectedPodCnt,
1212-
expectedLogProcessesCnt,
1213-
)
1214-
Eventually(func() int {
1215-
return len(fdbCluster.GetLogPods().Items)
1216-
}).Should(BeNumerically("==", expectedPodCnt))
1168+
serverPerPod = initialLogServerPerPod * 2
1169+
log.Printf("new log servers per Pod: %d", initialLogServerPerPod)
12171170
})
12181171

12191172
AfterEach(func() {
1220-
log.Printf("set log servers per Pod to %d", initialLogServerPerPod)
1221-
Expect(
1222-
fdbCluster.SetTransactionServerPerPod(
1223-
initialLogServerPerPod,
1224-
expectedLogProcessesCnt,
1225-
true,
1226-
),
1227-
).ShouldNot(HaveOccurred())
12281173
log.Printf(
12291174
"expectedPodCnt: %d, expectedProcessesCnt: %d",
12301175
expectedPodCnt,
@@ -1235,29 +1180,71 @@ var _ = Describe("Operator", Label("e2e", "pr"), func() {
12351180
}).Should(BeNumerically("==", expectedPodCnt))
12361181
})
12371182

1238-
It(
1239-
"should update the log servers to the expected amount and should create transaction Pods",
1240-
func() {
1241-
serverPerPod := initialLogServerPerPod * 2
1183+
When("when using log servers", func() {
1184+
AfterEach(func() {
1185+
log.Printf("set log servers per Pod to %d", initialLogServerPerPod)
12421186
Expect(
1243-
fdbCluster.SetTransactionServerPerPod(
1244-
serverPerPod,
1245-
expectedLogProcessesCnt,
1246-
true,
1247-
),
1187+
fdbCluster.SetLogServersPerPod(initialLogServerPerPod, true),
12481188
).ShouldNot(HaveOccurred())
1189+
})
1190+
1191+
BeforeEach(func() {
1192+
Expect(fdbCluster.SetLogServersPerPod(serverPerPod, true)).ShouldNot(HaveOccurred())
1193+
})
1194+
1195+
It("should update the log servers to the expected amount", func() {
1196+
Expect(fdbCluster.SetLogServersPerPod(serverPerPod, true)).ShouldNot(HaveOccurred())
12491197
log.Printf(
12501198
"expectedPodCnt: %d, expectedProcessesCnt: %d",
12511199
expectedPodCnt,
12521200
expectedPodCnt*serverPerPod,
12531201
)
12541202
fdbCluster.ValidateProcessesCount(
1255-
fdbv1beta2.ProcessClassTransaction,
1203+
fdbv1beta2.ProcessClassLog,
12561204
expectedPodCnt,
12571205
expectedPodCnt*serverPerPod,
12581206
)
1259-
},
1260-
)
1207+
})
1208+
})
1209+
1210+
When("migrating from log processes to transaction processes", func() {
1211+
AfterEach(func() {
1212+
log.Printf("set log servers per Pod to %d", initialLogServerPerPod)
1213+
Expect(
1214+
fdbCluster.SetTransactionServerPerPod(
1215+
initialLogServerPerPod,
1216+
expectedLogProcessesCnt,
1217+
true,
1218+
),
1219+
).ShouldNot(HaveOccurred())
1220+
})
1221+
1222+
BeforeEach(func() {
1223+
Expect(
1224+
fdbCluster.SetTransactionServerPerPod(
1225+
serverPerPod,
1226+
expectedLogProcessesCnt,
1227+
true,
1228+
),
1229+
).ShouldNot(HaveOccurred())
1230+
})
1231+
1232+
It(
1233+
"should update the log servers to the expected amount and should create transaction Pods",
1234+
func() {
1235+
log.Printf(
1236+
"expectedPodCnt: %d, expectedProcessesCnt: %d",
1237+
expectedPodCnt,
1238+
expectedPodCnt*serverPerPod,
1239+
)
1240+
fdbCluster.ValidateProcessesCount(
1241+
fdbv1beta2.ProcessClassTransaction,
1242+
expectedPodCnt,
1243+
expectedPodCnt*serverPerPod,
1244+
)
1245+
},
1246+
)
1247+
})
12611248
})
12621249

12631250
When("Replacing a Pod with PVC stuck in Terminating state", func() {

0 commit comments

Comments
 (0)