use of com.wavefront.sdk.entities.tracing.sampling.RateSampler in project java by wavefrontHQ.
the class PushAgentTest method testHealthCheckAdminPorts.
@Test
public void testHealthCheckAdminPorts() throws Exception {
port = findAvailablePort(2888);
int port2 = findAvailablePort(3888);
int port3 = findAvailablePort(4888);
int port4 = findAvailablePort(5888);
int adminPort = findAvailablePort(6888);
proxy.proxyConfig.pushListenerPorts = port + "," + port2 + "," + port3 + "," + port4;
proxy.proxyConfig.adminApiListenerPort = adminPort;
proxy.proxyConfig.httpHealthCheckPath = "/health";
proxy.proxyConfig.httpHealthCheckAllPorts = true;
proxy.proxyConfig.httpHealthCheckFailStatusCode = 403;
proxy.healthCheckManager = new HealthCheckManagerImpl(proxy.proxyConfig);
SpanSampler sampler = new SpanSampler(new RateSampler(1.0D), () -> null);
proxy.startGraphiteListener(String.valueOf(port), mockHandlerFactory, null, sampler);
proxy.startGraphiteListener(String.valueOf(port2), mockHandlerFactory, null, sampler);
proxy.startGraphiteListener(String.valueOf(port3), mockHandlerFactory, null, sampler);
proxy.startGraphiteListener(String.valueOf(port4), mockHandlerFactory, null, sampler);
proxy.startAdminListener(adminPort);
waitUntilListenerIsOnline(adminPort);
assertEquals(404, httpGet("http://localhost:" + adminPort + "/"));
assertEquals(200, httpGet("http://localhost:" + port + "/health"));
assertEquals(200, httpGet("http://localhost:" + port2 + "/health"));
assertEquals(200, httpGet("http://localhost:" + port3 + "/health"));
assertEquals(200, httpGet("http://localhost:" + port4 + "/health"));
assertEquals(202, httpGet("http://localhost:" + port + "/health2"));
assertEquals(400, httpGet("http://localhost:" + adminPort + "/status"));
assertEquals(405, httpPost("http://localhost:" + adminPort + "/status", ""));
assertEquals(404, httpGet("http://localhost:" + adminPort + "/status/somethingelse"));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port2));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port3));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port4));
assertEquals(405, httpGet("http://localhost:" + adminPort + "/disable"));
assertEquals(405, httpGet("http://localhost:" + adminPort + "/enable"));
assertEquals(405, httpGet("http://localhost:" + adminPort + "/disable/" + port));
assertEquals(405, httpGet("http://localhost:" + adminPort + "/enable/" + port));
// disabling port and port3
assertEquals(200, httpPost("http://localhost:" + adminPort + "/disable/" + port, ""));
assertEquals(200, httpPost("http://localhost:" + adminPort + "/disable/" + port3, ""));
assertEquals(503, httpGet("http://localhost:" + adminPort + "/status/" + port));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port2));
assertEquals(503, httpGet("http://localhost:" + adminPort + "/status/" + port3));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port4));
assertEquals(403, httpGet("http://localhost:" + port + "/health"));
assertEquals(200, httpGet("http://localhost:" + port2 + "/health"));
assertEquals(403, httpGet("http://localhost:" + port3 + "/health"));
assertEquals(200, httpGet("http://localhost:" + port4 + "/health"));
// disable all
assertEquals(200, httpPost("http://localhost:" + adminPort + "/disable", ""));
assertEquals(503, httpGet("http://localhost:" + adminPort + "/status/" + port));
assertEquals(503, httpGet("http://localhost:" + adminPort + "/status/" + port2));
assertEquals(503, httpGet("http://localhost:" + adminPort + "/status/" + port3));
assertEquals(503, httpGet("http://localhost:" + adminPort + "/status/" + port4));
assertEquals(403, httpGet("http://localhost:" + port + "/health"));
assertEquals(403, httpGet("http://localhost:" + port2 + "/health"));
assertEquals(403, httpGet("http://localhost:" + port3 + "/health"));
assertEquals(403, httpGet("http://localhost:" + port4 + "/health"));
// enable port3 and port4
assertEquals(200, httpPost("http://localhost:" + adminPort + "/enable/" + port3, ""));
assertEquals(200, httpPost("http://localhost:" + adminPort + "/enable/" + port4, ""));
assertEquals(503, httpGet("http://localhost:" + adminPort + "/status/" + port));
assertEquals(503, httpGet("http://localhost:" + adminPort + "/status/" + port2));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port3));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port4));
assertEquals(403, httpGet("http://localhost:" + port + "/health"));
assertEquals(403, httpGet("http://localhost:" + port2 + "/health"));
assertEquals(200, httpGet("http://localhost:" + port3 + "/health"));
assertEquals(200, httpGet("http://localhost:" + port4 + "/health"));
// enable all
// enable port3 and port4
assertEquals(200, httpPost("http://localhost:" + adminPort + "/enable", ""));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port2));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port3));
assertEquals(200, httpGet("http://localhost:" + adminPort + "/status/" + port4));
assertEquals(200, httpGet("http://localhost:" + port + "/health"));
assertEquals(200, httpGet("http://localhost:" + port2 + "/health"));
assertEquals(200, httpGet("http://localhost:" + port3 + "/health"));
assertEquals(200, httpGet("http://localhost:" + port4 + "/health"));
}
Aggregations