Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

References

CPS-1379 - Getting issue details... STATUS

Description

Previously, data was inserted into the database for persistence testing by using SQL scripts. This led to data which cannot conform to any yang model being used for testing purposes

Issues & Decisions

#IssueNotes Decision
1Insert data using Service Layer MethodsValidates data with minimal test performance impact if it works

Primary solution

2Insert data using a cps container with test containersValidates data but can have a bigger performance hit. Also issues relating to which image is used for the image that is spun upPossible secondary solution 
3Insert data using liquibaseNo data validation but will be hopefully easier to read. Also cannot add more data/reset data during testingNot sure if it's worth it, will be similar to the current implementation unless the data can be inserted in json format somehow


Using Service Layer Methods

https://gerrit.nordix.org/c/onap/cps/+/16357/3 (Patchset 3)

CpsPersistenceSpecBase2.groovy

Since this SpringBootTest does not have the scope of the service layer included, we need to manually tell spring where to find the beans when the test is run. This is done through an inner class with the Configuration annotation and ComponentScan for the relevant modules. The Autowired annotation catches the beans for the other layers and then the Bean annotated methods bring the beans to the outer test class. There are issues with bean instantiation order in this test hence why the Lazy annotation is also included. 

Configuration Inner Class
@ComponentScan("org.onap.cps.api,org.onap.cps.spi,org.onap.cps.spi.repository,org.onap.cps.notification")
    @Configuration
//    @ContextConfiguration(classes = [KafkaAutoConfiguration, KafkaProducerListener, NotificationErrorHandler])
    static class TestConfig {
        @Autowired
        @Lazy
        CpsAdminService cpsAdminService

        @Autowired
        @Lazy
        DataspaceRepository dataspaceRepository

        @Autowired
        @Lazy
        AnchorRepository anchorRepository

        @Autowired
        @Lazy
        FragmentRepository fragmentRepository
//
//        @Autowired
//        @Lazy
//        NotificationService notificationService
//
        @Autowired
        @Lazy
        YangResourceRepository yangResourceRepository

        @Autowired
        @Lazy
        SchemaSetRepository schemaSetRepository

        @Autowired
        @Lazy
        ModuleReferenceRepository moduleReferenceRepository

        @Autowired
        @Lazy
        EntityManagerFactory entityManagerFactory
//
//        @Autowired
//        @Lazy
//        KafkaTemplate kafkaTemplate
//
//        @Bean
//        CpsAdminService cpsAdminService() {
//            cpsAdminService
//            return cpsAdminService
//        }
//
        @Bean
        DataspaceRepository dataspaceRepository() {
            return dataspaceRepository
        }

        @Bean
        AnchorRepository anchorRepository() {
            return anchorRepository
        }

        @Bean
        FragmentRepository fragmentRepository() {
            return fragmentRepository
        }

        @Bean
        YangResourceRepository yangResourceRepository() {
            return yangResourceRepository
        }

        @Bean
        SchemaSetRepository schemaSetRepository() {
            return schemaSetRepository
        }

        @Bean
        ModuleReferenceRepository moduleReferenceRepository() {
            return moduleReferenceRepository
        }

        @Bean
        EntityManagerFactory entityManagerFactory() {
            return entityManagerFactory
        }
    }

Currently this test results in an ambiguous stackoverflow error which I reckon is due to two beans being created at the same time. Tried renaming the beans and it doesn't seem to have an effect.

Stack Overflow Error
java.lang.StackOverflowError
	at java.base/java.lang.Throwable.getOurStackTrace(Throwable.java:839)
	at java.base/java.lang.Throwable.getStackTrace(Throwable.java:831)
	at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:79)
	at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
	at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
	at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
	at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)...

Using CPS Container

https://gerrit.nordix.org/c/onap/cps/+/16357/4 (Patchset 4)

Using an image of CPS we can insert the data for the tests. We already use a testcontainer for the postgres used. Currently testcontainers is trying to pull docker from nordix which is resulting in an error for this implementation. 

Docker Error
Caused by: com.github.dockerjava.api.exception.NotFoundException: Status 404: {"message":"manifest for nexus3.onap.org:10001/library/docker/compose:1.29.2 not found: manifest unknown: manifest unknown"}
  • No labels