You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We create contracts using the kotlin DSL, add a dependency on the stub artefact in maven and then execute tests against stubs. When performing such tests using @AutoConfigureStubRunner where there are about 30 kotlin contracts it takes about 30 seconds to initialize the test.
When running with TRACE logging I see this output every ~1 second so my theory is that it takes about that time to compile each contract which is obviously painfully slow.
o.s.c.io.support.SpringFactoriesLoader : Loaded [org.springframework.cloud.contract.spec.ContractConverter] names: [org.springframework.cloud.contract.spec.internal.KotlinContractConverter]
Running the tests with IntelliJ profiler enabled also backs up this theory as a large proportion of the time is spent in the JvmScriptCompiler.invoke method.
I'm aware that kotlin compilation is apparently slow but I don't know why it would take so long to compile relatively trivial DSLs.
Dwelling on this a bit more, I think there is a deeper issue which is that StubRunner only needs to compile the contracts if triggers are to be used. In the REST use case (as opposed to messaging), the mappings (aka stubs) to insert into Wiremock are all that is required. Hence perhaps StubRunner should be configurable to disable the compilation of contracts and just load the stubs instead (i.e. update the logic here to skip contracts based on such a flag)
The text was updated successfully, but these errors were encountered:
adamleantech
changed the title
Tests against Kotlin defined contract stubs take a long time to be initialized - slow compilation?
StubRunner should not compile contracts by default
Jul 5, 2024
Using version 4.1.2.
We create contracts using the kotlin DSL, add a dependency on the stub artefact in maven and then execute tests against stubs. When performing such tests using @AutoConfigureStubRunner where there are about 30 kotlin contracts it takes about 30 seconds to initialize the test.
When running with TRACE logging I see this output every ~1 second so my theory is that it takes about that time to compile each contract which is obviously painfully slow.
o.s.c.io.support.SpringFactoriesLoader : Loaded [org.springframework.cloud.contract.spec.ContractConverter] names: [org.springframework.cloud.contract.spec.internal.KotlinContractConverter]
Running the tests with IntelliJ profiler enabled also backs up this theory as a large proportion of the time is spent in the JvmScriptCompiler.invoke method.
I'm aware that kotlin compilation is apparently slow but I don't know why it would take so long to compile relatively trivial DSLs.
Dwelling on this a bit more, I think there is a deeper issue which is that StubRunner only needs to compile the contracts if triggers are to be used. In the REST use case (as opposed to messaging), the mappings (aka stubs) to insert into Wiremock are all that is required. Hence perhaps StubRunner should be configurable to disable the compilation of contracts and just load the stubs instead (i.e. update the logic here to skip contracts based on such a flag)
The text was updated successfully, but these errors were encountered: