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

Support testing any application on any k8s/ocp cluster #1133

Merged
merged 12 commits into from
Mar 13, 2024

Conversation

nirs
Copy link
Member

@nirs nirs commented Nov 13, 2023

Add support for testing new applications from multiple repos, on multiple cluster types, using different storage.

  • Lint also enable-dr and disable-dr scripts
  • Configurable path in basic-test/config.yaml
  • Support feature_gates options
  • Enable StatefulSetAutoDeletePVC feature gate
  • Fix waiting for drcluster and drpolicy
  • Fix hard coded pvc selector label
  • Make dr policy configurable
  • More generic logs
  • Remove channel deploy/undeploy
  • Support multiple configurations
  • Add test configurations

Status:

Note: To test on odr we need more subscription overlays in ocm-ramen-samples.

@nirs nirs changed the title Make application path configurable Support testing statefulset Nov 13, 2023
@nirs nirs force-pushed the test-path branch 2 times, most recently from 2db77ca to 1bc8955 Compare November 13, 2023 22:57
@nirs

This comment was marked as outdated.

test/drenv/minikube.py Outdated Show resolved Hide resolved
@nirs nirs marked this pull request as draft November 14, 2023 17:10
@nirs nirs marked this pull request as ready for review November 14, 2023 18:03
@nirs

This comment was marked as outdated.

@nirs nirs changed the title Support testing statefulset Support testing any application on any k8s/ocp cluster Nov 16, 2023
@nirs

This comment was marked as outdated.

test/drenv/test.py Outdated Show resolved Hide resolved
test/basic-test/run Outdated Show resolved Hide resolved
test/drenv/test.py Outdated Show resolved Hide resolved
@nirs

This comment was marked as outdated.

@nirs nirs marked this pull request as draft March 8, 2024 01:53
@nirs
Copy link
Member Author

nirs commented Mar 9, 2024

Example run with busybox deployment

$ basic-test/run envs/regional-dr.yaml 
2024-03-08 03:40:48,847 INFO    [deploy] Deploying application
2024-03-08 03:40:48,847 INFO    [deploy] Deploying application 'deployment-rbd'
2024-03-08 03:40:49,968 INFO    [deploy] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-08 03:40:50,210 INFO    [deploy] Application running on cluster 'dr1'
2024-03-08 03:40:50,352 INFO    [enable-dr] Enable DR
2024-03-08 03:40:50,413 INFO    [enable-dr] Disabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-08 03:40:50,544 INFO    [enable-dr] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-08 03:40:50,937 INFO    [enable-dr] waiting for namespace deployment-rbd
2024-03-08 03:40:51,061 INFO    [enable-dr] Waiting until 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' reports status
2024-03-08 03:40:51,385 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' Available condition
2024-03-08 03:40:51,563 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' PeerReady condition
2024-03-08 03:40:51,738 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' first replication
2024-03-08 03:42:21,118 INFO    [enable-dr] DR enabled
2024-03-08 03:42:21,287 INFO    [failover] Fail over application
2024-03-08 03:42:21,348 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' Available condition
2024-03-08 03:42:21,532 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' PeerReady condition
2024-03-08 03:42:21,699 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' first replication
2024-03-08 03:42:21,807 INFO    [failover] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-08 03:42:22,066 INFO    [failover] Starting failover for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' to cluster 'dr2'
2024-03-08 03:42:22,194 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' Available condition
2024-03-08 03:42:51,232 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' PeerReady condition
2024-03-08 03:45:21,146 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' first replication
2024-03-08 03:45:51,226 INFO    [failover] Application was failed over
2024-03-08 03:45:51,361 INFO    [relocate] Relocate application
2024-03-08 03:45:51,420 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' Available condition
2024-03-08 03:45:51,598 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' PeerReady condition
2024-03-08 03:45:51,757 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' first replication
2024-03-08 03:45:51,866 INFO    [relocate] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-08 03:45:52,133 INFO    [relocate] Starting relocate for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' to cluster 'dr1'
2024-03-08 03:45:52,338 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' phase 'Relocated'
2024-03-08 03:48:21,307 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' Available condition
2024-03-08 03:48:21,499 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' PeerReady condition
2024-03-08 03:48:51,239 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc' first replication
2024-03-08 03:48:51,306 INFO    [relocate] Application was relocated
2024-03-08 03:48:51,439 INFO    [disable-dr] Disable DR
2024-03-08 03:48:51,489 INFO    [disable-dr] Deleting 'drplacementcontrol.ramendr.openshift.io/deployment-rbd-drpc'
2024-03-08 03:49:21,113 INFO    [disable-dr] Enabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-08 03:49:21,192 INFO    [disable-dr] DR was disabled
2024-03-08 03:49:21,312 INFO    [undeploy] Deleting application
2024-03-08 03:49:21,312 INFO    [undeploy] Undeploying application 'deployment-rbd'

