Skip to content

Commit 2dec299

Browse files
committed
Add tests for database and distributed architecture
Signed-off-by: Dmitry Tantsur <[email protected]>
1 parent 38036a4 commit 2dec299

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

test/suite_test.go

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var _ = BeforeSuite(func() {
8383

8484
})
8585

86-
func WaitForIronic(name types.NamespacedName) *metal3api.Ironic {
86+
func WaitForIronic(name types.NamespacedName, distributed bool) *metal3api.Ironic {
8787
GinkgoHelper()
8888

8989
ironic := &metal3api.Ironic{}
@@ -98,8 +98,19 @@ func WaitForIronic(name types.NamespacedName) *metal3api.Ironic {
9898
if cond != nil && cond.Status == metav1.ConditionTrue {
9999
return true
100100
}
101-
102101
GinkgoWriter.Printf("Current status of Ironic: %+v\n", ironic)
102+
103+
serviceName := fmt.Sprintf("%s-service", name.Name)
104+
if distributed {
105+
deploy, err := clientset.AppsV1().DaemonSets(name.Namespace).Get(ctx, serviceName, metav1.GetOptions{})
106+
Expect(err).NotTo(HaveOccurred())
107+
GinkgoWriter.Printf("... status of DaemonSet: %+v\n", deploy)
108+
} else {
109+
deploy, err := clientset.AppsV1().Deployments(name.Namespace).Get(ctx, serviceName, metav1.GetOptions{})
110+
Expect(err).NotTo(HaveOccurred())
111+
GinkgoWriter.Printf("... status of Deployment: %+v\n", deploy)
112+
}
113+
103114
return false
104115
}).WithTimeout(15 * time.Minute).WithPolling(10 * time.Second).Should(BeTrue())
105116

@@ -180,7 +191,45 @@ var _ = Describe("Ironic object tests", func() {
180191
DeleteAndWait(ironic)
181192
})
182193

183-
ironic = WaitForIronic(name)
194+
ironic = WaitForIronic(name, false)
195+
VerifyIronic(ironic)
196+
})
197+
198+
It("creates distributed Ironic", func() {
199+
name := types.NamespacedName{
200+
Name: "test-ironic",
201+
Namespace: namespace,
202+
}
203+
204+
ironicDb := &metal3api.IronicDatabase{
205+
ObjectMeta: metav1.ObjectMeta{
206+
Name: fmt.Sprintf("%s-db", name.Name),
207+
Namespace: name.Namespace,
208+
},
209+
}
210+
211+
err := k8sClient.Create(ctx, ironicDb)
212+
Expect(err).NotTo(HaveOccurred())
213+
214+
ironic := &metal3api.Ironic{
215+
ObjectMeta: metav1.ObjectMeta{
216+
Name: name.Name,
217+
Namespace: name.Namespace,
218+
},
219+
Spec: metal3api.IronicSpec{
220+
DatabaseRef: corev1.LocalObjectReference{
221+
Name: ironicDb.Name,
222+
},
223+
Distributed: true,
224+
},
225+
}
226+
err = k8sClient.Create(ctx, ironic)
227+
Expect(err).NotTo(HaveOccurred())
228+
DeferCleanup(func() {
229+
DeleteAndWait(ironic)
230+
})
231+
232+
ironic = WaitForIronic(name, true)
184233
VerifyIronic(ironic)
185234
})
186235
})

0 commit comments

Comments
 (0)