@@ -78,15 +78,15 @@ public class ApmServerClientTest {
78
78
@ Before
79
79
public void setUp () throws IOException {
80
80
URL url1 = new URL ("http" , "localhost" , apmServer1 .port (), "/" );
81
- URL url2 = new URL ("http" , "localhost" , apmServer2 .port (), "/" );
81
+ URL url2 = new URL ("http" , "localhost" , apmServer2 .port (), "/proxy " );
82
82
// APM server 6.x style
83
83
apmServer1 .stubFor (get (urlEqualTo ("/" )).willReturn (okForJson (Map .of ("ok" , Map .of ("version" , "6.7.0-SNAPSHOT" )))));
84
84
apmServer1 .stubFor (get (urlEqualTo ("/test" )).willReturn (notFound ()));
85
85
apmServer1 .stubFor (get (urlEqualTo ("/not-found" )).willReturn (notFound ()));
86
86
// APM server 7+ style
87
- apmServer2 .stubFor (get (urlEqualTo ("/" )).willReturn (okForJson (Map .of ("version" , "7.3.0-RC1" ))));
88
- apmServer2 .stubFor (get (urlEqualTo ("/test" )).willReturn (ok ("hello from server 2" )));
89
- apmServer2 .stubFor (get (urlEqualTo ("/not-found" )).willReturn (notFound ()));
87
+ apmServer2 .stubFor (get (urlEqualTo ("/proxy/ " )).willReturn (okForJson (Map .of ("version" , "7.3.0-RC1" ))));
88
+ apmServer2 .stubFor (get (urlEqualTo ("/proxy/ test" )).willReturn (ok ("hello from server 2" )));
89
+ apmServer2 .stubFor (get (urlEqualTo ("/proxy/ not-found" )).willReturn (notFound ()));
90
90
91
91
config = SpyConfiguration .createSpyConfig ();
92
92
reporterConfiguration = config .getConfig (ReporterConfiguration .class );
@@ -176,7 +176,7 @@ public void testUseNextUrlOnError() throws Exception {
176
176
apmServerClient .execute ("/test" , HttpURLConnection ::getResponseCode );
177
177
178
178
apmServer1 .verify (0 , getRequestedFor (urlEqualTo ("/test" )));
179
- apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/test" )));
179
+ apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/proxy/ test" )));
180
180
assertThat (apmServerClient .getErrorCount ()).isEqualTo (1 );
181
181
}
182
182
@@ -194,7 +194,7 @@ public void testRetry() throws Exception {
194
194
assertThat (apmServerClient .<String >execute ("/test" , conn -> new String (conn .getInputStream ().readAllBytes ()))).isEqualTo ("hello from server 2" );
195
195
assertThat (Objects .requireNonNull (apmServerClient .getCurrentUrl ()).getPort ()).isEqualTo (apmServer2 .port ());
196
196
apmServer1 .verify (1 , getRequestedFor (urlEqualTo ("/test" )));
197
- apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/test" )));
197
+ apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/proxy/ test" )));
198
198
assertThat (apmServerClient .getErrorCount ()).isEqualTo (1 );
199
199
}
200
200
@@ -204,7 +204,7 @@ public void testRetryFailure() {
204
204
.isInstanceOf (FileNotFoundException .class )
205
205
.matches (t -> t .getSuppressed ().length == 1 , "should have a suppressed exception" );
206
206
apmServer1 .verify (1 , getRequestedFor (urlEqualTo ("/not-found" )));
207
- apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/not-found" )));
207
+ apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/proxy/ not-found" )));
208
208
// two failures -> urls wrap
209
209
assertThat (Objects .requireNonNull (apmServerClient .getCurrentUrl ()).getPort ()).isEqualTo (apmServer1 .port ());
210
210
assertThat (apmServerClient .getErrorCount ()).isEqualTo (2 );
@@ -217,7 +217,7 @@ public void testExecuteSuccessfullyForAllUrls() {
217
217
return null ;
218
218
});
219
219
apmServer1 .verify (1 , getRequestedFor (urlEqualTo ("/not-found" )));
220
- apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/not-found" )));
220
+ apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/proxy/ not-found" )));
221
221
// no failures -> urls in initial state
222
222
assertThat (Objects .requireNonNull (apmServerClient .getCurrentUrl ()).getPort ()).isEqualTo (apmServer1 .port ());
223
223
assertThat (apmServerClient .getErrorCount ()).isZero ();
@@ -231,7 +231,7 @@ public void testExecuteFailureForAllUrls() {
231
231
return null ;
232
232
});
233
233
apmServer1 .verify (1 , getRequestedFor (urlEqualTo ("/not-found" )));
234
- apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/not-found" )));
234
+ apmServer2 .verify (1 , getRequestedFor (urlEqualTo ("/proxy/ not-found" )));
235
235
assertThat (apmServerClient .getErrorCount ()).isEqualTo (0 );
236
236
}
237
237
0 commit comments