So I have multiple Test classes for Selenium tests that all extend from the same BaseTestEnvironment:
@ExtendWith({SpringExtension.class})
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestPropertySource(locations = "classpath:application-e2e-test.properties")
public abstract class SeleniumBaseTestEnvironment
Each test class extends from it and cleans the application context with DirtiestContext after all its tests are finished
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class ExperimentCreationTest extends SeleniumBaseTestEnvironment {
Database for these test is inmemory H2.
This worked fine for some time but with more test classes added I get Out of Memory exceptions, but I have no clue what might be the cause.
The webdrivers should all be closed and from what it seems to me the database connections are closed as well.
2021-07-29 14:52:41.125 INFO 9492 --- [ool-30-thread-1] i.g.bonigarcia.seljup.DockerService : Stopping Docker container aerokube/selenoid:1.10.1
2021-07-29 14:52:42.115 INFO 9492 --- [ool-30-thread-2] i.g.bonigarcia.seljup.DockerService : Stopping Docker container psharkey/novnc:3.3-t6
2021-07-29 14:52:43.607 INFO 9492 --- [ Test worker] o.s.m.s.b.SimpleBrokerMessageHandler : Stopping...
2021-07-29 14:52:43.607 INFO 9492 --- [ Test worker] o.s.m.s.b.SimpleBrokerMessageHandler : BrokerAvailabilityEvent[available=false, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0 destination(s)], registry[0 sessions]]]]
2021-07-29 14:52:43.608 INFO 9492 --- [ Test worker] o.s.m.s.b.SimpleBrokerMessageHandler : Stopped.
2021-07-29 14:52:43.673 INFO 9492 --- [ Test worker] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'brokerChannelExecutor'
2021-07-29 14:52:43.674 INFO 9492 --- [ Test worker] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'messageBrokerTaskScheduler'
2021-07-29 14:52:43.674 INFO 9492 --- [ Test worker] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'TntTaskExecutor'
2021-07-29 14:52:43.675 INFO 9492 --- [ Test worker] o.s.s.quartz.SchedulerFactoryBean : Shutting down Quartz Scheduler
2021-07-29 14:52:43.682 INFO 9492 --- [ Test worker] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'clientOutboundChannelExecutor'
2021-07-29 14:52:43.682 INFO 9492 --- [ Test worker] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'clientInboundChannelExecutor'
2021-07-29 14:52:43.682 INFO 9492 --- [ Test worker] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-07-29 14:52:43.683 INFO 9492 --- [ Test worker] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
2021-07-29 14:52:43.693 INFO 9492 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-13 - Shutdown initiated...
2021-07-29 14:52:43.694 DEBUG 9492 --- [ Test worker] com.zaxxer.hikari.pool.HikariPool : HikariPool-13 - Before shutdown stats (total=10, active=0, idle=10, waiting=0)
2021-07-29 14:52:43.694 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn120: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.695 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn121: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.695 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn122: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.695 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn123: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.695 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn124: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.695 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn125: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.695 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn126: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.695 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn127: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.696 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn128: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.696 DEBUG 9492 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : HikariPool-13 - Closing connection conn129: url=jdbc:h2:mem:testdb user=SA: (connection evicted)
2021-07-29 14:52:43.696 DEBUG 9492 --- [ Test worker] com.zaxxer.hikari.pool.HikariPool : HikariPool-13 - After shutdown stats (total=0, active=0, idle=0, waiting=0)
2021-07-29 14:52:43.696 INFO 9492 --- [ Test worker] com.zaxxer.hikari.HikariDataSource : HikariPool-13 - Shutdown completed.
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message can't create name string at ./open/src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 827
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "mysql-cj-abandoned-connection-cleanup"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Catalina-utility-1"
Does anyone have a suggestion on how I can solve this problem? Also, I'm not really experienced when it comes to java memory management and how to parse gc.