From 3929be6ce2970c19f4eec1f10ea185b34276c113 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Sun, 13 Oct 2024 23:33:39 +0300 Subject: [PATCH] Add volsync block self test Add an overlay using rook-ceph-block pvc. We deploy and both test in parallel. Signed-off-by: Nir Soffer --- .../volsync/app/base/kustomization.yaml | 1 - test/addons/volsync/app/block/deploy.yaml | 56 +++++++++++++++++++ .../volsync/app/block/kustomization.yaml | 24 ++++++++ .../volsync/app/{base => file}/deploy.yaml | 0 .../volsync/app/file/kustomization.yaml | 1 + .../volsync/rd/block/kustomization.yaml | 33 +++++++++++ test/addons/volsync/rs/block/rs.yaml | 21 +++++++ test/addons/volsync/rs/block/secret.yaml | 11 ++++ test/addons/volsync/test | 33 +++++++---- test/envs/volsync.yaml | 1 + 10 files changed, 169 insertions(+), 12 deletions(-) create mode 100644 test/addons/volsync/app/block/deploy.yaml create mode 100644 test/addons/volsync/app/block/kustomization.yaml rename test/addons/volsync/app/{base => file}/deploy.yaml (100%) create mode 100644 test/addons/volsync/rd/block/kustomization.yaml create mode 100644 test/addons/volsync/rs/block/rs.yaml create mode 100644 test/addons/volsync/rs/block/secret.yaml diff --git a/test/addons/volsync/app/base/kustomization.yaml b/test/addons/volsync/app/base/kustomization.yaml index c50eb98bb..66849fe5c 100644 --- a/test/addons/volsync/app/base/kustomization.yaml +++ b/test/addons/volsync/app/base/kustomization.yaml @@ -5,5 +5,4 @@ resources: - namespace.yaml - pvc.yaml -- deploy.yaml namespace: volsync-test diff --git a/test/addons/volsync/app/block/deploy.yaml b/test/addons/volsync/app/block/deploy.yaml new file mode 100644 index 000000000..81654c368 --- /dev/null +++ b/test/addons/volsync/app/block/deploy.yaml @@ -0,0 +1,56 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +# yamllint disable rule:line-length +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + appname: busybox + name: busybox +spec: + replicas: 1 + selector: + matchLabels: + appname: busybox + template: + metadata: + labels: + appname: busybox + spec: + containers: + - image: quay.io/nirsof/busybox:stable + imagePullPolicy: IfNotPresent + name: busybox + command: + - sh + - -c + - | + trap exit TERM + image_size=1073741824 # 1Gi + block_size=512 + blocks=$((image_size/block_size)) + block_number=0 + while true; do + data=$(date) + echo $data + echo $data | dd of=/dev/xvda bs=$block_size seek=$block_number status=none conv=fsync + sleep 10 & + wait + block_number=$((block_number+1)) + if [ $block_number -ge $blocks ]; then + block_number=0; + fi + done + volumeDevices: + - name: volume + devicePath: /dev/xvda + volumes: + - name: volume + persistentVolumeClaim: + claimName: busybox-pvc + securityContext: + runAsUser: 10000 + runAsGroup: 10000 + fsGroup: 10000 diff --git a/test/addons/volsync/app/block/kustomization.yaml b/test/addons/volsync/app/block/kustomization.yaml new file mode 100644 index 000000000..84e42ad1e --- /dev/null +++ b/test/addons/volsync/app/block/kustomization.yaml @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +namespace: volsync-test-block +resources: + - ../base + - deploy.yaml +patches: + # Customize for internal ceph rbd storage. + - target: + kind: PersistentVolumeClaim + name: busybox-pvc + patch: |- + - op: replace + path: /spec/storageClassName + value: rook-ceph-block + - op: replace + path: /spec/accessModes + value: + - ReadWriteOnce + - op: replace + path: /spec/volumeMode + value: Block diff --git a/test/addons/volsync/app/base/deploy.yaml b/test/addons/volsync/app/file/deploy.yaml similarity index 100% rename from test/addons/volsync/app/base/deploy.yaml rename to test/addons/volsync/app/file/deploy.yaml diff --git a/test/addons/volsync/app/file/kustomization.yaml b/test/addons/volsync/app/file/kustomization.yaml index 9bf4a8418..ca791b729 100644 --- a/test/addons/volsync/app/file/kustomization.yaml +++ b/test/addons/volsync/app/file/kustomization.yaml @@ -5,6 +5,7 @@ namespace: volsync-test-file resources: - ../base + - deploy.yaml patches: # Customize for internal cephfs storage. - target: diff --git a/test/addons/volsync/rd/block/kustomization.yaml b/test/addons/volsync/rd/block/kustomization.yaml new file mode 100644 index 000000000..797529ead --- /dev/null +++ b/test/addons/volsync/rd/block/kustomization.yaml @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +namespace: volsync-test-block +resources: + - ../base +patches: + # Customize for internal ceph rbd storage. + - target: + kind: PersistentVolumeClaim + name: volsync-pvc + patch: |- + - op: replace + path: /spec/storageClassName + value: rook-ceph-block + - op: replace + path: /spec/accessModes + value: + - ReadWriteOnce + - op: replace + path: /spec/volumeMode + value: Block + - target: + kind: ReplicationDestination + name: busybox-dst + patch: |- + - op: replace + path: /spec/rsyncTLS/storageClassName + value: rook-ceph-block + - op: replace + path: /spec/rsyncTLS/volumeSnapshotClassName + value: csi-rbdplugin-snapclass diff --git a/test/addons/volsync/rs/block/rs.yaml b/test/addons/volsync/rs/block/rs.yaml new file mode 100644 index 000000000..7945df597 --- /dev/null +++ b/test/addons/volsync/rs/block/rs.yaml @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: volsync.backube/v1alpha1 +kind: ReplicationSource +metadata: + name: busybox-src +spec: + sourcePVC: busybox-pvc + trigger: + manual: replication-1 + rsyncTLS: + keySecret: volsync-rsync-tls-busybox-dst-block + address: volsync-rsync-tls-dst-busybox-dst.volsync-test-block.svc.clusterset.local + copyMethod: Snapshot + volumeSnapshotClassName: csi-rbdplugin-snapclass + moverSecurityContext: + runAsUser: 10000 + runAsGroup: 10000 + fsGroup: 10000 diff --git a/test/addons/volsync/rs/block/secret.yaml b/test/addons/volsync/rs/block/secret.yaml new file mode 100644 index 000000000..8d8252768 --- /dev/null +++ b/test/addons/volsync/rs/block/secret.yaml @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: The RamenDR authors +# SPDX-License-Identifier: Apache-2.0 + +--- +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: volsync-rsync-tls-busybox-dst-block +data: + psk.txt: $value diff --git a/test/addons/volsync/test b/test/addons/volsync/test index 9a1382989..3929cf0f4 100755 --- a/test/addons/volsync/test +++ b/test/addons/volsync/test @@ -3,6 +3,7 @@ # SPDX-FileCopyrightText: The RamenDR authors # SPDX-License-Identifier: Apache-2.0 +import concurrent.futures import json import os import sys @@ -228,6 +229,20 @@ def teardown(cluster1, cluster2, variant): ) +def test(cluster1, cluster2, variant): + setup_application(cluster1, variant) + setup_replication_destination(cluster2, variant) + + wait_for_application(cluster1, variant) + wait_for_replication_destination(cluster2, variant) + + setup_replication_secret(cluster1, cluster2, variant) + setup_replication_service(cluster1, cluster2, variant) + + run_replication(cluster1, variant) + teardown(cluster1, cluster2, variant) + + if len(sys.argv) != 3: print(f"Usage: {sys.argv[0]} cluster1 cluster2") sys.exit(1) @@ -235,14 +250,10 @@ if len(sys.argv) != 3: os.chdir(os.path.dirname(__file__)) cluster1, cluster2 = sys.argv[1:] -setup_application(cluster1, "file") -setup_replication_destination(cluster2, "file") - -wait_for_application(cluster1, "file") -wait_for_replication_destination(cluster2, "file") - -setup_replication_secret(cluster1, cluster2, "file") -setup_replication_service(cluster1, cluster2, "file") - -run_replication(cluster1, "file") -teardown(cluster1, cluster2, "file") +with concurrent.futures.ThreadPoolExecutor() as e: + tests = [ + e.submit(test, cluster1, cluster2, "file"), + e.submit(test, cluster1, cluster2, "block"), + ] + for t in concurrent.futures.as_completed(tests): + t.result() diff --git a/test/envs/volsync.yaml b/test/envs/volsync.yaml index dc01edacf..0d73d4b72 100644 --- a/test/envs/volsync.yaml +++ b/test/envs/volsync.yaml @@ -27,6 +27,7 @@ templates: - name: rook-operator - name: rook-cluster - name: rook-toolbox + - name: rook-pool - name: rook-cephfs - addons: - name: external-snapshotter