-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Enable Hibernate ORM multitenancy IT on CI #9390
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7c65431
Minor polishing of the Hibernate Multitenancy support code and tests
Sanne cc6f4d5
Reconfigure MariaDB in CI actions for multi-DB tests
Sanne bdeab9d
Introduce a 'mariadb.base_url' variable for multitenancy tests
Sanne 7854809
Add podman instructions to the jpa-mariadb tests as well
Sanne 3201928
Flyway migrations for Multitenancy IT needs to be more resilient
Sanne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
14 changes: 7 additions & 7 deletions
14
integration-tests/hibernate-tenancy/src/main/resources/application.properties
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
# Hibernate ORM settings | ||
quarkus.hibernate-orm.database.generation=none | ||
quarkus.hibernate-orm.multitenant=DATABASE | ||
quarkus.hibernate-orm.validate-tenant-in-current-sessions=false | ||
|
||
# Maria DB URL | ||
mariadb.url=jdbc:mariadb://localhost:3306 | ||
|
||
# Default DB Configuration | ||
quarkus.datasource.db-kind=mariadb | ||
quarkus.datasource.username=root | ||
quarkus.datasource.password=secret | ||
quarkus.datasource.jdbc.url=${mariadb.url}/hibernate_orm_test | ||
quarkus.datasource.jdbc.url=${mariadb.base_url}/hibernate_orm_test | ||
quarkus.datasource.jdbc.max-size=1 | ||
quarkus.datasource.jdbc.min-size=1 | ||
quarkus.flyway.migrate-at-start=true | ||
#Reset Flyway metadata at boot, as the database might have been tainted by previous integration tests: | ||
quarkus.flyway.clean-at-start=true | ||
quarkus.flyway.locations=classpath:database/default | ||
|
||
# DATABASE Tenant 'base' Configuration | ||
quarkus.datasource.base.db-kind=mariadb | ||
quarkus.datasource.base.username=jane | ||
quarkus.datasource.base.password=abc | ||
quarkus.datasource.base.jdbc.url=${mariadb.url}/base | ||
quarkus.datasource.base.jdbc.url=${mariadb.base_url}/base | ||
quarkus.datasource.base.jdbc.max-size=1 | ||
quarkus.datasource.base.jdbc.min-size=1 | ||
quarkus.flyway.base.migrate-at-start=true | ||
quarkus.flyway.base.clean-at-start=true | ||
quarkus.flyway.base.locations=classpath:database/base | ||
|
||
# DATABASE Tenant 'mycompany' Configuration | ||
quarkus.datasource.mycompany.db-kind=mariadb | ||
quarkus.datasource.mycompany.username=john | ||
quarkus.datasource.mycompany.password=def | ||
quarkus.datasource.mycompany.jdbc.url=${mariadb.url}/mycompany | ||
quarkus.datasource.mycompany.jdbc.url=${mariadb.base_url}/mycompany | ||
quarkus.datasource.mycompany.jdbc.max-size=1 | ||
quarkus.datasource.mycompany.jdbc.min-size=1 | ||
quarkus.flyway.mycompany.migrate-at-start=true | ||
quarkus.flyway.mycompany.clean-at-start=true | ||
quarkus.flyway.mycompany.locations=classpath:database/mycompany | ||
|
8 changes: 4 additions & 4 deletions
8
...on-tests/hibernate-tenancy/src/main/resources/database/default/V1.0.0__init_databases.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
CREATE DATABASE base; | ||
CREATE USER 'jane'@'%' IDENTIFIED BY 'abc'; | ||
CREATE DATABASE IF NOT EXISTS base; | ||
CREATE USER IF NOT EXISTS 'jane'@'%' IDENTIFIED BY 'abc'; | ||
GRANT ALL privileges ON base.* TO 'jane'@'%'; | ||
|
||
CREATE DATABASE mycompany; | ||
CREATE USER 'john'@'%' IDENTIFIED BY 'def'; | ||
CREATE DATABASE IF NOT EXISTS mycompany; | ||
CREATE USER IF NOT EXISTS 'john'@'%' IDENTIFIED BY 'def'; | ||
GRANT ALL privileges ON mycompany.* TO 'john'@'%'; | ||
|
||
FLUSH PRIVILEGES; |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want to do this? It could introduce a race condition, because multiple parallel requests will use the same object. I think this is not thread safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems fine to me - this is indeed a race condition but it's benign, as the end result doesn't change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is correct. I just thought the "computeIfAbsent" is a more accurate usage of the API and does not cause such questions, because it is defined by the API of the hash map implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you - your solution was more elegant. But we try to avoid lambdas for efficiency reasons. Of course we're not extreme about it: lambdas are a fine solution when they are a good solution, but I still tend to prefer avoiding them in such situations.