Search in sources :

Example 91 with DockerConnection

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

the class ImageRunSWTBotTest method testNetworkModeDefault.

@Test
public void testNetworkModeDefault() throws CoreException {
    final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("foo:latest").build()).container(MockContainerFactory.name("foo_bar").build()).build();
    final DockerConnection connection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    final String runImageLaunchConfigurationName = configureRunImageLaunchConfiguration(connection, "");
    final ILaunchConfiguration runDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, runImageLaunchConfigurationName);
    assertThat(runDockerImageLaunchConfig).isNotNull();
    assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.CONNECTION_NAME, "")).isEqualTo("Test");
    assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.NETWORK_MODE, "")).isEqualTo("");
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) DockerClient(com.spotify.docker.client.DockerClient) Test(org.junit.Test)

Example 92 with DockerConnection

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

the class ImageSearchSWTBotTest method shouldAllowForDefaultLatestTag.

@Test
public void shouldAllowForDefaultLatestTag() {
    // given
    final DockerClient client = MockDockerClientFactory.onSearch("foo", MockImageSearchResultFactory.name("foo").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when opening the "Pull..." wizard
    SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images").select();
    dockerExplorerViewBot.bot().tree().contextMenu("Pull...").click();
    // when specifying a term
    bot.textWithLabel(WizardMessages.getString("ImagePullPushPage.name.label")).setText("foo");
    // when clicking on the "Search..." button
    bot.button(WizardMessages.getString("ImagePull.search.label")).click();
    // then the search should have been triggered and results should be
    // available
    assertThat(bot.table().rowCount()).isEqualTo(1);
    assertThat(bot.button("Next >").isEnabled()).isTrue();
    assertThat(bot.button("Finish").isEnabled()).isTrue();
    bot.button("Finish").click();
    // when back to Pull wizard, the Image name field should be filled
    assertThat(bot.textWithLabel(WizardMessages.getString("ImagePullPushPage.name.label")).getText()).isEqualTo("foo:latest");
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) Test(org.junit.Test)

Example 93 with DockerConnection

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

the class NewDockerConnectionSWTBotTest method configureUnixSocketConnection.

private IDockerConnection configureUnixSocketConnection(final String connectionName, final String pathToSocket) {
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from(connectionName, client).withUnixSocketConnectionSettings(pathToSocket);
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    return dockerConnection;
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient)

Example 94 with DockerConnection

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

the class NewDockerConnectionPage method onTestConnectionButtonSelection.

/**
 * Verifies that the given connection settings work by trying to connect to
 * the target Docker daemon
 *
 * @return
 */
private SelectionListener onTestConnectionButtonSelection() {
    return new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent event) {
            try {
                getWizard().getContainer().run(true, false, monitor -> {
                    monitor.beginTask(WizardMessages.getString(// $NON-NLS-1$
                    "DockerConnectionPage.pingTask"), IProgressMonitor.UNKNOWN);
                    try {
                        final DockerConnection dockerConnection = getDockerConnection();
                        dockerConnection.open(false);
                        dockerConnection.ping();
                        dockerConnection.close();
                        // ping succeeded
                        displaySuccessDialog();
                    } catch (DockerException e) {
                        // in Eclipse.org AERI
                        if (e.getCause() != null) {
                            displayErrorDialog(e.getCause());
                        } else {
                            displayErrorDialog(e);
                        }
                    }
                });
            } catch (InvocationTargetException | InterruptedException o_O) {
                Activator.log(o_O);
            }
        }

        private void displaySuccessDialog() {
            displayDialog(WizardMessages.getString(// $NON-NLS-1$
            "DockerConnectionPage.success"), WizardMessages.getString(// $NON-NLS-1$
            "DockerConnectionPage.pingSuccess"), SWT.ICON_INFORMATION, new String[] { WizardMessages.getString(// $NON-NLS-1$
            "DockerConnectionPage.ok") });
        }

        private void displayErrorDialog(final Throwable cause) {
            displayDialog(WizardMessages.getString(// $NON-NLS-1$
            "DockerConnectionPage.failure"), WizardMessages.getFormattedString(// $NON-NLS-1$
            "DockerConnectionPage.pingFailure", cause.getMessage()), SWT.ICON_ERROR, new String[] { WizardMessages.getString(// $NON-NLS-1$
            "DockerConnectionPage.ok") });
        }

        private void displayDialog(final String dialogTitle, final String dialogMessage, final int icon, final String[] buttonLabels) {
            Display.getDefault().syncExec(() -> new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dialogTitle, null, dialogMessage, icon, buttonLabels, 0).open());
        }
    };
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerException(org.eclipse.linuxtools.docker.core.DockerException) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 95 with DockerConnection

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

the class ContainerVMInstall method getInstallLocation.

@Override
public File getInstallLocation() {
    if (installLocation == null) {
        DockerConnection conn = getConnection();
        ImageQuery q = new ImageQuery(conn, image.id());
        installLocation = q.getDefaultJVMInstallLocation();
        q.destroy();
    }
    return installLocation;
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection)

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