Skip to content

Commit

Permalink
Disable the location consumer contract tests due to flakiness that re…
Browse files Browse the repository at this point in the history
…quires some investigation.
  • Loading branch information
edeandrea committed Apr 18, 2024
1 parent 5c6508f commit 19e883e
Showing 1 changed file with 42 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import jakarta.ws.rs.core.Response.Status;

import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import io.quarkus.panache.mock.PanacheMock;
import io.quarkus.test.junit.QuarkusTest;
Expand All @@ -39,7 +39,7 @@
import au.com.dius.pact.consumer.dsl.PactDslRootValue;
import au.com.dius.pact.consumer.dsl.PactDslWithProvider;
import au.com.dius.pact.consumer.junit.MockServerConfig;
import au.com.dius.pact.consumer.junit5.PactConsumerTestExt;
import au.com.dius.pact.consumer.junit5.PactConsumerTest;
import au.com.dius.pact.consumer.junit5.PactTestFor;
import au.com.dius.pact.consumer.junit5.ProviderType;
import au.com.dius.pact.consumer.model.MockServerImplementation;
Expand All @@ -51,7 +51,7 @@

@QuarkusTest
@TestProfile(PactConsumerContractTestProfile.class)
@ExtendWith(PactConsumerTestExt.class)
@PactConsumerTest
@PactTestFor(pactVersion = PactSpecVersion.V4)
@MockServerConfig(
providerName = "rest-heroes",
Expand Down Expand Up @@ -298,42 +298,43 @@ public V4Pact helloLocationsPact(PactBuilder builder) {
.toPact();
}

@Pact(consumer = "rest-fights", provider = "grpc-locations")
public V4Pact randomLocationFoundPact(PactBuilder builder) {
return builder
.usingPlugin("protobuf")
.expectsToReceive("A request for a random location", "core/interaction/synchronous-message")
.with(Map.of(
"pact:proto", filePath("src/main/proto/locationservice-v1.proto"),
"pact:content-type", "application/grpc",
"pact:proto-service", "Locations/GetRandomLocation",
"request", Map.of(),
"response", Map.of(
"name", "matching(regex, '.+', '%s')".formatted(DEFAULT_LOCATION_NAME),
"picture", "matching(regex, '((http|https):\\/\\/).+', '%s')".formatted(DEFAULT_LOCATION_PICTURE)
)
))
.toPact();
}

@Pact(consumer = "rest-fights", provider = "grpc-locations")
public V4Pact randomLocationNotFoundPact(PactBuilder builder) {
return builder
.usingPlugin("protobuf")
.given("No random location found")
.expectsToReceive("A request for a random location", "core/interaction/synchronous-message")
.with(Map.of(
"pact:proto", filePath("src/main/proto/locationservice-v1.proto"),
"pact:content-type", "application/grpc",
"pact:proto-service", "Locations/GetRandomLocation",
"request", Map.of(),
"responseMetadata", Map.of(
"grpc-status", io.grpc.Status.NOT_FOUND.getCode().name(),
"grpc-message", "A location was not found"
)
))
.toPact();
}
// Disable the location tests for now due to some flakiness that needs some investigation
// @Pact(consumer = "rest-fights", provider = "grpc-locations")
// public V4Pact randomLocationFoundPact(PactBuilder builder) {
// return builder
// .usingPlugin("protobuf")
// .expectsToReceive("A request for a random location", "core/interaction/synchronous-message")
// .with(Map.of(
// "pact:proto", filePath("src/main/proto/locationservice-v1.proto"),
// "pact:content-type", "application/grpc",
// "pact:proto-service", "Locations/GetRandomLocation",
// "request", Map.of(),
// "response", Map.of(
// "name", "matching(regex, '.+', '%s')".formatted(DEFAULT_LOCATION_NAME),
// "picture", "matching(regex, '((http|https):\\/\\/).+', '%s')".formatted(DEFAULT_LOCATION_PICTURE)
// )
// ))
// .toPact();
// }
//
// @Pact(consumer = "rest-fights", provider = "grpc-locations")
// public V4Pact randomLocationNotFoundPact(PactBuilder builder) {
// return builder
// .usingPlugin("protobuf")
// .given("No random location found")
// .expectsToReceive("A request for a random location", "core/interaction/synchronous-message")
// .with(Map.of(
// "pact:proto", filePath("src/main/proto/locationservice-v1.proto"),
// "pact:content-type", "application/grpc",
// "pact:proto-service", "Locations/GetRandomLocation",
// "request", Map.of(),
// "responseMetadata", Map.of(
// "grpc-status", io.grpc.Status.NOT_FOUND.getCode().name(),
// "grpc-message", "A location was not found"
// )
// ))
// .toPact();
// }

@Test
@PactTestFor(pactMethods = { "randomHeroNotFoundPact", "randomVillainNotFoundPact" })
Expand Down Expand Up @@ -561,6 +562,7 @@ void helloLocationsSuccess() {
verifyNoInteractions(this.heroClient, this.villainClient, this.narrationClient);
}

@Disabled("Flaky - need to figure out why")
@Test
@PactTestFor(pactMethods = "randomLocationFoundPact", providerType = ProviderType.SYNCH_MESSAGE)
void findRandomLocationSuccess() {
Expand All @@ -580,6 +582,7 @@ void findRandomLocationSuccess() {
verifyNoInteractions(this.heroClient, this.villainClient, this.narrationClient);
}

@Disabled("Flaky - need to figure out why")
@Test
@PactTestFor(pactMethods = "randomLocationNotFoundPact", providerType = ProviderType.SYNCH_MESSAGE)
void findRandomLocationNoLocationFound() {
Expand Down

0 comments on commit 19e883e

Please sign in to comment.