-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple e2e tests for replication
Signed-off-by: Ryotaro Banno <ryotaro.banno@gmail.com>
- Loading branch information
1 parent
bfe05cf
commit 5dc2dfb
Showing
13 changed files
with
378 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package multik8s | ||
|
||
import ( | ||
_ "embed" | ||
"errors" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/cybozu-go/mantle/test/util" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"k8s.io/apimachinery/pkg/api/meta" | ||
|
||
mantlev1 "github.com/cybozu-go/mantle/api/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestMtest(t *testing.T) { | ||
if os.Getenv("E2ETEST") == "" { | ||
t.Skip("Run under e2e/") | ||
} | ||
|
||
RegisterFailHandler(Fail) | ||
|
||
SetDefaultEventuallyPollingInterval(time.Second) | ||
SetDefaultEventuallyTimeout(3 * time.Minute) | ||
|
||
RunSpecs(t, "rbd backup system test with multiple k8s clusters") | ||
} | ||
|
||
var _ = Describe("Mantle", func() { | ||
Context("wait controller to be ready", waitControllerToBeReady) | ||
Context("replication test", replicationTestSuite) | ||
}) | ||
|
||
func waitControllerToBeReady() { | ||
It("wait for mantle-controller to be ready", func() { | ||
Eventually(func() error { | ||
return checkDeploymentReady(primaryK8sCluster, "rook-ceph", "mantle-controller") | ||
}).Should(Succeed()) | ||
|
||
Eventually(func() error { | ||
return checkDeploymentReady(primaryK8sCluster, "rook-ceph", "mantle-controller") | ||
}).Should(Succeed()) | ||
}) | ||
} | ||
|
||
func replicationTestSuite() { | ||
Describe("replication test", func() { | ||
It("should eventually set SyncedToRemote of a MantleBackup to True after it is created", func() { | ||
namespace := util.GetUniqueName("ns-") | ||
pvcName := util.GetUniqueName("pvc-") | ||
backupName := util.GetUniqueName("mb-") | ||
scName := util.GetUniqueName("sc-") | ||
poolName := util.GetUniqueName("pool-") | ||
|
||
By("setting up the environment") | ||
Eventually(func() error { | ||
return createNamespace(primaryK8sCluster, namespace) | ||
}).Should(Succeed()) | ||
Eventually(func() error { | ||
return applyRBDPoolAndSCTemplate(primaryK8sCluster, cephClusterNamespace, poolName, scName) | ||
}).Should(Succeed()) | ||
Eventually(func() error { | ||
return applyPVCTemplate(primaryK8sCluster, namespace, pvcName, scName) | ||
}).Should(Succeed()) | ||
|
||
By("creating a MantleBackup object") | ||
Eventually(func() error { | ||
return applyMantleBackupTemplate(primaryK8sCluster, namespace, pvcName, backupName) | ||
}).Should(Succeed()) | ||
|
||
By("checking MantleBackup's SyncedToRemote status") | ||
Eventually(func() error { | ||
mb, err := getMB(primaryK8sCluster, namespace, backupName) | ||
if err != nil { | ||
return err | ||
} | ||
cond := meta.FindStatusCondition(mb.Status.Conditions, mantlev1.BackupConditionSyncedToRemote) | ||
if cond == nil { | ||
return errors.New("couldn't find condition SyncedToRemote") | ||
} | ||
if cond.Status != metav1.ConditionTrue { | ||
return errors.New("status of SyncedToRemote condition is not True") | ||
} | ||
return nil | ||
}).Should(Succeed()) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: mantle.cybozu.io/v1 | ||
kind: MantleBackup | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: mantlebackup | ||
app.kubernetes.io/instance: %s | ||
app.kubernetes.io/part-of: mantle | ||
app.kubernetes.io/managed-by: kustomize | ||
app.kubernetes.io/created-by: mantle | ||
name: %s | ||
namespace: %s | ||
spec: | ||
pvc: %s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: %s | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
storageClassName: %s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: ceph.rook.io/v1 | ||
kind: CephBlockPool | ||
metadata: | ||
name: %s | ||
namespace: %s | ||
spec: | ||
failureDomain: osd | ||
replicated: | ||
size: 1 | ||
requireSafeReplicaSize: false | ||
--- | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: %s | ||
provisioner: rook-ceph.rbd.csi.ceph.com | ||
parameters: | ||
clusterID: %s | ||
pool: %s | ||
imageFormat: "2" | ||
imageFeatures: layering | ||
csi.storage.k8s.io/provisioner-secret-name: rook-csi-rbd-provisioner | ||
csi.storage.k8s.io/provisioner-secret-namespace: %s | ||
csi.storage.k8s.io/controller-expand-secret-name: rook-csi-rbd-provisioner | ||
csi.storage.k8s.io/controller-expand-secret-namespace: %s | ||
csi.storage.k8s.io/node-stage-secret-name: rook-csi-rbd-node | ||
csi.storage.k8s.io/node-stage-secret-namespace: %s | ||
csi.storage.k8s.io/fstype: ext4 | ||
allowVolumeExpansion: true | ||
reclaimPolicy: Delete |
Oops, something went wrong.