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

Introduce quarkus.datasource.devservices.init-script-path #30455

Merged
merged 1 commit into from
Jan 19, 2023

Conversation

gastaldi
Copy link
Contributor

  • This enables specifying a SQL initialization script for Dev Services Databases

Added tests

@gastaldi
Copy link
Contributor Author

This may be interesting for #29756

@gastaldi gastaldi force-pushed the init_script branch 3 times, most recently from f1c2ce2 to 447950f Compare January 18, 2023 19:39
@Sanne
Copy link
Member

Sanne commented Jan 18, 2023

nice!

@Sanne
Copy link
Member

Sanne commented Jan 18, 2023

My only concern would be that this adds yet-another-way to do such things; we already have the Hibernate import scripts and also the liquibase/flyway migration tools.
I suppose that's overkill for most such uses cases? Also they don't play well with the reactive extensions.

It would be really nice if someone could dedicate some time to unify the experience; e.g. having the power of the migration tools but presented in a super-simple and light way. Until that day comes, I'm ok to have this.

@gastaldi
Copy link
Contributor Author

@Sanne those are valid concerns, but this use case is specifically to allow creating additional users in the DB that would then be consumed by Flyway, which should happen before the app initializes

@gastaldi gastaldi added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jan 18, 2023
@Sanne
Copy link
Member

Sanne commented Jan 18, 2023

@gastaldi right, not meaning to block this - not at all. Just thinking out loud :)

@quarkus-bot

This comment has been minimized.

@gastaldi
Copy link
Contributor Author

Disabling test in Windows because it seems that Docker isn't properly configured there:

