]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: Adding rgw multisite support
authorRedouane Kachach <rkachach@redhat.com>
Thu, 23 Feb 2023 16:16:39 +0000 (17:16 +0100)
committerAdam King <adking@redhat.com>
Tue, 25 Apr 2023 12:36:54 +0000 (08:36 -0400)
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
(cherry picked from commit 3e4ef2c967f24e5b993116a679225750faf528bc)

qa/suites/orch/cephadm/workunits/task/test_rgw_multisite.yaml [new file with mode: 0644]
qa/tasks/rgw_module.py [new file with mode: 0644]

diff --git a/qa/suites/orch/cephadm/workunits/task/test_rgw_multisite.yaml b/qa/suites/orch/cephadm/workunits/task/test_rgw_multisite.yaml
new file mode 100644 (file)
index 0000000..424fb45
--- /dev/null
@@ -0,0 +1,43 @@
+roles:
+- - host.a
+  - mon.a
+  - mgr.a
+  - osd.0
+- - host.b
+  - mon.b
+  - mgr.b
+  - osd.1
+- - host.c
+  - mon.c
+  - osd.2
+tasks:
+- install:
+- cephadm:
+- cephadm.shell:
+    host.a:
+      - ceph mgr module enable rgw
+- rgw_module.apply:
+    specs:
+      - rgw_realm: myrealm1
+        rgw_zonegroup: myzonegroup1
+        rgw_zone: myzone1
+        placement:
+          hosts:
+           - ceph-node-0
+           - ceph-node-1
+        spec:
+          rgw_frontend_port: 5500
+- cephadm.shell:
+    host.a:
+      - |
+        set -e
+        set -x
+        TOKENS=$(ceph rgw realm tokens)
+        echo $TOKENS | jq --exit-status '.[0].realm == "myrealm1"'
+        echo $TOKENS | jq --exit-status '.[0].token'
+        TOKEN_JSON=$(ceph rgw realm tokens | jq -r '.[0].token' | base64 --decode)
+        echo $TOKEN_JSON | jq --exit-status '.realm_name == "myrealm1"'
+        echo $TOKEN_JSON | jq --exit-status '.endpoint | test("http://.+:\\d+")'
+        echo $TOKEN_JSON | jq --exit-status '.realm_id | test("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$")'
+        echo $TOKEN_JSON | jq --exit-status '.access_key'
+        echo $TOKEN_JSON | jq --exit-status '.secret'
diff --git a/qa/tasks/rgw_module.py b/qa/tasks/rgw_module.py
new file mode 100644 (file)
index 0000000..0d2ca90
--- /dev/null
@@ -0,0 +1,53 @@
+import logging
+import yaml
+
+from teuthology import misc as teuthology
+
+
+log = logging.getLogger(__name__)
+
+
+def _shell(ctx, cluster_name, remote, args, extra_cephadm_args=[], **kwargs):
+    teuthology.get_testdir(ctx)
+    return remote.run(
+        args=[
+            'sudo',
+            ctx.cephadm,
+            '--image', ctx.ceph[cluster_name].image,
+            'shell',
+            '-c', '/etc/ceph/{}.conf'.format(cluster_name),
+            '-k', '/etc/ceph/{}.client.admin.keyring'.format(cluster_name),
+            '--fsid', ctx.ceph[cluster_name].fsid,
+            ] + extra_cephadm_args + [
+            '--',
+            ] + args,
+        **kwargs
+    )
+
+
+def apply(ctx, config):
+    """
+    Apply spec
+
+      tasks:
+        - rgw_module.apply:
+            specs:
+            - rgw_realm: myrealm1
+              rgw_zonegroup: myzonegroup1
+              rgw_zone: myzone1
+              placement:
+                hosts:
+                 - ceph-node-0
+                 - ceph-node-1
+              spec:
+                rgw_frontend_port: 5500
+    """
+    cluster_name = config.get('cluster', 'ceph')
+    specs = config.get('specs', [])
+    y = yaml.dump_all(specs)
+    log.info(f'Applying spec(s):\n{y}')
+    _shell(
+        ctx, cluster_name, ctx.ceph[cluster_name].bootstrap_remote,
+        ['ceph', 'rgw', 'realm', 'bootstrap', '-i', '-'],
+        stdin=y,
+    )