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(dp): migration tests framework + poc test #12591

Merged
merged 2 commits into from Apr 29, 2022

Conversation

WojSad
Copy link
Contributor

@WojSad WojSad commented Apr 28, 2022

Signed-off-by: Wojciech Sadowy wojciech.sadowy@freedomfi.com

feat(dp): migration tests framework + poc test

Summary

Added AlembicTestCase allowing to test python migrations, check database state before and after the migration, test individual tables etc.

@WojSad WojSad requested review from a team and m-trojanowski April 28, 2022 13:51
@pull-request-size pull-request-size bot added the size/L Denotes a Pull Request that changes 100-499 lines. label Apr 28, 2022
@github-actions
Copy link
Contributor

Thanks for opening a PR! 💯

A couple initial guidelines

Howto

  • Reviews. The "Reviewers" listed for this PR are the Magma maintainers who will shepherd it.
  • Checks. All required CI checks must pass before merge.
  • Merge. Once approved and passing CI checks, use the ready2merge label to indicate the maintainers can merge your PR.

More info

Please take a moment to read through the Magma project's

If this is your first Magma PR, also consider reading

@github-actions
Copy link
Contributor

github-actions bot commented Apr 28, 2022

Oops! Looks like you failed the Python Format Check.

Howto

♻️ Updated: ✅ The check is passing the Python Format Check after the last commit.

@WojSad WojSad force-pushed the migration-tests branch 3 times, most recently from a05c6b6 to b46069e Compare April 29, 2022 08:03
class Testb0cad5321c88TestCase(AlembicTestCase):

def setUp(self) -> None:
super().setUp()
Copy link
Contributor

Choose a reason for hiding this comment

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

It is possible to create different kind of test:

  • specify some data before migration (that would be some records in the database)
  • specify expected data after migration

For example suppose that we have the following table:

CREATE TABLE T (ID INT);

And the following records:

INSERT INTO T VALUES(1);
INSERT INTO T VALUES(2);

now when we execute the following migration:

ALTER TABLE T ADD COLUMN A INT;
UPDATE T SET A = ID;

then we should get the following result:

SELECT * FROM T
ID, A
1, 1
2, 2

So the question is can we do it with this version of a framework?

Wojciech Sadowy added 2 commits April 29, 2022 14:03
Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>
Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>
@WojSad WojSad merged commit 39e430e into magma:master Apr 29, 2022
@jkmar jkmar deleted the migration-tests branch April 29, 2022 13:49
emakeev pushed a commit to emakeev/magma that referenced this pull request Aug 5, 2022
* feat(dp): migration tests framework + poc test

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

* fix alembic configuration

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

Co-authored-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a Pull Request that changes 100-499 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants