Search in sources :

Example 1 with BatchOperationResult

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

the class HostResourceTest method returns_200_empty_batch.

@Test
public void returns_200_empty_batch() {
    HostSuspensionResource hostSuspensionResource = new HostSuspensionResource(alwaysAllowOrchestrator);
    BatchOperationResult response = hostSuspensionResource.suspendAll("parentHostname", Collections.emptyList());
    ;
    assertThat(response.success());
}
Also used : BatchOperationResult(com.yahoo.vespa.orchestrator.restapi.wire.BatchOperationResult) Test(org.junit.Test)

Example 2 with BatchOperationResult

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

the class HostResourceTest method returns_200_on_success_batch.

@Test
public void returns_200_on_success_batch() {
    HostSuspensionResource hostSuspensionResource = new HostSuspensionResource(alwaysAllowOrchestrator);
    BatchOperationResult response = hostSuspensionResource.suspendAll("parentHostname", Arrays.asList("hostname1", "hostname2"));
    assertThat(response.success());
}
Also used : BatchOperationResult(com.yahoo.vespa.orchestrator.restapi.wire.BatchOperationResult) Test(org.junit.Test)

Example 3 with BatchOperationResult

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

the class OrchestratorImplTest method testBatchSuspendCallWithFailureReason.

@Test(expected = OrchestratorException.class)
public void testBatchSuspendCallWithFailureReason() {
    String parentHostName = "host1.test.yahoo.com";
    List<String> hostNames = Arrays.asList("a1.host1.test.yahoo.com", "a2.host1.test.yahoo.com");
    String failureReason = "Failed to suspend";
    when(configServerApi.put("/orchestrator/v1/suspensions/hosts/host1.test.yahoo.com?hostname=a1.host1.test.yahoo.com&hostname=a2.host1.test.yahoo.com", Optional.empty(), BatchOperationResult.class)).thenReturn(new BatchOperationResult(failureReason));
    orchestrator.suspend(parentHostName, hostNames);
}
Also used : BatchOperationResult(com.yahoo.vespa.orchestrator.restapi.wire.BatchOperationResult) Test(org.junit.Test)

Example 4 with BatchOperationResult

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

the class OrchestratorImpl method suspend.

@Override
public void suspend(String parentHostName, List<String> hostNames) {
    final BatchOperationResult batchOperationResult;
    try {
        String params = String.join("&hostname=", hostNames);
        String url = String.format("%s/%s?hostname=%s", ORCHESTRATOR_PATH_PREFIX_HOST_SUSPENSION_API, parentHostName, params);
        batchOperationResult = configServerApi.put(url, Optional.empty(), BatchOperationResult.class);
    } catch (HttpException e) {
        throw new OrchestratorException("Failed to batch suspend for " + parentHostName + ": " + e.toString());
    } catch (Exception e) {
        throw new RuntimeException("Got error on batch suspend for " + parentHostName + ", with nodes " + hostNames, e);
    }
    batchOperationResult.getFailureReason().ifPresent(reason -> {
        throw new OrchestratorException(reason);
    });
}
Also used : HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) BatchOperationResult(com.yahoo.vespa.orchestrator.restapi.wire.BatchOperationResult) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException)

Aggregations

BatchOperationResult (com.yahoo.vespa.orchestrator.restapi.wire.BatchOperationResult)4 Test (org.junit.Test)3 HttpException (com.yahoo.vespa.hosted.node.admin.configserver.HttpException)1