Search code examples
spring-bootspring-boot-testspring-cloud-contract

Spring cloud contract PCF dependencies


To test spring boot micro services deployed in PCF environment, our team started implementing spring-cloud-contract framework.

To explain my problem, we have two microservices A and B and A is consuming B service. I have developed contract at B and stub-runner at A. When I do gradle clean build on B (before PCF deployment), stubs are being generated but acceptance tests (generated by cloud contract framework) are failing due to PCF dependencies (db and other certificates). Is there anyway to test contracts and service A test cases after PCF deployment?


Solution

  • Yes, there are. Please read through the documentation of the Spring Cloud Pipelines project. http://cloud.spring.io/spring-cloud-pipelines/single/spring-cloud-pipelines.html#_opinionated_implementation . We deploy the stub runner application as a standalone process and while deploying it we pass the ids of stubs we would like it to start. Stub Runner can register stubs under Eureka (remember that your installation needs to allow multiple port binding) and it can send messages to real brokers.

    I don't fully understand this part

    stubs are being generated but acceptance tests (generated by cloud contract framework) are failing due to PCF dependencies (db and other certificates)

    You're the one that controls the base class and test setup. You can setup the context however you want to. Also, remember that it's not recommended to use any DB and certificates in the contract tests. You should just verify if the HTTP communication works fine without integrating with any underlaying infra.