Skip to content

Commit

Permalink
tests/migrations: allow admin api to fail due to nodes going down
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtanov committed Aug 28, 2024
1 parent 2723960 commit b0af060
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/rptest/tests/data_migrations_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,28 @@ def migration_in_one_of_states():

def create_and_wait(self, migration: InboundDataMigration
| OutboundDataMigration):
reply = self.admin.create_data_migration(migration).json()
self.logger.info(f"create migration reply: {reply}")
def migration_id_if_exists():
for n in self.redpanda.nodes:
for m in self.admin.list_data_migrations(node).json():
if m == migration:
return m[id]
return None

try:
reply = self.admin.create_data_migration(migration).json()
self.logger.info(f"create migration reply: {reply}")
migration_id = reply["id"]
except requests.exceptions.HTTPError as e:
maybe_id = migration_id_if_exists()
if maybe_id is None:
raise
migration_id = maybe_id
self.logger.info(f"create migration failed "
f"but migration {migration_id} present: {e}")

def migration_is_present(id: int):
return self.on_all_live_nodes(id, lambda m: True)

migration_id = reply["id"]
wait_until(
lambda: migration_is_present(migration_id), 30, 2,
f"Expected migration with id {migration_id} is not present")
Expand Down

0 comments on commit b0af060

Please sign in to comment.