@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); }