@nirs nirs force-pushed the test-path branch 2 times, most recently from 189d89a to 42c093c Compare March 11, 2024 12:08
@nirs nirs marked this pull request as ready for review March 11, 2024 12:36
@nirs
Copy link
Member Author

nirs commented Mar 11, 2024

Example run with kubvirt vm

Starting the env

$ drenv start envs/regional-dr-kubevirt.yaml
2024-03-11 13:49:46,138 INFO    [rdr-kubevirt] Starting environment
2024-03-11 13:49:47,029 INFO    [dr1] Starting minikube cluster
2024-03-11 13:49:47,184 INFO    [dr2] Starting minikube cluster
2024-03-11 13:49:48,206 INFO    [hub] Starting minikube cluster
2024-03-11 13:53:16,620 INFO    [hub] Cluster started in 208.41 seconds
2024-03-11 13:53:16,621 INFO    [hub/0] Running addons/ocm-hub/start
2024-03-11 13:54:44,081 INFO    [hub/0] addons/ocm-hub/start completed in 87.46 seconds
2024-03-11 13:54:44,081 INFO    [hub/0] Running addons/ocm-controller/start
2024-03-11 13:54:45,795 INFO    [dr1] Cluster started in 298.77 seconds
2024-03-11 13:54:45,795 INFO    [dr1] Configuring containerd
2024-03-11 13:54:46,506 INFO    [dr1/0] Running addons/cert-manager/start
2024-03-11 13:54:46,507 INFO    [dr1/1] Running addons/ocm-cluster/start
2024-03-11 13:54:46,507 INFO    [dr1/2] Running addons/csi-addons/start
2024-03-11 13:55:05,095 INFO    [dr1/0] addons/cert-manager/start completed in 18.59 seconds
2024-03-11 13:55:05,095 INFO    [dr1/0] Running addons/rook-operator/start
2024-03-11 13:55:06,257 INFO    [hub/0] addons/ocm-controller/start completed in 22.18 seconds
2024-03-11 13:55:06,258 INFO    [hub/0] Running addons/cert-manager/start
2024-03-11 13:55:19,181 INFO    [dr1/2] addons/csi-addons/start completed in 32.67 seconds
2024-03-11 13:55:19,182 INFO    [dr1/2] Running addons/olm/start
2024-03-11 13:55:29,775 INFO    [hub/0] addons/cert-manager/start completed in 23.52 seconds
2024-03-11 13:55:29,776 INFO    [hub/0] Running addons/olm/start
2024-03-11 13:55:37,890 INFO    [dr2] Cluster started in 350.71 seconds
2024-03-11 13:55:37,890 INFO    [dr2] Configuring containerd
2024-03-11 13:55:38,654 INFO    [dr2/0] Running addons/cert-manager/start
2024-03-11 13:55:38,654 INFO    [dr2/1] Running addons/ocm-cluster/start
2024-03-11 13:55:38,654 INFO    [dr2/2] Running addons/csi-addons/start
2024-03-11 13:55:40,252 INFO    [dr1/0] addons/rook-operator/start completed in 35.16 seconds
2024-03-11 13:55:40,253 INFO    [dr1/0] Running addons/rook-cluster/start
2024-03-11 13:55:51,580 INFO    [dr1/2] addons/olm/start completed in 32.40 seconds
2024-03-11 13:55:51,580 INFO    [dr1/2] Running addons/minio/start
2024-03-11 13:55:57,100 INFO    [dr1/1] addons/ocm-cluster/start completed in 70.59 seconds
2024-03-11 13:55:57,100 INFO    [dr1/1] Running addons/ocm-cluster/test
2024-03-11 13:56:00,437 INFO    [dr2/2] addons/csi-addons/start completed in 21.78 seconds
2024-03-11 13:56:00,437 INFO    [dr2/2] Running addons/olm/start
2024-03-11 13:56:12,455 INFO    [dr1/1] addons/ocm-cluster/test completed in 15.36 seconds
2024-03-11 13:56:12,455 INFO    [dr1/1] Running addons/cdi/start
2024-03-11 13:56:13,040 INFO    [dr2/0] addons/cert-manager/start completed in 34.39 seconds
2024-03-11 13:56:13,040 INFO    [dr2/0] Running addons/rook-operator/start
2024-03-11 13:56:15,235 INFO    [dr1/2] addons/minio/start completed in 23.66 seconds
2024-03-11 13:56:15,235 INFO    [dr1/2] Running addons/velero/start
2024-03-11 13:56:17,382 INFO    [hub/0] addons/olm/start completed in 47.61 seconds
2024-03-11 13:56:17,383 INFO    [hub/0] Running addons/submariner/start
2024-03-11 13:56:29,991 INFO    [dr2/2] addons/olm/start completed in 29.55 seconds
2024-03-11 13:56:29,992 INFO    [dr2/2] Running addons/minio/start
2024-03-11 13:56:47,076 INFO    [dr2/2] addons/minio/start completed in 17.08 seconds
2024-03-11 13:56:47,077 INFO    [dr2/2] Running addons/velero/start
2024-03-11 13:57:01,445 INFO    [dr2/0] addons/rook-operator/start completed in 48.40 seconds
2024-03-11 13:57:01,445 INFO    [dr2/0] Running addons/rook-cluster/start
2024-03-11 13:57:01,753 INFO    [dr1/1] addons/cdi/start completed in 49.30 seconds
2024-03-11 13:57:01,753 INFO    [dr1/1] Running addons/cdi/test
2024-03-11 13:57:09,578 INFO    [dr1/2] addons/velero/start completed in 54.34 seconds
2024-03-11 13:57:09,578 INFO    [dr1/2] Running addons/velero/test
2024-03-11 13:57:17,493 INFO    [dr2/2] addons/velero/start completed in 30.42 seconds
2024-03-11 13:57:17,493 INFO    [dr2/2] Running addons/velero/test
2024-03-11 13:57:20,040 INFO    [dr2/1] addons/ocm-cluster/start completed in 101.39 seconds
2024-03-11 13:57:20,040 INFO    [dr2/1] Running addons/ocm-cluster/test
2024-03-11 13:57:24,390 INFO    [hub/0] addons/submariner/start completed in 67.01 seconds
2024-03-11 13:57:24,390 INFO    [hub/0] Running addons/submariner/test
2024-03-11 13:57:29,284 INFO    [dr2/1] addons/ocm-cluster/test completed in 9.24 seconds
2024-03-11 13:57:29,284 INFO    [dr2/1] Running addons/cdi/start
2024-03-11 13:57:33,365 INFO    [dr1/1] addons/cdi/test completed in 31.61 seconds
2024-03-11 13:57:33,365 INFO    [dr1/1] Running addons/recipe/start
2024-03-11 13:57:34,623 INFO    [dr1/1] addons/recipe/start completed in 1.26 seconds
2024-03-11 13:57:42,463 INFO    [dr1/2] addons/velero/test completed in 32.88 seconds
2024-03-11 13:57:42,463 INFO    [dr1/2] Running addons/kubevirt/start
2024-03-11 13:57:57,013 INFO    [dr2/2] addons/velero/test completed in 39.52 seconds
2024-03-11 13:57:57,014 INFO    [dr2/2] Running addons/kubevirt/start
2024-03-11 13:58:14,972 INFO    [dr1/0] addons/rook-cluster/start completed in 154.72 seconds
2024-03-11 13:58:14,972 INFO    [dr1/0] Running addons/rook-pool/start
2024-03-11 13:58:18,695 INFO    [dr2/1] addons/cdi/start completed in 49.41 seconds
2024-03-11 13:58:18,695 INFO    [dr2/1] Running addons/cdi/test
2024-03-11 13:58:23,954 INFO    [hub/0] addons/submariner/test completed in 59.56 seconds
2024-03-11 13:58:40,024 INFO    [dr1/0] addons/rook-pool/start completed in 25.05 seconds
2024-03-11 13:58:40,025 INFO    [dr1/0] Running addons/rook-toolbox/start
2024-03-11 13:58:44,907 INFO    [dr1/0] addons/rook-toolbox/start completed in 4.88 seconds
2024-03-11 13:59:33,261 INFO    [dr2/1] addons/cdi/test completed in 74.57 seconds
2024-03-11 13:59:33,261 INFO    [dr2/1] Running addons/recipe/start
2024-03-11 13:59:36,888 INFO    [dr2/1] addons/recipe/start completed in 3.63 seconds
2024-03-11 13:59:38,946 INFO    [dr2/0] addons/rook-cluster/start completed in 157.50 seconds
2024-03-11 13:59:38,946 INFO    [dr2/0] Running addons/rook-pool/start
2024-03-11 14:00:00,096 INFO    [dr2/0] addons/rook-pool/start completed in 21.15 seconds
2024-03-11 14:00:00,096 INFO    [dr2/0] Running addons/rook-toolbox/start
2024-03-11 14:00:02,717 INFO    [dr2/0] addons/rook-toolbox/start completed in 2.62 seconds
2024-03-11 14:00:17,913 INFO    [dr2/2] addons/kubevirt/start completed in 140.90 seconds
2024-03-11 14:00:17,914 INFO    [dr2/2] Running addons/kubevirt/test
2024-03-11 14:00:21,612 INFO    [dr1/2] addons/kubevirt/start completed in 159.15 seconds
2024-03-11 14:00:21,612 INFO    [dr1/2] Running addons/kubevirt/test
2024-03-11 14:00:56,816 INFO    [dr1/2] addons/kubevirt/test completed in 35.20 seconds
2024-03-11 14:01:25,676 INFO    [dr2/2] addons/kubevirt/test completed in 67.76 seconds
2024-03-11 14:01:25,677 INFO    [rdr-kubevirt/0] Running addons/rbd-mirror/start
2024-03-11 14:01:25,678 INFO    [rdr-kubevirt/1] Running addons/volsync/start
2024-03-11 14:02:09,057 INFO    [rdr-kubevirt/1] addons/volsync/start completed in 43.38 seconds
2024-03-11 14:02:09,057 INFO    [rdr-kubevirt/1] Running addons/volsync/test
2024-03-11 14:02:43,671 INFO    [rdr-kubevirt/0] addons/rbd-mirror/start completed in 77.99 seconds
2024-03-11 14:02:43,671 INFO    [rdr-kubevirt/0] Running addons/rbd-mirror/test
2024-03-11 14:02:48,395 INFO    [rdr-kubevirt/1] addons/volsync/test completed in 39.34 seconds
2024-03-11 14:02:59,349 INFO    [rdr-kubevirt/0] addons/rbd-mirror/test completed in 15.68 seconds
2024-03-11 14:02:59,350 INFO    [rdr-kubevirt] Dumping ramen e2e config to '/home/nsoffer/.config/drenv/rdr-kubevirt'
2024-03-11 14:02:59,475 INFO    [rdr-kubevirt] Environment started in 793.34 seconds

