Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for assert statements to migration tool #9107

Merged
merged 3 commits into from
May 12, 2022

Conversation

jzaralim
Copy link
Contributor

Description

What the title says.

Parses ASSERT commands in migrations and runs them with the Java client. If the assertion fails, then the migration will be halted.

Testing done

Manual, unit, integration

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@jzaralim jzaralim marked this pull request as ready for review May 12, 2022 07:01
@jzaralim jzaralim requested a review from a team as a code owner May 12, 2022 07:01
@jzaralim jzaralim requested a review from jnh5y May 12, 2022 07:01
@@ -266,6 +268,8 @@ private void shouldApplyMigrations() throws Exception {
configFilePath,
migrationsDir,
"CREATE STREAM ${streamName} (A STRING) WITH (KAFKA_TOPIC='FOO', PARTITIONS=1, VALUE_FORMAT='JSON');\n" +
"ASSERT TOPIC FOO WITH (PARTITIONS=1) TIMEOUT 5 SECONDS;\n" +
"ASSERT NOT EXISTS SCHEMA ID 3 TIMEOUT 5 SECONDS;\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen to a migration script if an assert failed?

Is that case worth testing? (Admittedly, it may be a pain.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing that would happen if any other statement fails - the migration completes exceptionally and the error is logged with something like Failed to execute sql: ASSERT TOPIC.... Error: Topic exists
Unfortunately the integration test only tests the happy path

Copy link
Member

@jnh5y jnh5y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely seeing the tests with the variable substitution. :shipit:

@jzaralim jzaralim merged commit 81a0b47 into master May 12, 2022
@jzaralim jzaralim deleted the assert-migration branch May 12, 2022 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants