Skip to content

Commit

Permalink
test/rgw: index zones by name instead of insertion order
Browse files Browse the repository at this point in the history
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 6327ade)
  • Loading branch information
cbodley authored and yehudasa committed May 9, 2016
1 parent 5edacdc commit 928ccf4
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/test/rgw/test_multi.py
Expand Up @@ -155,7 +155,6 @@ def __init__(self, realm, credentials, clusters):
self.credentials = credentials
self.clusters = clusters
self.zones = {}
self.total_zones = 0

def init_zone(self, cluster, zg, zone_name, first_zone_port):
is_master = (first_zone_port == cluster.port)
Expand All @@ -172,26 +171,19 @@ def init_zone(self, cluster, zg, zone_name, first_zone_port):

def add_zone(self, cluster, zg, zone_name, is_master):
zone = RGWZone(self.realm, cluster, zg, zone_name)
self.zones[self.total_zones] = zone
self.total_zones += 1
self.zones[zone_name] = zone

if is_master:
self.master_zone = zone


def get_zone(self, num):
if num >= self.total_zones:
return None
return self.zones[num]
def get_zone(self, zone_name):
return self.zones[zone_name]

def get_zones(self):
for (k, zone) in self.zones.iteritems():
yield zone


def num_zones(self):
return self.total_zones

def meta_sync_status(self, zone):
if zone.zone_name == self.master_zone.zone_name:
return None
Expand Down Expand Up @@ -744,11 +736,11 @@ def test_multi_period_incremental_sync():
realm.meta_checkpoint()

# kill zone 3 gateway to freeze sync status to incremental in first period
z3 = realm.get_zone(2)
z3 = realm.get_zone('us-3')
z3.cluster.stop_rgw()

# change master to zone 2 -> period 2
realm.set_master_zone(realm.get_zone(1))
realm.set_master_zone(realm.get_zone('us-2'))

for zone, bucket_name in zone_bucket.iteritems():
if zone == z3:
Expand All @@ -758,10 +750,10 @@ def test_multi_period_incremental_sync():
k.set_contents_from_string('qweqwe')

# wait for zone 1 to sync
realm.zone_meta_checkpoint(realm.get_zone(0))
realm.zone_meta_checkpoint(realm.get_zone('us-1'))

# change master back to zone 1 -> period 3
realm.set_master_zone(realm.get_zone(0))
realm.set_master_zone(realm.get_zone('us-1'))

for zone, bucket_name in zone_bucket.iteritems():
if zone == z3:
Expand Down

0 comments on commit 928ccf4

Please sign in to comment.