Preparing the cluster

$ ramenctl deploy test/envs/regional-dr-kubevirt.yaml 
2024-03-11 14:04:42,184 INFO    [ramenctl] Starting deploy
2024-03-11 14:04:42,189 INFO    [ramenctl] Saving image 'quay.io/ramendr/ramen-operator:latest'
2024-03-11 14:04:43,301 INFO    [ramenctl] Loading image in cluster 'dr1'
2024-03-11 14:04:43,302 INFO    [ramenctl] Loading image in cluster 'dr2'
2024-03-11 14:04:43,302 INFO    [ramenctl] Loading image in cluster 'hub'
2024-03-11 14:04:48,604 INFO    [ramenctl] Deploying ramen operator in cluster 'hub'
2024-03-11 14:04:51,172 INFO    [ramenctl] Deploying ramen operator in cluster 'dr1'
2024-03-11 14:04:53,397 INFO    [ramenctl] Deploying ramen operator in cluster 'dr2'
2024-03-11 14:04:55,488 INFO    [ramenctl] Finished deploy in 13.30 seconds

$ ramenctl config test/envs/regional-dr-kubevirt.yaml 
2024-03-11 14:05:03,269 INFO    [ramenctl] Starting config
2024-03-11 14:05:03,633 INFO    [ramenctl] Waiting until ramen-hub-operator is rolled out
2024-03-11 14:05:03,708 INFO    [ramenctl] Creating ramen s3 secrets in cluster 'hub'
2024-03-11 14:05:05,303 INFO    [ramenctl] Updating ramen config map in cluster 'hub'
2024-03-11 14:05:05,584 INFO    [ramenctl] Creating dr-clusters for regional-dr
2024-03-11 14:05:05,897 INFO    [ramenctl] Creating dr-policy for regional-dr
2024-03-11 14:05:06,214 INFO    [ramenctl] Waiting until s3 secrets are propagated to managed clusters
2024-03-11 14:05:14,265 INFO    [ramenctl] Waiting until DRClusters report phase
2024-03-11 14:05:14,358 INFO    [ramenctl] Waiting until DRClusters phase is available
2024-03-11 14:05:14,611 INFO    [ramenctl] Waiting until DRPolicy is validated
2024-03-11 14:05:14,771 INFO    [ramenctl] Finished config in 11.50 seconds

