Search in sources :

Example 6 with TestFrameworkException

use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.

the class DockerBasedService method stop.

@Override
public void stop() {
    try {
        Service.Criteria criteria = Service.Criteria.builder().serviceName(this.serviceName).build();
        List<Service> serviceList = Exceptions.handleInterruptedCall(() -> dockerClient.listServices(criteria));
        for (int i = 0; i < serviceList.size(); i++) {
            String serviceId = serviceList.get(i).id();
            Exceptions.handleInterrupted(() -> dockerClient.removeService(serviceId));
        }
    } catch (DockerException e) {
        throw new TestFrameworkException(TestFrameworkException.Type.RequestFailed, "Unable to remove service.", e);
    }
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Service(com.spotify.docker.client.messages.swarm.Service)

Example 7 with TestFrameworkException

use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.

the class DockerBasedService method scaleService.

@Override
public CompletableFuture<Void> scaleService(final int instanceCount) {
    try {
        Preconditions.checkArgument(instanceCount >= 0, "negative value: %s", instanceCount);
        Service.Criteria criteria = Service.Criteria.builder().serviceName(this.serviceName).build();
        TaskSpec taskSpec = Exceptions.handleInterruptedCall(() -> dockerClient.listServices(criteria).get(0).spec().taskTemplate());
        String serviceId = getServiceID();
        EndpointSpec endpointSpec = Exceptions.handleInterruptedCall(() -> dockerClient.inspectService(serviceId).spec().endpointSpec());
        Service service = Exceptions.handleInterruptedCall(() -> dockerClient.inspectService(serviceId));
        Exceptions.handleInterrupted(() -> dockerClient.updateService(serviceId, service.version().index(), ServiceSpec.builder().endpointSpec(endpointSpec).mode(ServiceMode.withReplicas(instanceCount)).taskTemplate(taskSpec).name(serviceName).networks(service.spec().networks()).build()));
        return Exceptions.handleInterruptedCall(() -> waitUntilServiceRunning());
    } catch (DockerException e) {
        throw new TestFrameworkException(TestFrameworkException.Type.RequestFailed, "Test failure: Unable to scale service to given instances=" + instanceCount, e);
    }
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) TaskSpec(com.spotify.docker.client.messages.swarm.TaskSpec) EndpointSpec(com.spotify.docker.client.messages.swarm.EndpointSpec) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Service(com.spotify.docker.client.messages.swarm.Service)

Example 8 with TestFrameworkException

use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.

the class DockerBasedService method getID.

@Override
public String getID() {
    Service.Criteria criteria = Service.Criteria.builder().serviceName(this.serviceName).build();
    String serviceId = null;
    try {
        List<Service> serviceList = Exceptions.handleInterrupted(() -> dockerClient.listServices(criteria));
        serviceId = serviceList.get(0).id();
    } catch (DockerException e) {
        throw new TestFrameworkException(TestFrameworkException.Type.RequestFailed, "Unable to get service id", e);
    }
    return serviceId;
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Service(com.spotify.docker.client.messages.swarm.Service)

Example 9 with TestFrameworkException

use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.

the class PravegaControllerService method start.

/**
 * Start the controller service.
 *
 * @param wait boolean to wait until service is running
 */
@Override
public void start(final boolean wait) {
    deleteApp("/pravega/controller");
    log.debug("Starting service: {}", getID());
    try {
        marathonClient.createApp(createPravegaControllerApp());
        if (wait) {
            waitUntilServiceRunning().get(10, TimeUnit.MINUTES);
        }
    } catch (MarathonException e) {
        handleMarathonException(e);
    } catch (InterruptedException | ExecutionException | TimeoutException ex) {
        throw new TestFrameworkException(InternalError, "Exception while " + "starting Pravega Controller Service", ex);
    }
}
Also used : TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) MarathonException(mesosphere.marathon.client.MarathonException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 10 with TestFrameworkException

use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.

the class ZookeeperService method start.

@Override
public void start(final boolean wait) {
    deleteApp("/pravega/exhibitor");
    log.info("Starting Zookeeper Service: {}", getID());
    try {
        marathonClient.createApp(createZookeeperApp());
        if (wait) {
            waitUntilServiceRunning().get(10, TimeUnit.MINUTES);
        }
    } catch (MarathonException e) {
        handleMarathonException(e);
    } catch (InterruptedException | ExecutionException | TimeoutException ex) {
        throw new TestFrameworkException(InternalError, "Exception while " + "starting Zookeeper Service", ex);
    }
}
Also used : TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) MarathonException(mesosphere.marathon.client.MarathonException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

TestFrameworkException (io.pravega.test.system.framework.TestFrameworkException)16 MarathonException (mesosphere.marathon.client.MarathonException)7 DockerException (com.spotify.docker.client.exceptions.DockerException)6 Service (com.spotify.docker.client.messages.swarm.Service)5 ExecutionException (java.util.concurrent.ExecutionException)5 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)5 TimeoutException (java.util.concurrent.TimeoutException)4 IOException (java.io.IOException)2 ServiceCreateResponse (com.spotify.docker.client.messages.ServiceCreateResponse)1 EndpointSpec (com.spotify.docker.client.messages.swarm.EndpointSpec)1 TaskSpec (com.spotify.docker.client.messages.swarm.TaskSpec)1 ApiClient (io.kubernetes.client.openapi.ApiClient)1 ApiException (io.kubernetes.client.openapi.ApiException)1 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Cleanup (lombok.Cleanup)1 App (mesosphere.marathon.client.model.v2.App)1 GetAppResponse (mesosphere.marathon.client.model.v2.GetAppResponse)1 Result (mesosphere.marathon.client.model.v2.Result)1