]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cleaned and modfied code
authorrakesh <rakesh@localhost.localdomain>
Thu, 7 Jun 2018 12:37:08 +0000 (18:07 +0530)
committerrakesh <rakesh@localhost.localdomain>
Thu, 7 Jun 2018 12:37:08 +0000 (18:07 +0530)
qa/tasks/rgw_system_test.py

index f96ba64862d28aeb80760af32b1783ba477c8075..e4bb8bad9b10f2fde0fb2a4e3f27c463fd14894d 100644 (file)
@@ -3,262 +3,19 @@ import contextlib
 import logging
 from teuthology import misc as teuthology
 from teuthology.orchestra import run
+
 log = logging.getLogger(__name__)
 import os
 import pwd
 import cStringIO
+import time
 
-class Test(object):
-
-    def __init__(self, script_name, configuration, port_number=None):
-        self.script_fname = script_name + ".py"
-        self.yaml_fname = script_name + ".yaml"
-        self.configuration = configuration
-        # self.port_number = port_number
-
-    def execution(self, clients):
-
-        log.info('test: %s' % self.script_fname)
-
-        temp_yaml_file = self.yaml_fname + "_" + str(os.getpid()) + pwd.getpwuid(os.getuid()).pw_name
-
-        if self.configuration is None:
-            assert isinstance(self.configuration, dict), "configuration not given"
-
-        data = self.configuration
-
-        log.info('creating yaml from the config: %s' % data)
-        local_file = '/tmp/' + temp_yaml_file
-        with open(local_file,  'w') as outfile:
-            outfile.write(yaml.dump(data, default_flow_style=False))
-
-        log.info('copying yaml to the client node')
-        destination_location = \
-            'rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/yamls/' + self.yaml_fname
-        clients[0].put_file(local_file,  destination_location)
-        clients[0].run(args=['ls', '-lt',
-                             'rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/yamls/'])
-        clients[0].run(args=['cat',
-                             'rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/yamls/' + self.yaml_fname])
-
-        clients[0].run(args=['sudo', 'rm', '-f', run.Raw('%s' % local_file)], check_status=False)
-
-        clients[0].run(
-            args=[
-                run.Raw(
-                    'sudo venv/bin/python2.7 rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/%s '
-                    '-c rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/yamls/%s ' % (self.script_fname, self.yaml_fname))])
-
-
-def test_exec(config, data, clients):
-
-    assert data is not None, "Got no test in configuration"
-
-    log.info('test name :%s' % config['test-name'])
-
-    script_name = config['test-name']
-    # port_number = config['port_number']
-
-    test = Test(script_name, data)
-    test.execution(clients)
-
-
-@contextlib.contextmanager
-def task(ctx, config):
-    """
-
-    tasks:
-    - rgw-system-test:
-        test-name: test_Mbuckets
-        config:
-            user_count: 3
-            bucket_count: 5
-
-    tasks:
-    - rgw-system-test:
-        test-name: test_Mbuckets_with_Nobjects
-        config:
-            user_count: 3
-            bucket_count: 5
-            objects_count: 5
-            min_file_size: 5
-            max_file_size: 10
-
-    tasks:
-    - rgw-system-test:
-        test-name: test_bucket_with_delete
-        config:
-            user_count: 3
-            bucket_count: 5
-            objects_count: 5
-            min_file_size: 5
-            max_file_size: 10
-
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_multipart_upload
-       config:
-           user_count: 3
-           bucket_count: 5
-           min_file_size: 5
-           max_file_size: 10
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_multipart_upload_download
-       config:
-           user_count: 3
-           bucket_count: 5
-           min_file_size: 5
-
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_multipart_upload_cancel
-       config:
-           user_count: 3
-           bucket_count: 5
-           break_at_part_no: 90
-           min_file_size: 1500
-           max_file_size: 1000
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_basic_versioning
-       config:
-           user_count: 3
-           bucket_count: 5
-           objects_count: 90
-           version_count: 5
-           min_file_size: 1000
-           max_file_size: 1500
-
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_delete_key_versions
-       config:
-            user_count: 3
-            bucket_count: 5
-            objects_count: 90
-            version_count: 5
-            min_file_size: 1000
-            max_file_size: 1500
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_suspend_versioning
-       config:
-           user_count: 3
-           bucket_count: 5
-           objects_count: 90
-           version_count: 5
-           min_file_size: 1000
-           max_file_size: 1500
-
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_version_with_revert
-       config:
-           user_count: 3
-           bucket_count: 5
-           objects_count: 90
-           version_count: 5
-           min_file_size: 1000
-           max_file_size: 1500
-
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_acls
-       config:
-           bucket_count: 5
-           objects_count: 90
-           min_file_size: 1000
-           max_file_size: 1500
-
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_acls_all_usrs
-       config:
-           bucket_count: 5
-           user_count: 3
-           objects_count: 90
-           min_file_size: 1000
-           max_file_size: 1500
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_acls_copy_obj
-       config:
-           objects_count: 90
-           min_file_size: 1000
-           max_file_size: 1500
-
-
-    tasks:
-    - rgw-system-test:
-       test-name: test_acls_reset
-       config:
-           bucket_count: 5
-           user_count: 3
-           objects_count: 90
-           min_file_size: 1000
-           max_file_size: 1500
-
-
-    """
-
-    log.info('starting the task')
-
-    log.info('config %s' % config)
-
-    if config is None:
-        config = {}
-
-    assert isinstance(config, dict), \
-        "task set-repo only supports a dictionary for configuration"
-
-    remotes = ctx.cluster.only(teuthology.is_type('client'))
-    clients = [
-        remote for remote,
-        roles_for_host in remotes.remotes.iteritems()]
-
-    log.info('cloning the repo to client.0 machines')
-
-    clients[0].run(args=['sudo', 'rm', '-rf', 'rgw-tests'], check_status=False)
-    clients[0].run(args=['mkdir', 'rgw-tests'])
-    clients[0].run(
-        args=[
-            'cd',
-            'rgw-tests',
-            run.Raw(';'),
-            'git',
-            'clone',
-            'http://gitlab.cee.redhat.com/ceph/ceph-qe-scripts.git',
-            ])
-
-    clients[0].run(args=['virtualenv', 'venv'])
-    clients[0].run(
-        args=[
-            'source',
-            'venv/bin/activate',
-            run.Raw(';'),
-            run.Raw('pip install boto names PyYaml ConfigParser'),
-            run.Raw(';'),
-            'deactivate'])
-
-    config['port_number'] = '8080'
-    test_config = config['config']
-
+def do_auto_calculate_io(clients, config, test_config):
     # re weight osds
 
     """
-    
-    # this code may be come of use in future, so just keep in comment. 
+
+    # this code may be come of use in future, so just keep in comment.
 
     out = cStringIO.StringIO()
     clients[0].run(args=['sudo', 'ceph', 'osd', 'df'], stdout=out)
@@ -300,7 +57,6 @@ def task(ctx, config):
         exit(1)
 
     if 'version' in config['test-name']:
-
         osize = (osize / int(test_config['version_count']))
 
     test_config['min_file_size'] = osize - 5
@@ -311,12 +67,16 @@ def task(ctx, config):
 
     clients[0].run(args=['sudo', 'ceph', 'osd', 'crush', 'tunables', 'optimal'])
 
-    # basic Upload
+    return test_config
+
+
+def execute_v1_tests(config, clients):
+    log.info('starting rgw_v1_system_tests')
 
     data = None
+    test_config = config['config']
 
     if config['test-name'] == 'test_Mbuckets':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -327,7 +87,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_Mbuckets_with_Nobjects':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -342,7 +101,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_Mbuckets_with_Nobjects_shards':
-
         # changing the value of config['test-name'] to take test_Mbuckets_with_Nobjects,
         # since this test also takes the following configuration
 
@@ -364,7 +122,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_bucket_with_delete':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -381,7 +138,6 @@ def task(ctx, config):
     # multipart
 
     if config['test-name'] == 'test_multipart_upload':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -395,7 +151,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_multipart_upload_download':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -409,7 +164,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_multipart_upload_cancel':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -426,7 +180,6 @@ def task(ctx, config):
     # Versioning
 
     if config['test-name'] == 'test_basic_versioning':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -442,7 +195,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_delete_key_versions':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -458,7 +210,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_suspend_versioning':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -474,7 +225,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_version_with_revert':
-
         data = dict(
             config=dict(
                 user_count=test_config['user_count'],
@@ -492,7 +242,6 @@ def task(ctx, config):
     # ACLs
 
     if config['test-name'] == 'test_acls':
-
         data = dict(
             config=dict(
                 bucket_count=test_config['bucket_count'],
@@ -506,7 +255,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_acls_all_usrs':
-
         data = dict(
             config=dict(
                 bucket_count=test_config['bucket_count'],
@@ -521,7 +269,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_acls_copy_obj':
-
         data = dict(
             config=dict(
                 objects_count=test_config['objects_count'],
@@ -534,7 +281,6 @@ def task(ctx, config):
         )
 
     if config['test-name'] == 'test_acls_reset':
-
         data = dict(
             config=dict(
                 objects_count=test_config['objects_count'],
@@ -548,7 +294,100 @@ def task(ctx, config):
             )
         )
 
-    test_exec(config, data, clients)
+    script_fname = config['test-name'] + ".py"
+    yaml_fname = script_fname + ".yaml"
+
+    log.info('test: %s' % script_fname)
+
+    temp_yaml_file = yaml_fname + "_" + str(os.getpid()) + pwd.getpwuid(os.getuid()).pw_name
+
+    log.info('creating yaml from the config: %s' % data)
+    local_file = '/tmp/' + temp_yaml_file
+    with open(local_file, 'w') as outfile:
+        outfile.write(yaml.dump(data, default_flow_style=False))
+
+    log.info('copying yaml to the client node')
+
+    destination_location = 'rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/yamls/' + yaml_fname
+    clients[0].put_file(local_file, destination_location)
+
+    clients[0].run(args=['ls', '-lt', 'rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/yamls/'])
+
+    clients[0].run(args=['cat', 'rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/yamls/' + yaml_fname])
+
+    clients[0].run(args=['sudo', 'rm', '-f', run.Raw('%s' % local_file)], check_status=False)
+
+    clients[0].run(
+        args=[
+            run.Raw(
+                'sudo venv/bin/python2.7 rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/%s '
+                '-c rgw-tests/ceph-qe-scripts/rgw/v1/tests/s3/yamls/%s ' % (script_fname, yaml_fname))])
+
+
+def execute_v2_tests():
+    # will be used if any of the v2 tests needed to be run as part of system tests
+
+    log.info('starting rgw_v2_system_tests')
+
+    pass
+
+
+@contextlib.contextmanager
+def task(ctx, config):
+    log.info('starting rgw_system_tests')
+
+    log.info('config %s' % config)
+
+    if config is None:
+        config = {}
+
+    assert isinstance(config, dict), \
+        "task set-repo only supports a dictionary for configuration"
+
+    remotes = ctx.cluster.only(teuthology.is_type('client'))
+    clients = [
+        remote for remote,
+                   roles_for_host in remotes.remotes.iteritems()]
+
+    log.info('cloning the repo to client.0 machines')
+
+    clients[0].run(args=['sudo', 'rm', '-rf', 'rgw-tests'], check_status=False)
+    clients[0].run(args=['mkdir', 'rgw-tests'])
+    clients[0].run(
+        args=[
+            'cd',
+            'rgw-tests',
+            run.Raw(';'),
+            'git',
+            'clone',
+            'http://gitlab.cee.redhat.com/ceph/ceph-qe-scripts.git',
+        ])
+
+    clients[0].run(args=['virtualenv', 'venv'])
+    clients[0].run(
+        args=[
+            'source',
+            'venv/bin/activate',
+            run.Raw(';'),
+            run.Raw('pip install boto names PyYaml ConfigParser'),
+            run.Raw(';'),
+            'deactivate'])
+
+    time.sleep(60)
+    log.info('trying to restart rgw service after sleep 60 secs')
+
+    clients[0].run(args=[run.Raw('sudo systemctl restart ceph-radosgw.target')])
+
+    log.info('starting the tests after sleep of 60 secs')
+    time.sleep(60)
+
+    log.info('test_dir_version: %s' % config['test_dir_version'])
+
+    if config['test_dir_version'] == 'v1':
+        execute_v1_tests(config, clients)
+
+    if config['test_dir_version'] == 'v2':
+        execute_v2_tests()
 
     try:
         yield
@@ -563,7 +402,7 @@ def task(ctx, config):
                 run.Raw(';'),
                 'deactivate'])
 
-        log.info('test completed')
+        log.info('Test completed')
 
         log.info("Deleting repos")