Closed egvimo closed 1 year ago
you can tweak the memory param in the task integrationTest
plugin section of the gradle files (build.gradle
or gradle/profile_<env>.gradle
.
We had to find a tradeoff for memory usage to constrained environments (I.e. GH actions)
Increasing the memory does not help. I've made some tests:
Version | Time | Result | Remark |
---|---|---|---|
7.8.1 | >120m (aborted) | :x: (OutOfMemory) | Memory increaded to 1024m |
7.8.1 | ~15m | :x: (OutOfMemory) | With default memory of 256m |
7.8.0 | ~15m | :x: (OutOfMemory) | With default memory of 256m |
7.7.0 | ~2m | :heavy_check_mark: | With default memory of 256m |
The first tests are running quick and fine, but the more tests there are, the slower they are getting. Until finally throwing an OutOfMemoyError
.
So something between 7.7.0 and 7.8.0 changed causing this behavior.
It’s related to testcontainer migration, azure doesn’t have docker support at windows. You will need to change embedded kafka to start an embedded version instead of testcontainer: https://github.com/jhipster/generator-jhipster/blob/cfc70f498ad2611f3fe366858753506bf0b01291/generators/server/templates/src/test/java/package/config/TestContainersSpringContextCustomizerFactory.java.ejs#L219-L229
And use dev profile to test with h2 instead of postgresql
There were no kafka test before v7.8.0. So kafka tests and testcontainer can be removed too.
@mshima, you are right. It is related to Kafka, but testcontainers are working well. We migrated our whole backend integration tests to testcontainers. So it's not related to them. Btw. we are using Azure DevOps CI with Ubuntu (the same is true for Github Actions).
TestContainersSpringContextCustomizerFactory
class, the tests are running fast like with 7.7.0, but the Kafka test is failing (obviously)So I think there is a Memory Leak in the TestContainersSpringContextCustomizerFactory
class.
@egvimo if you ever find this leak please fix! I wasn't 100% sure when implementing this class and there are not that much samples of usage in there...
@Tcharl it seems that JHipster Kotlin has the same issue. I've fixed it by reusing the ContextCustomizer
instead of creating every time a new one in the factory method. At least this worked with Kotlin. Didn't tried with Java yet. Something like:
public class TestContainersSpringContextCustomizerFactory implements ContextCustomizerFactory {
// ...
private static ContextCustomizer contextCustomizer;
@Override
public ContextCustomizer createContextCustomizer(Class<?> testClass, List<ContextConfigurationAttributes> configAttributes) {
if (contextCustomizer == null) {
contextCustomizer = (context, mergedConfig) -> {
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
// ...
};
}
return contextCustomizer;
}
}
Overview of the issue
If there are several entities, the integration tests are failing with an
OutOfMemoryError
.The tests are failing mostly around the 15th entity.
This is also happening in CI. Reproduced in Azure DevOps and GitHub.
And the integration tests are very slow compared to before.
Motivation for or Use Case
Tests should not fail with OutOfMemory error.
Reproduce the error
./gradlew integrationTest -x webapp -x webapp_test
Related issues
Suggest a Fix
Something changed between 7.6.0 and 7.8.1, which causes this error. I'm currently using version 7.6.0 and wanted to Upgrade to the newest version. Earlier I tried to upgrade to 7.7.0 and as far as I recall the problem was not there (but I'm not 100 % sure).
JHipster Version(s)
7.8.1
JHipster configuration
JDL definitions
Entity configuration(s)
entityName.json
files generated in the.jhipster
directorySee my sample app for full example.
Browsers and Operating System
Windows 10
Azure DevOps CI
GitHub Actions
[x] Checking this box is mandatory (this is just to show you read everything)