Search in sources :

Example 6 with WatchContext

use of org.eclipse.jkube.kit.build.service.docker.watch.WatchContext in project jkube by eclipse.

the class WatchServiceTest method testCopyFilesToContainer.

@Test
public void testCopyFilesToContainer() throws Exception {
    // Given
    AtomicBoolean fileCopied = new AtomicBoolean(false);
    WatchContext watchContext = WatchContext.builder().watchMode(WatchMode.copy).containerCopyTask(f -> fileCopied.compareAndSet(false, true)).build();
    File fileToCopy = Files.createTempFile("test-changed-files", "tar").toFile();
    WatchService.ImageWatcher imageWatcher = new WatchService.ImageWatcher(imageConfiguration, watchContext, "test-img", "efe1234");
    WatchService watchService = new WatchService(archiveService, buildService, queryService, runService, logger);
    // When
    watchService.copyFilesToContainer(fileToCopy, imageWatcher);
    // Then
    assertTrue(fileCopied.get());
}
Also used : WatchMode(org.eclipse.jkube.kit.config.image.WatchMode) Files(java.nio.file.Files) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) WatchContext(org.eclipse.jkube.kit.build.service.docker.watch.WatchContext) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AtomicReference(java.util.concurrent.atomic.AtomicReference) File(java.io.File) WatchImageConfiguration(org.eclipse.jkube.kit.config.image.WatchImageConfiguration) KitLogger(org.eclipse.jkube.kit.common.KitLogger) Mocked(mockit.Mocked) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) File(java.io.File) WatchContext(org.eclipse.jkube.kit.build.service.docker.watch.WatchContext) Test(org.junit.Test)

Example 7 with WatchContext

use of org.eclipse.jkube.kit.build.service.docker.watch.WatchContext in project jkube by eclipse.

the class WatchServiceTest method testCallPostExec.

@Test
public void testCallPostExec() throws Exception {
    // Given
    AtomicBoolean postExecCommandExecuted = new AtomicBoolean(false);
    WatchContext watchContext = WatchContext.builder().watchMode(WatchMode.copy).containerCommandExecutor(imageWatcher -> {
        postExecCommandExecuted.set(true);
        return "Some Output";
    }).build();
    WatchService.ImageWatcher imageWatcher = new WatchService.ImageWatcher(imageConfiguration, watchContext, "test-img", "efe1234");
    WatchService watchService = new WatchService(archiveService, buildService, queryService, runService, logger);
    // When
    watchService.callPostExec(imageWatcher);
    // Then
    assertTrue(postExecCommandExecuted.get());
}
Also used : WatchMode(org.eclipse.jkube.kit.config.image.WatchMode) Files(java.nio.file.Files) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) WatchContext(org.eclipse.jkube.kit.build.service.docker.watch.WatchContext) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AtomicReference(java.util.concurrent.atomic.AtomicReference) File(java.io.File) WatchImageConfiguration(org.eclipse.jkube.kit.config.image.WatchImageConfiguration) KitLogger(org.eclipse.jkube.kit.common.KitLogger) Mocked(mockit.Mocked) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WatchContext(org.eclipse.jkube.kit.build.service.docker.watch.WatchContext) Test(org.junit.Test)

Aggregations

WatchContext (org.eclipse.jkube.kit.build.service.docker.watch.WatchContext)7 File (java.io.File)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 KitLogger (org.eclipse.jkube.kit.common.KitLogger)4 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)4 Before (org.junit.Before)4 Test (org.junit.Test)4 Files (java.nio.file.Files)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Mocked (mockit.Mocked)3 WatchImageConfiguration (org.eclipse.jkube.kit.config.image.WatchImageConfiguration)3 WatchMode (org.eclipse.jkube.kit.config.image.WatchMode)3 Assert.assertEquals (org.junit.Assert.assertEquals)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 IOException (java.io.IOException)2 List (java.util.List)2 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)2 Container (io.fabric8.kubernetes.api.model.Container)1 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)1 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)1