@Test(groups = {"integration", "live"}) public void testGetAssignableLocations() throws Exception { for (Location location : client.listAssignableLocations()) { getAnonymousLogger().warning("location " + location); assert location.getId() != null : location; assert location != location.getParent() : location; assert location.getScope() != null : location; switch (location.getScope()) { case PROVIDER: assertProvider(location); break; case REGION: assertProvider(location.getParent()); break; case ZONE: Location provider = location.getParent().getParent(); // zone can be a direct descendant of provider if (provider == null) provider = location.getParent(); assertProvider(provider); break; case HOST: Location provider2 = location.getParent().getParent().getParent(); // zone can be a direct descendant of provider if (provider2 == null) provider2 = location.getParent().getParent(); assertProvider(provider2); break; } } }
@Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithOneSpecifiedName") 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 = buildTemplate(client.templateBuilder()); 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); }