Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StubRunner should not compile contracts by default #2122

Open
adamleantech opened this issue Jun 28, 2024 · 0 comments
Open

StubRunner should not compile contracts by default #2122

adamleantech opened this issue Jun 28, 2024 · 0 comments

Comments

@adamleantech
Copy link

adamleantech commented Jun 28, 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)

@adamleantech 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants