mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-22 09:29:43 +00:00
rearrange regions info container
Now able to easily get the master and secondaries Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
parent
232dd35817
commit
1c6b1ba1f6
1 changed files with 25 additions and 5 deletions
|
@ -9,7 +9,6 @@ import string
|
||||||
|
|
||||||
s3 = bunch.Bunch()
|
s3 = bunch.Bunch()
|
||||||
config = bunch.Bunch()
|
config = bunch.Bunch()
|
||||||
regions = bunch.Bunch()
|
|
||||||
targets = bunch.Bunch()
|
targets = bunch.Bunch()
|
||||||
|
|
||||||
# this will be assigned by setup()
|
# this will be assigned by setup()
|
||||||
|
@ -121,6 +120,29 @@ class TargetConnection:
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.connection = conn
|
self.connection = conn
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class RegionsInfo:
|
||||||
|
def __init__(self):
|
||||||
|
self.m = bunch.Bunch()
|
||||||
|
self.master = None
|
||||||
|
self.secondaries = []
|
||||||
|
|
||||||
|
def add(self, name, region_config):
|
||||||
|
self.m[name] = region_config
|
||||||
|
if (region_config.is_master):
|
||||||
|
if not self.master is None:
|
||||||
|
raise RuntimeError(
|
||||||
|
'multiple regions defined as master'
|
||||||
|
)
|
||||||
|
self.master = region_config
|
||||||
|
else:
|
||||||
|
self.secondaries.append(region_config)
|
||||||
|
def get(self, name):
|
||||||
|
return self.m[name];
|
||||||
|
|
||||||
|
regions = RegionsInfo()
|
||||||
|
|
||||||
# nosetests --processes=N with N>1 is safe
|
# nosetests --processes=N with N>1 is safe
|
||||||
_multiprocess_can_split_ = True
|
_multiprocess_can_split_ = True
|
||||||
|
|
||||||
|
@ -148,7 +170,6 @@ def setup():
|
||||||
|
|
||||||
s3.clear()
|
s3.clear()
|
||||||
config.clear()
|
config.clear()
|
||||||
regions.clear()
|
|
||||||
|
|
||||||
for section in cfg.sections():
|
for section in cfg.sections():
|
||||||
try:
|
try:
|
||||||
|
@ -157,8 +178,7 @@ def setup():
|
||||||
continue
|
continue
|
||||||
if type_ != 'region':
|
if type_ != 'region':
|
||||||
continue
|
continue
|
||||||
region_conf = TargetConfig(cfg, section)
|
regions.add(name, TargetConfig(cfg, section))
|
||||||
regions[name] = region_conf
|
|
||||||
|
|
||||||
for section in cfg.sections():
|
for section in cfg.sections():
|
||||||
try:
|
try:
|
||||||
|
@ -170,7 +190,7 @@ def setup():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
region_name = cfg.get(section, 'region')
|
region_name = cfg.get(section, 'region')
|
||||||
region_config = regions[region_name]
|
region_config = regions.get(region_name)
|
||||||
except ConfigParser.NoOptionError:
|
except ConfigParser.NoOptionError:
|
||||||
region_config = TargetConfig(cfg, section)
|
region_config = TargetConfig(cfg, section)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue