fullben / java-persistence-benchmark

Benchmark for comparing the performance of a JPA-based and MicroStream-based persistence implementation, loosely based on the TPC-C benchmark.
5 stars 2 forks source link

Tests in ms-jacis and ms-sync are broken #5

Open fullben opened 1 year ago

fullben commented 1 year ago

Observed Behavior

In version 2.1.1 of the benchmark, execution of any test in the ms-jacis and ms-sync subprojects fails with the error:

Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)

And root cause:

Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'embeddedStorageManager' defined in de.uniba.dsg.wss.service.MicroStreamTestConfiguration: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=microStreamTestConfiguration; factoryMethodName=embeddedStorageManager; initMethodName=null; destroyMethodName=(inferred); defined in de.uniba.dsg.wss.service.MicroStreamTestConfiguration] for bean 'embeddedStorageManager': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=msConfiguration; factoryMethodName=embeddedStorageManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [de/uniba/dsg/wss/MsConfiguration.class]] bound.

Expected Behavior

Tests should complete successfully :)

Analysis

As far as I can tell, the tests cannot be initialized since the default configuration of the actual applications in those subprojects has a default bean for the MicroStream EmbeddedStorageManager, being defined in the MsConfiguration classes of those projects and the tests attempt to create a bean with the same name in the MicroStreamTestConfiguration classes.

I don't really understand why this causes an exception, since in my understanding the @TestConfiguration annotation in the MicroStreamTestConfiguration classes should result in the storage manager beans defined in the MsConfiguration classes to be overridden by the storage manager beans defined in MicroStreamTestConfiguration classes.

I assume this is a test configuration issue. When looking into this issue, we should maybe also look into whether the @SpringBootTest annotation is the appropriate approach in these projects, this spins up a full application, with all the beans. Might be overkill.

fullben commented 1 year ago

@johannes-manner could you look into this?