public void stopContainer(@Observes AfterConversion afterConversion) { if (this.flv2mp4 != null) { try { flv2mp4.stop(); flv2mp4.destroy(); } catch (CubeControlException e) { Logger.getLogger(VideoConversionLifecycleManager.class.getName()).log(Level.WARNING, "Failed to stop flv2mp4", e); } } } }
public void stopContainer(@Observes AfterConversion afterConversion) { if (this.flv2mp4 != null) { flv2mp4.stop(); flv2mp4.destroy(); } } }
public void attachShutDownHookForceStopDockerContainers(@Observes(precedence = 200) BeforeSuite event, final CubeRegistry cubeRegistry) { Runtime.getRuntime().addShutdownHook(new Thread(() -> { final List<Cube<?>> cubes = cubeRegistry.getCubes(); for (Cube cube : cubes) { try { cube.stop(); } catch (final Throwable e) { Logger.getLogger(ForceStopDockerContainersShutdownHook.class.getName()).log(Level.WARNING, "Failed to stop container: " + cube.getId(), e); } finally { try { cube.destroy(); } catch (final Throwable ignore) { //no-op } } } })); } }
public void attachShutDownHookForceStopDockerContainers(@Observes(precedence = 200) BeforeSuite event, final CubeRegistry cubeRegistry) { Runtime.getRuntime().addShutdownHook(new Thread(() -> { final List<Cube<?>> cubes = cubeRegistry.getCubes(); for (Cube cube : cubes) { try { cube.stop(); } catch (final Throwable e) { Logger.getLogger(ForceStopDockerContainersShutdownHook.class.getName()).log(Level.WARNING, "Failed to stop container: " + cube.getId(), e); } finally { try { cube.destroy(); } catch (final Throwable ignore) { //no-op } } } })); } }
public void destroy(@Observes DestroyCube event, CubeRegistry registry) { validateAndGet(registry, event.getCubeId()).destroy(); }
public void destroy(@Observes DestroyCube event, CubeRegistry registry) { validateAndGet(registry, event.getCubeId()).destroy(); }
@Test public void shouldDestroyCube() { fire(new DestroyCube(CUBE_ID)); verify(cube).destroy(); }
public void stopRecording(@Observes After afterTestMethod, TestResult testResult, CubeDroneConfiguration cubeDroneConfiguration, SeleniumContainers seleniumContainers) { try { if (this.vnc != null) { vnc.stop(); Path finalLocation = null; if (shouldRecordOnlyOnFailure(testResult, cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } else { if (shouldRecordAlways(cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } } vnc.destroy(); this.afterVideoRecordedEvent.fire(new AfterVideoRecorded(afterTestMethod, finalLocation)); } } catch (CubeControlException e) { Logger.getLogger(VncRecorderLifecycleManager.class.getName()).log(Level.WARNING, "Failed to stop vnc", e); } }
@Test public void should_stop_vnc_by_default() throws IOException, NoSuchMethodException { final File destination = temporaryFolder.newFolder("destination"); final File video = temporaryFolder.newFile("file.flv"); when(seleniumContainers.getVideoRecordingFile()).thenReturn(video.toPath()); when(after.getTestClass()).thenReturn(new TestClass(VncRecorderLifecycleManagerTest.class)); when(after.getTestMethod()).thenReturn( VncRecorderLifecycleManagerTest.class.getMethod("should_stop_vnc_by_default")); Map<String, String> conf = new HashMap<>(); conf.put("videoOutput", destination.getAbsolutePath()); TestResult testResult = TestResult.passed(); VncRecorderLifecycleManager vncRecorderLifecycleManager = new VncRecorderLifecycleManager(); vncRecorderLifecycleManager.vnc = cube; vncRecorderLifecycleManager.afterVideoRecordedEvent = event; vncRecorderLifecycleManager.stopRecording(after, testResult, CubeDroneConfiguration.fromMap(conf), seleniumContainers ); verify(cube).stop(); verify(cube).destroy(); }
public void stopRecording(@Observes After afterTestMethod, TestResult testResult, CubeDroneConfiguration cubeDroneConfiguration, SeleniumContainers seleniumContainers) { if (this.vnc != null) { vnc.stop(); Path finalLocation = null; if (shouldRecordOnlyOnFailure(testResult, cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } else { if (shouldRecordAlways(cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } } vnc.destroy(); this.afterVideoRecordedEvent.fire(new AfterVideoRecorded(afterTestMethod, finalLocation)); } }