Search in sources :

Example 36 with RateSampler

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"));
}
Also used : RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) SpanSampler(com.wavefront.agent.sampler.SpanSampler) HealthCheckManagerImpl(com.wavefront.agent.channel.HealthCheckManagerImpl) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Aggregations

SpanSampler (com.wavefront.agent.sampler.SpanSampler)36 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)36 Test (org.junit.Test)35 Annotation (wavefront.report.Annotation)23 EasyMock.anyString (org.easymock.EasyMock.anyString)13 Span (wavefront.report.Span)12 Socket (java.net.Socket)10 Batch (io.jaegertracing.thriftjava.Batch)9 Process (io.jaegertracing.thriftjava.Process)9 BufferedOutputStream (java.io.BufferedOutputStream)9 ByteString (com.google.protobuf.ByteString)8 Tag (io.jaegertracing.thriftjava.Tag)8 Collector (io.opentelemetry.exporters.jaeger.proto.api_v2.Collector)8 Model (io.opentelemetry.exporters.jaeger.proto.api_v2.Model)8 ByteBuffer (java.nio.ByteBuffer)8 Collector (io.jaegertracing.thriftjava.Collector)7 ReportPoint (wavefront.report.ReportPoint)7 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)5 ByteBuf (io.netty.buffer.ByteBuf)5 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)5