0

I am facing weird issue for pact testing. When I use local pact-broker same test is passing however, when I use remote pact-broker test is failing.

systemProperty 'pactbroker.url', 'https://pact-broker.internal-dev.com/' // Test is failing

systemProperty 'pactbroker.url', 'http://localhost:9292/' // Test is passing, I have setup locally and published to it

Errors:

No Pact files were found to verify
Provider: Provider1
Source: Pact Broker https://pact-broker.internal-dev.com/
au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify
Provider: Provider1
Source: Pact Broker https://pact-broker.internal-dev.com/
    at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:49)
    at au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider.provideTestTemplateInvocationContexts(PactVerificationSpringProvider.kt:24)
    at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:102) and more

Any idea?

Note: This is happening to only one service. For all other services, same setup is working fine and even this is working fine in local broker host. I tried to debug and tests is coming empty.

enter image description here

// Exception point tests.first is empty which should not be. It is not empty when I use Provider2 which for different service.

override fun provideTestTemplateInvocationContexts(context: ExtensionContext): Stream<TestTemplateInvocationContext> {
    logger.trace { "provideTestTemplateInvocationContexts called" }
    val tests = resolvePactSources(context)
    return when {
      tests.first.isNotEmpty() -> tests.first.stream() as Stream<TestTemplateInvocationContext>
      AnnotationSupport.isAnnotated(context.requiredTestClass, IgnoreNoPactsToVerify::class.java) ->
        listOf(DummyTestTemplate).stream() as Stream<TestTemplateInvocationContext>
      else -> throw NoPactsFoundException("No Pact files were found to verify\n${tests.second}")
    }
  }

When I used the provider Provider2(this is for other service) instead of Provider1(I need this), looks like pact is getting resolved and failing for not matching tests, this verifies everything is good in case of setup. I guess somehow it is versioning issue but not sure why passing in local. I tried to rename the provider in publisher side and use it with new name, still same issue.

Pacts on server: enter image description here

Pati Ram Yadav
  • 815
  • 1
  • 8
  • 22
  • I fixed myself. Basically It was versioning issue. The main application version was deleted and hash commit was being used to tag the version in consumer which never exists or always be different. – Pati Ram Yadav Jul 05 '22 at 23:34

0 Answers0