Search in sources :

Example 1 with ServiceResponse

use of com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker.ServiceResponse in project vespa by vespa-engine.

the class ApplicationConvergenceCheckerTest method converge.

@Test
public void converge() throws IOException, SAXException {
    ApplicationConvergenceChecker checker = new ApplicationConvergenceChecker((client, serviceUri) -> () -> string2json("{\"config\":{\"generation\":3}}"));
    HttpResponse serviceListResponse = checker.serviceListToCheckForConfigConvergence(application, URI.create("http://foo:234/serviceconverge"));
    assertThat(serviceListResponse.getStatus(), is(200));
    assertEquals("{\"services\":[" + "{\"host\":\"localhost\"," + "\"port\":1337," + "\"type\":\"container\"," + "\"url\":\"http://foo:234/serviceconverge/localhost:1337\"}]," + "\"debug\":{\"wantedGeneration\":3}," + "\"url\":\"http://foo:234/serviceconverge\"}", SessionHandlerTest.getRenderedString(serviceListResponse));
    ServiceResponse serviceResponse = checker.serviceConvergenceCheck(application, "localhost:1337", URI.create("http://foo:234/serviceconverge/localhost:1337"));
    assertThat(serviceResponse.getStatus(), is(200));
    assertEquals("{" + "\"debug\":{" + "\"host\":\"localhost:1337\"," + "\"wantedGeneration\":3," + "\"currentGeneration\":3}," + "\"url\":\"http://foo:234/serviceconverge/localhost:1337\"," + "\"converged\":true}", SessionHandlerTest.getRenderedString(serviceResponse));
    ServiceResponse hostMissingResponse = checker.serviceConvergenceCheck(application, "notPresent:1337", URI.create("http://foo:234/serviceconverge/notPresent:1337"));
    assertThat(hostMissingResponse.getStatus(), is(410));
    assertEquals("{\"debug\":{" + "\"host\":\"notPresent:1337\"," + "\"wantedGeneration\":3," + "\"problem\":\"Host:port (service) no longer part of application, refetch list of services.\"}," + "\"url\":\"http://foo:234/serviceconverge/notPresent:1337\"}", SessionHandlerTest.getRenderedString(hostMissingResponse));
}
Also used : ServiceResponse(com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker.ServiceResponse) HttpResponse(com.yahoo.container.jdisc.HttpResponse) Test(org.junit.Test) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest)

Aggregations

HttpResponse (com.yahoo.container.jdisc.HttpResponse)1 ServiceResponse (com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker.ServiceResponse)1 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)1 Test (org.junit.Test)1