Search in sources :

Example 56 with DockerClient

use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.

the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainersCategory.

@Test
public void shouldRetrieveConnectionFromSelectedContainersCategory() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    final SWTBotTreeItem containers = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers");
    // when selecting the container
    containers.select();
    // then current connection should be found
    Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 57 with DockerClient

use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.

the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainerVolumesCategory.

@Test
public void shouldRetrieveConnectionFromSelectedContainerVolumesCategory() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.volume("/path/to/host:/path/to/container:Z,ro").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    final SWTBotTreeItem volumes = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Volumes");
    volumes.select();
    // then current connection should be found
    Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 58 with DockerClient

use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.

the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainerLink.

@Test
public void shouldRetrieveConnectionFromSelectedContainerLink() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.link("/foo:/bar/foo").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    final SWTBotTreeItem link = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Links", "foo (foo)");
    // when selecting the Link
    link.select();
    // then current connection should be found
    Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 59 with DockerClient

use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.

the class BuildDockerImageShortcutSWTBotTest method shouldPromptForAnotherConnectionWhenBuildingDockerImageOnSecondCallAfterConnectionWasReplaced.

@RunWithProject("foo")
public void shouldPromptForAnotherConnectionWhenBuildingDockerImageOnSecondCallAfterConnectionWasReplaced() throws InterruptedException, com.spotify.docker.client.exceptions.DockerException, IOException {
    // given
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when
    SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
    // then expect a dialog, fill the "repository" text field and click "Ok"
    assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
    bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
    // when launching the build
    SWTUtils.syncExec(() -> {
        bot.button("OK").click();
    });
    // then the 'DockerConnection#buildImage(...) method should have been
    // called within the specified timeout
    Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(3)).times(1)).build(Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class), Matchers.anyVararg());
    // when trying to call again after connection was replaced, there should
    // be an error dialog
    final DockerConnection dockerConnection2 = MockDockerConnectionFactory.from("Test 2", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection2);
    SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
    // then expect a dialog, fill the "repository" text field and click "Ok"
    assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
    bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
    // when launching the build
    SWTUtils.syncExec(() -> {
        bot.button("OK").click();
    });
    // then the 'DockerConnection#buildImage(...) method should have been
    // called within the specified timeout
    Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(3)).times(2)).build(Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class), Matchers.anyVararg());
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Path(java.nio.file.Path) DockerClient(com.spotify.docker.client.DockerClient) ProgressHandler(com.spotify.docker.client.ProgressHandler) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 60 with DockerClient

use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.

the class BuildDockerImageShortcutSWTBotTest method shouldNotBuildDockerImageOnSecondCallWhenAllConnectionWereRemoved.

@Test
@RunWithProject("foo")
public void shouldNotBuildDockerImageOnSecondCallWhenAllConnectionWereRemoved() throws InterruptedException, com.spotify.docker.client.exceptions.DockerException, IOException {
    // given
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when
    SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
    // then expect a dialog, fill the "repository" text field and click "Ok"
    assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
    bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
    // when launching the build
    SWTUtils.syncExec(() -> {
        bot.button("OK").click();
    });
    // then the 'DockerConnection#buildImage(...) method should have been
    // called within the specified timeout
    Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(30)).times(1)).build(Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class), Matchers.anyVararg());
    // when trying to call again after connection was removed, there should
    // be an error dialog
    DockerConnectionManager.getInstance().removeConnection(dockerConnection);
    SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click(), false);
    final SWTBotShell shell = bot.shell("Edit Configuration");
    assertThat(shell).isNotNull();
    assertThat(shell.bot().button("Run").isEnabled()).isFalse();
    // closing the wizard
    SWTUtils.asyncExec(() -> {
        shell.bot().button(IDialogConstants.CLOSE_LABEL).click();
    }, false);
    // do not save the config while closing
    SWTUtils.syncExec(() -> {
        bot.button(IDialogConstants.NO_LABEL).click();
    });
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Path(java.nio.file.Path) DockerClient(com.spotify.docker.client.DockerClient) ProgressHandler(com.spotify.docker.client.ProgressHandler) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Aggregations

DockerClient (com.spotify.docker.client.DockerClient)185 Test (org.junit.Test)102 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)75 DefaultDockerClient (com.spotify.docker.client.DefaultDockerClient)38 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)20 JobId (com.spotify.helios.common.descriptors.JobId)19 DockerException (com.spotify.docker.client.exceptions.DockerException)18 TaskStatus (com.spotify.helios.common.descriptors.TaskStatus)18 LogStream (com.spotify.docker.client.LogStream)17 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)15 Container (com.spotify.docker.client.messages.Container)14 Path (java.nio.file.Path)12 DockerException (org.eclipse.linuxtools.docker.core.DockerException)12 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)12 Matchers.containsString (org.hamcrest.Matchers.containsString)11 HostConfig (com.spotify.docker.client.messages.HostConfig)10 HeliosClient (com.spotify.helios.client.HeliosClient)10 ContainerConfig (com.spotify.docker.client.messages.ContainerConfig)9 ContainerInfo (com.spotify.docker.client.messages.ContainerInfo)9 RunWithProject (org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)9