reddycharan commented on a change in pull request #1726: Introduce lifecycle
components for managing components in AutoRecovery
URL: https://github.com/apache/bookkeeper/pull/1726#discussion_r222465154
##########
File path:
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
##########
@@ -1072,4 +1105,94 @@ private void corruptFile(File file) throws IOException {
}
}
+ @Test(timeout = 20000)
+ public void
testIOVertexHTTPServerEndpointForBookieWithPrometheusProvider() throws
Exception {
+ File tmpDir = createTempDir("bookie", "test");
+
+ final ServerConfiguration conf =
TestBKConfiguration.newServerConfiguration()
+ .setJournalDirName(tmpDir.getPath()).setLedgerDirNames(new
String[] { tmpDir.getPath() })
+
.setBookiePort(PortManager.nextFreePort()).setMetadataServiceUri(metadataServiceUri)
+ .setListeningInterface(null);
+
+ /*
+ * enable io.vertx http server
+ */
+ int nextFreePort = PortManager.nextFreePort();
+ conf.setStatsProviderClass(PrometheusMetricsProvider.class);
+ conf.setHttpServerEnabled(true);
+ conf.setProperty(HttpServerLoader.HTTP_SERVER_CLASS,
"org.apache.bookkeeper.http.vertx.VertxHttpServer");
+ conf.setHttpServerPort(nextFreePort);
+
+ // 1. building the component stack:
+ LifecycleComponent server = Main.buildBookieServer(new
BookieConfiguration(conf));
+ // 2. start the server
+ CompletableFuture<Void> stackComponentFuture =
ComponentStarter.startComponent(server);
+
+ // Now, hit the rest endpoint for metrics
+ URL url = new URL("http://localhost:" + nextFreePort +
HttpRouter.METRICS);
+ URLConnection urlc = url.openConnection();
+ BufferedReader in = new BufferedReader(new
InputStreamReader(urlc.getInputStream()));
+ String inputLine;
+ StringBuilder metricsStringBuilder = new StringBuilder();
+ while ((inputLine = in.readLine()) != null) {
+ metricsStringBuilder.append(inputLine);
+ }
+ in.close();
+ String metrics = metricsStringBuilder.toString();
+ // do primitive checks if metrics string contains some stats
+ assertTrue("Metrics should contain basic counters",
metrics.contains(BookKeeperServerStats.BOOKIE_ADD_ENTRY));
+
+ // Now, hit the rest endpoint for configs
+ url = new URL("http://localhost:" + nextFreePort +
HttpRouter.SERVER_CONFIG);
+ @SuppressWarnings("unchecked")
+ Map<String, Object> configMap = om.readValue(url, Map.class);
+ if (configMap.isEmpty() || !configMap.containsKey("bookiePort")) {
+ Assert.fail("Failed to map configurations to valid JSON entries.");
+ }
+ stackComponentFuture.cancel(true);
+ }
+
+ @Test(timeout = 20000)
Review comment:
removed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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