Skip to content

Commit

Permalink
move multicluster test
Browse files Browse the repository at this point in the history
  • Loading branch information
zmraul committed Oct 9, 2023
1 parent bca5638 commit 8bec9e2
Showing 1 changed file with 53 additions and 49 deletions.
102 changes: 53 additions & 49 deletions tests/integration/ha/test_ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8bec9e2

Please sign in to comment.