2023-01-18T21:05:40.4908354Z [INFO] Running io.quarkus.it.jdbc.postgresql.DevServicesTest
2023-01-18T21:05:47.2255532Z 2023-01-18 21:05:47,086 WARN  [org.tes.uti.TestcontainersConfiguration] (build-76) Attempted to read Testcontainers configuration file at file:/C:/Users/runneradmin/.testcontainers.properties but the file was not found. Exception message: FileNotFoundException: C:\Users\runneradmin\.testcontainers.properties (The system cannot find the file specified)
2023-01-18T21:05:48.5759881Z 2023-01-18 21:05:48,497 INFO  [org.tes.doc.DockerClientProviderStrategy] (build-76) Found Docker environment with local Npipe socket (npipe:////./pipe/docker_engine)
2023-01-18T21:05:48.5761371Z 2023-01-18 21:05:48,497 WARN  [org.tes.doc.DockerClientProviderStrategy] (build-76) windows is currently not supported
2023-01-18T21:05:48.5767640Z 2023-01-18 21:05:48,512 INFO  [org.tes.doc.DockerMachineClientProviderStrategy] (build-76) docker-machine executable was not found on PATH ([C:\Program Files\Git\mingw64\bin, C:\Program Files\Git\usr\bin, C:\Users\runneradmin\bin, C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.17-8\x64\bin, C:\Program Files\MongoDB\Server\5.0\bin, C:\aliyun-cli, C:\vcpkg, C:\Program Files (x86)\NSIS, C:\tools\zstd, C:\Program Files\Mercurial, C:\hostedtoolcache\windows\stack\2.9.3\x64, C:\cabal\bin, C:\ghcup\bin, C:\tools\ghc-9.4.4\bin, C:\Program Files\dotnet, C:\mysql\bin, C:\Program Files\R\R-4.2.2\bin\x64, C:\SeleniumWebDrivers\GeckoDriver, C:\Program Files (x86)\sbt\bin, C:\Program Files (x86)\GitHub CLI, C:\Program Files\Git\usr\bin, C:\Program Files (x86)\pipx_bin, C:\npm\prefix, C:\hostedtoolcache\windows\go\1.17.13\x64\bin, C:\hostedtoolcache\windows\Python\3.9.13\x64\Scripts, C:\hostedtoolcache\windows\Python\3.9.13\x64, C:\hostedtoolcache\windows\Ruby\3.0.5\x64\bin, C:\tools\kotlinc\bin, C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\8.0.352-8\x64\bin, C:\Program Files\ImageMagick-7.1.0-Q16-HDRI, C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin, C:\ProgramData\kind, C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin, C:\Windows\system32, C:\Windows, C:\Windows\System32\Wbem, C:\Windows\System32\WindowsPowerShell\v1.0, C:\Windows\System32\OpenSSH, C:\Program Files\dotnet, C:\ProgramData\Chocolatey\bin, C:\Program Files\PowerShell\7, C:\Program Files\Microsoft\Web Platform Installer, C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn, C:\Program Files\Microsoft SQL Server\150\Tools\Binn, C:\Program Files\OpenSSL\bin, C:\Strawberry\c\bin, C:\Strawberry\perl\site\bin, C:\Strawberry\perl\bin, C:\ProgramData\chocolatey\lib\pulumi\tools\Pulumi\bin, C:\Program Files\TortoiseSVN\bin, C:\Program Files\CMake\bin, C:\ProgramData\chocolatey\lib\maven\apache-maven-3.8.7\bin, C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code, C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager, C:\Program Files\nodejs, C:\Program Files\Git\cmd, C:\Program Files\Git\mingw64\bin, C:\Program Files\Git\usr\bin, C:\Program Files\GitHub CLI, C:\tools\php, C:\Program Files (x86)\sbt\bin, C:\SeleniumWebDrivers\ChromeDriver, C:\SeleniumWebDrivers\EdgeDriver, C:\Program Files\Amazon\AWSCLIV2, C:\Program Files\Amazon\SessionManagerPlugin\bin, C:\Program Files\Amazon\AWSSAMCLI\bin, C:\Program Files\Microsoft SQL Server\130\Tools\Binn, C:\Program Files\LLVM\bin, C:\Users\runneradmin\.dotnet\tools, C:\Users\runneradmin\.cargo\bin, C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps])
2023-01-18T21:05:48.5772560Z 2023-01-18 21:05:48,512 ERROR [org.tes.doc.DockerClientProviderStrategy] (build-76) Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
2023-01-18T21:05:48.5773421Z    NpipeSocketClientProviderStrategy: failed with exception InvalidConfigurationException (windows containers are currently not supported)As no valid configuration was found, execution cannot continue.
2023-01-18T21:05:48.5774079Z See https://www.testcontainers.org/on_failure.html for more details.
2023-01-18T21:05:51.7591436Z 2023-01-18 21:05:51,741 WARN  [io.qua.dep.IsDockerWorking] (build-76) 'docker -v' returned an error code. Make sure your Docker binary is correct

@gastaldi gastaldi force-pushed the init_script branch 5 times, most recently from 2d6cc0b to 2d43ffe Compare January 19, 2023 18:39
- This enables specifying a SQL initialization script for Dev Services Databases

Added tests
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 19, 2023

Failing Jobs - Building 6b4baf2

Status Name Step Failures Logs Raw logs
✔️ JVM Tests - JDK 11
JVM Tests - JDK 11 Windows Build Failures Logs Raw logs
✔️ JVM Tests - JDK 17
✔️ JVM Tests - JDK 18

Full information is available in the Build summary check run.

Failures

⚙️ JVM Tests - JDK 11 Windows #

- Failing: extensions/opentelemetry/deployment 
! Skipped: extensions/micrometer-registry-prometheus/deployment extensions/micrometer/deployment extensions/quartz/deployment and 26 more

📦 extensions/opentelemetry/deployment

io.quarkus.opentelemetry.deployment.instrumentation.GrpcOpenTelemetryTest.streamingBlocking line 225 - More details - Source on GitHub

io.smallrye.mutiny.TimeoutException
	at io.smallrye.mutiny.operators.uni.UniBlockingAwait.await(UniBlockingAwait.java:64)
	at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:65)

