]> git.proxmox.com Git - ceph.git/blame - ceph/qa/tasks/rgw_multisite_tests.py
bump version to 18.2.2-pve1
[ceph.git] / ceph / qa / tasks / rgw_multisite_tests.py
CommitLineData
31f18b77
FG
1"""
2rgw multisite testing
3"""
20effc67 4import importlib.util
31f18b77 5import logging
31f18b77
FG
6import nose.core
7import nose.config
20effc67 8import sys
31f18b77 9
1e59de90 10from nose.plugins.manager import DefaultPluginManager
20effc67 11from teuthology.config import config as teuth_config
31f18b77 12from teuthology.exceptions import ConfigError
20effc67 13from teuthology.repo_utils import fetch_repo
31f18b77
FG
14from teuthology.task import Task
15from teuthology import misc
16
31f18b77
FG
17log = logging.getLogger(__name__)
18
eafe8130 19
31f18b77
FG
20class RGWMultisiteTests(Task):
21 """
22 Runs the rgw_multi tests against a multisite configuration created by the
23 rgw-multisite task. Tests are run with nose, using any additional 'args'
20effc67
TL
24 provided. Overrides for tests.Config can be set in 'config'. The 'branch'
25 and 'repo' can be overridden to clone the rgw_multi tests from another
26 release.
31f18b77
FG
27
28 - rgw-multisite-tests:
29 args:
20effc67 30 - tests.py:test_object_sync
31f18b77
FG
31 config:
32 reconfigure_delay: 60
20effc67
TL
33 branch: octopus
34 repo: https://github.com/ceph/ceph.git
31f18b77
FG
35
36 """
37 def __init__(self, ctx, config):
38 super(RGWMultisiteTests, self).__init__(ctx, config)
39
40 def setup(self):
41 super(RGWMultisiteTests, self).setup()
42
43 overrides = self.ctx.config.get('overrides', {})
44 misc.deep_merge(self.config, overrides.get('rgw-multisite-tests', {}))
45
46 if not self.ctx.rgw_multisite:
47 raise ConfigError('rgw-multisite-tests must run after the rgw-multisite task')
48 realm = self.ctx.rgw_multisite.realm
49 master_zone = realm.meta_master_zone()
50
20effc67
TL
51 branch = self.config.get('branch')
52 if not branch:
53 # run from suite_path
54 suite_path = self.ctx.config.get('suite_path')
55 self.module_path = suite_path + '/../src/test/rgw/rgw_multi'
56 else:
57 # clone the qa branch
58 repo = self.config.get('repo', teuth_config.get_ceph_qa_suite_git_url())
59 log.info("cloning suite branch %s from %s...", branch, repo)
60 clonedir = fetch_repo(repo, branch)
61 # import its version of rgw_multi
62 self.module_path = clonedir + '/src/test/rgw/rgw_multi'
63
64 log.info("importing tests from %s", self.module_path)
65 spec = importlib.util.spec_from_file_location('rgw_multi', self.module_path + '/__init__.py')
66 module = importlib.util.module_from_spec(spec)
67 sys.modules[spec.name] = module
68 spec.loader.exec_module(module)
69
70 from rgw_multi import multisite, tests
71
31f18b77
FG
72 # create the test user
73 log.info('creating test user..')
74 user = multisite.User('rgw-multisite-test-user')
75 user.create(master_zone, ['--display-name', 'Multisite Test User',
39ae355f 76 '--gen-access-key', '--gen-secret', '--caps', 'roles=*'])
31f18b77
FG
77
78 config = self.config.get('config', {})
79 tests.init_multi(realm, user, tests.Config(**config))
80 tests.realm_meta_checkpoint(realm)
81
82 def begin(self):
83 # extra arguments for nose can be passed as a string or list
84 extra_args = self.config.get('args', [])
85 if not isinstance(extra_args, list):
86 extra_args = [extra_args]
87 argv = [__name__] + extra_args
88
89 log.info("running rgw multisite tests on '%s' with args=%r",
20effc67
TL
90 self.module_path, extra_args)
91
92 # run nose tests in the module path
93 conf = nose.config.Config(stream=get_log_stream(), verbosity=2, workingDir=self.module_path)
1e59de90 94 conf.plugins = DefaultPluginManager() # overrides default = NoPlugins()
20effc67 95 assert nose.run(argv=argv, config=conf), 'rgw multisite test failures'
eafe8130 96
31f18b77
FG
97
98def get_log_stream():
99 """ return a log stream for nose output """
100 # XXX: this is a workaround for IOErrors when nose writes to stderr,
101 # copied from vstart_runner.py
102 class LogStream(object):
103 def __init__(self):
104 self.buffer = ""
105
106 def write(self, data):
107 self.buffer += data
108 if "\n" in self.buffer:
109 lines = self.buffer.split("\n")
110 for line in lines[:-1]:
111 log.info(line)
112 self.buffer = lines[-1]
113
114 def flush(self):
115 pass
116
117 return LogStream()
118
eafe8130 119
31f18b77 120task = RGWMultisiteTests