$ kubectl apply -k https://github.com/nirs/ocm-kubevirt-samples.git/channel?ref=layout --context hub
namespace/kubevirt-samples created
channel.apps.open-cluster-management.io/kubevirt-gitops created

Running basic test

Test config:

$ cat kubevirt.yaml
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
repo: https://github.com/nirs/ocm-kubevirt-samples.git
path: subscription/vm-pvc-k8s-regional
branch: layout
name: vm-pvc
namespace: vm-pvc
dr_policy: dr-policy
pvc_label: vm

Deploy:

$ basic-test/deploy -c kubevirt.yaml envs/regional-dr-kubevirt.yaml
2024-03-11 14:15:02,829 INFO    [deploy] Deploying application
2024-03-11 14:15:02,829 INFO    [deploy] Deploying application 'vm-pvc'
2024-03-11 14:15:04,031 INFO    [deploy] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-11 14:15:04,233 INFO    [deploy] Application running on cluster 'dr1'

$ kubectl get vm,vmi,pod,pvc -n vm-pvc --context dr1
NAME                            AGE   STATUS    READY
virtualmachine.kubevirt.io/vm   61s   Running   True

NAME                                    AGE   PHASE     IP            NODENAME   READY
virtualmachineinstance.kubevirt.io/vm   61s   Running   10.244.0.68   dr1        True

