Search in sources :

Example 1 with StatusHandler

use of com.yahoo.vespa.clustercontroller.core.status.StatusHandler in project vespa by vespa-engine.

the class StatusPagesTest method testStatusThroughContainer.

@Test
public void testStatusThroughContainer() throws Exception {
    startingTest("StatusPagesTest::testStatusThroughContainer()");
    FleetControllerOptions options = new FleetControllerOptions("mycluster");
    options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(3, 10)));
    final StatusHandler.ContainerStatusPageServer statusServer = new StatusHandler.ContainerStatusPageServer();
    setUpFleetController(true, options, true, statusServer);
    setUpVdsNodes(true, new DummyVdsNodeOptions());
    waitForStableSystem();
    // ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 100, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1000));
    // FleetControllerComponent fcComp = new FleetControllerComponent();
    // fcComp.addFleetController("mycluster", fleetController, statusServer);
    StatusHandler comp = new StatusHandler(new StatusHandler.ClusterStatusPageServerSet() {

        @Override
        public StatusHandler.ContainerStatusPageServer get(String cluster) {
            return ("mycluster".equals(cluster) ? statusServer : null);
        }

        @Override
        public Map<String, StatusHandler.ContainerStatusPageServer> getAll() {
            Map<String, StatusHandler.ContainerStatusPageServer> map = new HashMap<>();
            map.put("mycluster", statusServer);
            return map;
        }
    });
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertEquals("<title>clusters</title>\n<a href=\"./mycluster\">mycluster</a><br>\n", result.getContent().toString());
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertEquals("<title>clusters</title>\n<a href=\"./mycluster\">mycluster</a><br>\n", result.getContent().toString());
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/mycluster");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertTrue(result.toString(true), result.getContent().toString().contains("mycluster Cluster Controller 0 Status Page"));
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/mycluster/");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertTrue(result.toString(true), result.getContent().toString().contains("mycluster Cluster Controller 0 Status Page"));
        assertTrue(result.toString(true), result.getContent().toString().contains("href=\"mycluster/node=distributor.0\""));
        assertTrue(result.toString(true), result.getContent().toString().contains("href=\"mycluster/node=storage.0\""));
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/mycluster/node=storage.0");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 200, result.getHttpReturnCode());
        assertTrue(result.toString(true), result.getContent().toString().contains("Node status for storage.0"));
        assertTrue(result.toString(true), result.getContent().toString().contains("href=\"..\""));
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v1/foo");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 404, result.getHttpReturnCode());
    }
    {
        HttpRequest request = new HttpRequest().setPath("/foobar/v1/mycluster/");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 404, result.getHttpReturnCode());
    }
    {
        HttpRequest request = new HttpRequest().setPath("/clustercontroller-status/v2/");
        HttpResult result = comp.handleRequest(request);
        assertEquals(result.toString(true), 404, result.getHttpReturnCode());
    }
// executor.shutdown();
}
Also used : HttpRequest(com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest) StatusHandler(com.yahoo.vespa.clustercontroller.core.status.StatusHandler) Distribution(com.yahoo.vdslib.distribution.Distribution) HttpResult(com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Distribution (com.yahoo.vdslib.distribution.Distribution)1 StatusHandler (com.yahoo.vespa.clustercontroller.core.status.StatusHandler)1 HttpRequest (com.yahoo.vespa.clustercontroller.utils.communication.http.HttpRequest)1 HttpResult (com.yahoo.vespa.clustercontroller.utils.communication.http.HttpResult)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1