@Test void testDescribe() { for (String region : newArrayList(Region.US_EAST_1)) { SortedSet<PlacementGroup> allResults = newTreeSet(client.getPlacementGroupServices().describePlacementGroupsInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { PlacementGroup group = allResults.last(); SortedSet<PlacementGroup> result = newTreeSet( client .getPlacementGroupServices() .describePlacementGroupsInRegion(region, group.getName())); assertNotNull(result); PlacementGroup compare = result.last(); assertEquals(compare, group); } } for (String region : client.getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { if (!region.equals(Region.US_EAST_1)) try { client.getPlacementGroupServices().describePlacementGroupsInRegion(region); assert false : "should be unsupported"; } catch (UnsupportedOperationException e) { } } }
@Test void testCreatePlacementGroup() { String groupName = PREFIX + "1"; client.getPlacementGroupServices().deletePlacementGroupInRegion(null, groupName); client.getPlacementGroupServices().createPlacementGroupInRegion(null, groupName); verifyPlacementGroup(groupName); }
@AfterTest public void shutdown() { if (group != null) { client .getPlacementGroupServices() .deletePlacementGroupInRegion(group.getRegion(), group.getName()); assert deletedTester.apply(group) : group; } }
private void verifyPlacementGroup(String groupName) { assert availableTester.apply( new PlacementGroup(Region.US_EAST_1, groupName, "cluster", State.PENDING)) : group; Set<PlacementGroup> oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(null, groupName); assertNotNull(oneResult); assertEquals(oneResult.size(), 1); group = oneResult.iterator().next(); assertEquals(group.getName(), groupName); assertEquals(group.getStrategy(), "cluster"); assert availableTester.apply(group) : group; }
public void testStartCCInstance() throws Exception { Template template = view.getComputeService().templateBuilder().fastest().osFamily(OsFamily.AMZN_LINUX).build(); assert template != null : "The returned template was null, but it should have a value."; assertEquals(template.getHardware().getProviderId(), InstanceType.CC2_8XLARGE); assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "ebs"); assertEquals(template.getImage().getUserMetadata().get("virtualizationType"), "hvm"); assertEquals(template.getImage().getUserMetadata().get("hypervisor"), "xen"); template .getOptions() .runScript(Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK())); String group = PREFIX + "cccluster"; view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); // TODO make this not lookup an explicit region client .getPlacementGroupServices() .deletePlacementGroupInRegion(null, "jclouds#" + group + "#us-east-1"); try { Set<? extends NodeMetadata> nodes = view.getComputeService().createNodesInGroup(group, 1, template); NodeMetadata node = getOnlyElement(nodes); getOnlyElement( getOnlyElement( client.getInstanceServices().describeInstancesInRegion(null, node.getProviderId()))); } catch (RunNodesException e) { System.err.println(e.getNodeErrors().keySet()); Throwables.propagate(e); } finally { view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); } }
private void createPlacementGroupInRegion(String region, String name) { checkNotNull(region, "region"); checkNotNull(name, "name"); logger.debug(">> creating placementGroup region(%s) name(%s)", region, name); try { ec2Client.getPlacementGroupServices().createPlacementGroupInRegion(region, name); logger.debug("<< created placementGroup(%s)", name); checkState( placementGroupAvailable.apply(new PlacementGroup(region, name, "cluster", State.PENDING)), String.format( "placementGroup region(%s) name(%s) failed to become available", region, name)); } catch (AWSResponseException e) { if (e.getError().getCode().equals("InvalidPlacementGroup.Duplicate")) { logger.debug("<< reused placementGroup(%s)", name); } else { throw e; } } }