use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.
the class BookkeeperService method start.
@Override
public void start(final boolean wait) {
deleteApp("/pravega/bookkeeper");
log.info("Starting Bookkeeper Service: {}", getID());
try {
marathonClient.createApp(createBookieApp());
if (wait) {
waitUntilServiceRunning().get(5, TimeUnit.MINUTES);
}
} catch (MarathonException e) {
handleMarathonException(e);
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
throw new TestFrameworkException(InternalError, "Exception while " + "starting Bookkeeper Service", ex);
}
}
use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.
the class MarathonBasedService method isRunning.
@Override
public boolean isRunning() {
try {
GetAppResponse app = marathonClient.getApp(this.id);
log.debug("App Details: {}", app);
// and the state of application is healthy.
if ((app.getApp().getTasksRunning().intValue() == app.getApp().getInstances().intValue()) && app.getApp().getTasksRunning().intValue() == app.getApp().getTasksHealthy().intValue()) {
log.info("App {} is running", this.id);
return true;
} else {
log.info("App {} is not running", this.id);
return false;
}
} catch (MarathonException ex) {
if (ex.getStatus() == NOT_FOUND.getStatusCode()) {
log.info("App is not running : {}", this.id);
return false;
}
throw new TestFrameworkException(RequestFailed, "Marathon Exception while fetching service details", ex);
}
}
use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.
the class MarathonBasedService method deleteApp.
void deleteApp(final String appID) {
try {
Result result = marathonClient.deleteApp(appID);
log.info("App: {} deleted, Deployment id is: {}", appID, result.getDeploymentId());
waitUntilDeploymentPresent(result.getDeploymentId()).get();
} catch (MarathonException e) {
if (e.getStatus() == NOT_FOUND.getStatusCode()) {
log.debug("Application does not exist");
} else {
throw new TestFrameworkException(RequestFailed, "Marathon Exception while deleting service", e);
}
} catch (InterruptedException | ExecutionException e) {
throw new TestFrameworkException(InternalError, "Exception during deleteApp", e);
}
}
use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.
the class K8sClient method downloadLogs.
/**
* Download logs of the specified pod.
*
* @param fromPod Pod logs to be copied.
* @param toFile Destination file of the logs.
* @return A Future which completes once the download operation completes.
*/
public CompletableFuture<Void> downloadLogs(final V1Pod fromPod, final String toFile) {
final AtomicInteger retryCount = new AtomicInteger(0);
return Retry.withExpBackoff(LOG_DOWNLOAD_INIT_DELAY_MS, 10, LOG_DOWNLOAD_RETRY_COUNT, RETRY_MAX_DELAY_MS).retryingOn(TestFrameworkException.class).throwingOn(RuntimeException.class).runInExecutor(() -> {
final String podName = fromPod.getMetadata().getName();
log.debug("Download logs from pod {}", podName);
try {
@Cleanup InputStream logStream = logUtility.streamNamespacedPodLog(fromPod);
// On every retry this method attempts to download the complete pod logs from from K8s api-server. Due to the
// amount of logs for a pod and the K8s cluster configuration it can so happen that the K8s api-server can
// return truncated logs. Hence, every retry attempt does not overwrite the previously downloaded logs for
// the pod.
String logFile = toFile + "-" + retryCount.incrementAndGet() + ".log";
Files.copy(logStream, Paths.get(logFile));
log.info("Logs downloaded from pod {} to {}", podName, logFile);
} catch (ApiException | IOException e) {
log.warn("Retryable error while downloading logs from pod {}. Error message: {} ", podName, e.getMessage());
throw new TestFrameworkException(TestFrameworkException.Type.RequestFailed, "Error while downloading logs");
}
}, executor);
}
use of io.pravega.test.system.framework.TestFrameworkException in project pravega by pravega.
the class SingleJUnitTestRunner method runMethod.
public void runMethod() {
Method m = null;
try {
m = this.testClass.getDeclaredMethod(this.methodName);
Statement statement = methodBlock(new FrameworkMethod(m) {
@Override
public Object invokeExplosively(final Object target, final Object... params) throws Throwable {
try {
Object result = super.invokeExplosively(target, params);
log.info("Test " + methodName + " completed without error.");
return result;
} catch (Throwable t) {
log.error("Test " + methodName + " failed with exception. ", t);
throw t;
}
}
});
statement.evaluate();
} catch (Throwable ex) {
throw new TestFrameworkException(TestFrameworkException.Type.InternalError, "Exception while running test" + " method: " + this.methodName, ex);
}
}
Aggregations