From cd089ee74eb01bb9d2208400296e61e9636df5ab Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 15 Jul 2021 16:49:12 -0400 Subject: [PATCH] qa/suites/orch/cephadm: add rgw nfs export test Signed-off-by: Sage Weil --- .../2-services/nfs-ingress-rgw.yaml | 89 +++++++++++++++++++ qa/tasks/python.py | 12 +-- 2 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 qa/suites/orch/cephadm/smoke-roleless/2-services/nfs-ingress-rgw.yaml diff --git a/qa/suites/orch/cephadm/smoke-roleless/2-services/nfs-ingress-rgw.yaml b/qa/suites/orch/cephadm/smoke-roleless/2-services/nfs-ingress-rgw.yaml new file mode 100644 index 0000000000000..8e18c5906c31c --- /dev/null +++ b/qa/suites/orch/cephadm/smoke-roleless/2-services/nfs-ingress-rgw.yaml @@ -0,0 +1,89 @@ +tasks: +- vip: + +# make sure cephadm notices the new IP +- cephadm.shell: + host.a: + - ceph orch device ls --refresh + +# stop kernel nfs server, if running +- vip.exec: + all-hosts: + - systemctl stop nfs-server + +- cephadm.shell: + host.a: + - ceph orch apply rgw foorgw --port 8800 + - ceph nfs cluster create foo --ingress --virtual-ip {{VIP0}}/{{VIPPREFIXLEN}} + +- vip.exec: + host.a: + - dnf install -y python3-boto3 || apt install -y python3-boto3 + - /home/ubuntu/cephtest/cephadm shell radosgw-admin user create --uid foouser --display-name foo > /tmp/user.json + +- python: + host.a: | + import boto3 + import json + + with open('/tmp/user.json', 'rt') as f: + info = json.loads(f.read()) + s3 = boto3.resource( + 's3', + aws_access_key_id=info['keys'][0]['access_key'], + aws_secret_access_key=info['keys'][0]['secret_key'], + endpoint_url='http://localhost:8800', + ) + bucket = s3.Bucket('foobucket') + bucket.create() + bucket.put_object(Key='myobject', Body='thebody') + +- cephadm.shell: + host.a: + - ceph nfs export create rgw foobucket foo --pseudo-path /foobucket + +- cephadm.wait_for_service: + service: nfs.foo +- cephadm.wait_for_service: + service: ingress.nfs.foo + +## export and mount + +- vip.exec: + host.a: + - mkdir /mnt/foo + - sleep 5 + - mount -t nfs {{VIP0}}:/foobucket /mnt/foo + - find /mnt/foo -ls + - grep thebody /mnt/foo/myobject + - echo test > /mnt/foo/newobject + - sync + +- python: + host.a: | + import boto3 + import json + from io import BytesIO + + with open('/tmp/user.json', 'rt') as f: + info = json.loads(f.read()) + s3 = boto3.resource( + 's3', + aws_access_key_id=info['keys'][0]['access_key'], + aws_secret_access_key=info['keys'][0]['secret_key'], + endpoint_url='http://localhost:8800', + ) + bucket = s3.Bucket('foobucket') + data = BytesIO() + bucket.download_fileobj(Fileobj=data, Key='newobject') + print(data.getvalue()) + assert data.getvalue().decode() == 'test\n' + +- vip.exec: + host.a: + - umount /mnt/foo + +- cephadm.shell: + host.a: + - ceph nfs export rm foo /foobucket + - ceph nfs cluster rm foo diff --git a/qa/tasks/python.py b/qa/tasks/python.py index 8dccd87a0932b..4ddb14f714538 100644 --- a/qa/tasks/python.py +++ b/qa/tasks/python.py @@ -15,23 +15,21 @@ def task(ctx, config): import boto3 c = boto3.resource(...) - or + The provided dict is normally indexed by role. You can also include a + 'sudo: false' key to run the code without sudo. tasks: - python: - sudo: true + sudo: false host.b: | import boto3 c = boto3.resource(...) - - The provided dict is normally indexed by role. However, you can also include a - 'sudo: true' key to run the code with sudo. """ assert isinstance(config, dict), "task python got invalid config" testdir = teuthology.get_testdir(ctx) - sudo = config.pop('sudo', False) + sudo = config.pop('sudo', True) for role, code in config.items(): (remote,) = ctx.cluster.only(role).remotes.keys() @@ -41,5 +39,7 @@ def task(ctx, config): 'TESTDIR={tdir}'.format(tdir=testdir), 'python3', ] + if sudo: + args = ['sudo'] + args remote.run(args=args, stdin=subst_vip(ctx, code)) -- 2.39.5