io.quarkus.opentelemetry.deployment.instrumentation.GrpcOpenTelemetryTest.streaming line 188 - More details - Source on GitHub

io.smallrye.mutiny.TimeoutException
	at io.smallrye.mutiny.operators.uni.UniBlockingAwait.await(UniBlockingAwait.java:64)
	at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:65)

io.quarkus.opentelemetry.deployment.instrumentation.GrpcOpenTelemetryTest.grpc line 101 - More details - Source on GitHub

io.smallrye.mutiny.TimeoutException
	at io.smallrye.mutiny.operators.uni.UniBlockingAwait.await(UniBlockingAwait.java:64)
	at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:65)

io.quarkus.opentelemetry.deployment.instrumentation.GrpcOpenTelemetryTest.error line 144 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Assertion condition defined as a lambda expression in io.quarkus.opentelemetry.deployment.common.TestSpanExporter expected: <2> but was: <9> within 30 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.AssertionCondition.await(AssertionCondition.java:119)

@gastaldi gastaldi merged commit bad8aa2 into quarkusio:main Jan 19, 2023
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jan 19, 2023
@quarkus-bot quarkus-bot bot added this to the 2.17 - main milestone Jan 19, 2023
@gastaldi gastaldi deleted the init_script branch January 19, 2023 22:58
@Serkan80
Copy link

Serkan80 commented Feb 8, 2023

Cool ! I was looking for something like this.

And does it also work for multi datasources ?

quarkus.datasource.datasource1.devservices.init-script-path=script1.sql
quarkus.datasource.datasource2.devservices.init-script-path=script2.sql

@gastaldi
Copy link
Contributor Author

gastaldi commented Feb 8, 2023

@Serkan80 yes, it should work for that scenario too