NAME                         READY   STATUS    RESTARTS   AGE
pod/virt-launcher-vm-74qsk   1/1     Running   0          61s

NAME                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
persistentvolumeclaim/root-disk   Bound    pvc-7fb2bd84-0dd5-4793-8e87-8555b86479e3   128Mi      RWX            rook-ceph-block   62s

Enable DR:

$ basic-test/enable-dr -c kubevirt.yaml envs/regional-dr-kubevirt.yaml
2024-03-11 14:17:14,888 INFO    [enable-dr] Enable DR
2024-03-11 14:17:14,932 INFO    [enable-dr] Disabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-11 14:17:15,032 INFO    [enable-dr] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-11 14:17:15,357 INFO    [enable-dr] waiting for namespace vm-pvc
2024-03-11 14:17:15,477 INFO    [enable-dr] Waiting until 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' reports status
2024-03-11 14:17:15,818 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' Available condition
2024-03-11 14:17:16,000 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' PeerReady condition
2024-03-11 14:17:16,209 INFO    [enable-dr] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' first replication
2024-03-11 14:18:45,126 INFO    [enable-dr] DR enabled

$ kubectl get vm,vmi,deploy,pvc,vrg,vr -n vm-pvc --context dr1
NAME                            AGE     STATUS    READY
virtualmachine.kubevirt.io/vm   4m10s   Running   True

NAME                                    AGE     PHASE     IP            NODENAME   READY
virtualmachineinstance.kubevirt.io/vm   4m10s   Running   10.244.0.68   dr1        True

NAME                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
persistentvolumeclaim/root-disk   Bound    pvc-7fb2bd84-0dd5-4793-8e87-8555b86479e3   128Mi      RWX            rook-ceph-block   4m11s

NAME                                                      DESIREDSTATE   CURRENTSTATE
volumereplicationgroup.ramendr.openshift.io/vm-pvc-drpc   primary        Primary

NAME                                                           AGE   VOLUMEREPLICATIONCLASS   PVCNAME     DESIREDSTATE   CURRENTSTATE
volumereplication.replication.storage.openshift.io/root-disk   2m    vrc-sample               root-disk   primary        Primary

Failover:

