Skip to content
Closed
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
12 changes: 6 additions & 6 deletions ramenctl/ramenctl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run(args):
cloud_secret = generate_cloud_credentials_secret(env["clusters"][0], args)

if env["hub"]:
hub_cm = generate_config_map("hub", env["clusters"], args)
hub_cm = generate_config_map("hub", env, args)

wait_for_ramen_hub_operator(env["hub"], args)

Expand All @@ -38,7 +38,7 @@ def run(args):
wait_for_dr_clusters(env["hub"], env["clusters"], args)
wait_for_dr_policy(env["hub"], args)
else:
dr_cluster_cm = generate_config_map("dr-cluster", env["clusters"], args)
dr_cluster_cm = generate_config_map("dr-cluster", env, args)

for cluster in env["clusters"]:
create_ramen_s3_secrets(cluster, s3_secrets)
Expand Down Expand Up @@ -89,7 +89,9 @@ def create_cloud_credentials_secret(cluster, yaml):
kubectl.apply("--filename=-", input=yaml, context=cluster, log=command.debug)


def generate_config_map(controller, clusters, args):
def generate_config_map(controller, env, args):
clusters = env["clusters"]
volsync = env["features"].get("volsync", True)
template = drenv.template(command.resource("configmap.yaml"))
return template.substitute(
name=f"ramen-{controller}-operator-config",
Expand All @@ -98,6 +100,7 @@ def generate_config_map(controller, clusters, args):
cluster2=clusters[1],
minio_url_cluster1=minio.service_url(clusters[0]),
minio_url_cluster2=minio.service_url(clusters[1]),
volsync_disabled="false" if volsync else "true",
namespace=args.ramen_namespace,
)

Expand Down Expand Up @@ -145,7 +148,6 @@ def wait_for_dr_clusters(hub, clusters, args):
drenv.wait_for(
f"drcluster/{name}",
output="jsonpath={.status.phase}",
namespace=args.ramen_namespace,
timeout=180,
profile=hub,
log=command.debug,
Expand All @@ -156,7 +158,6 @@ def wait_for_dr_clusters(hub, clusters, args):
"drcluster",
"--all",
"--for=jsonpath={.status.phase}=Available",
f"--namespace={args.ramen_namespace}",
context=hub,
log=command.debug,
)
Expand All @@ -167,7 +168,6 @@ def wait_for_dr_policy(hub, args):
kubectl.wait(
"drpolicy/dr-policy",
"--for=condition=Validated",
f"--namespace={args.ramen_namespace}",
context=hub,
log=command.debug,
)
2 changes: 2 additions & 0 deletions ramenctl/ramenctl/resources/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ data:
clusterServiceVersionName: ramen-dr-cluster-operator.v0.0.1
kubeObjectProtection:
veleroNamespaceName: velero
volSync:
disabled: $volsync_disabled
s3StoreProfiles:
- s3ProfileName: minio-on-$cluster1
s3Bucket: bucket
Expand Down
2 changes: 2 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ sources := $(wildcard \
addons/*/start \
addons/*/test \
addons/*/stop \
*/enable-dr \
*/disable-dr \
*/deploy \
*/undeploy \
*/failover \
Expand Down
4 changes: 4 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ $ drenv delete envs/example.yaml
- `extra_config`: List of extra config key=value. Each item adds
`--extra-config` minikube option. See `minikube start --help` to
see the possible keys and values.
- `feature_gates`: List of Kubernetes feature gates key=value. Each
item adds `--feature-gates` minikube option. See
[Feature Gates](https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/)
for possible keys and values.
- `containerd`: Optional containerd configuration object. See
`containerd config default` for available options.
- `workers`: Optional list of workers to run when starting a
Expand Down
2 changes: 1 addition & 1 deletion test/addons/cdi/cr/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# yamllint disable rule:line-length
---
resources:
- https://github.com/kubevirt/containerized-data-importer/releases/download/v1.57.0/cdi-cr.yaml
- https://github.com/kubevirt/containerized-data-importer/releases/download/v1.58.0/cdi-cr.yaml
2 changes: 1 addition & 1 deletion test/addons/cdi/disk/source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ metadata:
spec:
source:
registry:
url: "docker://quay.io/alitke/cirros:latest"
url: "docker://quay.io/nirsof/cirros:0.6.2-1"
2 changes: 1 addition & 1 deletion test/addons/cdi/operator/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# yamllint disable rule:line-length
---
resources:
- https://github.com/kubevirt/containerized-data-importer/releases/download/v1.57.0/cdi-operator.yaml
- https://github.com/kubevirt/containerized-data-importer/releases/download/v1.58.0/cdi-operator.yaml
22 changes: 22 additions & 0 deletions test/addons/cdi/start
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 json
import os
import sys

Expand All @@ -27,6 +28,19 @@ def deploy(cluster):
print("Deploying cdi cr")
kubectl.apply("--kustomize=cr", context=cluster)

print("Configuring insecure local registry")
patch = {
"spec": {"config": {"insecureRegistries": ["host.minikube.internal:5000"]}}
}
kubectl.patch(
"cdi",
"cdi",
"--patch",
json.dumps(patch),
"--type=merge",
context=cluster,
)


def wait(cluster):
print("Waiting until cdi cr is available")
Expand All @@ -37,6 +51,14 @@ def wait(cluster):
"--timeout=300s",
context=cluster,
)
print("Waiting until cdi cr finished progressing")
kubectl.wait(
"cdi.cdi.kubevirt.io/cdi",
"--for=condition=progressing=False",
f"--namespace={NAMESPACE}",
"--timeout=300s",
context=cluster,
)


