-
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
base: develop
Are you sure you want to change the base?
Fix DB unit tests #3186
Conversation
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
- Useful in database testing, allows enabling/disabling tests based on whether `postgresql` or `mysql` is present in the list of active profiles.
…Inactive for mysql
- The MySQL image is in UTC, but if you run the tests from a machine on different timezone, conversions are made inconsistently depending on the datatype used in the JDBC queries. - Therefore, some tests have trouble fetching things "in the past", or may mark some tokens as "expired". - This fixes the tests by hardcoding the timezone to UTC for the specific test.
scripts/docker-compose.yml
Outdated
|
||
services: | ||
postgres: | ||
image: "postgres:17.2" |
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.
please check if https://github.com/cloudfoundry/uaa/blob/develop/scripts/start_db_helper.sh can be re-used
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.
PR still in Work in Progress mode
We wrote this on MacOS, I see failures on Linux. Working on those today
Test that fail: JdbcApprovalStoreTests.deleteProviderDeletesApprovals Why: - Table users has column id char(30) - Table authz_approvals has column user_id varchar(30) These two don't match when joining in a query Suspect: https://dev.mysql.com/worklog/task/?id=12129
For example, joining authz_approvals.user_id is varchar fails when joining against a padded char column
…keyword in SQL Now we can use MySQL 8 Downgrade to PostgreSQL 15 (need to find out exactly what the test matrix should be)
New findings
Items Left to Do
|
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.
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, notably with Postgres. We have fixed those issues.
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.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:
@WithTimeZone
MySQL + the JDBC driver have issues with default time zones. We added an extension to hardcode the timezone to UTC in some unit tests, similar to what JUnit Pioneer does.