$ basic-test/failover -c kubevirt.yaml envs/regional-dr-kubevirt.yaml
2024-03-11 14:19:50,014 INFO    [failover] Fail over application
2024-03-11 14:19:50,062 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' Available condition
2024-03-11 14:19:50,226 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' PeerReady condition
2024-03-11 14:19:50,378 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' first replication
2024-03-11 14:19:50,475 INFO    [failover] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-11 14:19:50,720 INFO    [failover] Starting failover for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' to cluster 'dr2'
2024-03-11 14:19:50,869 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' Available condition
2024-03-11 14:20:15,363 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' PeerReady condition
2024-03-11 14:23:15,238 INFO    [failover] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' first replication
2024-03-11 14:23:15,315 INFO    [failover] Application was failed over

$ kubectl get vm,vmi,pod,pvc,vrg,vr -n vm-pvc --context dr2
NAME                            AGE     STATUS    READY
virtualmachine.kubevirt.io/vm   6m56s   Running   True

NAME                                    AGE     PHASE     IP            NODENAME   READY
virtualmachineinstance.kubevirt.io/vm   6m55s   Running   10.244.0.66   dr2        True

NAME                         READY   STATUS    RESTARTS   AGE
pod/virt-launcher-vm-4t4m7   1/1     Running   0          6m55s

NAME                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
persistentvolumeclaim/root-disk   Bound    pvc-7fb2bd84-0dd5-4793-8e87-8555b86479e3   128Mi      RWX            rook-ceph-block   7m21s

NAME                                                      DESIREDSTATE   CURRENTSTATE
volumereplicationgroup.ramendr.openshift.io/vm-pvc-drpc   primary        Primary

NAME                                                           AGE     VOLUMEREPLICATIONCLASS   PVCNAME     DESIREDSTATE   CURRENTSTATE
volumereplication.replication.storage.openshift.io/root-disk   7m21s   vrc-sample               root-disk   primary        Primary

$ virtctl ssh cirros@vm --context dr2 -n vm-pvc --known-hosts='' -c 'head -30 /var/log/ramen.log'
WARNING: skipping hostkey check, provide --known-hosts to fix this
Mon Mar 11 13:15:37 UTC 2024 START uptime=3.45
Mon Mar 11 13:15:47 UTC 2024 UPDATE
Mon Mar 11 13:15:57 UTC 2024 UPDATE
Mon Mar 11 13:16:07 UTC 2024 UPDATE
Mon Mar 11 13:16:17 UTC 2024 UPDATE
Mon Mar 11 13:16:27 UTC 2024 UPDATE
Mon Mar 11 13:16:37 UTC 2024 UPDATE
Mon Mar 11 13:16:47 UTC 2024 UPDATE
Mon Mar 11 13:16:57 UTC 2024 UPDATE
Mon Mar 11 13:17:07 UTC 2024 UPDATE
Mon Mar 11 13:17:17 UTC 2024 UPDATE
Mon Mar 11 13:17:27 UTC 2024 UPDATE
Mon Mar 11 13:17:37 UTC 2024 UPDATE
Mon Mar 11 13:17:47 UTC 2024 UPDATE
Mon Mar 11 13:17:57 UTC 2024 UPDATE
Mon Mar 11 13:18:07 UTC 2024 UPDATE
Mon Mar 11 13:18:17 UTC 2024 UPDATE
Mon Mar 11 13:18:27 UTC 2024 UPDATE
Mon Mar 11 13:18:37 UTC 2024 UPDATE
Mon Mar 11 13:18:47 UTC 2024 UPDATE
Mon Mar 11 13:18:57 UTC 2024 UPDATE
Mon Mar 11 13:20:28 UTC 2024 START uptime=3.57
Mon Mar 11 13:20:38 UTC 2024 UPDATE
Mon Mar 11 13:20:48 UTC 2024 UPDATE
Mon Mar 11 13:20:58 UTC 2024 UPDATE
Mon Mar 11 13:21:08 UTC 2024 UPDATE
Mon Mar 11 13:21:18 UTC 2024 UPDATE
Mon Mar 11 13:21:28 UTC 2024 UPDATE
Mon Mar 11 13:21:38 UTC 2024 UPDATE
Mon Mar 11 13:21:48 UTC 2024 UPDATE

Relocate:

