@Override public void fireTestIgnored(Description description) { LoggingUtil.INSTANCE.warn("Test ignored"); runNotifier.fireTestIgnored(description); }
void pullImage(VirtualResource virtualResource, String image, String imageName, String imageTag, TestContext testContext) { RetryPolicy retryPolicy = new RetryPolicy() .retryOn(Throwable.class) .withBackoff(virtualResource.delay(), virtualResource.maxDelay(), virtualResource.unit()) .withMaxRetries(virtualResource.maxRetries()); Failsafe.with(retryPolicy) .onRetry(throwable -> LoggingUtil.INSTANCE.warn("Retrying pull request of image '{}'", image, throwable) ) .onFailure(throwable -> LoggingUtil.INSTANCE.error("Image image '{}' could not be pulled: ", image, throwable)) .run(() -> { try { CountDownLatch latch = new CountDownLatch(1); client.pullImageCmd(imageName) .withTag(imageTag) .exec(new PullCallback(virtualResource, latch)); ExceptionUtil.INSTANCE.raise(!latch.await(virtualResource.timeout(), virtualResource.unit()), "Could not start virtual resource '{}' for test '{}'", imageName, testContext.getName() ); } catch (InterruptedException e) { LoggingUtil.INSTANCE.warn("Image '{}' pull request interrupted", image); Thread.currentThread().interrupt(); } }); }
/** * Pull the given virtual resource. * * @param virtualResource the virtual resource * @param image the image */ void pullImage(VirtualResource virtualResource, String image) { RetryPolicy retryPolicy = new RetryPolicy() .retryOn(Throwable.class) .withDelay(virtualResource.delay(), virtualResource.unit()) .withMaxRetries(virtualResource.maxRetries()); Failsafe.with(retryPolicy) .onRetry(throwable -> LoggingUtil.INSTANCE.warn( "Retrying pull request of image '{}'", image, throwable)) .onFailure(throwable -> LoggingUtil.INSTANCE.error( "Image image '{}' could not be pulled: ", image, throwable)) .run(() -> client.pull(image, new AnsiProgressHandler())); }
void removeContainer(String containerId, VirtualResource virtualResource) { LoggingUtil.INSTANCE.info("Stopping and Removing Docker Container {}", containerId); if (client.inspectContainerCmd(containerId).exec().getState().getRunning()) { client.stopContainerCmd(containerId).exec(); try { client.waitContainerCmd(containerId) .exec(new WaitCallback(containerId)) .awaitCompletion(); } catch (InterruptedException e) { LoggingUtil.INSTANCE.warn("wating for container interrupted", e); Thread.currentThread().interrupt(); } } RetryPolicy retryPolicy = new RetryPolicy() .retryOn(Throwable.class) .withBackoff(virtualResource.delay(), virtualResource.maxDelay(), virtualResource.unit()) .withMaxRetries(virtualResource.maxRetries()) .withMaxDuration(8000, TimeUnit.MILLISECONDS); Failsafe.with(retryPolicy) .onRetry(throwable -> LoggingUtil.INSTANCE.debug("Trying to remove Docker Container {}", containerId, throwable)) .onSuccess(result -> { LoggingUtil.INSTANCE.info("Docker Container '{}' Removed", containerId); client.removeVolumeCmd(containerId).exec(); }) .onFailure(throwable -> LoggingUtil.INSTANCE.error("Docker Container '{}' could not be removed", containerId, throwable)) .run(() -> client.removeContainerCmd(containerId).exec()); }