Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate volsync in test environment #927

Merged
merged 8 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ environment.
[Velero Basic Install](https://velero.io/docs/v1.11/basic-install/)
for the details. Version 1.9.3 or later is required.

1. Install `helm` tool - on Fedora you can use:

```
dnf install helm
```

See [Installing Helm](https://helm.sh/docs/intro/install/) for other options.

1. Install `docker`

```
Expand Down Expand Up @@ -574,6 +582,7 @@ simpler and faster to work with a minimal environment.
- `rook.yaml` - for testing `rook` deployment
- `submariner.yaml` - for testing `submariner` deployment
- `velero.yaml` - for testing `velero` deployment
- `volsync.yaml` - for testing `volsync` deployment

## Testing drenv

Expand Down
8 changes: 4 additions & 4 deletions test/addons/submariner/test
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def wait_for_service(cluster, namespace):
f"deploy/{SERVICE}",
"--for=condition=Available",
f"--namespace={namespace}",
"--timeout=60s",
"--timeout=120s",
context=cluster,
)

Expand All @@ -109,7 +109,7 @@ def wait_for_pod(cluster, namespace):
"pod/test",
"--for=condition=Ready",
f"--namespace={namespace}",
"--timeout=60s",
"--timeout=120s",
context=cluster,
)

Expand All @@ -130,7 +130,7 @@ def wait_for_service_export(cluster, namespace):
f"serviceexports/{SERVICE}",
"--for=condition=Synced=True",
f"--namespace={namespace}",
"--timeout=60s",
"--timeout=120s",
context=cluster,
)
exports = kubectl.describe(
Expand All @@ -147,7 +147,7 @@ def wait_for_service_import(cluster, namespace):
f"serviceimports/{SERVICE}",
output="jsonpath={.status.clusters}",
namespace=namespace,
timeout=60,
timeout=120,
profile=cluster,
)
imports = kubectl.describe(
Expand Down
7 changes: 7 additions & 0 deletions test/addons/volsync/destination/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
resources:
- namespace.yaml
- replication-dst.yaml
8 changes: 8 additions & 0 deletions test/addons/volsync/destination/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: Namespace
metadata:
name: busybox
20 changes: 20 additions & 0 deletions test/addons/volsync/destination/replication-dst.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: volsync.backube/v1alpha1
kind: ReplicationDestination
metadata:
name: busybox-dst
namespace: busybox
spec:
rsyncTLS:
copyMethod: Snapshot
capacity: 1Gi
accessModes: [ReadWriteOnce]
storageClassName: csi-hostpath-sc
volumeSnapshotClassName: csi-hostpath-snapclass
moverSecurityContext:
runAsUser: 10000
runAsGroup: 10000
fsGroup: 10000
47 changes: 47 additions & 0 deletions test/addons/volsync/source/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
appname: busybox
name: busybox
namespace: busybox
spec:
replicas: 1
selector:
matchLabels:
appname: busybox
template:
metadata:
labels:
appname: busybox
spec:
containers:
- image: docker.io/library/busybox:latest
imagePullPolicy: IfNotPresent
name: busybox
command:
- sh
- -c
- |
trap exit TERM
while true; do
echo $(date) | tee -a /mnt/test/outfile
sync
sleep 10 &
wait
done
volumeMounts:
- name: volume
mountPath: /mnt/test
volumes:
- name: volume
persistentVolumeClaim:
claimName: busybox-pvc
securityContext:
runAsUser: 10000
runAsGroup: 10000
fsGroup: 10000
8 changes: 8 additions & 0 deletions test/addons/volsync/source/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
resources:
- namespace.yaml
- pvc.yaml
- deploy.yaml
8 changes: 8 additions & 0 deletions test/addons/volsync/source/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: Namespace
metadata:
name: busybox
17 changes: 17 additions & 0 deletions test/addons/volsync/source/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: busybox-pvc
namespace: busybox
labels:
appname: busybox
spec:
accessModes: [ReadWriteOnce]
storageClassName: csi-hostpath-sc
resources:
requests:
storage: 1Gi
22 changes: 22 additions & 0 deletions test/addons/volsync/source/replication-src.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: volsync.backube/v1alpha1
kind: ReplicationSource
metadata:
name: busybox-src
namespace: busybox
spec:
sourcePVC: busybox-pvc
trigger:
manual: replication-1
rsyncTLS:
keySecret: volsync-rsync-tls-busybox-dst
address: volsync-rsync-tls-dst-busybox-dst.busybox.svc.clusterset.local
copyMethod: Snapshot
volumeSnapshotClassName: csi-hostpath-snapclass
moverSecurityContext:
runAsUser: 10000
runAsGroup: 10000
fsGroup: 10000
12 changes: 12 additions & 0 deletions test/addons/volsync/source/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: volsync-rsync-tls-busybox-dst
namespace: busybox
data:
psk.txt: $value
72 changes: 51 additions & 21 deletions test/addons/volsync/start
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,66 @@
import os
import sys

from drenv import commands
from drenv import kubectl

CRDS = [
"../../../hack/test/volsync.backube_replicationsources.yaml",
"../../../hack/test/volsync.backube_replicationdestinations.yaml",
]
NAMESPACE = "volsync-system"
DEPLOYMENT = "volsync"


def deploy(cluster):
print("Deploying volsync crds")
for crd in CRDS:
kubectl.apply(f"--filename={crd}", context=cluster)
def add_helm_repo():
print("Adding helm backube repo")
cmd = [
"helm",
"repo",
"add",
"backube",
"https://backube.github.io/helm-charts/",
]
for line in commands.watch(*cmd):
print(line)


def wait(cluster):
print("Waiting until cdrs are established")
for crd in CRDS:
kubectl.wait(
"--for=condition=established",
f"--filename={crd}",
context=cluster,
)
def install_volsync(cluster):
print(f"Installing volsync in cluster '{cluster}'")
cmd = [
"helm",
"upgrade",
"--install",
"--create-namespace",
"--namespace",
NAMESPACE,
DEPLOYMENT,
"backube/volsync",
"--kube-context",
cluster,
]
for line in commands.watch(*cmd):
print(line)


if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} cluster")
def wait_for_deployment(cluster):
print(f"Waiting until deployment {DEPLOYMENT} is rolled out in cluster '{cluster}'")
kubectl.rollout(
"status",
f"deploy/{DEPLOYMENT}",
f"--namespace={NAMESPACE}",
"--timeout=300s",
context=cluster,
)


if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} cluster1 cluster2")
sys.exit(1)

os.chdir(os.path.dirname(__file__))
cluster = sys.argv[1]
clusters = sys.argv[1:]

add_helm_repo()

for cluster in clusters:
install_volsync(cluster)

deploy(cluster)
wait(cluster)
for cluster in clusters:
wait_for_deployment(cluster)
Loading
Loading