-
Notifications
You must be signed in to change notification settings - Fork 828
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
Fix DB unit tests #3186
Fix DB unit tests #3186
Conversation
New findings
Items Left to Do
Notes
This previously passed even if I shut down MySQL database. proving that the DB was not tested. |
a5a0075
to
4df9ab8
Compare
Update:
This was fixed with a new composed annotation,
Verified that it's not used in unit tests, by removing the |
307daa7
to
a8b3815
Compare
Side note, there was a flake earlier on:
Errors were:
And:
|
f30f7d3
to
d3ba14f
Compare
...er/src/main/resources/org/cloudfoundry/identity/uaa/db/mysql/V4_112__Users_id_to_Varchar.sql
Show resolved
Hide resolved
server/src/main/java/org/cloudfoundry/identity/uaa/db/beans/FlywayConfiguration.java
Show resolved
Hide resolved
maybe was not good enough documented, but if I had to use a DB in past I setup the docker for it via
because this uses the same images which run in all of our tests I guess for your Mac/Processor this is not possible... thus a plain Linux is always the best choice for development |
622b0fa
to
6c588e2
Compare
Thanks for the trick running the tests. It is possible to run on my Mac, it's just slower than a plain x86 proc. The reason for the docker-compose is mostly to be able to debug DB tests inside my IDE :) |
1. mysql on port 3306 2. postgresql on port 5432 3. ldap on port 389 and 636 (ssl)
- search for `@Disabled` to find tests commented out that don't work for MySQL - This is an initial stab at the problem and will be improved subsequently
- Useful in database testing, allows enabling/disabling tests based on whether `postgresql` or `mysql` is present in the list of active profiles.
- BootstrapTests rely on HSQL as they only use the default profile, therefore we do not need to run them in postgres or mysql mode. They would run against HSQL even in those cases.
- Duplicate of `Branding#testExternalizedBranding`
- Ensure the data is only stored in memory and not persisted across container restarts. - It means we do not need to delete the volumes between runs. - It requires 1GB memory per database.
6c588e2
to
8738e29
Compare
yeah the docker-compose helps to better understand the setup. for ldap we need similar thing. https://github.com/cloudfoundry/uaa?tab=readme-ov-file#connecting-uaa-to-local-ldap-server I only start DBs, when we have new columns with an index on it, then we check with explain and SQL if the index is really used or not... for all other cases... only a new column and no index I dont need the real DB |
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.
Ok for me
if I started a DB on my machine and map ports , e.g. -p 3306:3306 I can debug then everything and can access my tables with a GUI like DBeaver, but docker-compose is ok |
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.
👍
server/src/test/java/org/cloudfoundry/identity/uaa/scim/jdbc/JdbcScimUserProvisioningTests.java
Show resolved
Hide resolved
…udeInactive to compare by "created" - this better matches what is actually done in prod, and avoids sorting by username where mysql has a different opinion of alphabetical ordering of `jo@` and `jo2@`.
- Now that we have re-enabled DB testing with cloudfoundrygh-3186, Postgres and MySQL tests are slower, and it is useful to enable some level of parallelism.
- Now that we have re-enabled DB testing with cloudfoundrygh-3186, Postgres and MySQL tests are slower, and it is useful to enable some level of parallelism.
- Now that we have re-enabled DB testing with cloudfoundrygh-3186, Postgres and MySQL tests are slower, and it is useful to enable some level of parallelism.
- Now that we have re-enabled DB testing with cloudfoundrygh-3186, Postgres and MySQL tests are slower, and it is useful to enable some level of parallelism.
- Now that we have re-enabled DB testing with cloudfoundrygh-3186, Postgres and MySQL tests are slower, and it is useful to enable some level of parallelism.
- Now that we have re-enabled DB testing with cloudfoundrygh-3186, Postgres and MySQL tests are slower, and it is useful to enable some level of parallelism.
Context
@fhanik and I have noticed that some unit tests did not respect the profile that was passed in, and always ran against an HSQL database, or were ignored
When you ran:
without a postgres database running, the tests would pass, which should not be the case when a database is involved.
This PR only addresses tests, by fixing this issue, fixing failing tests and adding tooling.
Consequences of the PR
postgresql
ormysql
is now twice as slow. On my m1 mac, it goes from "just under 5 minutes" to "in the 10-12 minute range"uaa_1
,uaa_2
, etc ; all the way up to 24. Sometimes your tests may complain thatuaa_33
or something similar does not exist. In order to avoid most problems, please run your gradle tests with--no-daemon
. If you want more details, head over todocs/testing.md
.Fixes
The tests in question:
@WithDatabaseContext
; because that annotation had@ActiveProfiles("default")
. We removed it.TableAndColumnNormalizationTest
, again annotated with@ActiveProfiles("default")
@DefaultTestContext
When we re-enabled the multi-profile support, we had issues in some tests, both with Postgres and MySQL. We have fixed those issues. The main issues were:
groups
was improperly quoted in MySQLEurope/Paris
) ; this is addressed by coercing the MySQL container to the same TZ as your host.Addition:
scripts/docker-compose.yml
We added a docker compose file to have MySQL and Postgres running locally. Using
run-unit-tests.sh
was not working well on our ARM-based macs. This is not expected to be the final setup, but a first step to help us run tests fast.We will converge startup scripts later on.
Addition:
@EnabledWithProfile
/@DisabledWithProfile
To selectively turn off some tests based on profiles ; instead of relying on custom use of
Assume.assumeXXX
andAssumptions.assumeXXX
which are harder to locate in the code.See the javadoc for their usage.
Addition:
docs/testing.md
Some findings on testing have been recorded in
docs/testing.md
.