0

I have a Quarkus application, producing a kafka message to a topic consumed by another service, I am writing provider tests (creating a nested object with 8-9 fields with further nesting, in pact to send and to verify the contract) for that using pact. But getting below error in local and in the gitlab pipeline as well.

ClassGraph-worker-11: Retried waiting for GCLocker too often allocating 120718 words

Fine the code snippet

import au.com.dius.pact.provider.MessageAndMetadata;
import au.com.dius.pact.provider.PactVerifyProvider;
import au.com.dius.pact.provider.junit5.MessageTestTarget;
import au.com.dius.pact.provider.junit5.PactVerificationContext;
import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider;
import au.com.dius.pact.provider.junitsupport.Provider;
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.Map;

@Provider("a-message-provider")
@PactBroker(url = "broker-url")
public class AnyMessageProviderTest {

  private final ObjectMapper objectMapper = new ObjectMapper();

  @BeforeAll
  public static void setUp() {
    System.setProperty("pact_do_not_track", "true");
    System.setProperty("pact.verifier.publishResults", "true");
    System.setProperty("pact.provider.version", "v1.0.0");
  }


  @BeforeEach
  void before(PactVerificationContext context) {
    context.setTarget(new MessageTestTarget());
  }

  @TestTemplate
  @ExtendWith(PactVerificationInvocationContextProvider.class)
  void pactVerificationTestTemplate(PactVerificationContext context) {
    context.verifyInteraction();
  }

  @PactVerifyProvider("An kafka message")
  MessageAndMetadata verifyOddsChange() throws IOException {

  //creating Event object here with nested objects

  return new MessageAndMetadata(objectMapper.writeValueAsBytes(event), Map.of("key", "3435345"));
}

}

NOTE:

quarkus version: 3.9.2,

pact library testImplementation 'au.com.dius.pact.provider:junit5:4.6.9'

6
  • Are you using pact standalone, or the Quarkus Pact extension? Commented Jun 4 at 12:57
  • I am not using quarkus pact extention, using this library mentioned in the question as well, testImplementation 'au.com.dius.pact.provider:junit5:4.6.9'
    – APK
    Commented Jun 4 at 17:08
  • I'd recommend switching to the extension. I'm not sure it will help this specific issue, but it resolves some incompatibilities between Pact and the Quarkus classloading model, and, eventually, hopefully, will have some nice usability enhancements. Commented Jun 5 at 8:21
  • @HollyCummins I though of using it but there are not code snippet for kafka messages. I could not see a proper documentation as well. Any reference
    – APK
    Commented Jun 5 at 9:58
  • You're right that the docs are a bit thin. That's partly because the programming model is just the Pact programming model. So you'd just swap the dependency in your pom, and then continue using Pact as you were. Commented Jun 5 at 14:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.