|
13 | 13 | import static org.junit.jupiter.api.Named.named;
|
14 | 14 | import static org.junit.jupiter.params.provider.Arguments.arguments;
|
15 | 15 |
|
| 16 | +import com.github.tomakehurst.wiremock.WireMockServer; |
| 17 | +import com.github.tomakehurst.wiremock.client.WireMock; |
16 | 18 | import com.google.protobuf.InvalidProtocolBufferException;
|
17 | 19 | import com.google.protobuf.Message;
|
18 | 20 | import com.linecorp.armeria.common.HttpRequest;
|
|
101 | 103 | import org.junit.jupiter.params.provider.ArgumentsSource;
|
102 | 104 | import org.junit.jupiter.params.provider.ValueSource;
|
103 | 105 | import org.junit.jupiter.params.support.ParameterDeclarations;
|
104 |
| -import org.mockserver.integration.ClientAndServer; |
105 | 106 | import org.slf4j.event.Level;
|
106 | 107 | import org.slf4j.event.LoggingEvent;
|
107 | 108 |
|
@@ -648,30 +649,35 @@ void nonRetryableError(int code) {
|
648 | 649 |
|
649 | 650 | @Test
|
650 | 651 | void proxy() {
|
651 |
| - // configure mockserver to proxy to the local OTLP server |
652 |
| - InetSocketAddress serverSocketAddress = server.httpSocketAddress(); |
653 |
| - try (ClientAndServer clientAndServer = |
654 |
| - ClientAndServer.startClientAndServer( |
655 |
| - serverSocketAddress.getHostName(), serverSocketAddress.getPort()); |
656 |
| - TelemetryExporter<T> exporter = |
657 |
| - exporterBuilder() |
658 |
| - // Configure exporter with server endpoint, and proxy options to route through |
659 |
| - // mockserver proxy |
660 |
| - .setEndpoint(server.httpUri() + path) |
661 |
| - .setProxyOptions( |
662 |
| - ProxyOptions.create( |
663 |
| - InetSocketAddress.createUnresolved("localhost", clientAndServer.getPort()))) |
664 |
| - .build()) { |
| 652 | + // configure wiremock to proxy to the local OTLP server |
| 653 | + WireMockServer wireMockServer = new WireMockServer(0); |
| 654 | + wireMockServer.start(); |
| 655 | + |
| 656 | + // Configure WireMock to proxy all requests to the actual server |
| 657 | + wireMockServer.stubFor( |
| 658 | + WireMock.any(WireMock.anyUrl()) |
| 659 | + .willReturn(WireMock.aResponse().proxiedFrom(server.httpUri().toString()))); |
| 660 | + |
| 661 | + try (TelemetryExporter<T> exporter = |
| 662 | + exporterBuilder() |
| 663 | + // Configure exporter with server endpoint, and proxy options to route through |
| 664 | + // wiremock proxy |
| 665 | + .setEndpoint(server.httpUri() + path) |
| 666 | + .setProxyOptions( |
| 667 | + ProxyOptions.create( |
| 668 | + InetSocketAddress.createUnresolved("localhost", wireMockServer.port()))) |
| 669 | + .build()) { |
665 | 670 |
|
666 | 671 | List<T> telemetry = Collections.singletonList(generateFakeTelemetry());
|
667 | 672 |
|
668 | 673 | assertThat(exporter.export(telemetry).join(10, TimeUnit.SECONDS).isSuccess()).isTrue();
|
669 |
| - // assert that mock server received request |
670 |
| - assertThat(clientAndServer.retrieveRecordedRequests(new org.mockserver.model.HttpRequest())) |
671 |
| - .hasSize(1); |
| 674 | + // assert that wiremock server received request |
| 675 | + wireMockServer.verify(1, WireMock.anyRequestedFor(WireMock.anyUrl())); |
672 | 676 | // assert that server received telemetry from proxy, and is as expected
|
673 | 677 | List<U> expectedResourceTelemetry = toProto(telemetry);
|
674 | 678 | assertThat(exportedResourceTelemetry).containsExactlyElementsOf(expectedResourceTelemetry);
|
| 679 | + } finally { |
| 680 | + wireMockServer.stop(); |
675 | 681 | }
|
676 | 682 | }
|
677 | 683 |
|
|
0 commit comments