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

Add sequential migration tests for MariaDB and MySQL #2502

Merged
merged 22 commits into from
Mar 8, 2024

Conversation

strickvl
Copy link
Contributor

@strickvl strickvl commented Mar 6, 2024

This pull request adds sequential migration tests for MariaDB and MySQL. The tests ensure that sequential migrations across multiple versions are working correctly.

Our current migration tests go through all versions incrementally, so this adds a final set of tests which picks 3 random versions and then orders them sequentially so that we have something a bit more 'real world' that approximates what a user might do. (DB is reset/wiped in between the first set of tests and the sequential testing.)

Summary by CodeRabbit

  • New Features
    • Improved database migration testing by enabling version comparison and sequential migration testing across multiple versions for MariaDB and MySQL.

@strickvl strickvl added internal To filter out internal PRs and issues tests Test suite additions or updates CI labels Mar 6, 2024
Copy link
Contributor

coderabbitai bot commented Mar 6, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The recent updates involve enhancing two scripts responsible for testing database migrations with a new function called version_compare. This addition allows for the comparison of semantic versions, enabling the scripts to handle migrations across various versions in a more orderly fashion. By selecting versions randomly and then sorting them according to semantic versioning principles, the scripts can now execute migrations sequentially, ensuring a smoother and more reliable testing process.

Changes

Files Change Summary
scripts/test-migrations-mariadb.sh,
scripts/test-migrations-mysql.sh
Added version_compare to compare semantic versions and implemented sequential migration testing based on sorted versions.

🐇✨
In the realm of code, where the bits do hop,
A rabbit devised a plan, not a flop.
With versions compared, and migrations aligned,
Our tests now leap forward, no version behind.
So here's to the changes, may they guide us right,
Through the thickest of bugs, to the dawn's early light.
🌟📜

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@github-actions github-actions bot added the enhancement New feature or request label Mar 6, 2024
@strickvl
Copy link
Contributor Author

strickvl commented Mar 6, 2024

@AlexejPenner as previously discussed, this was one of the low-hanging fruit I said we'd implement on OSS side to better approximate what a user might do.

@strickvl
Copy link
Contributor Author

strickvl commented Mar 6, 2024

@coderabbitai review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between e93c687 and e1c6893.
Files selected for processing (2)
  • scripts/test-migrations-mariadb.sh (1 hunks)
  • scripts/test-migrations-mysql.sh (1 hunks)
Additional comments: 2
scripts/test-migrations-mariadb.sh (1)
  • 121-148: The implementation of testing for sequential migrations is a significant enhancement. However, there are a few areas that could be refined:
  • The script selects a fixed number of versions (3) for sequential migrations. It might be more flexible to allow the number of versions to be configurable via a script argument or environment variable.
  • The sorting of versions using sort is a clever use of shell utilities. However, consider adding a comment explaining the sorting flags for clarity, as the -t. and -k options might not be immediately clear to all readers.
  • The cleanup steps (zenml disconnect, docker rm -f mariadb, deactivate) are crucial for ensuring that resources are properly released after the tests. It's good practice to also trap errors and ensure these cleanup steps are executed even if the script exits prematurely due to an error.

Consider making the number of versions for sequential migrations configurable and adding explanatory comments for the sorting command.

scripts/test-migrations-mysql.sh (1)
  • 160-187: The implementation of testing for sequential migrations in the MySQL script, like in the MariaDB script, could benefit from a few refinements:
  • Make the number of versions for sequential migrations configurable.
  • Add explanatory comments for the sorting command to improve readability.
  • Ensure cleanup steps are executed even if the script exits prematurely due to an error by using error trapping.

Consider applying the same improvements suggested for the MariaDB script to enhance flexibility, clarity, and robustness.

scripts/test-migrations-mariadb.sh Outdated Show resolved Hide resolved
scripts/test-migrations-mysql.sh Outdated Show resolved Hide resolved
strickvl and others added 2 commits March 6, 2024 17:58
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@strickvl
Copy link
Contributor Author

strickvl commented Mar 6, 2024

@coderabbitai review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between e1c6893 and c1b2118.
Files selected for processing (2)
  • scripts/test-migrations-mariadb.sh (1 hunks)
  • scripts/test-migrations-mysql.sh (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • scripts/test-migrations-mariadb.sh
  • scripts/test-migrations-mysql.sh

Copy link
Contributor

github-actions bot commented Mar 7, 2024

E2E template updates in examples/e2e have been pushed.

Copy link
Contributor

@avishniakov avishniakov left a comment

Choose a reason for hiding this comment

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

Nice idea!

@strickvl strickvl merged commit 0b82d40 into develop Mar 8, 2024
55 checks passed
@strickvl strickvl deleted the feature/drunk-hop-skip-db-migration-testing branch March 8, 2024 08:44
adtygan pushed a commit to adtygan/zenml that referenced this pull request Mar 21, 2024
* Add sequential migration tests for MariaDB and MySQL

* add semantic version order

* Update scripts/test-migrations-mariadb.sh

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* coderabbit suggestion for version comparison

* fresh start for sequential testing

* add missing code

* Remove unnecessary code in test-migrations-mariadb.sh

* list the drunk migration sequence

* focused testing

* add padding for logs

* always install importlib_metadata

* fix mysql db upgrades

* ruff

* fix mariadb too

* add mariadb for testing

* Auto-update of E2E template

* fix mariadb

* fresh mariadb

* fresh mysql

* fix final missing zenml

* CI as it should be

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: GitHub Actions <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI enhancement New feature or request internal To filter out internal PRs and issues run-slow-ci tests Test suite additions or updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants