]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/rgw_multisite_tests.py
5354e756fd737715bb4da5bf9f43f0f25989d7a2
10 from teuthology
.config
import config
as teuth_config
11 from teuthology
.exceptions
import ConfigError
12 from teuthology
.repo_utils
import fetch_repo
13 from teuthology
.task
import Task
14 from teuthology
import misc
16 log
= logging
.getLogger(__name__
)
19 class RGWMultisiteTests(Task
):
21 Runs the rgw_multi tests against a multisite configuration created by the
22 rgw-multisite task. Tests are run with nose, using any additional 'args'
23 provided. Overrides for tests.Config can be set in 'config'. The 'branch'
24 and 'repo' can be overridden to clone the rgw_multi tests from another
27 - rgw-multisite-tests:
29 - tests.py:test_object_sync
33 repo: https://github.com/ceph/ceph.git
36 def __init__(self
, ctx
, config
):
37 super(RGWMultisiteTests
, self
).__init
__(ctx
, config
)
40 super(RGWMultisiteTests
, self
).setup()
42 overrides
= self
.ctx
.config
.get('overrides', {})
43 misc
.deep_merge(self
.config
, overrides
.get('rgw-multisite-tests', {}))
45 if not self
.ctx
.rgw_multisite
:
46 raise ConfigError('rgw-multisite-tests must run after the rgw-multisite task')
47 realm
= self
.ctx
.rgw_multisite
.realm
48 master_zone
= realm
.meta_master_zone()
50 branch
= self
.config
.get('branch')
53 suite_path
= self
.ctx
.config
.get('suite_path')
54 self
.module_path
= suite_path
+ '/../src/test/rgw/rgw_multi'
57 repo
= self
.config
.get('repo', teuth_config
.get_ceph_qa_suite_git_url())
58 log
.info("cloning suite branch %s from %s...", branch
, repo
)
59 clonedir
= fetch_repo(repo
, branch
)
60 # import its version of rgw_multi
61 self
.module_path
= clonedir
+ '/src/test/rgw/rgw_multi'
63 log
.info("importing tests from %s", self
.module_path
)
64 spec
= importlib
.util
.spec_from_file_location('rgw_multi', self
.module_path
+ '/__init__.py')
65 module
= importlib
.util
.module_from_spec(spec
)
66 sys
.modules
[spec
.name
] = module
67 spec
.loader
.exec_module(module
)
69 from rgw_multi
import multisite
, tests
71 # create the test user
72 log
.info('creating test user..')
73 user
= multisite
.User('rgw-multisite-test-user')
74 user
.create(master_zone
, ['--display-name', 'Multisite Test User',
75 '--gen-access-key', '--gen-secret'])
77 config
= self
.config
.get('config', {})
78 tests
.init_multi(realm
, user
, tests
.Config(**config
))
79 tests
.realm_meta_checkpoint(realm
)
82 # extra arguments for nose can be passed as a string or list
83 extra_args
= self
.config
.get('args', [])
84 if not isinstance(extra_args
, list):
85 extra_args
= [extra_args
]
86 argv
= [__name__
] + extra_args
88 log
.info("running rgw multisite tests on '%s' with args=%r",
89 self
.module_path
, extra_args
)
91 # run nose tests in the module path
92 conf
= nose
.config
.Config(stream
=get_log_stream(), verbosity
=2, workingDir
=self
.module_path
)
93 assert nose
.run(argv
=argv
, config
=conf
), 'rgw multisite test failures'
97 """ return a log stream for nose output """
98 # XXX: this is a workaround for IOErrors when nose writes to stderr,
99 # copied from vstart_runner.py
100 class LogStream(object):
104 def write(self
, data
):
106 if "\n" in self
.buffer:
107 lines
= self
.buffer.split("\n")
108 for line
in lines
[:-1]:
110 self
.buffer = lines
[-1]
118 task
= RGWMultisiteTests