jihoonson commented on a change in pull request #9594: Fix double count ssl
connection metrics
URL: https://github.com/apache/druid/pull/9594#discussion_r402632354
##########
File path:
server/src/test/java/org/apache/druid/server/initialization/JettyTest.java
##########
@@ -311,4 +430,69 @@ public void testGzipRequestDecompression() throws
Exception
new InputStreamResponseHandler()
).get()), Charset.defaultCharset()));
}
+
+ @Test
+ public void testNumConnectionsMetricHttp() throws Exception
+ {
+ String text = "hello";
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(out)) {
+ gzipOutputStream.write(text.getBytes(Charset.defaultCharset()));
+ }
+ Request request = new Request(HttpMethod.POST, new URL("http://localhost:"
+ port + "/slow/hello"));
+ request.setHeader("Content-Encoding", "gzip");
+ request.setContent(MediaType.TEXT_PLAIN, out.toByteArray());
+
+ JettyServerModule jsm = inj.getInstance(JettyServerModule.class);
+ Assert.assertEquals(0, jsm.getActiveConnections());
+ ListenableFuture<InputStream> go = client.go(
+ request,
+ new InputStreamResponseHandler()
+ );
+ // sad
+ Thread.sleep(100);
Review comment:
Maybe there is some better way for waiting here rather than sleeping.. Maybe
we can do like
```java
while (jsm.getActiveConnections() == 0) {
Thread.sleep(100);
}
Assert.assertEquals(1, jsm.getActiveConnections());
go.get();
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]