if len(sys.argv) != 2:
Expand Down
2 changes: 1 addition & 1 deletion test/addons/kubevirt/cr/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# yamllint disable rule:line-length
---
resources:
- https://github.com/kubevirt/kubevirt/releases/download/v1.0.1/kubevirt-cr.yaml
- https://github.com/kubevirt/kubevirt/releases/download/v1.1.1/kubevirt-cr.yaml
2 changes: 1 addition & 1 deletion test/addons/kubevirt/operator/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# yamllint disable rule:line-length
---
resources:
- https://github.com/kubevirt/kubevirt/releases/download/v1.0.1/kubevirt-operator.yaml
- https://github.com/kubevirt/kubevirt/releases/download/v1.1.1/kubevirt-operator.yaml
11 changes: 7 additions & 4 deletions test/basic-test/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
# SPDX-License-Identifier: Apache-2.0

---
repo: https://github.com/ramendr/ocm-ramen-samples.git
branch: main
name: busybox-sample
namespace: busybox-sample
repo: https://github.com/nirs/ocm-ramen-samples.git
path: k8s/busybox-regional-rbd-deploy/sub
branch: test
name: busybox-regional-rbd-deploy
namespace: busybox-regional-rbd-deploy
dr_policy: busybox-regional-rbd-deploy
pvc_label: busybox
4 changes: 2 additions & 2 deletions test/basic-test/undeploy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ from drenv import test
test.start("undeploy", __file__)
args = test.parse_args()

test.info("Deleting busybox example application")
test.info("Deleting application")
test.undeploy()
test.info("Application was undeployed successfully")
test.info("Application was deleted")
11 changes: 11 additions & 0 deletions test/configs/k8s/busybox-regional-rbd-deploy.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

---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: k8s/busybox-regional-rbd-deploy/sub
branch: test
name: busybox-regional-rbd-deploy
namespace: busybox-regional-rbd-deploy
dr_policy: busybox-regional-rbd-deploy
pvc_label: busybox
11 changes: 11 additions & 0 deletions test/configs/k8s/busybox-regional-rbd-ds.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

---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: k8s/busybox-regional-rbd-ds/sub
branch: test
name: busybox-regional-rbd-ds
namespace: busybox-regional-rbd-ds
dr_policy: busybox-regional-rbd-ds
pvc_label: busybox
11 changes: 11 additions & 0 deletions test/configs/k8s/busybox-regional-rbd-sts.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

---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: k8s/busybox-regional-rbd-sts/sub
branch: test
name: busybox-regional-rbd-sts
namespace: busybox-regional-rbd-sts
dr_policy: busybox-regional-rbd-sts
pvc_label: busybox
11 changes: 11 additions & 0 deletions test/configs/k8s/kubevirt-pvc.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

---
repo: https://github.com/nirs/ocm-kubevirt-samples.git
path: subscription
branch: test
name: kubevirt-sample
namespace: kubevirt-sample
dr_policy: kubevirt-sample
pvc_label: vm-standalone-dv-odr-regional
11 changes: 11 additions & 0 deletions test/configs/odr/busybox-metro-rbd-deploy.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

---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: odr/busybox-metro-rbd-deploy/sub
branch: test-odr
name: busybox-metro-rbd-deploy
namespace: busybox-metro-rbd-deploy
dr_policy: busybox-metro-rbd-deploy
pvc_label: busybox
11 changes: 11 additions & 0 deletions test/configs/odr/busybox-regional-cephfs-deploy.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

