From 8bec9e218f1beeab176fbeea4f02321c60042f0e Mon Sep 17 00:00:00 2001 From: Raul Zamora Date: Mon, 9 Oct 2023 23:41:09 +0200 Subject: [PATCH] move multicluster test --- tests/integration/ha/test_ha.py | 102 +++++++++++++++++--------------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/tests/integration/ha/test_ha.py b/tests/integration/ha/test_ha.py index b64eee9b..a4bfaf52 100644 --- a/tests/integration/ha/test_ha.py +++ b/tests/integration/ha/test_ha.py @@ -117,6 +117,59 @@ async def test_replicated_events(ops_test: OpsTest): ] +async def test_multi_cluster_isolation(ops_test: OpsTest, kafka_charm): + second_kafka_name = f"{APP_NAME}-two" + second_zk_name = f"{ZK_NAME}-two" + + await asyncio.gather( + ops_test.model.deploy( + kafka_charm, application_name=second_kafka_name, num_units=1, series="jammy" + ), + ops_test.model.deploy( + ZK_NAME, channel="edge", application_name=second_zk_name, num_units=1, series="jammy" + ), + ) + + await ops_test.model.wait_for_idle( + apps=[second_kafka_name, second_zk_name], + idle_period=30, + timeout=3600, + ) + assert ops_test.model.applications[second_kafka_name].status == "blocked" + + await ops_test.model.add_relation(second_kafka_name, second_zk_name) + await ops_test.model.wait_for_idle( + apps=[second_kafka_name, second_zk_name, APP_NAME], + idle_period=30, + ) + + produce_and_check_logs( + model_full_name=ops_test.model_full_name, + kafka_unit_name=f"{APP_NAME}/0", + provider_unit_name=f"{DUMMY_NAME}/0", + topic="hot-topic", + replication_factor=3, + num_partitions=1, + ) + + # Check that logs are not found on the second cluster + with pytest.raises(AssertionError): + check_logs( + model_full_name=ops_test.model_full_name, + kafka_unit_name=f"{second_kafka_name}/0", + topic="hot-topic", + ) + + await asyncio.gather( + ops_test.model.applications[second_kafka_name].destroy( + destroy_storage=True, force=True, no_wait=True + ), + ops_test.model.applications[second_zk_name].destroy( + destroy_storage=True, force=True, no_wait=True + ), + ) + + async def test_kill_broker_with_topic_leader( ops_test: OpsTest, c_writes: ContinuousWrites, @@ -321,55 +374,6 @@ async def test_full_cluster_restart( assert_continuous_writes_consistency(result=result) -async def test_multi_cluster_isolation(ops_test: OpsTest, kafka_charm): - second_kafka_name = f"{APP_NAME}-two" - second_zk_name = f"{ZK_NAME}-two" - - await asyncio.gather( - ops_test.model.deploy( - kafka_charm, application_name=second_kafka_name, num_units=1, series="jammy" - ), - ops_test.model.deploy( - ZK_NAME, channel="edge", application_name=second_zk_name, num_units=1, series="jammy" - ), - ) - - await ops_test.model.wait_for_idle( - apps=[second_kafka_name, second_zk_name], - idle_period=30, - timeout=3600, - ) - assert ops_test.model.applications[second_kafka_name].status == "blocked" - - await ops_test.model.add_relation(second_kafka_name, second_zk_name) - await ops_test.model.wait_for_idle( - apps=[second_kafka_name, second_zk_name, APP_NAME], - idle_period=30, - ) - - produce_and_check_logs( - model_full_name=ops_test.model_full_name, - kafka_unit_name=f"{APP_NAME}/0", - provider_unit_name=f"{DUMMY_NAME}/0", - topic="hot-topic", - replication_factor=3, - num_partitions=1, - ) - - # Check that logs are not found on the second cluster - with pytest.raises(AssertionError): - check_logs( - model_full_name=ops_test.model_full_name, - kafka_unit_name=f"{second_kafka_name}/0", - topic="hot-topic", - ) - - await asyncio.gather( - ops_test.model.applications[second_kafka_name].destroy(), - ops_test.model.applications[second_zk_name].destroy(), - ) - - @pytest.mark.abort_on_fail async def test_network_cut_without_ip_change( ops_test: OpsTest,