Skip to content

Commit

Permalink
Add volsync block self test
Browse files Browse the repository at this point in the history
Add an overlay using rook-ceph-block pvc. We deploy and both test in
parallel.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs authored and BenamarMk committed Oct 14, 2024
1 parent 4774731 commit 3929be6
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 12 deletions.
1 change: 0 additions & 1 deletion test/addons/volsync/app/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
resources:
- namespace.yaml
- pvc.yaml
- deploy.yaml
namespace: volsync-test
56 changes: 56 additions & 0 deletions test/addons/volsync/app/block/deploy.yaml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions test/addons/volsync/app/block/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
1 change: 1 addition & 0 deletions test/addons/volsync/app/file/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace: volsync-test-file
resources:
- ../base
- deploy.yaml
patches:
# Customize for internal cephfs storage.
- target:
Expand Down
33 changes: 33 additions & 0 deletions test/addons/volsync/rd/block/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions test/addons/volsync/rs/block/rs.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions test/addons/volsync/rs/block/secret.yaml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 22 additions & 11 deletions test/addons/volsync/test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import concurrent.futures
import json
import os
import sys
Expand Down Expand Up @@ -228,21 +229,31 @@ 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)

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()
1 change: 1 addition & 0 deletions test/envs/volsync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ templates:
- name: rook-operator
- name: rook-cluster
- name: rook-toolbox
- name: rook-pool
- name: rook-cephfs
- addons:
- name: external-snapshotter
Expand Down

0 comments on commit 3929be6

Please sign in to comment.