use of com.spotify.docker.client.messages.Image 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);
}
use of com.spotify.docker.client.messages.Image in project linuxtools by eclipse.
the class DockerImageHierarchyViewSWTBotTest method setupViews.
@Before
public void setupViews() {
this.bot = new SWTWorkbenchBot();
SWTUtils.asyncExec(() -> {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerExplorerView.VIEW_ID);
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Failed to open Docker Explorer view: " + e.getMessage());
}
});
this.dockerExplorerViewBot = bot.viewById(DockerExplorerView.VIEW_ID);
this.dockerExplorerView = (DockerExplorerView) (dockerExplorerViewBot.getViewReference().getView(true));
// make sure that the Docker Image Hierarchy view is closed
this.bot.views().stream().filter(v -> v.getReference().getId().equals(DockerImageHierarchyView.VIEW_ID)).forEach(v -> v.close());
}
use of com.spotify.docker.client.messages.Image in project linuxtools by eclipse.
the class ImageRunSWTBotTest method shouldCreateLaunchConfigurationWhenRunningNamedContainer.
@Test
public void shouldCreateLaunchConfigurationWhenRunningNamedContainer() throws InterruptedException, DockerException, CoreException {
// images to use
final String imageName = "foo/bar:latest";
final Image image = MockImageFactory.id("1a2b3c4d5e6f7g").name(imageName).build();
final ImageInfo imageInfo = MockImageInfoFactory.volume("/foo/bar").command(Arrays.asList("the", "command")).entrypoint(Arrays.asList("the", "entrypoint")).build();
// container to be created
final String containerName = "foo_bar";
final Container createdContainer = MockContainerFactory.id("MockContainer").name(containerName).imageName("1a2b3c4d5e6f7g").status("Started 1 second ago").build();
final ContainerInfo containerInfo = MockContainerInfoFactory.build();
final DockerClient client = MockDockerClientFactory.image(image, imageInfo).build();
// expected response when creating the container
final ContainerCreation containerCreation = Mockito.mock(ContainerCreation.class);
Mockito.when(containerCreation.id()).thenReturn("MockContainer");
Mockito.when(client.createContainer(Matchers.any(), Matchers.any())).thenReturn(containerCreation);
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
// configure the Connection Manager
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// when select images and click on run to open the wizard
SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images", "foo/bar").select();
dockerExplorerViewBot.bot().tree().contextMenu("Run...").click();
// $NON-NLS-1$
bot.waitUntil(Conditions.shellIsActive("Run a Docker Image"), TimeUnit.SECONDS.toMillis(1));
// configure container
bot.text(0).setText(containerName);
// bot.button("Next >").click();
// update the client to make sure the container exists once the call to "Finish" is done
MockDockerClientFactory.addContainer(client, createdContainer, containerInfo);
bot.button("Finish").click();
// wait for background job to complete
SWTUtils.waitForJobsToComplete();
// then
// check that the client was called
Mockito.verify(client).createContainer(Matchers.any(), Matchers.eq(containerName));
// check that a launch configuration was created
final ILaunchConfiguration launchConfiguration = LaunchConfigurationUtils.getLaunchConfigurationByName(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, "foo_bar_latest");
assertThat(launchConfiguration).isNotNull();
}
use of com.spotify.docker.client.messages.Image in project linuxtools by eclipse.
the class DockerConnectionTest method shouldLoadImages.
@Test
public void shouldLoadImages() throws DockerException {
// given
final Image fooImage = MockImageFactory.id("foo").build();
final Image barImage = MockImageFactory.id("bar").build();
final DockerClient client = MockDockerClientFactory.image(fooImage).image(barImage).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
dockerConnection.open(false);
// when
final List<IDockerImage> images = dockerConnection.getImages();
// then
assertThat(images).hasSize(2);
}
use of com.spotify.docker.client.messages.Image in project linuxtools by eclipse.
the class DockerConnectionTest method hasImageTest.
@Test
public void hasImageTest() throws DockerException {
// given
final Image fooImage = MockImageFactory.id("foo").name("foo", "foo:latest", "foo:1.0", "org/foo", "org/foo:1.0", "org/foo:latest").build();
final DockerClient client = MockDockerClientFactory.image(fooImage).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
// when
dockerConnection.open(false);
// then
assertTrue(dockerConnection.hasImage("foo", null));
assertTrue(dockerConnection.hasImage("foo", "latest"));
assertTrue(dockerConnection.hasImage("foo", "1.0"));
assertTrue(dockerConnection.hasImage("org/foo", null));
assertTrue(dockerConnection.hasImage("org/foo", "latest"));
assertTrue(dockerConnection.hasImage("org/foo", "1.0"));
}
Aggregations