Skip to content

Commit 6d4a876

Browse files
committed
test: ensuring migration works for etcd and postgresql
Signed-off-by: Dario Tranchitella <[email protected]>
1 parent f60cc56 commit 6d4a876

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

config/samples/kamaji_v1alpha1_tenantcontrolplane.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
labels:
66
tenant.clastix.io: k8s-130
77
spec:
8+
dataStore: postgresql-bronze
89
controlPlane:
910
deployment:
1011
replicas: 2

e2e/tcp_migration_test.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ import (
2222
"github.com/clastix/kamaji/internal/utilities"
2323
)
2424

25-
var _ = Describe("When migrating a Tenant Control Plane to another datastore", func() {
25+
func featureTestMigration(driver string) {
2626
var tcp *kamajiv1alpha1.TenantControlPlane
2727
// Create a TenantControlPlane resource into the cluster
2828
JustBeforeEach(func() {
2929
// Fill TenantControlPlane object
3030
tcp = &kamajiv1alpha1.TenantControlPlane{
3131
ObjectMeta: metav1.ObjectMeta{
32-
Name: fmt.Sprintf("migrating-%s-etcd", rand.String(5)),
32+
Name: fmt.Sprintf("migrating-%s-%s", rand.String(5), driver),
3333
Namespace: "default",
3434
},
3535
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
36-
DataStore: "etcd-bronze",
36+
DataStore: fmt.Sprintf("%s-bronze", driver),
3737
ControlPlane: kamajiv1alpha1.ControlPlane{
3838
Deployment: kamajiv1alpha1.DeploymentSpec{
3939
Replicas: pointer.To(int32(1)),
@@ -91,7 +91,7 @@ var _ = Describe("When migrating a Tenant Control Plane to another datastore", f
9191
return err
9292
}
9393

94-
tcp.Spec.DataStore = "etcd-silver"
94+
tcp.Spec.DataStore = fmt.Sprintf("%s-silver", driver)
9595

9696
return k8sClient.Update(context.Background(), tcp)
9797
}, time.Minute, time.Second).ShouldNot(HaveOccurred())
@@ -114,11 +114,19 @@ var _ = Describe("When migrating a Tenant Control Plane to another datastore", f
114114
}
115115

116116
return tcp.Status.Storage.DataStoreName
117-
}, time.Minute, time.Second).Should(BeEquivalentTo("etcd-silver"))
117+
}, time.Minute, time.Second).Should(BeEquivalentTo(fmt.Sprintf("%s-silver", driver)))
118118

119119
By("checking the presence of the previous Namespace")
120120
Eventually(func() error {
121121
return tcpClient.Get(context.Background(), types.NamespacedName{Name: ns.GetName()}, &corev1.Namespace{})
122122
}).ShouldNot(HaveOccurred())
123123
})
124+
}
125+
126+
var _ = Describe("When migrating a Tenant Control Plane to another datastore (etcd)", func() {
127+
featureTestMigration("etcd")
128+
})
129+
130+
var _ = Describe("When migrating a Tenant Control Plane to another datastore (postgresql)", func() {
131+
featureTestMigration("postgresql")
124132
})

0 commit comments

Comments
 (0)