Search in sources :

Example 61 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class BuildDockerImageShortcutSWTBotTest method shouldPromptDialogThenBuildDockerImageOnFirstCall.

@Test
@RunWithProject("foo")
public void shouldPromptDialogThenBuildDockerImageOnFirstCall() 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());
}
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) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 62 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class DockerComposeSWTBotTest method shouldStartDockerComposeWithExistingLaunchConfiguration.

@Test
@RunWithProject("foo")
public void shouldStartDockerComposeWithExistingLaunchConfiguration() throws CoreException {
    // given
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    final IFile dockerComposeScript = projectInit.getProject().getFile("docker-compose.yml");
    LaunchConfigurationUtils.createDockerComposeUpLaunchConfiguration(dockerConnection, dockerComposeScript);
    // when
    SWTUtils.asyncExec(() -> getRunAsDockerComposeContextMenu("foo", "docker-compose.yml").click());
    // then confirm the connection
    final SWTBotToolbarButton consoleToolbarStopButton = SWTUtils.getConsoleToolbarButtonWithTooltipText(bot, ConsoleMessages.getString("DockerComposeStopAction.tooltip"));
    ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isEnabled();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) IFile(org.eclipse.core.resources.IFile) DockerClient(com.spotify.docker.client.DockerClient) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 63 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class DockerComposeSWTBotTest method shouldStartDockerComposeFromScratch.

@Test
@RunWithProject("foo")
public void shouldStartDockerComposeFromScratch() throws CoreException {
    // given
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when
    SWTUtils.asyncExec(() -> getRunAsDockerComposeContextMenu("foo", "docker-compose.yml").click());
    // then confirm the connection
    bot.button("OK").click();
    // wait for the job to run
    SWTUtils.waitForJobsToComplete();
    // then expect the console to be displayed
    assertThat(SWTUtils.isConsoleViewVisible(this.bot)).isTrue();
    // expect the 'stop' button to be enabled
    final SWTBotToolbarButton consoleToolbarStopButton = SWTUtils.getConsoleToolbarButtonWithTooltipText(bot, ConsoleMessages.getString("DockerComposeStopAction.tooltip"));
    ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isEnabled();
    // verify that the launch configuration was saved
    final ILaunchConfiguration launchConfiguration = LaunchConfigurationUtils.getLaunchConfigurationByName(IDockerComposeLaunchConfigurationConstants.CONFIG_TYPE_ID, "Docker Compose [foo]");
    assertThat(launchConfiguration).isNotNull();
    // verify the latch
    assertThat(latch.getCount()).isEqualTo(1);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) DockerClient(com.spotify.docker.client.DockerClient) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 64 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class DockerComposeSWTBotTest method shouldRestartDockerCompose.

@Test
@RunWithProject("foo")
public void shouldRestartDockerCompose() throws InterruptedException, DockerException {
    // given
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when starting without launch config
    SWTUtils.asyncExec(() -> getRunAsDockerComposeContextMenu("foo", "docker-compose.yml").click());
    bot.button("OK").click();
    // wait for the job to run
    SWTUtils.waitForJobsToComplete();
    // when stopping
    final SWTBotToolbarButton consoleToolbarStopButton = SWTUtils.getConsoleToolbarButtonWithTooltipText(bot, ConsoleMessages.getString("DockerComposeStopAction.tooltip"));
    ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isEnabled();
    consoleToolbarStopButton.click();
    // redo the setup to get a new mock process
    setupMockedProcessLauncher();
    // when restarting
    SWTUtils.asyncExec(() -> getRunAsDockerComposeContextMenu("foo", "docker-compose.yml").click());
    // wait for the job to run
    SWTUtils.waitForJobsToComplete();
    // then
    ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isEnabled();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 65 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class VariablesTest method setUpForMockito.

private void setUpForMockito() throws DockerException, InterruptedException {
    // images to use
    final Image image = MockImageFactory.id("1a2b3c4d5e6f7g").name(IMAGE_UHTTPD + ":" + IMAGE_TAG_LATEST).build();
    final ImageInfo imageInfo = MockImageInfoFactory.volume("/foo/bar").command(Arrays.asList("the", "command")).entrypoint(Arrays.asList("the", "entrypoint")).env(Arrays.asList("FOO", "barbarbar")).build();
    // container to be created
    this.createdContainer = MockContainerFactory.id("1MockContainer").name(CONTAINER_NAME).imageName("1a2b3c4d5e6f7g").status("Started 1 second ago").build();
    this.containerInfo = MockContainerInfoFactory.privilegedMode(true).id("TestTestTestTestTest").ipAddress("127.0.0.1").build();
    this.client = MockDockerClientFactory.image(image, imageInfo).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from(DEFAULT_CONNECTION_NAME, client).withDefaultTCPConnectionSettings();
    // configure the Connection Manager
    MockDockerConnectionManager.configureConnectionManager(dockerConnection);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Image(com.spotify.docker.client.messages.Image) ImageInfo(com.spotify.docker.client.messages.ImageInfo)

Aggregations

DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)108 DockerClient (com.spotify.docker.client.DockerClient)75 Test (org.junit.Test)71 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)31 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)21 DockerException (org.eclipse.linuxtools.docker.core.DockerException)18 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)15 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)9 RunWithProject (org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 Job (org.eclipse.core.runtime.jobs.Job)8 Path (java.nio.file.Path)6 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)6 ProgressHandler (com.spotify.docker.client.ProgressHandler)5 RunConsole (org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole)5 PropertySheet (org.eclipse.ui.views.properties.PropertySheet)5 TabbedPropertySheetPage (org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)5 Before (org.junit.Before)5 File (java.io.File)4 IOException (java.io.IOException)4