Skip to content

Commit

Permalink
CephRGWTest: Deduplicate code to create multi-site relation
Browse files Browse the repository at this point in the history
Signed-off-by: Ionut Balutoiu <[email protected]>
  • Loading branch information
Ionut Balutoiu committed Apr 25, 2024
1 parent 5054a79 commit a7cf06f
Showing 1 changed file with 29 additions and 40 deletions.
69 changes: 29 additions & 40 deletions zaza/openstack/charm_tests/ceph/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,33 @@ def configure_rgw_apps_for_multisite(self):
}
)

def setup_rgw_multisite_relation(self):
"""Setup multi-site relation between primary and secondary apps."""
multisite_relation = zaza_model.get_relation_id(
self.primary_rgw_app, self.secondary_rgw_app,
remote_interface_name='secondary'
)
if multisite_relation is None:
logging.info('Configuring Multisite')
self.configure_rgw_apps_for_multisite()
zaza_model.add_relation(
self.primary_rgw_app,
self.primary_rgw_app + ":primary",
self.secondary_rgw_app + ":secondary"
)
zaza_model.block_until_unit_wl_status(
self.secondary_rgw_unit, "waiting"
)

zaza_model.block_until_unit_wl_status(
self.secondary_rgw_unit, "active"
)
zaza_model.block_until_unit_wl_status(
self.primary_rgw_unit, "active"
)
zaza_model.wait_for_unit_idle(self.secondary_rgw_unit)
zaza_model.wait_for_unit_idle(self.primary_rgw_unit)

def clean_rgw_multisite_config(self, app_name):
"""Clear Multisite Juju config values to default.
Expand Down Expand Up @@ -1102,29 +1129,7 @@ def test_004_multisite_directional_sync_policy(self):
zaza_model.wait_for_unit_idle(self.primary_rgw_unit)

# Setup multisite relation.
multisite_relation = zaza_model.get_relation_id(
self.primary_rgw_app, self.secondary_rgw_app,
remote_interface_name='secondary'
)
if multisite_relation is None:
logging.info('Configuring Multisite')
self.configure_rgw_apps_for_multisite()
zaza_model.add_relation(
self.primary_rgw_app,
self.primary_rgw_app + ":primary",
self.secondary_rgw_app + ":secondary"
)
zaza_model.block_until_unit_wl_status(
self.secondary_rgw_unit, "waiting"
)
zaza_model.block_until_unit_wl_status(
self.primary_rgw_unit, "active"
)
zaza_model.block_until_unit_wl_status(
self.secondary_rgw_unit, "active"
)
zaza_model.wait_for_unit_idle(self.secondary_rgw_unit)
zaza_model.wait_for_unit_idle(self.primary_rgw_unit)
self.setup_rgw_multisite_relation()

logging.info('Waiting for Data and Metadata to Synchronize')
# NOTE: We only check the secondary zone, because the sync policy flow
Expand Down Expand Up @@ -1317,24 +1322,8 @@ def test_100_migration_and_multisite_failover(self):
).put(Body=obj_data)

# If Primary/Secondary relation does not exist, add it.
if zaza_model.get_relation_id(
self.primary_rgw_app, self.secondary_rgw_app,
remote_interface_name='secondary'
) is None:
logging.info('Configuring Multisite')
self.configure_rgw_apps_for_multisite()
zaza_model.add_relation(
self.primary_rgw_app,
self.primary_rgw_app + ":primary",
self.secondary_rgw_app + ":secondary"
)
zaza_model.block_until_unit_wl_status(
self.secondary_rgw_unit, "waiting"
)
self.setup_rgw_multisite_relation()

zaza_model.block_until_unit_wl_status(
self.secondary_rgw_unit, "active"
)
logging.info('Waiting for Data and Metadata to Synchronize')
self.wait_for_status(self.secondary_rgw_app, is_primary=False)
self.wait_for_status(self.primary_rgw_app, is_primary=True)
Expand Down

0 comments on commit a7cf06f

Please sign in to comment.