DataONEorg / bookkeeper

Bookkeeper keeps track of DataONE product subscriptions and quotas for researchers using the extended services.
Other
1 stars 2 forks source link

upgrade tests to latest junit-jupiter #87

Closed mbjones closed 1 week ago

mbjones commented 1 year ago

For security reasons, I upgraded the junit-jupiter libraries based on dependabot recommendations to go from 5.4.2 to 5.4.9. This seems to have stopped all tests from being run -- need to check into compatibility and be sure all tests run and pass.

mbjones commented 1 year ago

I moved junit-jupiter back to 5.4.2 to get the tests running again. I also reconfigured the tests for a newer version of Flyway and to have the db migration scripts in the helm/db/migrations directory. These are now picked up from the filesystem during testing, rather than from the classpath. Tests are now functional on linux and passing with sha 0fc4c8813c6c9. We can punt on the upgrade to 5.4.9 to a later time when it is more necessary.

N.B. Tests are not running on my version of MacOS Bug Sur, because of a problem with the OpenTable Embedded Postgres DB we are using in the tests. The problem is common and seems to be due to an issue with the openssl library on Big Sur that prevents postgres from loading a needed library. We are using an old (0.13.1) version of the embedded-pg -- more recent versions like 1.0.1 could work as they have shifted to using Docker-based PG installs. However, they require Docker for Mac to be installed, and don't seem to support Rancher Desktop and containerd, so I punted for now on getting this fixed (I was also unsure how that docker requirement would play out in GHA).

In the longer term we should upgrade to the 1.0.x series and get tests working, but in the meantime, tests are running well under GHA. See GHA builds.

mbjones commented 1 week ago

To fix the testing problems, migrated to use Testcontainers (1.20.1) framework in sha ed80960 and got rid of embedded-pg. Also upgraded JUnit to most recent version (5.11.0), and simplified the configuration to eliminate older junit dependencies that are no longer needed.

Testcontainers works well, but has difficulty using Rancher Desktop on M1 and other apple silicon macs. There is a workaround, which is to set an environment variable that helps get connected to the Rancher VM. The RD workaround sets an environment variable by running:

$ export TESTCONTAINERS_HOST_OVERRIDE=$(rdctl shell ip a show rd0 | awk '/inet / {sub("/.*",""); print $2}')

Then you can run the tests successfully. Within VS Code, setting this environment variable can be accomplished by modifying the settings.json file for vscode to have the right env variable set to the IP address of the VM host (see command above to determine that IP address), like so:

{
    "java.test.config": {
        "env": {"TESTCONTAINERS_HOST_OVERRIDE": "192.168.40.34"}
    }
}