Repository navigation
Gate the Flyway run on an environment flag and add ephemeral MySQL storage. - #31
Merged
Merged
Conversation
…SQL storage. The test bootstrap of the consuming services wrapped MySQL and Flyway in an if on RUN_MIGRATIONS and repeated the root credentials the MySQL definition already holds. Flyway now takes the MySQL definition, starts it only when a command runs, and onlyWhenEnabled() moves the run behind the flag in the same chain.
…the tmpfs mounts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The integration test bootstrap of the services that consume the library wrapped MySQL and Flyway in
if (getenv('RUN_MIGRATIONS') === '1'), kept the started MySQL in a variable only to hand it to Flyway, and repeated the root credentials the MySQL definition already holds. Each bootstrap also chose its own readiness timeout and connection retries.The suites were slow too. MySQL wrote its data and binary log to the container disk, and Flyway waited for MySQL to accept connections a second time after
runIfNotExists()had already waited.What changes
FlywayDockerContainer::withSource()takes theMySQLDockerContainerdefinition. Flyway starts it withrunIfNotExists()only when a command runs, and reads the root user and password from it.onlyWhenEnabled(variable: 'RUN_MIGRATIONS')returns aFlywayContainerGated. It reads the variable when a command runs. When the variable is not1,repair,migrate,validateandcleanAndMigratereturnnulland no Docker command runs, neither for Flyway nor for MySQL. The ungated Flyway keeps returning a non-nullExecutionCompleted.withCredentials(password:, username:)overrides the credentials read from the MySQL definition.MySQLDockerContainer::withEphemeralStorage()mounts/var/lib/mysqlon tmpfs and passes--skip-log-bin. Measured withmysql:8.4, the boot went from 14 to 20 seconds down to 10 to 12 seconds, and a batch of 300TRUNCATEandINSERTstatements from 14 to 17 seconds down to 2 seconds.GenericDockerContainer::withTmpfsMount(pathOnContainer:)mounts a tmpfs in any container.DockerCommandExecutionFailedhas a private constructor and afrom(reason:, command:)factory, like the other exceptions.The bootstrap of a service becomes one chain:
Validated against two consuming services with the local source in their
vendor, together with Infection reusing the PHPUnit coverage.make testswent from 1443 to 947 seconds in one and from 424 to 312 seconds in the other, with every mutant still killed.Public API
The change is breaking, so the release is
5.0.0.Changed:
FlywayDockerContainer::withSource(password:, username:, container:)becomeswithSource(container:)and takes aMySQLDockerContainerdefinition instead of a started container.DockerCommandExecutionFailedis built throughfrom(reason:, command:).Added:
FlywayDockerContainer::onlyWhenEnabled(),FlywayContainerGated,FlywayDockerContainer::withCredentials(),MySQLDockerContainer::withEphemeralStorage()andGenericDockerContainer::withTmpfsMount().Related issue
None.
Checklist
01, the absence of any Docker command when it is off, the credentials read from the definition and their override, the tmpfs mount and the ephemeral storage arguments, and a single readiness ping before Flyway.make reviewpasses.make testspasses. 182 tests, lines 100% (777/777), MSI 100% (331 of 331 killed).