@Test(dependsOnMethods = "testCreateNetwork") public void testListNetworks() { List<Network> networks = api().listNetworks(); for (Network network : networks) { assertNotNull(network.id()); } }
@BeforeClass protected void init() { if (api.getImageApi().inspectImage(ALPINE_IMAGE_TAG) == null) { CreateImageOptions options = CreateImageOptions.Builder.fromImage(ALPINE_IMAGE_TAG); InputStream createImageStream = api.getImageApi().createImage(options); consumeStream(createImageStream); } image = api.getImageApi().inspectImage(ALPINE_IMAGE_TAG); assertNotNull(image); Config containerConfig = Config.builder().image(image.id()) .cmd(ImmutableList.of("sh", "-c", "touch hello; while true; do echo hello world; sleep 1; done")) .build(); container = api.getContainerApi().createContainer("jclouds-test-network", containerConfig); api.getContainerApi().startContainer(container.id()); container = api.getContainerApi().inspectContainer(container.id()); }
@Test(dependsOnMethods = "testCreateNetwork") public void testGetNetwork() { network = api().inspectNetwork(network.id()); assertNotNull(network); }
public void testCreateNetwork() throws IOException, InterruptedException { network = api().createNetwork(Network.create(NETWORK_NAME, null, null, null, null, ImmutableMap.<String, Network.Details> of(), ImmutableMap.<String, String> of())); assertNotNull(network); assertNotNull(network.id()); }
@Test(dependsOnMethods = "testGetNetwork") public void testAttachContainerToNetwork() { api().connectContainerToNetwork(network.id(), container.id()); container = api.getContainerApi().inspectContainer(container.id()); assertTrue(Iterables.any(container.networkSettings().networks().keySet(), Predicates.equalTo(network.name()))); }
@Test(dependsOnMethods = "testAttachContainerToNetwork") public void testDisconnectContainerFromNetwork() { api().disconnectContainerFromNetwork(network.id(), container.id()); container = api.getContainerApi().inspectContainer(container.id()); assertFalse(Iterables.any(container.networkSettings().networks().keySet(), Predicates.equalTo(network.name()))); }
@AfterClass(alwaysRun = true) protected void tearDown() { if (container != null) { api.getContainerApi().stopContainer(container.id()); api.getContainerApi().removeContainer(container.id()); } if (network != null) { api().removeNetwork(network.id()); } }