use of com.spotify.docker.client.DockerClient 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.DockerClient in project linuxtools by eclipse.
the class ImageRunSWTBotTest method testNetworkModeOther.
@Test
public void testNetworkModeOther() 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, "jeffnet");
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("jeffnet");
}
use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.
the class ImageRunSWTBotTest method testNetworkModeBridge.
@Test
public void testNetworkModeBridge() 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, "bridge");
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("bridge");
}
use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.
the class ImageSearchSWTBotTest method shouldNotTriggerSearchIfNoTermWasGiven.
@Test
public void shouldNotTriggerSearchIfNoTermWasGiven() {
// given
final DockerClient client = MockDockerClientFactory.onSearch("foo", MockImageSearchResultFactory.name("foo").build()).build();
// when opening the pull wizard...
openPullWizard(client);
// ... and directly opening the search wizard
openSearchWizard();
// then the search should have been triggered and results should be available
assertThat(bot.table().rowCount()).isEqualTo(0);
}
use of com.spotify.docker.client.DockerClient in project linuxtools by eclipse.
the class ImageSearchSWTBotTest method shouldReduceSearchResultsToExactGivenTerm.
@Test
public void shouldReduceSearchResultsToExactGivenTerm() {
// given
final DockerClient client = MockDockerClientFactory.onSearch("foo/bar", MockImageSearchResultFactory.name("foo/bar").build(), MockImageSearchResultFactory.name("other/bar").build()).build();
// when opening the pull wizard...
openPullWizard(client);
// ... and specifying a term...
bot.textWithLabel(WizardMessages.getString("ImagePullPushPage.name.label")).setText("foo/bar");
// ... and then opening the search wizard
openSearchWizard();
// then the search should have been triggered and a single result should be
// available
assertThat(bot.table().rowCount()).isEqualTo(1);
}
Aggregations