]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
renamed the taskfile and added code to work on nfs-ganesha-rgw-v2(boto3 based)
authorrakesh <rakesh@localhost.localdomain>
Mon, 18 Jun 2018 17:05:36 +0000 (22:35 +0530)
committerrakesh <rakesh@localhost.localdomain>
Mon, 18 Jun 2018 17:05:36 +0000 (22:35 +0530)
qa/tasks/nfs_ganesha.py [deleted file]
qa/tasks/nfs_ganesha_rgw_v2.py [new file with mode: 0644]

diff --git a/qa/tasks/nfs_ganesha.py b/qa/tasks/nfs_ganesha.py
deleted file mode 100644 (file)
index 647f4f3..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-import contextlib
-import logging
-import os
-from teuthology import misc as teuthology
-from teuthology.orchestra import run
-import cStringIO
-import json
-
-log = logging.getLogger(__name__)
-
-def NFS_Ganesh_RGW_config_gen(conf):
-
-    ganesha_conf = '''
-                EXPORT
-                {
-                        Export_ID=77;
-                        Path = "/";
-                        Pseudo = "/";
-                        Access_Type = RW;
-                        SecType = "sys";
-                        NFS_Protocols = %s;
-                        Transport_Protocols = TCP;
-
-                        FSAL {
-                                Name = RGW;
-                                User_Id = %s;
-                                Access_Key_Id ="%s";
-                                Secret_Access_Key = "%s";
-                        }
-                }
-
-                NFSV4 {
-                    Allow_Numeric_Owners = true;
-                    Only_Numeric_Owners = true;
-                }
-
-                Cache_Inode {
-                    Dir_Max = 10000;
-                }
-
-                RGW {
-                    name = %s";
-                    ceph_conf = "/etc/ceph/ceph.conf";
-                    init_args = "-d --debug-rgw=16";
-                }
-
-        ''' % (conf['nfs_version'],
-               conf['user_id'],
-               conf['access_key'],
-               conf['secret_key'],
-               conf['hostname'])
-
-    return ganesha_conf
-
-
-@contextlib.contextmanager
-def task(ctx, config):
-    """
-     Install and config NFS-Ganesha and mount
-
-     tasks:
-        - ssh-keys: null
-        - ceph-ansible: null
-        - nfs_ganesha:
-            cluster_name: ceph
-            mount_point: ~/ganesha_mnt  # full path
-            nfs_version: 4 # 3 or 4
-            type: rgw # rgw or fs
-
-    """
-    if config is None:
-        config = {}
-
-    assert isinstance(config, dict), \
-        "task set-repo only supports a dictionary for configuration"
-
-    nfs_version = config['nfs_version']
-    mount_point = config['mount_point']
-    cluster_name = config['cluster_name']
-
-    log.info('got nfs version: %s' % nfs_version)
-
-    remotes = ctx.cluster.only(teuthology.is_type('mon'))
-    mon = [
-        remote for remote,
-                   roles_for_host in remotes.remotes.iteritems()]
-
-    rgw_remote = ctx.cluster.only(teuthology.is_type('rgw'))
-    rgw = [
-        remote for remote,
-                   roles_for_host in rgw_remote.remotes.iteritems()]
-
-    client_remote = ctx.cluster.only(teuthology.is_type('client'))
-    client = [
-        remote for remote,
-                   roles_for_host in client_remote.remotes.iteritems()]
-
-    # clone the repo
-
-    client[0].run(args=['sudo', 'rm', '-rf', 'nfs-ganesha-rgw'], check_status=False)
-    client[0].run(args=['sudo', 'rm', '-rf', run.Raw('/tmp/nfs-ganesh-rgw_log*')], check_status=False)
-    client[0].run(args=['mkdir', '-p', 'nfs-ganesha-rgw'])
-
-    # stop native nfs-ganesha service.
-
-    client[0].run(args=['sudo', 'systemctl', 'stop', 'nfs-server.service'])  # systemctl stop nfs-server.service
-    client[0].run(args=['sudo', 'systemctl', 'disable', 'nfs-server.service'])  # systemctl disable nfs-server.service
-
-    # copy admin.keyring from mon to rgw, client node because of bz
-
-    out = cStringIO.StringIO()
-    mon[0].run(args=['sudo', 'cat', '/etc/ceph/%s.client.admin.keyring' % cluster_name], stdout=out)
-    v_as_out = out.read()
-    teuthology.create_file(rgw[0], '/etc/ceph/%s.client.admin.keyring' % cluster_name, data=v_as_out, sudo=True)
-    teuthology.create_file(client[0], '/etc/ceph/%s.client.admin.keyring' % cluster_name, data=v_as_out, sudo=True)
-
-    if config['type'] == 'rgw':
-
-        out = cStringIO.StringIO()
-        rgw[0].run(args=['radosgw-admin', 'user', 'create', '--display-name="johnny rotten"', '--uid=johnny'],
-                   stdout=out)
-        v_as_out = out.read()
-
-        v_as_json = json.loads(v_as_out)
-
-        config['user_id'] = v_as_json['user_id']
-        config['display_name'] = v_as_json['display_name']
-
-        config['access_key'] = v_as_json['keys'][0]['access_key']
-
-        config['secret_key'] = v_as_json['keys'][0]['secret_key']
-
-        client['hostname'] = "client.rgw.%s" % rgw[0].shortname
-
-    config['nfs_version'] = nfs_version
-
-    # generate nfs_ganesha config
-
-    ganesha_config = NFS_Ganesh_RGW_config_gen(config)
-
-    log.info('ganesha_config: %s' % ganesha_config)
-
-    # install nfs_ganesha_rgw
-
-    client[0].run(args=['sudo', 'yum', 'install', 'nfs-ganesha-rgw', '-y'])
-
-    # backup default ganesha config file and write the generated config file
-
-    client[0].run(args=['sudo', 'mv', '/etc/ganesha/ganesha.conf', '/etc/ganesha/ganesha.conf.bkp'])
-
-    ganesha_config_path_on_client = '/etc/ganesha/ganesha.conf'
-
-    teuthology.sudo_write_file(rgw[0], ganesha_config_path_on_client, ganesha_config)
-
-    # start the nfs_ganesha service
-
-    client[0].run(args=['sudo', '/usr/bin/ganesha.nfsd', '-f', '/etc/ganesha/ganesha.conf'])
-
-    client[0].run(args=['mkdir', '-p', run.Raw(mount_point)])
-
-    # mount NFS_Ganesha
-
-    client[0].run(args=[run.Raw('sudo mount -v -t nfs -o nfsvers=%s,sync,rw,noauto,soft,proto=tcp %s:/  %s' %
-                             (nfs_version,
-                              rgw[0].shortname,
-                              mount_point))])
-
-    try:
-        yield
-    finally:
-        log.info("un-mount ganesha mount_point")
-
-        client[0].run(args=['sudo', 'umount', run.Raw(mount_point)])
-
-        log.info('removing nfs-ganesha-rgw')
-
-        client[0].run(args=['sudo', 'yum', 'remove', 'nfs-ganesha-rgw', '-y'])
diff --git a/qa/tasks/nfs_ganesha_rgw_v2.py b/qa/tasks/nfs_ganesha_rgw_v2.py
new file mode 100644 (file)
index 0000000..3f5890b
--- /dev/null
@@ -0,0 +1,164 @@
+import contextlib
+import logging
+import os
+from teuthology import misc as teuthology
+from teuthology.orchestra import run
+import pwd
+import yaml
+import cStringIO
+import json
+import psutil
+import re
+import time
+
+log = logging.getLogger(__name__)
+
+# format in {"test-name": "script-file"}
+
+tests_mapper = {'test_on_nfs_io_create': 'test_on_nfs_io',
+                'test_on_nfs_io_delete': 'test_on_nfs_io',
+                'test_on_nfs_io_move': 'test_on_nfs_io',
+                'test_on_s3_io_create': 'test_on_s3_io',
+                'test_on_s3_io_delete': 'test_on_s3_io',
+                'test_on_s3_io_move': 'test_on_s3_io',
+                }
+
+
+@contextlib.contextmanager
+def task(ctx, config):
+
+    log.info('starting nfs_ganesha_rgw tests')
+    # RGW and NFS should be on the same machine
+
+    if config is None:
+        config = {}
+
+    assert isinstance(config, dict), \
+        "task set-repo only supports a dictionary for configuration"
+
+    test_name = config['test-name'] + ".yaml"
+    script_name = tests_mapper.get(config['test-name'], None) + ".py"
+    nfs_version = config['nfs-version']
+    mount_dir = config['mount-dir']
+
+    log.info('got test_name: %s' % test_name)
+    log.info('got nfs version: %s' % nfs_version)
+    log.info('got mount dir: %s' % mount_dir)
+
+    remotes = ctx.cluster.only(teuthology.is_type('mon'))
+    mon = [remote for remote, roles_for_host in remotes.remotes.iteritems()]
+
+    rgw_remote = ctx.cluster.only(teuthology.is_type('rgw'))
+    rgw = [remote for remote, roles_for_host in rgw_remote.remotes.iteritems()]
+
+    # clone the repo
+
+    rgw[0].run(args=['sudo', 'rm', '-rf', 'nfs-ganesha-rgw'], check_status=False)
+    rgw[0].run(args=['sudo', 'rm', '-rf', run.Raw('/tmp/nfs-ganesh-rgw_log*')], check_status=False)
+    rgw[0].run(args=['mkdir', '-p', 'nfs-ganesha-rgw'])
+
+    # stop native nfs-ganesha service.
+
+    rgw[0].run(args=['sudo', 'systemctl', 'stop', 'nfs-server.service'])  # systemctl stop nfs-server.service
+    rgw[0].run(args=['sudo', 'systemctl', 'disable', 'nfs-server.service'])  # systemctl disable nfs-server.service
+
+    out = cStringIO.StringIO()
+    mon[0].run(args=['sudo', 'cat', '/etc/ceph/ceph.client.admin.keyring'], stdout=out)
+    v_as_out = out.read()
+    teuthology.create_file(rgw[0], '/etc/ceph/ceph.client.admin.keyring', data=v_as_out, sudo=True)
+
+    # parsing nfs-ganesha conf file
+
+    out = cStringIO.StringIO()
+    rgw[0].run(args=['sudo', 'cat', '/etc/ganesha/ganesha.conf'],
+               stdout=out)
+    v_as_out = out.readlines()
+
+    clean = lambda x: re.sub('[^A-Za-z0-9]+', '', x)
+
+    for content in v_as_out:
+
+        if 'Access_Key_Id' in content:
+            access_key = clean(content.split('=')[1])
+
+        if 'Secret_Access_Key' in content:
+            secret_key = clean(content.split('=')[1])
+
+        if 'User_Id' in content:
+            rgw_user_id = clean(content.split('=')[1])
+
+        if 'Pseudo' in content:
+            pseudo = content.split('=')[1].strip(' ').strip('\n').strip(' ').strip(';').strip('/')
+
+    rgw[0].run(args=['sudo', 'setenforce', '1'])
+
+    log.info('restarting nfs_ganesha service')
+
+    rgw[0].run(args=['sudo', 'systemctl', 'restart', 'nfs-ganesha.service'])
+
+    time.sleep(60)
+
+    rgw[0].run(args=['cd', 'nfs-ganesha-rgw', run.Raw(';'), 'git', 'clone',
+                     'http://gitlab.cee.redhat.com/ceph/ceph-qe-scripts.git'])
+
+    rgw[0].run(args=['cd', 'nfs-ganesha-rgw/ceph-qe-scripts', run.Raw(';'), 'git', 'checkout', 'wip-nfs-v2'])
+
+    rgw[0].run(args=['virtualenv', 'venv'])
+    rgw[0].run(
+        args=[
+            'source',
+            'venv/bin/activate',
+            run.Raw(';'),
+            run.Raw('pip install boto boto3 names PyYaml psutil ConfigParser'),
+            run.Raw(';'),
+            'deactivate'])
+
+    # copy rgw user details (yaml format) to nfs node or rgw node
+
+    rgw_user_config = dict(user_id=rgw_user_id,
+                           access_key=access_key,
+                           secret_key=secret_key,
+                           rgw_hostname=rgw[0].shortname,
+                           ganesha_config_exists=True,
+                           already_mounted=False,
+                           nfs_version=nfs_version,
+                           nfs_mnt_point=mount_dir,
+                           Pseudo=pseudo
+                           )
+
+    rgw_user_config_fname = 'rgw_user.yaml'
+
+    temp_yaml_file = rgw_user_config_fname + "_" + str(os.getpid()) + pwd.getpwuid(os.getuid()).pw_name
+
+    log.info('creating rgw_user_config_fname: %s' % rgw_user_config)
+    local_file = '/tmp/' + temp_yaml_file
+    with open(local_file, 'w') as outfile:
+        outfile.write(yaml.dump(rgw_user_config, default_flow_style=False))
+
+    log.info('copying rgw_user_config_fname to the client node')
+    destination_location = 'nfs-ganesha-rgw/ceph-qe-scripts/rgw/v2/tests/nfs-ganesha/config/' + rgw_user_config_fname
+    rgw[0].put_file(local_file, destination_location)
+
+    rgw[0].run(args=[run.Raw('sudo rm -rf %s' % local_file)], check_status=False)
+
+    # run the test
+
+    rgw[0].run(
+        args=[run.Raw(
+            'sudo venv/bin/python2.7 nfs-ganesha-rgw/ceph-qe-scripts/rgw/v2/tests/nfs-ganesha/%s '
+            '-r nfs-ganesha-rgw/ceph-qe-scripts/rgw/v2/tests/nfs-ganesha/config/rgw_user.yaml '
+            '-c nfs-ganesha-rgw/ceph-qe-scripts/rgw/v2/tests/nfs-ganesha/config/%s ' % (script_name, test_name))])
+
+    try:
+        yield
+    finally:
+        log.info("Deleting the test soot")
+
+        rgw[0].run(args=['sudo', 'umount', run.Raw('%s' % mount_dir)])
+
+        cleanup = lambda x: rgw[0].run(args=[run.Raw('sudo rm -rf %s' % x)])
+
+        soot = ['venv', 'rgw-tests', 'test_data' '*.json', 'Download.*', 'Download', '*.mpFile', 'x*', 'key.*', 'Mp.*',
+                '*.key.*']
+
+        map(cleanup, soot)