Search in sources :

Example 36 with DockerClient

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

the class DockerExplorerViewSWTBotTest method shouldShowContainerVolumes.

@Test
public void shouldShowContainerVolumes() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.volume("/path/to/container").volume("/path/to/host:/path/to/container").volume("/path/to/host:/path/to/container:Z,ro").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    SWTUtils.asyncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
    // when
    final SWTBotTreeItem volumesTreeItem = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Volumes");
    // then
    SWTBotTreeItemAssertions.assertThat(volumesTreeItem).isExpanded().hasChildItems(3);
    SWTBotTreeItemAssertions.assertThat(volumesTreeItem.getNode(0)).hasText("/path/to/container");
    SWTBotTreeItemAssertions.assertThat(volumesTreeItem.getNode(1)).hasText("/path/to/host -> /path/to/container");
    SWTBotTreeItemAssertions.assertThat(volumesTreeItem.getNode(2)).hasText("/path/to/host -> /path/to/container (Z,ro)");
}
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 37 with DockerClient

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

the class DockerImageHierarchyViewSWTBotTest method setupData.

@Before
public void setupData() {
    // data is built as follows:
    // root_image
    // |- foo_image1
    // _|- foo_container1 (Up)
    // _|- foo_image2
    // __|- foo_container21 (Exited)
    // __|- foo_container22 (Paused)
    // |- bar_image11
    // _|- bar_container1
    final Image rootImage = MockImageFactory.id("sha256:root_image").name("root_image").build();
    final Image fooImage1 = MockImageFactory.id("sha256:foo_image1").name("foo_image1").parentId("sha256:root_image").build();
    final Image fooImage2 = MockImageFactory.id("sha256:foo_image2").name("foo_image2", "foo_image2_alias").parentId("sha256:foo_image1").build();
    final Container fooContainer1 = MockContainerFactory.id("sha256:foo_container1").name("foo_container1").imageName("foo_image1").status("Up").build();
    final Container fooContainer21 = MockContainerFactory.id("sha256:foo_container21").name("foo_container21").imageName("foo_image2").status("Exited").build();
    final Container fooContainer22 = MockContainerFactory.id("sha256:foo_container22").name("foo_container22").imageName("foo_image2_alias").status("Up (Paused)").build();
    final Image barImage1 = MockImageFactory.id("sha256:bar_image1").name("bar_image1").parentId("sha256:root_image").build();
    final Container barContainer1 = MockContainerFactory.id("sha256:bar_container1").name("bar_container1").imageName("bar_image1").build();
    final DockerClient client = MockDockerClientFactory.image(rootImage).image(fooImage1).container(fooContainer1).image(fooImage2).container(fooContainer21).container(fooContainer22).image(barImage1).container(barContainer1).build();
    this.connection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    this.connection.getImages(true);
    this.connection.getContainers(true);
    DockerConnectionManagerUtils.configureConnectionManager(connection);
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) Container(com.spotify.docker.client.messages.Container) DockerClient(com.spotify.docker.client.DockerClient) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) Image(com.spotify.docker.client.messages.Image) Before(org.junit.Before)

Example 38 with DockerClient

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

the class DockerImagesViewSWTBotTest method shouldRemoveListenersWhenClosingView.

@Test
public void shouldRemoveListenersWhenClosingView() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("angry_bar").status("Stopped").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    SWTUtils.getTreeItem(dockerExplorerBotView, "Test").select();
    // remove the DockerContainerRefreshManager
    dockerConnection.removeContainerListener(DockerContainerRefreshManager.getInstance());
    // DockerExplorerView inner classes
    assertThat(dockerConnection.getImageListeners()).hasSize(2);
    // close the Docker Images View
    dockerImagesBotView.close();
    // there should be one listener left: DockerExplorerView
    assertThat(dockerConnection.getImageListeners()).hasSize(1);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) Test(org.junit.Test)

Example 39 with DockerClient

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

the class DockerImagesViewSWTBotTest method verifyBuildAndPullActionEnablement.

@Test
public void verifyBuildAndPullActionEnablement() {
    // given
    final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("angry_bar").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    SWTUtils.syncExec(() -> SWTUtils.getView(bot, "org.eclipse.ui.views.PropertySheet", true));
    this.dockerImagesView.setFocus();
    // select the container in the table
    selectImageInTable("angry_bar");
    List<SWTBotToolbarButton> buttons = this.dockerImagesBotView.getToolbarButtons();
    for (SWTBotToolbarButton button : buttons) {
        if (button.getText().equals("Build Image")) {
            assertThat(button.isEnabled());
        } else if (button.getText().equals("Pull...")) {
            assertThat(button.isEnabled());
        }
    }
    unselectImages();
    buttons = this.dockerImagesBotView.getToolbarButtons();
    for (SWTBotToolbarButton button : buttons) {
        if (button.getText().equals("Build Image")) {
            assertThat(button.isEnabled());
        } else if (button.getText().equals("Pull...")) {
            assertThat(button.isEnabled());
        }
    }
    unselectConnections();
    buttons = this.dockerImagesBotView.getToolbarButtons();
    for (SWTBotToolbarButton button : buttons) {
        if (button.getText().equals("Build Image")) {
            assertThat(!button.isEnabled());
        } else if (button.getText().equals("Pull...")) {
            assertThat(!button.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)

Example 40 with DockerClient

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

the class DockerImagesViewSWTBotTest method setup.

@Before
public void setup() {
    this.bot = new SWTWorkbenchBot();
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("angry_bar").status("Stopped").build()).image(MockImageFactory.id("987654321abcde").name("default:1").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Default", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    SWTUtils.asyncExec(() -> {
        try {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerExplorerView.VIEW_ID);
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerImagesView.VIEW_ID);
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail("Failed to open Docker Images view: " + e.getMessage());
        }
    });
    this.dockerImagesBotView = bot.viewById("org.eclipse.linuxtools.docker.ui.dockerImagesView");
    this.dockerImagesView = (DockerImagesView) (dockerImagesBotView.getViewReference().getView(true));
    this.dockerExplorerBotView = bot.viewById(DockerExplorerView.VIEW_ID);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) DockerClient(com.spotify.docker.client.DockerClient) Before(org.junit.Before)

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