From 2796048643629640ebfa32aafb4162f1b2888de9 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 26 Jan 2011 10:24:59 -0800 Subject: [PATCH] trmk vcloudexpress regression --- .../terremark/TerremarkClientLiveTest.java | 26 +++++++---------- ...CatalogNameVAppTemplateNameToEndpoint.java | 28 +++++++++++++------ .../compute/BaseComputeServiceLiveTest.java | 6 ++-- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java index a0fc557c84..8baf7694bf 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java @@ -33,7 +33,6 @@ import static org.testng.Assert.assertNotNull; import java.io.IOException; import java.net.URI; import java.util.List; -import java.util.NoSuchElementException; import java.util.Properties; import java.util.Map.Entry; import java.util.concurrent.ExecutionException; @@ -41,7 +40,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jclouds.Constants; -import org.jclouds.http.HttpResponseException; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; @@ -83,13 +81,6 @@ import com.google.inject.Module; public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTest { - // Terremark service call 695,490 - @Override - @Test(expectedExceptions = NoSuchElementException.class) - public void testCatalog() throws Exception { - super.testCatalog(); - } - protected String expectedOs = "Ubuntu Linux (64-bit)"; protected String itemName = "Ubuntu JeOS 9.10 (64-bit)"; @@ -149,7 +140,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes prepare(); StringBuffer name = new StringBuffer(); for (int i = 0; i < 15; i++) - name.append("a"); + name.append("c"); String serverName = name.toString();// "adriantest"; long hardDisk = 4194304; @@ -166,6 +157,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes TerremarkCatalogItem item = tmClient.findCatalogItemInOrgCatalogNamed(null, null, itemName); + assert item != null; + // if this template supports setting the root password, let's add it to // our options CustomizationParameters customizationOptions = tmClient.getCustomizationOptions(item.getCustomizationOptions() @@ -175,6 +168,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes VCloudExpressVAppTemplate vAppTemplate = tmClient.getVAppTemplate(item.getEntity().getHref()); + assert vAppTemplate != null; + // instantiate, noting vApp returned has minimal details vApp = tmClient.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName, instantiateOptions); @@ -196,8 +191,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes try {// per docs, this is not supported tmClient.cancelTask(deployTask.getHref()); - } catch (HttpResponseException e) { - assertEquals(e.getResponse().getStatusCode(), 501); + } catch (UnsupportedOperationException e) { } assert successTester.apply(deployTask.getHref()); @@ -302,14 +296,14 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes try {// per docs, this is not supported tmClient.undeployVApp(vApp.getHref()); - } catch (HttpResponseException e) { - assertEquals(e.getResponse().getStatusCode(), 501); + assert false; + } catch (UnsupportedOperationException e) { } try {// per docs, this is not supported tmClient.suspendVApp(vApp.getHref()); - } catch (HttpResponseException e) { - assertEquals(e.getResponse().getStatusCode(), 501); + assert false; + } catch (UnsupportedOperationException e) { } assert successTester.apply(tmClient.resetVApp(vApp.getHref()).getHref()); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java index 1bbe1304a9..6c73108cef 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java @@ -48,8 +48,8 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function>>> orgCatalogItemMap, - @Org String defaultOrg, @Catalog String defaultCatalog) { + Supplier>>> orgCatalogItemMap, + @Org String defaultOrg, @Catalog String defaultCatalog) { this.orgCatalogItemMap = orgCatalogItemMap; this.defaultOrg = defaultOrg; this.defaultCatalog = defaultCatalog; @@ -65,13 +65,23 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function> catalogs = checkNotNull(orgCatalogItemMap.get().get(org)); - return catalogs.get(catalog).get(catalogItem).getEntity().getHref(); - } catch (NullPointerException e) { - throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in " - + orgCatalogItemMap.get()); - } + Map>> orgCatalogItemMap = this.orgCatalogItemMap.get(); + + if (!orgCatalogItemMap.containsKey(org)) + throw new NoSuchElementException("org: " + org + " not found in " + orgCatalogItemMap.keySet()); + Map> catalogs = orgCatalogItemMap.get(org); + + if (!catalogs.containsKey(catalog)) + throw new NoSuchElementException("catalog: " + org + "/" + catalog + " not found in " + catalogs.keySet()); + Map catalogMap = catalogs.get(catalog); + + if (!catalogMap.containsKey(catalogItem)) + throw new NoSuchElementException("item: " + org + "/" + catalog + "/" + catalogItem + " not found in " + + catalogMap.keySet()); + CatalogItem item = catalogMap.get(catalogItem); + + return checkNotNull(item.getEntity(), "item: " + org + "/" + catalog + "/" + catalogItem + " has no entity") + .getHref(); } } \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 104f801050..8a3847bccc 100755 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -239,11 +239,11 @@ public abstract class BaseComputeServiceLiveTest { } for (Entry response : client.runScriptOnNodesMatching( - runningWithTag(tag), Statements.exec("echo hello"), overrideCredentialsWith(good).wrapInInitScript(false)) - .entrySet()) + runningWithTag(tag), Statements.exec("echo hello"), + overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet()) assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": " + response.getValue(); - + runScriptWithCreds(tag, os, good); checkNodes(nodes, tag);