@gsmet gsmet modified the milestones: 3.0.0.Alpha4, 2.16.3.Final Feb 15, 2023
benkard added a commit to benkard/mulkcms2 that referenced this pull request Apr 2, 2023
This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [flow-bin](https://github.com/flowtype/flow-bin) ([changelog](https://github.com/facebook/flow/blob/master/Changelog.md)) | devDependencies | minor | [`^0.199.0` -> `^0.200.0`](https://renovatebot.com/diffs/npm/flow-bin/0.199.0/0.200.0) |
| [com.rometools:rome](http://rometools.com) ([source](https://github.com/rometools/rome)) | compile | minor | `1.18.0` -> `1.19.0` |
| [org.postgresql:postgresql](https://jdbc.postgresql.org) ([source](https://github.com/pgjdbc/pgjdbc)) | build | patch | `42.5.3` -> `42.5.4` |
| [org.jsoup:jsoup](https://jsoup.org/) ([source](https://github.com/jhy/jsoup)) | compile | patch | `1.15.3` -> `1.15.4` |
| [io.quarkus:quarkus-maven-plugin](https://github.com/quarkusio/quarkus) | build | patch | `2.16.2.Final` -> `2.16.3.Final` |
| [io.quarkus:quarkus-universe-bom](https://github.com/quarkusio/quarkus-platform) | import | patch | `2.16.2.Final` -> `2.16.3.Final` |

---

### Release Notes

<details>
<summary>flowtype/flow-bin</summary>

### [`v0.200.0`](flow/flow-bin@9618443...b6c1eb0)

[Compare Source](flow/flow-bin@9618443...b6c1eb0)

### [`v0.199.1`](flow/flow-bin@05bb4e3...9618443)

[Compare Source](flow/flow-bin@05bb4e3...9618443)

</details>

<details>
<summary>rometools/rome</summary>

### [`v1.19.0`](https://github.com/rometools/rome/releases/tag/1.19.0)

[Compare Source](rometools/rome@1.18.0...1.19.0)

<!-- Release notes generated using configuration in .github/release.yml at 1.19.0 -->

#### What's Changed

##### 🔨 Dependency Upgrades

-   Bump flatten-maven-plugin from 1.2.7 to 1.3.0 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#565
-   Bump maven-bundle-plugin from 5.1.5 to 5.1.8 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#563
-   Bump maven-dependency-plugin from 3.3.0 to 3.5.0 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#602
-   Bump maven-deploy-plugin from 2.8.2 to 3.1.0 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#607
-   Bump maven-jar-plugin from 3.2.2 to 3.3.0 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#574
-   Bump maven-javadoc-plugin from 3.3.1 to 3.5.0 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#609
-   Bump maven-scm-plugin from 1.12.2 to 1.13.0 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#554
-   Bump assertj-core from 3.22.0 to 3.24.2 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#603
-   Bump slf4j-api from 1.7.36 to 2.0.6 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#596

##### Other Changes

-   Bump actions/setup-java from 3.3.0 to 3.10.0 by [@&#8203;dependabot](https://github.com/dependabot) in rometools/rome#606
-   Bump logback-classic from 1.2.10 to 1.3.5 by [@&#8203;PatrickGotthard](https://github.com/PatrickGotthard) in rometools/rome#611

**Full Changelog**: rometools/rome@1.18.0...1.19.0

</details>

<details>
<summary>pgjdbc/pgjdbc</summary>

### [`v42.5.4`](https://github.com/pgjdbc/pgjdbc/blob/HEAD/CHANGELOG.md#&#8203;4254-2023-02-15-102104--0500)

##### Fixed

fix: fix testGetSQLTypeQueryCache by searching for xid type. We used to search for box type but it is now cached. xid is not cached, this nuance is required for the test.
fix OidValueCorrectnessTest BOX_ARRAY OID, by adding BOX_ARRAY to the oidTypeName map \[MR [#&#8203;2810](https://github.com/pgjdbc/pgjdbc/issues/2810)]\((https://github.com/pgjdbc/pgjdbc/pull/2810).
fixes [Issue #&#8203;2804](pgjdbc/pgjdbc#2804).
fix: Make sure that github CI runs tests on all [MRs #&#8203;2809](\(https://github.com/pgjdbc/pgjdbc/pull/2809\)).

</details>

<details>
<summary>quarkusio/quarkus</summary>

### [`v2.16.3.Final`](https://github.com/quarkusio/quarkus/releases/tag/2.16.3.Final)

[Compare Source](quarkusio/quarkus@2.16.2.Final...2.16.3.Final)

##### Major changes

-   [#&#8203;29756](quarkusio/quarkus#29756) - Support custom Flyway credentials/URL

##### Complete changelog

-   [#&#8203;31141](quarkusio/quarkus#31141) - Resolve roles allowed configuration expression after config setup is completed
-   [#&#8203;31129](quarkusio/quarkus#31129) - Fix stuck HTTP2 request when sent challenge has resumed request
-   [#&#8203;31125](quarkusio/quarkus#31125) - Add "keep-alive-enabled" parameter to REST client reactive
-   [#&#8203;31112](quarkusio/quarkus#31112) - Qute - fix assignability check when validating expressions
-   [#&#8203;31099](quarkusio/quarkus#31099) - Use the effective Maven project build config when initializing sources and classes paths for dev mode
-   [#&#8203;31092](quarkusio/quarkus#31092) - Make sure quarkus:go-offline properly supports test scoped dependencies
-   [#&#8203;31077](quarkusio/quarkus#31077) - Qute: regression in template extension method with byte array
-   [#&#8203;31076](quarkusio/quarkus#31076) - Quarkiverse: Install instead of verify
-   [#&#8203;31074](quarkusio/quarkus#31074) - Added quarkus-jms-spi to quarkus bom
-   [#&#8203;31059](quarkusio/quarkus#31059) - Path lookup must also consider interfaces
-   [#&#8203;31046](quarkusio/quarkus#31046) - Simplify Quarkiverse release.yml workflow
-   [#&#8203;31038](quarkusio/quarkus#31038) - Update Instrumentation Processor check logic to match comment
-   [#&#8203;31036](quarkusio/quarkus#31036) - Use CDI when accessing UserTransaction/TransactionManager in QuarkusTransaction
-   [#&#8203;31028](quarkusio/quarkus#31028) - Fix typo in snapstart enable config
-   [#&#8203;31016](quarkusio/quarkus#31016) - Re-initialize platform dependent netty classes/values at runtime
-   [#&#8203;30988](quarkusio/quarkus#30988) - Race condition in SmallRye Config property expansion for [@&#8203;RolesAllowed](https://github.com/RolesAllowed) value?
-   [#&#8203;30964](quarkusio/quarkus#30964) - Add ConfigMappings from a builder class to support full hot reload
-   [#&#8203;30961](quarkusio/quarkus#30961) - Error of quarkus:dev when the project.build.directory is overridden by a profile
-   [#&#8203;30960](quarkusio/quarkus#30960) - Register CDI Bean when ConfigMapping is marked as Unremovable
-   [#&#8203;30922](quarkusio/quarkus#30922) - Fix dependency parsing in JBangBuilderImpl
-   [#&#8203;30885](quarkusio/quarkus#30885) - Add concurrency configuration to the GitHub Action workflows
-   [#&#8203;30843](quarkusio/quarkus#30843) - Micrometer-Extension writes wrong URI-Tag when Path-Variables defined at Interface-Level
-   [#&#8203;30672](quarkusio/quarkus#30672) - Avoid creating CSRF cookie if no CSRF token was created
-   [#&#8203;30648](quarkusio/quarkus#30648) - Support passing filename to multipart form data output
-   [#&#8203;30594](quarkusio/quarkus#30594) - CSRF: exception thrown when authentication falied
-   [#&#8203;30570](quarkusio/quarkus#30570) - Set filename for PartItems in MultipartFormDataOutput
-   [#&#8203;30455](quarkusio/quarkus#30455) - Introduce `quarkus.datasource.devservices.init-script-path`
-   [#&#8203;29756](quarkusio/quarkus#29756) - Support custom Flyway credentials/URL
-   [#&#8203;29631](quarkusio/quarkus#29631) - [@&#8203;Unremovable](https://github.com/Unremovable) ConfigMapping is still removed
-   [#&#8203;29630](quarkusio/quarkus#29630) - Changes to configmappings not being applied during hot reload
-   [#&#8203;28709](quarkusio/quarkus#28709) - QuarkusTransaction does not fire [@&#8203;Initialized](https://github.com/Initialized)(TransactionScoped.class)
-   [#&#8203;24639](quarkusio/quarkus#24639) - configure dedicated db user for database migrations: DML-only user for datasource, but DDL user for migration
-   [#&#8203;23360](quarkusio/quarkus#23360) - "Request has already been read" using vertx + auth
-   [#&#8203;17839](quarkusio/quarkus#17839) - Invalid memory configuration for netty maxDirectMemory in native image

</details>

<details>
<summary>quarkusio/quarkus-platform</summary>

### [`v2.16.3.Final`](quarkusio/quarkus-platform@2.16.2.Final...2.16.3.Final)

[Compare Source](quarkusio/quarkus-platform@2.16.2.Final...2.16.3.Final)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

👻 **Immortal**: This MR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
nscuro added a commit to DependencyTrack/hyades that referenced this pull request May 27, 2023
As of Quarkus 2.16.3 it is possible to provide an init script to the database testcontainer (quarkusio/quarkus#30455).

We previously had to use Flyway to initialize the container with the API server SQL schema. This is no longer necessary.

Signed-off-by: nscuro <nscuro@protonmail.com>
@viniciusvasti
Copy link
Contributor

It is not working for me.
I'm getting org.postgresql.util.PSQLException: ERROR: relation "<table>" does not exist
Does the defined script run before Flyway migrations?
I'd like to have my migrations ran then populate the database for dev and test profiles only.
Shouldn't this property allow that?

@gastaldi
Copy link
Contributor Author

No, the init-script-path script is executed before Flyway executes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants