From 67a2ba6addd2e5329bb107e1520c0a75cd7f89d5 Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Tue, 20 Nov 2018 14:30:32 +0100 Subject: [PATCH] tests: tests for master zone deletion Adding a basic test in test_multi that creates a new zonegroup and zone and removes them, period update after zone deletion will fail now lessening the chance for the period referring to a non existant master_zone. Subsequent zonegroup deletion will allow things to pass. Signed-off-by: Abhishek Lekshmanan (cherry picked from commit e3d60c053316c1bc108ca3b3c38f8354db3690be) --- src/test/rgw/rgw_multi/tests.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/test/rgw/rgw_multi/tests.py b/src/test/rgw/rgw_multi/tests.py index 0807677d5d8c3..29dab8322f38a 100644 --- a/src/test/rgw/rgw_multi/tests.py +++ b/src/test/rgw/rgw_multi/tests.py @@ -4,6 +4,7 @@ import string import sys import time import logging +import errno try: from itertools import izip_longest as zip_longest @@ -21,7 +22,7 @@ from nose.tools import eq_ as eq from nose.plugins.attrib import attr from nose.plugins.skip import SkipTest -from .multisite import Zone +from .multisite import Zone, ZoneGroup from .conn import get_gateway_connection @@ -849,6 +850,34 @@ def test_zonegroup_remove(): # validate the resulting period zonegroup.period.update(z1, commit=True) + +def test_zg_master_zone_delete(): + + master_zg = realm.master_zonegroup() + master_zone = master_zg.master_zone + + assert(len(master_zg.zones) >= 1) + master_cluster = master_zg.zones[0].cluster + + rm_zg = ZoneGroup('remove_zg') + rm_zg.create(master_cluster) + + rm_zone = Zone('remove', rm_zg, master_cluster) + rm_zone.create(master_cluster) + master_zg.period.update(master_zone, commit=True) + + + rm_zone.delete(master_cluster) + # Period update: This should now fail as the zone will be the master zone + # in that zg + _, retcode = master_zg.period.update(master_zone, check_retcode=False) + assert(retcode == errno.EINVAL) + + # Proceed to delete the zonegroup as well, previous period now does not + # contain a dangling master_zone, this must succeed + rm_zg.delete(master_cluster) + master_zg.period.update(master_zone, commit=True) + def test_set_bucket_website(): buckets, zone_bucket = create_bucket_per_zone_in_realm() for _, bucket in zone_bucket: -- 2.39.5