-
Notifications
You must be signed in to change notification settings - Fork 456
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
Run tests in parallel on different JVM forks #3068
base: master
Are you sure you want to change the base?
Conversation
Creates a db for each test class, tests classes are run in parallel, methods within a class are sequential. Ignoring the test failures below, this runs in _about_ the same amount of time as MorphiaOrg#3068 - JVM forks of `1C` on an Mac M1 Max was ~2min (in above PR) - A single JVM with 20 threads ran in 2 min (increasing this 40 threads saved another 15 seconds) Results may vary depnding on OS, specs, where docker is running, etc There are still 5 test failures: ``` [ERROR] Failures: [ERROR] TestVersioning.testAlternateFailures:97->MorphiaTestSetup.withTestConfig:177->MorphiaTestSetup.withConfig:199->lambda$testAlternateFailures$1:100 Expected MongoWriteException to be thrown, but nothing was thrown [ERROR] TestIndexes.shouldNotAllowMultipleTextIndexes » Test Method TestIndexes.shouldNotAllowMultipleTextIndexes()[pri:0, instance:dev.morphia.test.indexes.TestIndexes@411341bd] should have thrown an exception of type class com.mongodb.MongoCommandException [ERROR] PathTargetTest.arrays:51->MorphiaTestSetup.withTestConfig:181->MorphiaTestSetup.withTestConfig:177->MorphiaTestSetup.withConfig:199->lambda$arrays$0:56 » Validation Could not resolve path 'listEmbeddedType.1.anotherField' against 'dev.morphia.test.internal.PathTargetTest$EntityWithListsAndArrays'. Unknown path element: 'anotherField'. [ERROR] PathTargetTest.interfaces:88->MorphiaTestSetup.withTestConfig:181->MorphiaTestSetup.withTestConfig:177->MorphiaTestSetup.withConfig:199->lambda$interfaces$3:95 » Validation Could not resolve path 'mapped.value' against 'dev.morphia.test.internal.PathTargetTest$HoldsAnInterface'. Unknown path element: 'value'. [ERROR] TestMapping.testExternalClass:377 Expected MappingException to be thrown, but nothing was thrown ``` NOTE: This code needs to be cleaned up and DRY'd a bit, it's hacky now.
A bit more hacking, and I was able to get most (all but 5) of the tests working running in parallel in a single JVM: bdemers@45cd1c6 Not sure if it's worth it or not, it runs in about the same amount of time, as this PR (which is basically a single config arg) Or you could just run against master: |
I think what you're running into is that If each class runs off in its own forked env/thread/whatever, we can simply rebuild it all each time (yes, we'll remap code more than we need but i'm working on optimizing that, too) and simply run each test with its own database. Then we won't have to worry about dropping databases while trying to write to them. In fact, there's no need to drop the databases anymore since they all run on ephemeral testcontainers instances. Let me see about unwinding the |
Low hanging fruit for running tests in parallel is forking multiple JVMs (
1C
, one per core) and having each one run tests sequentially.This cuts the build time from 5m to 2m on my laptop.
NOTE: I was writing up my thoughts on other ways to run the tests in parallel without needing to fork, but then I realized all the tests are using"mongodb://localhost:27017/" + TEST_DB_NAME;
, so I'm not sure how running my tests worked?Answer:
morphia/core/src/test/java/dev/morphia/test/MorphiaTestSetup.java
Lines 62 to 65 in 29a32b8
@evanchooly I was chatting with @trishagee to get the tests to run in parallel.