Search in sources :

Example 1 with UpdateHostResponse

use of com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse in project vespa by vespa-engine.

the class HostResourceTest method returns_200_on_success.

@Test
public void returns_200_on_success() {
    HostResource hostResource = new HostResource(alwaysAllowOrchestrator, uriInfo);
    final String hostName = "hostname";
    UpdateHostResponse response = hostResource.suspend(hostName);
    assertThat(response.hostname()).isEqualTo(hostName);
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) Test(org.junit.Test)

Example 2 with UpdateHostResponse

use of com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse in project vespa by vespa-engine.

the class HostResource method webExceptionWithDenialReason.

private static WebApplicationException webExceptionWithDenialReason(String operationDescription, HostName hostName, HostStateChangeDeniedException e) {
    HostStateChangeDenialReason hostStateChangeDenialReason = new HostStateChangeDenialReason(e.getConstraintName(), operationDescription + " failed: " + e.getMessage());
    UpdateHostResponse response = new UpdateHostResponse(hostName.s(), hostStateChangeDenialReason);
    return new WebApplicationException(hostStateChangeDenialReason.toString(), e, Response.status(Response.Status.CONFLICT).entity(response).type(MediaType.APPLICATION_JSON_TYPE).build());
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) WebApplicationException(javax.ws.rs.WebApplicationException) HostStateChangeDenialReason(com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason)

Example 3 with UpdateHostResponse

use of com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse in project vespa by vespa-engine.

the class OrchestratorImplTest method testResumeCall.

@Test
public void testResumeCall() {
    when(configServerApi.delete(OrchestratorImpl.ORCHESTRATOR_PATH_PREFIX_HOST_API + "/" + hostName + "/suspended", UpdateHostResponse.class)).thenReturn(new UpdateHostResponse(hostName, null));
    orchestrator.resume(hostName);
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) Test(org.junit.Test)

Example 4 with UpdateHostResponse

use of com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse in project vespa by vespa-engine.

the class OrchestratorImplTest method testSuspendCallWithFailureReason.

@Test(expected = OrchestratorException.class)
public void testSuspendCallWithFailureReason() {
    when(configServerApi.put(OrchestratorImpl.ORCHESTRATOR_PATH_PREFIX_HOST_API + "/" + hostName + "/suspended", Optional.empty(), UpdateHostResponse.class)).thenReturn(new UpdateHostResponse(hostName, new HostStateChangeDenialReason("hostname", "fail")));
    orchestrator.suspend(hostName);
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HostStateChangeDenialReason(com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason) Test(org.junit.Test)

Example 5 with UpdateHostResponse

use of com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse in project vespa by vespa-engine.

the class OrchestratorImplTest method testSuspendCall.

@Test
public void testSuspendCall() {
    when(configServerApi.put(OrchestratorImpl.ORCHESTRATOR_PATH_PREFIX_HOST_API + "/" + hostName + "/suspended", Optional.empty(), UpdateHostResponse.class)).thenReturn(new UpdateHostResponse(hostName, null));
    orchestrator.suspend(hostName);
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) Test(org.junit.Test)

Aggregations

UpdateHostResponse (com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse)8 Test (org.junit.Test)5 HostStateChangeDenialReason (com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason)3 HttpException (com.yahoo.vespa.hosted.node.admin.configserver.HttpException)2 WebApplicationException (javax.ws.rs.WebApplicationException)1