$ basic-test/relocate -c kubevirt.yaml envs/regional-dr-kubevirt.yaml
2024-03-11 14:31:10,547 INFO    [relocate] Relocate application
2024-03-11 14:31:10,606 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' Available condition
2024-03-11 14:31:10,777 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' PeerReady condition
2024-03-11 14:31:10,950 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' first replication
2024-03-11 14:31:11,077 INFO    [relocate] Waiting for 'placement.cluster.open-cluster-management.io/placement' decisions
2024-03-11 14:31:11,373 INFO    [relocate] Starting relocate for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' to cluster 'dr1'
2024-03-11 14:31:11,540 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' phase 'Relocated'
2024-03-11 14:32:45,347 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' Available condition
2024-03-11 14:32:45,544 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' PeerReady condition
2024-03-11 14:33:15,437 INFO    [relocate] Waiting for 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc' first replication
2024-03-11 14:33:15,504 INFO    [relocate] Application was relocated

$ kubectl get vm,vmi,pod,pvc,vrg,vr -n vm-pvc --context dr1
NAME                            AGE   STATUS    READY
virtualmachine.kubevirt.io/vm   59s   Running   True

NAME                                    AGE   PHASE     IP            NODENAME   READY
virtualmachineinstance.kubevirt.io/vm   59s   Running   10.244.0.69   dr1        True

NAME                         READY   STATUS    RESTARTS   AGE
pod/virt-launcher-vm-klxzk   1/1     Running   0          59s

NAME                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
persistentvolumeclaim/root-disk   Bound    pvc-7fb2bd84-0dd5-4793-8e87-8555b86479e3   128Mi      RWX            rook-ceph-block   90s

NAME                                                      DESIREDSTATE   CURRENTSTATE
volumereplicationgroup.ramendr.openshift.io/vm-pvc-drpc   primary        Primary

NAME                                                           AGE   VOLUMEREPLICATIONCLASS   PVCNAME     DESIREDSTATE   CURRENTSTATE
volumereplication.replication.storage.openshift.io/root-disk   77s   vrc-sample               root-disk   primary        Primary

$ virtctl ssh cirros@vm --context dr1 -n vm-pvc --known-hosts='' -c 'tail /var/log/ramen.log'
WARNING: skipping hostkey check, provide --known-hosts to fix this
Mon Mar 11 13:31:09 UTC 2024 UPDATE
Mon Mar 11 13:31:15 UTC 2024 STOP
Mon Mar 11 13:32:57 UTC 2024 START uptime=3.23
Mon Mar 11 13:33:07 UTC 2024 UPDATE
Mon Mar 11 13:33:17 UTC 2024 UPDATE
Mon Mar 11 13:33:27 UTC 2024 UPDATE
Mon Mar 11 13:33:37 UTC 2024 UPDATE
Mon Mar 11 13:33:47 UTC 2024 UPDATE
Mon Mar 11 13:33:57 UTC 2024 UPDATE
Mon Mar 11 13:34:07 UTC 2024 UPDATE

Disable DR:

$ basic-test/disable-dr -c kubevirt.yaml envs/regional-dr-kubevirt.yaml 
2024-03-11 14:34:32,894 INFO    [disable-dr] Disable DR
2024-03-11 14:34:32,947 INFO    [disable-dr] Deleting 'drplacementcontrol.ramendr.openshift.io/vm-pvc-drpc'
2024-03-11 14:34:45,180 INFO    [disable-dr] Enabling OCM scheduling for 'placement.cluster.open-cluster-management.io/placement'
2024-03-11 14:34:45,272 INFO    [disable-dr] DR was disabled

$ kubectl get vm,vmi,pod,pvc,vrg,vr -n vm-pvc --context dr1
NAME                            AGE     STATUS    READY
virtualmachine.kubevirt.io/vm   2m14s   Running   True

NAME                                    AGE     PHASE     IP            NODENAME   READY
virtualmachineinstance.kubevirt.io/vm   2m14s   Running   10.244.0.69   dr1        True

NAME                         READY   STATUS    RESTARTS   AGE
pod/virt-launcher-vm-klxzk   1/1     Running   0          2m14s

NAME                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
persistentvolumeclaim/root-disk   Bound    pvc-7fb2bd84-0dd5-4793-8e87-8555b86479e3   128Mi      RWX            rook-ceph-block   2m45s

Undeploy:

