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);
}
}
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);
}
}
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;
}
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);
}
}
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);
}
}
Aggregations