mirror of https://github.com/apache/jclouds.git
[JCLOUDS-1157] fix networks in DockerComputeServiceAdapterLiveTest
This commit is contained in:
parent
58e11d42d1
commit
c4605a32d4
|
@ -46,6 +46,7 @@ import org.jclouds.docker.compute.strategy.DockerComputeServiceAdapter;
|
||||||
import org.jclouds.docker.domain.Container;
|
import org.jclouds.docker.domain.Container;
|
||||||
import org.jclouds.docker.domain.Image;
|
import org.jclouds.docker.domain.Image;
|
||||||
import org.jclouds.docker.domain.Network;
|
import org.jclouds.docker.domain.Network;
|
||||||
|
import org.jclouds.docker.features.NetworkApi;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
|
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "DockerComputeServiceAdapterLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "DockerComputeServiceAdapterLiveTest")
|
||||||
|
@ -67,8 +68,8 @@ public class DockerComputeServiceAdapterLiveTest extends BaseDockerApiLiveTest {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
String imageName = SSHABLE_IMAGE + ":" + SSHABLE_IMAGE_TAG;
|
String imageName = SSHABLE_IMAGE + ":" + SSHABLE_IMAGE_TAG;
|
||||||
defaultImage = adapter.getImage(imageName);
|
defaultImage = adapter.getImage(imageName);
|
||||||
network1 = api.getNetworkApi().createNetwork(Network.builder().name("network1").driver("overlay").build());
|
network1 = createAndInspectNetwork("network1");
|
||||||
network2 = api.getNetworkApi().createNetwork(Network.builder().name("network2").driver("overlay").build());
|
network2 = createAndInspectNetwork("network2");
|
||||||
assertNotNull(defaultImage);
|
assertNotNull(defaultImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,14 +117,16 @@ public class DockerComputeServiceAdapterLiveTest extends BaseDockerApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetImageNotHiddenByCache() {
|
public void testGetImageNotHiddenByCache() {
|
||||||
//Ensure image to be tested is unknown to jclouds and docker and that cache is warm
|
// Ensure image to be tested is unknown to jclouds and docker and that
|
||||||
|
// cache is warm
|
||||||
assertNull(findImageFromListImages(CHUANWEN_COWSAY));
|
assertNull(findImageFromListImages(CHUANWEN_COWSAY));
|
||||||
assertNull(api.getImageApi().inspectImage(CHUANWEN_COWSAY));
|
assertNull(api.getImageApi().inspectImage(CHUANWEN_COWSAY));
|
||||||
|
|
||||||
// Get new image
|
// Get new image
|
||||||
adapter.getImage(CHUANWEN_COWSAY);
|
adapter.getImage(CHUANWEN_COWSAY);
|
||||||
|
|
||||||
assertNotNull(findImageFromListImages(CHUANWEN_COWSAY), "New image is not available from listImages presumably due to caching");
|
assertNotNull(findImageFromListImages(CHUANWEN_COWSAY),
|
||||||
|
"New image is not available from listImages presumably due to caching");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateNodeWithMultipleNetworks() {
|
public void testCreateNodeWithMultipleNetworks() {
|
||||||
|
@ -137,7 +140,7 @@ public class DockerComputeServiceAdapterLiveTest extends BaseDockerApiLiveTest {
|
||||||
|
|
||||||
assertTrue(guest.getNode().networkSettings().networks().containsKey("network1"));
|
assertTrue(guest.getNode().networkSettings().networks().containsKey("network1"));
|
||||||
assertTrue(guest.getNode().networkSettings().networks().containsKey("network2"));
|
assertTrue(guest.getNode().networkSettings().networks().containsKey("network2"));
|
||||||
assertEquals(guest.getNode().networkSettings().secondaryIPAddresses().size(), 2);
|
assertEquals(guest.getNode().networkSettings().networks().size(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Image findImageFromListImages(final String image) {
|
private Image findImageFromListImages(final String image) {
|
||||||
|
@ -159,4 +162,15 @@ public class DockerComputeServiceAdapterLiveTest extends BaseDockerApiLiveTest {
|
||||||
return ImmutableSet.<Module> of(getLoggingModule(), new SshjSshClientModule());
|
return ImmutableSet.<Module> of(getLoggingModule(), new SshjSshClientModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates network (driver="bridge") with given name and then inspects it to
|
||||||
|
* fully populate the returned {@link Network} object.
|
||||||
|
*
|
||||||
|
* @param networkName
|
||||||
|
*/
|
||||||
|
private Network createAndInspectNetwork(final String networkName) {
|
||||||
|
final NetworkApi networkApi = api.getNetworkApi();
|
||||||
|
Network network = networkApi.createNetwork(Network.builder().name(networkName).driver("bridge").build());
|
||||||
|
return networkApi.inspectNetwork(network.id());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue