@Test(enabled = true, dependsOnMethods = "testConcurrentUseOfComputeServiceToCreateNodes") public void testCreateTwoNodesWithRunScript() throws Exception { try { client.destroyNodesMatching(inGroup(group)); } catch (NoSuchElementException e) { } refreshTemplate(); try { nodes = newTreeSet(client.createNodesInGroup(group, 2, template)); } catch (RunNodesException e) { nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet())); throw e; } assertEquals(nodes.size(), 2); checkNodes(nodes, group, "bootstrap"); NodeMetadata node1 = nodes.first(); NodeMetadata node2 = nodes.last(); // credentials aren't always the same // assertEquals(node1.getCredentials(), node2.getCredentials()); assertLocationSameOrChild(checkNotNull(node1.getLocation(), "location of %s", node1), template.getLocation()); assertLocationSameOrChild(checkNotNull(node2.getLocation(), "location of %s", node2), template.getLocation()); checkImageIdMatchesTemplate(node1); checkImageIdMatchesTemplate(node2); checkOsMatchesTemplate(node1); checkOsMatchesTemplate(node2); }
@Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithRunScript") public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception { initializeContext(); Location existingLocation = Iterables.get(this.nodes, 0).getLocation(); boolean existingLocationIsAssignable = Iterables.any(client.listAssignableLocations(), Predicates.equalTo(existingLocation)); if (existingLocationIsAssignable) { getAnonymousLogger().info("creating another node based on existing nodes' location: " + existingLocation); template = addRunScriptToTemplate(client.templateBuilder().fromTemplate(template) .locationId(existingLocation.getId()).build()); } else { refreshTemplate(); getAnonymousLogger().info( format("%s is not assignable; using template's location %s as ", existingLocation, template.getLocation())); } Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, template); assertEquals(nodes.size(), 1); checkNodes(nodes, group, "bootstrap"); NodeMetadata node = Iterables.getOnlyElement(nodes); if (existingLocationIsAssignable) assertEquals(node.getLocation(), existingLocation); else this.assertLocationSameOrChild(checkNotNull(node.getLocation(), "location of %s", node), template.getLocation()); checkOsMatchesTemplate(node); this.nodes.add(node); }
@Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithOneSpecifiedName") public void testCreateTwoNodesWithRunScript() throws Exception { try { client.destroyNodesMatching(inGroup(group)); } catch (NoSuchElementException e) { } refreshTemplate(); try { nodes = newTreeSet(client.createNodesInGroup(group, 2, template)); } catch (RunNodesException e) { nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet())); throw e; } assertEquals(nodes.size(), 2, "expected two nodes but was " + nodes); checkNodes(nodes, group, "bootstrap"); NodeMetadata node1 = nodes.first(); NodeMetadata node2 = nodes.last(); // credentials aren't always the same // assertEquals(node1.getCredentials(), node2.getCredentials()); assertLocationSameOrChild(checkNotNull(node1.getLocation(), "location of %s", node1), template.getLocation()); assertLocationSameOrChild(checkNotNull(node2.getLocation(), "location of %s", node2), template.getLocation()); checkImageIdMatchesTemplate(node1); checkImageIdMatchesTemplate(node2); checkOsMatchesTemplate(node1); checkOsMatchesTemplate(node2); }
@Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") public void testGet() throws Exception { Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex( filter(client.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))), new Function<NodeMetadata, String>() { @Override public String apply(NodeMetadata from) { return from.getId(); } })); for (NodeMetadata node : nodes) { metadataMap.remove(node.getId()); NodeMetadata metadata = client.getNodeMetadata(node.getId()); assertEquals(metadata.getProviderId(), node.getProviderId()); assertEquals(metadata.getGroup(), node.getGroup()); assertLocationSameOrChild(checkNotNull(metadata.getLocation(), "location of %s", metadata), template.getLocation()); checkImageIdMatchesTemplate(metadata); checkOsMatchesTemplate(metadata); assert (metadata.getStatus() == Status.RUNNING) : metadata; // due to DHCP the addresses can actually change in-between runs. assertEquals(metadata.getPrivateAddresses().size(), node.getPrivateAddresses().size(), format( "[%s] didn't match: [%s]", metadata.getPrivateAddresses(), node.getPrivateAddresses().size())); assertEquals(metadata.getPublicAddresses().size(), node.getPublicAddresses().size(), format( "[%s] didn't match: [%s]", metadata.getPublicAddresses(), node.getPublicAddresses().size())); } assertNodeZero(metadataMap.values()); }
else this.assertLocationSameOrChild(checkNotNull(node.getLocation(), "location of %s", node), template.getLocation()); checkOsMatchesTemplate(node); this.nodes = newTreeSet(concat(this.nodes, nodes));
assertLocationSameOrChild(checkNotNull(metadata.getLocation(), "location of %s", metadata), template.getLocation()); checkImageIdMatchesTemplate(metadata); checkOsMatchesTemplate(metadata); assert metadata.getStatus() == Status.RUNNING : metadata;