@Test(enabled = true, dependsOnMethods = "testTemplateMatch") public void testCreateTwoNodesWithRunScript() throws Exception { try { client.destroyNodesMatching(NodePredicates.withTag(tag)); } catch (HttpResponseException e) { // TODO hosting.com throws 400 when we try to delete a vApp } catch (NoSuchElementException e) { } template = buildTemplate(client.templateBuilder()); template .getOptions() .installPrivateKey(keyPair.get("private")) .authorizePublicKey(keyPair.get("public")) .runScript(buildScript(template.getImage().getOsFamily()).getBytes()); try { nodes = Sets.newTreeSet(client.runNodesWithTag(tag, 2, template)); } catch (RunNodesException e) { nodes = Sets.newTreeSet(Iterables.concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet())); throw e; } assertEquals(nodes.size(), 2); checkNodes(nodes, tag); NodeMetadata node1 = nodes.first(); NodeMetadata node2 = nodes.last(); // credentials aren't always the same // assertEquals(node1.getCredentials(), node2.getCredentials()); assertLocationSameOrChild(node1.getLocation(), template.getLocation()); assertLocationSameOrChild(node2.getLocation(), template.getLocation()); assertEquals(node1.getImage(), template.getImage()); assertEquals(node2.getImage(), template.getImage()); }
@Test(enabled = true, dependsOnMethods = "testCompareSizes") public void testCreateTwoNodesWithRunScript() throws Exception { try { client.destroyNodesMatching(withTag(tag)); } catch (NoSuchElementException e) { } refreshTemplate(); try { nodes = newTreeSet(client.runNodesWithTag(tag, 2, template)); } catch (RunNodesException e) { nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet())); throw e; } assertEquals(nodes.size(), 2); checkNodes(nodes, tag); NodeMetadata node1 = nodes.first(); NodeMetadata node2 = nodes.last(); // credentials aren't always the same // assertEquals(node1.getCredentials(), node2.getCredentials()); assertLocationSameOrChild(node1.getLocation(), template.getLocation()); assertLocationSameOrChild(node2.getLocation(), 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(withTag(tag), 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.getTag(), node.getTag()); assertLocationSameOrChild(metadata.getLocation(), template.getLocation()); checkImageIdMatchesTemplate(metadata); checkOsMatchesTemplate(metadata); assertEquals(metadata.getState(), NodeState.RUNNING); // due to DHCP the addresses can actually change in-between runs. assertEquals(metadata.getPrivateAddresses().size(), node.getPrivateAddresses().size()); assertEquals(metadata.getPublicAddresses().size(), node.getPublicAddresses().size()); } assertNodeZero(metadataMap.values()); }
@Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithRunScript") public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception { initializeContextAndClient(); TreeSet<NodeMetadata> nodes = Sets.newTreeSet(client.runNodesWithTag(tag, 1, template)); checkNodes(nodes, tag); NodeMetadata node = nodes.first(); this.nodes.add(node); assertEquals(nodes.size(), 1); assertLocationSameOrChild(node.getLocation(), template.getLocation()); assertEquals(node.getImage(), template.getImage()); }
@Test( enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") public void testGet() throws Exception { Set<? extends NodeMetadata> metadataSet = Sets.newHashSet( Iterables.filter( client.listNodesDetailsMatching(NodePredicates.all()), Predicates.and( NodePredicates.withTag(tag), Predicates.not(NodePredicates.TERMINATED)))); for (NodeMetadata node : nodes) { metadataSet.remove(node); NodeMetadata metadata = client.getNodeMetadata(node.getId()); assertEquals(metadata.getProviderId(), node.getProviderId()); assertEquals(metadata.getTag(), node.getTag()); assertLocationSameOrChild(metadata.getLocation(), template.getLocation()); assertEquals(metadata.getImage(), template.getImage()); assertEquals(metadata.getState(), NodeState.RUNNING); assertEquals(metadata.getPrivateAddresses(), node.getPrivateAddresses()); assertEquals(metadata.getPublicAddresses(), node.getPublicAddresses()); } assertNodeZero(metadataSet); }