$ basic-test/undeploy -c kubevirt.yaml envs/regional-dr-kubevirt.yaml
2024-03-11 14:35:21,790 INFO    [undeploy] Deleting application
2024-03-11 14:35:21,790 INFO    [undeploy] Undeploying application 'vm-pvc'
2024-03-11 14:35:27,932 INFO    [undeploy] Application was deleted

nirs added 11 commits March 13, 2024 04:25
The script are tiny but it is nice to have verify them with flake8,
pylint and black.

Signed-off-by: Nir Soffer <[email protected]>
Add "path" config, so test config looks like OpenShift UI:

    repo: https://github.com/RamenDR/ocm-ramen-samples.git
    path: subscription
    branch: main
    name: busybox-sample
    namespace: busybox-sample

With this we can use basic test to test any subscription based
application in ocm-ramen-samples[1] and ocm-kubevirt-samples[2].

[1] https://github.com/RamenDR/ocm-ramen-samples
[2] https://github.com/aglitke/ocm-kubevirt-samples

Signed-off-by: Nir Soffer <[email protected]>
It is possible now to enable Kubernetes feature gates[1] using minikube
--feature-gates option[2]. We will use this to enable
StatefulSetAutoDeletePVC feature gate.

Example config:

    profiles:
      - name: featured
        feature_gates:
          - StatefulSetAutoDeletePVC=true

[1] https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/
[2] https://minikube.sigs.k8s.io/docs/handbook/config/#enabling-feature-gates

Signed-off-by: Nir Soffer <[email protected]>
With this we can create a statesfulset with
persistentVolumeClaimRetentionPolicy[1] to have the PVCs deleted when a
stateful set is deleted. This policy is required for relocate, otherwise
ramen get stuck waiting for vrs to become secondary.

[1] https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention

Signed-off-by: Nir Soffer <[email protected]>
We use `--namespace ramen-system` but these are deployed in cluster
scope. I guess the `--namespace` is ignored in this case since this code
works as is.

Signed-off-by: Nir Soffer <[email protected]>
Add `pvc_label` configuration so we can test any application. With this
we can run basic-test with vms from ocm-kubeivrt-samples[1].

[1] https://github.com/aglitke/ocm-kubevirt-samples

Signed-off-by: Nir Soffer <[email protected]>
Previously the dr policy name was hard coded, which works for drenv
default dr policy but not for OpenShift clusters. To run with OpenShift
cluster you can either change the dr_policy configuration to match it to
the actual dr policy, or create a new policy manually before running the
tests.

Signed-off-by: Nir Soffer <[email protected]>
Since we can test any application now (e.g. busybox, kubvirt), we don't
want to mention busybox in the logs. Use config['name'] when we can to
make the logs more clear.

Signed-off-by: Nir Soffer <[email protected]>
To run tests concurrently, we cannot delete the channel when we deploy
an application, so the test cannot be responsible for deploying and
deleting the channel.

Creating a channel for the tests is now a manual step documented in
docs/testing.md and docs/user-quick-start.md.

Signed-off-by: Nir Soffer <[email protected]>
basic-test can be run now with custom configuration file. This can be
used to run multiple tests concurrently.

    test/basic-test/run --config rbd-deploy.yaml $env 2>rbd.log &
    test/basic-test/run --config cephfs-deploy.yaml $env 2>cephfs.log &
    wait

Signed-off-by: Nir Soffer <[email protected]>
@nirs nirs force-pushed the test-path branch 2 times, most recently from 304d635 to b2c0f54 Compare March 13, 2024 16:28
@nirs nirs marked this pull request as draft March 13, 2024 17:58
Add tests configuration for the current subscriptions in
ocm-ramen-samples. We will add more configurations when new
subscriptions are added.

To run test using a custom configuration use:

    basic-test/run \
        --config configs/deployment-k8s-regional-rbd \
        env.yaml

The default config.yaml is a symlink to the new configuration to keep
developers flows working.

Developers can create their own test configuration without modifying the
source:

    cp configs/deployment-k8s-regional-rbd.yaml ~/test/myconfig.yaml
    # edit myconfig.yaml...
    basic-test/run -c ~/test/myconfig.yaml envs/regional-dr.yaml

Signed-off-by: Nir Soffer <[email protected]>
@nirs nirs marked this pull request as ready for review March 13, 2024 18:04
@ShyamsundarR ShyamsundarR merged commit 072cabb into RamenDR:main Mar 13, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants