protected void doServerAsyncProcessingVerificationTestForUrl(String endpointUrl, boolean expectNettyWorkerThreadToBeDifferentThanExecutor) throws ExecutionException, InterruptedException { // Clear the data and run the test clearDataForNewTest(); List<Future<Map<String, String>>> futures = new ArrayList<>(); int numSimultaneousCalls = NUMBER_OF_REQUESTS; for (int i = 0; i < numSimultaneousCalls; i++) { futures.add(sendServerRequest(endpointUrl)); } // Wait for all the requests to return List<Map<String, String>> results = new ArrayList<>(); for (Future<Map<String, String>> f : futures) { results.add(f.get()); } // We need to sleep for a short time to give the metrics handler a chance to process the request before we start asserting on the metrics values. Thread.sleep(250); }
@Before public void setUp() throws Exception { executor = Executors.newCachedThreadPool(); serverConfig = new MetricsTestConfig(); metricsListener = (CodahaleMetricsListener) serverConfig.metricsListener(); endpointMetricsHandler = (EndpointMetricsHandlerDefaultImpl) metricsListener.getEndpointMetricsHandler(); assertTrue(serverConfig.endpointsPort() > 0); logger.info("Dynamically chose server port {}", serverConfig.endpointsPort()); nonblockingEndpointUrl = "http://127.0.0.1:" + serverConfig.endpointsPort() + NON_BLOCKING_MATCHING_PATH; server = new Server(serverConfig); server.startup(); // Perform a "warmup" to get the Server ready to go - the first call is always slower than normal. List<Future<?>> warmupCalls = new ArrayList<>(); warmupCalls.add(sendServerRequest(nonblockingEndpointUrl)); for (Future f : warmupCalls) { f.get(); } }