@Override protected Template buildTemplate(TemplateBuilder templateBuilder) { Template template = super.buildTemplate(templateBuilder); template.getOptions().authorizePublicKey(keyPair.get("public")); return template; }
private Template refreshTemplate() { return template = addRunScriptToTemplate(buildTemplate(client.templateBuilder())); }
protected Template refreshTemplate() { return template = addRunScriptToTemplate(buildTemplate(templateBuilder())); }
@Test(enabled = true, dependsOnMethods = "testDestroyNodes", alwaysRun = true) public void testCreateTwoNodesWithOneSpecifiedName() throws Exception { template = buildTemplate(templateBuilder()); template.getOptions().nodeNames(ImmutableSet.of("first-node")); try { this.nodes = newTreeSet(client.createNodesInGroup(group, 2, template)); } catch (RunNodesException e) { this.nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet())); throw e; } assertEquals(this.nodes.size(), 2, "expected two nodes but was " + nodes); NodeMetadata node1 = Iterables.getFirst(this.nodes, null); NodeMetadata node2 = Iterables.getLast(this.nodes, null); // credentials aren't always the same // assertEquals(node1.getCredentials(), node2.getCredentials()); assertTrue(node1.getName().equals("first-node") || node2.getName().equals("first-node"), "one node should be named 'first-node'"); assertFalse(node1.getName().equals("first-node") && node2.getName().equals("first-node"), "one node should be named something other than 'first-node"); }
final String group = "twin" + groupNum; groups.add(group); template = buildTemplate(templateBuilder()); template.getOptions().inboundPorts(22, 8080).blockOnPort(22, 300 + groupNum); ListenableFuture<NodeMetadata> future = userExecutor.submit(new Callable<NodeMetadata>() {
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testCreateNodeWithCustomHardware() throws Exception { Template template = buildTemplate(templateBuilder() .hardwareId("automatic:cores=2;ram=4096")); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group + "custom", 1, template)); assertThat(node.getHardware().getRam()).isEqualTo(4096); assertThat(node.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); } finally { client.destroyNodesMatching(inGroup(group + "custom")); } }
@Test(enabled = true, dependsOnMethods = { "testImagesCache" }) public void testTemplateMatch() throws Exception { template = buildTemplate(client.templateBuilder()); Template toMatch = client.templateBuilder().imageId(template.getImage().getId()).build(); assertEquals(toMatch.getImage(), template.getImage()); }
@Test(enabled = true, dependsOnMethods = { "testImagesCache" }) public void testTemplateMatch() throws Exception { template = buildTemplate(templateBuilder()); Template toMatch = client.templateBuilder().imageId(template.getImage().getId()).build(); assertEquals(toMatch.getImage(), template.getImage()); }
@Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithRunScript", alwaysRun = true) public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception { if (this.nodes == null || this.nodes.isEmpty()) { template = buildTemplate(templateBuilder()); try { nodes = newTreeSet(client.createNodesInGroup(group, 1, template)); template = buildTemplate(templateBuilder()); template = addRunScriptToTemplate(client.templateBuilder().fromTemplate(template) .locationId(existingLocation.getId()).build());
@Test public void testWeCanCancelTasks() throws Exception { String group = this.group + "w"; try { client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { } template = buildTemplate(templateBuilder()); try { Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, template); NodeMetadata node = getOnlyElement(nodes); weCanCancelTasks(node); } finally { client.destroyNodesMatching(inGroup(group)); } }
public void testOptionToNotBlock() throws Exception { String group = this.group + "block"; try { client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { } // no inbound ports template = buildTemplate(templateBuilder()); template.getOptions().blockUntilRunning(false).inboundPorts(); try { long time = currentTimeMillis(); Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, template); NodeMetadata node = getOnlyElement(nodes); assert node.getStatus() != Status.RUNNING : node; long duration = (currentTimeMillis() - time) / 1000; assert duration < nonBlockDurationSeconds : format("duration(%d) longer than expected(%d) seconds! ", duration, nonBlockDurationSeconds); } finally { client.destroyNodesMatching(inGroup(group)); } }
@Test(enabled = true) public void testGet() throws Exception { template = buildTemplate(templateBuilder()); try { nodes = newTreeSet(client.createNodesInGroup(group, 1, template));
protected void createAndRunAServiceInGroup(String group) throws RunNodesException { // note that some cloud providers do not support mixed case tag names ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("test", group); ImmutableSet<String> tags = ImmutableSet.of(group); Stopwatch watch = Stopwatch.createStarted(); template = buildTemplate(templateBuilder()); template.getOptions().inboundPorts(22, 8080).blockOnPort(22, 300).userMetadata(userMetadata).tags(tags); NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, template)); long createSeconds = watch.elapsed(TimeUnit.SECONDS); final String nodeId = node.getId(); checkUserMetadataContains(node, userMetadata); checkTagsInNodeEquals(node, tags); getAnonymousLogger().info( format("<< available node(%s) os(%s) in %ss", node.getId(), node.getOperatingSystem(), createSeconds)); watch.reset().start(); client.runScriptOnNode(nodeId, JettyStatements.install(), nameTask("configure-jetty")); long configureSeconds = watch.elapsed(TimeUnit.SECONDS); getAnonymousLogger().info( format( "<< configured node(%s) with %s and jetty %s in %ss", nodeId, exec(nodeId, "java -fullversion"), exec(nodeId, JettyStatements.version()), configureSeconds)); trackAvailabilityOfProcessOnNode(JettyStatements.start(), "start jetty", node); client.runScriptOnNode(nodeId, JettyStatements.stop(), runAsRoot(false).wrapInInitScript(false)); trackAvailabilityOfProcessOnNode(JettyStatements.start(), "start jetty", node); }
template = buildTemplate(templateBuilder()); template.getOptions().blockOnPort(22, 120); try {