Skip to content

Commit

Permalink
Use labels to locate the drpc
Browse files Browse the repository at this point in the history
Instead of assuming the drpc name, which is different in our busybox
samples and in openshift, use the label app=app-name to locate the drpc.

With this change the failover and relocate scripts should be compatible
with openshift. The deploy and undeploy scripts are not since we don't
have samples using placement.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs authored and ShyamsundarR committed Oct 3, 2023
1 parent f1a31ed commit f7366dc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/basic-test/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
---
repo: https://github.com/ramendr/ocm-ramen-samples.git
branch: main
name: busybox-sample
namespace: busybox-sample
name: busybox-drpc
49 changes: 35 additions & 14 deletions test/drenv/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ def failover(cluster):
"""
Start failover to cluster.
"""
info("Starting failover to cluster '%s'", cluster)
drpc = _drpc_name()

info("Starting failover for '%s' to cluster '%s'", drpc, cluster)
patch = {"spec": {"action": "Failover", "failoverCluster": cluster}}
kubectl.patch(
f"drpc/{config['name']}",
drpc,
"--patch",
json.dumps(patch),
"--type=merge",
Expand All @@ -143,10 +145,12 @@ def relocate(cluster):
"""
Start relocate to cluster.
"""
info("Starting relocate to cluster '%s'", cluster)
drpc = _drpc_name()

info("Starting relocate for '%s' to cluster '%s'", drpc, cluster)
patch = {"spec": {"action": "Relocate", "preferredCluster": cluster}}
kubectl.patch(
f"drpc/{config['name']}",
drpc,
"--patch",
json.dumps(patch),
"--type=merge",
Expand All @@ -169,9 +173,11 @@ def wait_for_drpc_status():
log=debug,
)

info("Waiting until busybox drpc reports status")
drpc = _drpc_name()

info("Waiting until '%s' reports status", drpc)
drenv.wait_for(
f"drpc/{config['name']}",
drpc,
output="jsonpath={.status}",
namespace=config["namespace"],
timeout=60,
Expand All @@ -181,9 +187,11 @@ def wait_for_drpc_status():


def wait_for_drpc_phase(phase):
info("Waiting for drpc '%s' phase", phase)
drpc = _drpc_name()

info("Waiting for '%s' phase '%s'", drpc, phase)
kubectl.wait(
f"drpc/{config['name']}",
drpc,
f"--for=jsonpath={{.status.phase}}={phase}",
f"--namespace={config['namespace']}",
"--timeout=300s",
Expand All @@ -199,29 +207,31 @@ def wait_until_drpc_is_stable(timeout=300):
- PeerReady=true
- lastGroupSyncTime!=''
"""
info("Waiting for Available condition")
drpc = _drpc_name()

info("Waiting for '%s' Available condition", drpc)
kubectl.wait(
f"drpc/{config['name']}",
drpc,
"--for=condition=Available",
f"--namespace={config['namespace']}",
f"--timeout={timeout}s",
context=env["hub"],
log=debug,
)

info("Waiting for PeerReady condition")
info("Waiting for '%s' PeerReady condition", drpc)
kubectl.wait(
f"drpc/{config['name']}",
drpc,
"--for=condition=PeerReady",
f"--namespace={config['namespace']}",
f"--timeout={timeout}s",
context=env["hub"],
log=debug,
)

info("Waiting for first replication")
info("Waiting for '%s' first replication", drpc)
drenv.wait_for(
f"drpc/{config['name']}",
drpc,
output="jsonpath={.status.lastGroupSyncTime}",
namespace=config["namespace"],
timeout=timeout,
Expand All @@ -230,6 +240,17 @@ def wait_until_drpc_is_stable(timeout=300):
)


def _drpc_name():
out = kubectl.get(
"drpc",
f"--selector=app={config['name']}",
f"--namespace={config['namespace']}",
"--output=name",
context=env["hub"],
)
return out.rstrip()


def _kustomization(cluster):
yaml = """
resources:
Expand Down

0 comments on commit f7366dc

Please sign in to comment.