Skip to content

Commit

Permalink
tests/migrations: randomly omit default namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtanov committed Sep 16, 2024
1 parent 3558630 commit cbdb967
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tests/rptest/tests/data_migrations_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
]


def make_namespaced_topic(topic: str) -> NamespacedTopic:
return NamespacedTopic(topic, random.choice([None, "kafka"]))


class TransferLeadersBackgroundThread:
def __init__(self, redpanda: RedpandaServiceBase, topic: str):
self.redpanda = redpanda
Expand Down Expand Up @@ -221,7 +225,7 @@ def test_creating_and_listing_migrations(self):

with Finjector(self.redpanda, self.scale).finj_thread():
# out
outbound_topics = [NamespacedTopic(t.name) for t in topics]
outbound_topics = [make_namespaced_topic(t.name) for t in topics]
out_migration = OutboundDataMigration(outbound_topics,
consumer_groups=[])

Expand Down Expand Up @@ -257,10 +261,10 @@ def test_creating_and_listing_migrations(self):

# in
inbound_topics = [
InboundTopic(NamespacedTopic(t.name),
InboundTopic(make_namespaced_topic(t.name),
alias=\
None if i == 0
else NamespacedTopic(f"{t.name}-alias"))
else make_namespaced_topic(f"{t.name}-alias"))
for i, t in enumerate(topics[:3])
]
in_migration = InboundDataMigration(topics=inbound_topics,
Expand Down Expand Up @@ -315,7 +319,7 @@ def test_higher_level_migration_api(self):

with Finjector(self.redpanda, self.scale).finj_thread():
# out
outbound_topics = [NamespacedTopic(t.name) for t in topics]
outbound_topics = [make_namespaced_topic(t.name) for t in topics]
reply = self.admin.unmount_topics(outbound_topics).json()
self.logger.info(f"create migration reply: {reply}")
out_migration_id = reply["id"]
Expand All @@ -332,10 +336,10 @@ def test_higher_level_migration_api(self):

# in
inbound_topics = [
InboundTopic(NamespacedTopic(t.name),
InboundTopic(make_namespaced_topic(t.name),
alias=\
None if i == 0
else NamespacedTopic(f"{t.name}-alias"))
else make_namespaced_topic(f"{t.name}-alias"))
for i, t in enumerate(topics[:3])
]
inbound_topics_spec = [
Expand Down Expand Up @@ -544,7 +548,7 @@ def test_migrated_topic_data_integrity(self, transfer_leadership: bool,
workload_topic.name) if transfer_leadership else nullcontext()
with out_tl_thread:
admin = Admin(self.redpanda)
workload_ns_topic = NamespacedTopic(workload_topic.name)
workload_ns_topic = make_namespaced_topic(workload_topic.name)
out_migration = OutboundDataMigration(topics=[workload_ns_topic],
consumer_groups=[])
out_migration_id = self.create_and_wait(out_migration)
Expand Down Expand Up @@ -623,7 +627,7 @@ def test_migrated_topic_data_integrity(self, transfer_leadership: bool,
inbound_topic_name = "aliased-workload-topic" if params.use_alias else workload_topic.name
alias = None
if params.use_alias:
alias = NamespacedTopic(topic=inbound_topic_name)
alias = make_namespaced_topic(topic=inbound_topic_name)

in_tl_thread = TransferLeadersBackgroundThread(
self.redpanda,
Expand Down

0 comments on commit cbdb967

Please sign in to comment.