Hi,
we are runnign Spring Boot 2.1.5 with Axon 4.1, spring boot test and Spock.
In tests we have InMemoryEventStorage configured like
`
@Bean
@Primary
InMemoryEventStorageEngine inMemoryEventStorageEngine() {
def engine = new InMemoryEventStorageEngine()
engine
}
@Bean
@Primary
EmbeddedEventStore embeddedEventStore() {
def store = EmbeddedEventStore.builder()
.storageEngine(inMemoryEventStorageEngine())
.build()
store
}
`
Each integration test inherits from ControllerIntegrationTest
`
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ActiveProfiles("test")
@ContextConfiguration(classes = [IntegrationTestConfiguration])
abstract class ControllerIntegrationTest extends Specification {
@Autowired
WebApplicationContext context
MockMvc mockMvc
@Autowired
ObjectMapper mapper
def setup() {
mockMvc = MockMvcBuilders
.webAppContextSetup(context)
.apply(springSecurity())
.build()
}
`
When running the tests with @DirtiesContext, the tests are performing ok, no failures, but each test has performance issues since its waiting till all the processors shut down (see log). Shutting each processor takes about second. While we have dozens of processor, the build time takes couple of extra minutes.
2019-08-03 07:09:07.088 INFO 80745 --- [ main] o.a.e.TrackingEventProcessor : Shutdown state set for Processor 'fi.traficom.lilja.applicationservice.log.projection'. Awaiting termination... e... 2019-08-03 07:09:07.898 INFO 80745 --- [ main] o.a.e.TrackingEventProcessor : Shutdown state set for Processor 'TasksForStateSagaProcessor'. Awaiting termination... ...
When we remove the @DirtiesContext, performance is increased significantly, but some tests are affected by the state of the previous one in the suite, e.g. where the first test flags CreateEntityCommand while the second test’s db is still containing the projection record for the given entity.
Is there any way how to avoid this situation?
I also tried to run the test db in the container (TestContainers), but the result was the same, still can see the records from previous test
Thank you for you help in advance!