]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/rgw_multisite_tests.py
822cbcf7910c9e9afa84fb14b1e1d200a3a86dee
10 from nose
.plugins
.manager
import DefaultPluginManager
11 from teuthology
.config
import config
as teuth_config
12 from teuthology
.exceptions
import ConfigError
13 from teuthology
.repo_utils
import fetch_repo
14 from teuthology
.task
import Task
15 from teuthology
import misc
17 log
= logging
.getLogger(__name__
)
20 class RGWMultisiteTests(Task
):
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'
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
28 - rgw-multisite-tests:
30 - tests.py:test_object_sync
34 repo: https://github.com/ceph/ceph.git
37 def __init__(self
, ctx
, config
):
38 super(RGWMultisiteTests
, self
).__init
__(ctx
, config
)
41 super(RGWMultisiteTests
, self
).setup()
43 overrides
= self
.ctx
.config
.get('overrides', {})
44 misc
.deep_merge(self
.config
, overrides
.get('rgw-multisite-tests', {}))
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()
51 branch
= self
.config
.get('branch')
54 suite_path
= self
.ctx
.config
.get('suite_path')
55 self
.module_path
= suite_path
+ '/../src/test/rgw/rgw_multi'
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'
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
)
70 from rgw_multi
import multisite
, tests
72 # create test account/user
73 log
.info('creating test user..')
74 user
= multisite
.User('rgw-multisite-test-user', account
='RGW11111111111111111')
75 master_zone
.cluster
.admin(['account', 'create', '--account-id', user
.account
])
76 user
.create(master_zone
, ['--display-name', 'TestUser',
77 '--gen-access-key', '--gen-secret'])
79 config
= self
.config
.get('config', {})
80 tests
.init_multi(realm
, user
, tests
.Config(**config
))
81 tests
.realm_meta_checkpoint(realm
)
84 # extra arguments for nose can be passed as a string or list
85 extra_args
= self
.config
.get('args', [])
86 if not isinstance(extra_args
, list):
87 extra_args
= [extra_args
]
88 argv
= [__name__
] + extra_args
90 log
.info("running rgw multisite tests on '%s' with args=%r",
91 self
.module_path
, extra_args
)
93 # run nose tests in the module path
94 conf
= nose
.config
.Config(stream
=get_log_stream(), verbosity
=2, workingDir
=self
.module_path
)
95 conf
.plugins
= DefaultPluginManager() # overrides default = NoPlugins()
96 assert nose
.run(argv
=argv
, config
=conf
), 'rgw multisite test failures'
100 """ return a log stream for nose output """
101 # XXX: this is a workaround for IOErrors when nose writes to stderr,
102 # copied from vstart_runner.py
103 class LogStream(object):
107 def write(self
, data
):
109 if "\n" in self
.buffer:
110 lines
= self
.buffer.split("\n")
111 for line
in lines
[:-1]:
113 self
.buffer = lines
[-1]
121 task
= RGWMultisiteTests