---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: odr/busybox-regional-cephfs-deploy/sub
branch: test-odr
name: busybox-regional-cephfs-deploy
namespace: busybox-regional-cephfs-deploy
dr_policy: busybox-regional-cephfs-deploy
pvc_label: busybox
11 changes: 11 additions & 0 deletions test/configs/odr/busybox-regional-rbd-deploy.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

---
repo: https://github.com/nirs/ocm-ramen-samples.git
path: odr/busybox-regional-rbd-deploy/sub
branch: test-odr
name: busybox-regional-rbd-deploy
namespace: busybox-regional-rbd-deploy
dr_policy: busybox-regional-rbd-deploy
pvc_label: busybox
35 changes: 27 additions & 8 deletions test/drenv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ def main():
p = argparse.ArgumentParser(prog="drenv")
p.add_argument("-v", "--verbose", action="store_true", help="Be more verbose")
p.add_argument(
"--skip-tests", dest="run_tests", action="store_false", help="Skip self tests"
"--skip-tests",
dest="run_tests",
action="store_false",
help="Skip addons 'test' hooks",
)
p.add_argument(
"--skip-addons",
dest="run_addons",
action="store_false",
help="Skip addons 'start' and 'stop' hooks",
)
p.add_argument("command", choices=commands, help="Command to run")
p.add_argument("--name-prefix", help="Prefix profile names")
Expand All @@ -52,7 +61,12 @@ def main():
def cmd_start(env, args):
start = time.monotonic()
logging.info("[%s] Starting environment", env["name"])
hooks = ["start", "test"] if args.run_tests else ["start"]

hooks = []
if args.run_addons:
hooks.append("start")
if args.run_tests:
hooks.append("test")

# Delaying `minikube start` ensures cluster start order.
execute(
Expand All @@ -62,7 +76,9 @@ def cmd_start(env, args):
hooks=hooks,
verbose=args.verbose,
)
execute(run_worker, env["workers"], hooks=hooks)

if hooks:
execute(run_worker, env["workers"], hooks=hooks)

if "ramen" in env:
ramen.dump_e2e_config(env)
Expand All @@ -77,7 +93,8 @@ def cmd_start(env, args):
def cmd_stop(env, args):
start = time.monotonic()
logging.info("[%s] Stopping environment", env["name"])
execute(stop_cluster, env["profiles"])
hooks = ["stop"] if args.run_addons else []
execute(stop_cluster, env["profiles"], hooks=hooks)
logging.info(
"[%s] Environment stopped in %.2f seconds",
env["name"],
Expand Down Expand Up @@ -147,17 +164,18 @@ def start_cluster(profile, hooks=(), verbose=False, **options):
if is_restart:
wait_for_deployments(profile)

execute(run_worker, profile["workers"], hooks=hooks)
if hooks:
execute(run_worker, profile["workers"], hooks=hooks)


def stop_cluster(profile, **options):
def stop_cluster(profile, hooks=(), **options):
cluster_status = cluster.status(profile["name"])

if cluster_status == cluster.READY:
if cluster_status == cluster.READY and hooks:
execute(
run_worker,
profile["workers"],
hooks=["stop"],
hooks=hooks,
reverse=True,
allow_failure=True,
)
Expand Down Expand Up @@ -207,6 +225,7 @@ def start_minikube_cluster(profile, verbose=False):
addons=profile["addons"],
service_cluster_ip_range=profile["service_cluster_ip_range"],
extra_config=profile["extra_config"],
feature_gates=profile["feature_gates"],
alsologtostderr=verbose,
)

Expand Down
1 change: 1 addition & 0 deletions test/drenv/envfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def _validate_profile(profile, addons_root):
profile.setdefault("ser", [])
profile.setdefault("service_cluster_ip_range", None)
profile.setdefault("extra_config", [])
profile.setdefault("feature_gates", [])
profile.setdefault("containerd", None)
profile.setdefault("workers", [])

Expand Down
5 changes: 5 additions & 0 deletions test/drenv/minikube.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def start(
addons=(),
service_cluster_ip_range=None,
extra_config=None,
feature_gates=None,
alsologtostderr=False,
):
args = []
Expand Down Expand Up @@ -77,6 +78,10 @@ def start(
for pair in extra_config:
args.extend(("--extra-config", pair))

if feature_gates:
# Unlike --extra-config this requires one comma separated value.
args.extend(("--feature-gates", ",".join(feature_gates)))

if alsologtostderr:
args.append("--alsologtostderr")

Expand Down
Loading