summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-02-15 23:11:26 -0800
committerPatrick Brady <pb071s@att.com>2017-02-15 23:13:06 -0800
commit1c192d2dd68724e292b6a30f463085a262e1e813 (patch)
treed0e2b3a396e169863cd0efaa835c8675e9d5aaac /appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test
parentc69ba05c7508aa7d7f675189a45c8c87569369ef (diff)
Moving all files to root directory
Change-Id: Ica5535fd6ec85f350fe1640b42137b49f83f10f0 Signed-off-by: Patrick Brady <pb071s@att.com>
Diffstat (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test')
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java54
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java943
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImplNoConnection.java170
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java159
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java147
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java107
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java181
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java451
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties109
9 files changed, 2321 insertions, 0 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java
new file mode 100644
index 000000000..4f797f859
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.appc.adapter.iaas.impl.IdentityURL;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+
+public class TestIdentityUrl {
+
+ private static String URL;
+
+ @BeforeClass
+ public static void before() {
+ Properties props = ConfigurationFactory.getConfiguration().getProperties();
+ URL = props.getProperty("");
+ }
+
+ /**
+ * Test that we can parse and interpret valid URLs
+ */
+ @Test
+ public void testValidURLs() {
+ URL = "http://192.168.1.1:5000/v2.0/";
+ IdentityURL idurl = IdentityURL.parseURL(URL);
+ assertNotNull(idurl);
+ System.out.println(idurl.getVersion());
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java
new file mode 100644
index 000000000..d83c18b04
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java
@@ -0,0 +1,943 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.iaas.ProviderAdapter;
+import org.openecomp.appc.adapter.iaas.impl.ProviderAdapterImpl;
+import org.openecomp.appc.adapter.iaas.impl.ProviderCache;
+import org.openecomp.appc.adapter.iaas.impl.ServiceCatalog;
+import org.openecomp.appc.adapter.iaas.impl.TenantCache;
+import org.openecomp.appc.adapter.iaas.impl.VMURL;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.exceptions.UnknownProviderException;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.zones.ComputeService;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.ContextFactory;
+import com.att.cdp.zones.model.Image;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Server.Status;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import com.woorea.openstack.keystone.model.Access.Service.Endpoint;
+
+/**
+ * Test the ProviderAdapter implementation.
+ */
+@Category(org.openecomp.appc.adapter.iaas.impl.TestProviderAdapterImpl.class)
+public class TestProviderAdapterImpl {
+
+ @SuppressWarnings("nls")
+ private static final String PROVIDER_NAME = "ILAB";
+
+ @SuppressWarnings("nls")
+ private static final String PROVIDER_TYPE = "OpenStackProvider";
+
+ private static String IDENTITY_URL;
+
+ private static String PRINCIPAL;
+
+ private static String CREDENTIAL;
+
+ private static String TENANT_NAME;
+
+ private static String TENANT_ID;
+
+ private static String USER_ID;
+
+ private static String REGION_NAME;
+
+ private static String SERVER_URL;
+
+ private static Class<?> providerAdapterImplClass;
+ private static Class<?> configurationFactoryClass;
+ private static Field providerCacheField;
+ private static Field configField;
+
+ private ProviderAdapterImpl adapter;
+
+ /**
+ * Use reflection to locate fields and methods so that they can be manipulated during the test to change the
+ * internal state accordingly.
+ *
+ * @throws NoSuchFieldException
+ * if the field(s) dont exist
+ * @throws SecurityException
+ * if reflective access is not allowed
+ * @throws NoSuchMethodException
+ * If the method(s) dont exist
+ */
+ @SuppressWarnings("nls")
+ @BeforeClass
+ public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
+ providerAdapterImplClass = ProviderAdapterImpl.class;
+ configurationFactoryClass = ConfigurationFactory.class;
+
+ providerCacheField = providerAdapterImplClass.getDeclaredField("providerCache");
+ providerCacheField.setAccessible(true);
+
+ configField = configurationFactoryClass.getDeclaredField("config");
+ configField.setAccessible(true);
+
+ Properties props = ConfigurationFactory.getConfiguration().getProperties();
+ IDENTITY_URL = props.getProperty("provider1.identity");
+ PRINCIPAL = props.getProperty("provider1.tenant1.userid", "appc");
+ CREDENTIAL = props.getProperty("provider1.tenant1.password", "appc");
+ TENANT_NAME = props.getProperty("provider1.tenant1.name", "appc");
+ TENANT_ID = props.getProperty("provider1.tenant1.id", "abcde12345fghijk6789lmnopq123rst");
+ REGION_NAME = props.getProperty("provider1.tenant1.region", "RegionOne");
+ SERVER_URL = props.getProperty("test.url");
+ }
+
+ /**
+ * Setup the test environment.
+ *
+ * @throws IllegalAccessException
+ * if this Field object is enforcing Java language access control and the underlying field is either
+ * inaccessible or final.
+ * @throws IllegalArgumentException
+ * if the specified object is not an instance of the class or interface declaring the underlying field
+ * (or a subclass or implementor thereof), or if an unwrapping conversion fails.
+ * @throws NullPointerException
+ * if the specified object is null and the field is an instance field.
+ * @throws ExceptionInInitializerError
+ * if the initialization provoked by this method fails.
+ */
+ @Before
+ public void setup() throws IllegalArgumentException, IllegalAccessException {
+ configField.set(null, null);
+ Properties properties = new Properties();
+ adapter = new ProviderAdapterImpl(properties);
+ }
+
+ /**
+ * This method inspects the provider adapter implementation to make sure that the cache of providers and tenants, as
+ * well as the service catalog, and all pools of contexts have been set up correctly.
+ *
+ * @throws IllegalAccessException
+ * if this Field object is enforcing Java language access control and the underlying field is
+ * inaccessible.
+ * @throws IllegalArgumentException
+ * if the specified object is not an instance of the class or interface declaring the underlying field
+ * (or a subclass or implementor thereof).
+ */
+ @SuppressWarnings({
+ "unchecked"
+ })
+ @Ignore
+ @Test
+ public void validateCacheIsCreatedCorrectly() throws IllegalArgumentException, IllegalAccessException {
+ Map<String, ProviderCache> providerCaches = (Map<String, ProviderCache>) providerCacheField.get(adapter);
+
+ assertNotNull(providerCaches);
+ assertEquals(1, providerCaches.size());
+ assertTrue(providerCaches.containsKey(PROVIDER_NAME));
+
+ ProviderCache providerCache = providerCaches.get(PROVIDER_NAME);
+ assertEquals(PROVIDER_NAME, providerCache.getProviderName());
+ assertEquals(PROVIDER_TYPE, providerCache.getProviderType());
+
+ Map<String, TenantCache> tenantCaches = providerCache.getTenants();
+ assertNotNull(tenantCaches);
+ assertEquals(1, tenantCaches.size());
+ assertTrue(tenantCaches.containsKey(TENANT_NAME));
+
+ TenantCache tenantCache = tenantCaches.get(TENANT_NAME);
+
+ assertEquals(TENANT_ID, tenantCache.getTenantId());
+ assertEquals(TENANT_NAME, tenantCache.getTenantName());
+ assertEquals(USER_ID, tenantCache.getUserid());
+
+ ServiceCatalog catalog = tenantCache.getServiceCatalog();
+ assertNotNull(catalog);
+
+ System.out.println(catalog.toString());
+ List<String> serviceTypes = catalog.getServiceTypes();
+ assertNotNull(serviceTypes);
+ assertEquals(12, serviceTypes.size());
+
+ assertEquals(TENANT_NAME, catalog.getTenantName());
+ assertEquals(TENANT_ID, catalog.getTenantId());
+
+ Set<String> regionNames = catalog.getRegions();
+ assertNotNull(regionNames);
+ assertEquals(1, regionNames.size());
+ assertTrue(regionNames.contains(REGION_NAME));
+
+ List<Endpoint> endpoints = catalog.getEndpoints(ServiceCatalog.IDENTITY_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ Endpoint endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+ assertEquals(IDENTITY_URL, endpoint.getPublicURL());
+
+ endpoints = catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+
+ endpoints = catalog.getEndpoints(ServiceCatalog.VOLUME_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+
+ endpoints = catalog.getEndpoints(ServiceCatalog.IMAGE_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+
+ endpoints = catalog.getEndpoints(ServiceCatalog.NETWORK_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+
+ assertTrue(catalog.isServicePublished(ServiceCatalog.IDENTITY_SERVICE));
+ assertTrue(catalog.isServicePublished(ServiceCatalog.COMPUTE_SERVICE));
+ assertTrue(catalog.isServicePublished(ServiceCatalog.VOLUME_SERVICE));
+ assertTrue(catalog.isServicePublished(ServiceCatalog.IMAGE_SERVICE));
+ assertTrue(catalog.isServicePublished(ServiceCatalog.NETWORK_SERVICE));
+ }
+
+ /**
+ * This test case is used to actually validate that a server has been restarted from an already running state
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ */
+ // @Ignore
+ @Test
+ public void testRestartRunningServer()
+ throws IllegalStateException, IllegalArgumentException, ZoneException, UnknownProviderException, IOException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+ properties.setProperty(ContextFactory.PROPERTY_DISABLE_PROXY, "true");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ if (!server.getStatus().equals(Status.RUNNING)) {
+ server.start();
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+ }
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.restartServer(params, svcContext);
+
+ assertEquals(Server.Status.RUNNING, server.getStatus());
+ }
+ }
+
+
+ /****************************************/
+ /**
+ * Tests that the vmStatuschecker method works and returns the correct status of the VM requested
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ */
+ // @Ignore
+ @Test
+ public void testVmStatuschecker() throws IllegalStateException, IllegalArgumentException, ZoneException,
+ UnknownProviderException, IOException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+ properties.setProperty(ContextFactory.PROPERTY_DISABLE_PROXY, "true");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ if (!server.getStatus().equals(Status.RUNNING)) {
+ server.start();
+ assertTrue(waitForStateChange(server, Status.RUNNING));}
+ //or instead of the if-block, can ensureRunning(server) be used?
+ ensureRunning(server);
+ assertEquals(Server.Status.RUNNING, server.getStatus());
+ }
+ }
+ /****************************************/
+
+
+ /**
+ * Tests that we can restart a server that is already stopped
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ // @Ignore
+ @Test
+ public void testRestartStoppedServer()
+ throws IllegalStateException, IllegalArgumentException, ZoneException, UnknownProviderException, IOException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ if (!server.getStatus().equals(Status.READY)) {
+ server.stop();
+ assertTrue(waitForStateChange(server, Status.READY));
+ }
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.restartServer(params, svcContext);
+
+ assertEquals(Server.Status.RUNNING, server.getStatus());
+
+ }
+ }
+
+ /**
+ * Tests that we can rebuild a running server (not created from a bootable volume)
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ * If the server cannot be rebuilt for some reason
+ */
+ // @Ignore
+ @Test
+ public void testRebuildRunningServer()
+ throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ ensureRunning(server);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.rebuildServer(params, svcContext);
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+
+ }
+ }
+
+ /**
+ * Tests that we can rebuild a paused server (not created from a bootable volume)
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ * If the server cannot be rebuilt for some reason
+ */
+ // @Ignore
+ @Test
+ public void testRebuildPausedServer()
+ throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ ensurePaused(server);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.rebuildServer(params, svcContext);
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+ }
+ }
+
+ /**
+ * Tests that we can rebuild a paused server (not created from a bootable volume)
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ * If the server cannot be rebuilt for some reason
+ */
+ // @Ignore
+ @Test
+ public void testRebuildSuspendedServer()
+ throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ ensureSuspended(server);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.rebuildServer(params, svcContext);
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+ }
+ }
+
+ /**
+ * Tests that we can rebuild a paused server (not created from a bootable volume)
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ * If the server cannot be rebuilt for some reason
+ */
+ // @Ignore
+ @Test
+ public void testRebuildStoppedServer()
+ throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ ensureStopped(server);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.rebuildServer(params, svcContext);
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+ }
+ }
+
+ /**
+ * Test subsequent action on second vm in different Tenant resulting in {"itemNotFound": {"message": "Instance could not be found", "code": 404}}
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ */
+
+ @Test
+ public void testTenantVerification() throws IllegalStateException, IllegalArgumentException, ZoneException,
+ IOException, APPCException {
+
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, "http://example.com:5000");
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, "APP-C");
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ String vmUrl =
+ "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+
+ //try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ // context.login("AppC", "AppC");
+
+ // call lookupServer on vm in defined tenant "APP-C_TLV"
+ VMURL vm = VMURL.parseURL(vmUrl);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+ params.put(ProviderAdapter.PROPERTY_IDENTITY_URL, "http://example.com:5000/v2.0");
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, "http://example.com:5000/v2.0");
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ long start, end = 0;
+
+ System.out.println("\n--------------------Begin lookupServer on tenant 1--------------------");
+ start = System.currentTimeMillis();
+ Server server = adapter.lookupServer(params, svcContext);
+ end = System.currentTimeMillis();
+
+ System.out.println(String.format("lookupServer on tenant 1 took %ds", (end - start) / 1000));
+ System.out.println("----------------------------------------------------------------------\n");
+ assertNotNull(server);
+
+ //repeat to show that context is reused for second request
+ System.out.println("\n-----------------Begin repeat lookupServer on tenant 1----------------");
+ start = System.currentTimeMillis();
+ server = adapter.lookupServer(params, svcContext);
+ end = System.currentTimeMillis();
+
+ System.out.println(String.format("Repeat lookupServer on tenant 1 took %ds", (end - start) / 1000));
+ System.out.println("----------------------------------------------------------------------\n");
+ assertNotNull(server);
+
+ // call lookupServer on vm in second tenant "Play"
+ // This is where we would fail due to using the previous
+ // tenants context
+ vmUrl = "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+ vm = VMURL.parseURL(vmUrl);
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+
+ System.out.println("\n--------------------Begin lookupServer on tenant 2--------------------");
+ start = System.currentTimeMillis();
+ server = adapter.lookupServer(params, svcContext);
+ end = System.currentTimeMillis();
+ System.out.println(String.format("\nlookupServer on tenant 2 took %ds", (end - start) / 1000));
+ System.out.println("----------------------------------------------------------------------\n");
+ assertNotNull(server);
+
+ // call lookupServer on vm in non-existing tenant
+ vmUrl = "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+ vm = VMURL.parseURL(vmUrl);
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+
+ System.out.println("\n--------------Begin lookupServer on non-existant tenant--------------");
+ start = System.currentTimeMillis();
+ server = adapter.lookupServer(params, svcContext);
+ end = System.currentTimeMillis();
+ System.out.println(String.format("\nlookupServer on tenant 3 took %ds", (end - start) / 1000));
+ System.out.println("----------------------------------------------------------------------\n");
+ assertNull(server);
+
+ //}
+ }
+ /****************************************/
+
+
+ @Test
+ public void testSnapshotServer() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, "http://example.com:5000");
+ // properties.setProperty(ContextFactory.PROPERTY_REGION, "");
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, "Play");
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ String vmUrl =
+ "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login("AppC", "AppC");
+ VMURL vm = VMURL.parseURL(vmUrl);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+ params.put(ProviderAdapter.PROPERTY_IDENTITY_URL, "http://example.com:5000/v2.0");
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, "http://example.com:5000/v2.0");
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ long start, end = 0;
+
+ start = System.currentTimeMillis();
+ Image image = adapter.createSnapshot(params, svcContext);
+ end = System.currentTimeMillis();
+
+ System.out.println(String.format("Image ID: %s", image.getId()));
+ System.out.println(String.format("Snapshot took %ds", (end - start) / 1000));
+
+ start = System.currentTimeMillis();
+ adapter.rebuildServer(params, svcContext);
+ end = System.currentTimeMillis();
+ System.out.println(String.format("Rebuild took %ds", (end - start) / 1000));
+ }
+
+ }
+
+ /**
+ * Ensures that the server is in stopped (shutdown) state prior to test
+ *
+ * @param server
+ * The server to ensure is stopped
+ * @throws ZoneException
+ * If the server can't be operated upon for some reason
+ */
+ @SuppressWarnings("nls")
+ private static void ensureStopped(Server server) throws ZoneException {
+ switch (server.getStatus()) {
+ case READY:
+ break;
+
+ case PENDING:
+ waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
+ Server.Status.SUSPENDED, Server.Status.ERROR);
+ ensureSuspended(server);
+ break;
+
+ case PAUSED:
+ server.unpause();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.stop();
+ waitForStateChange(server, Server.Status.READY);
+ break;
+
+ case SUSPENDED:
+ server.resume();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.stop();
+ waitForStateChange(server, Server.Status.READY);
+ break;
+
+ case RUNNING:
+ server.stop();
+ waitForStateChange(server, Server.Status.READY);
+ break;
+
+ case DELETED:
+ case ERROR:
+ default:
+ fail("Server state is not valid for test - " + server.getStatus().name());
+ }
+ }
+
+ /**
+ * Ensures that the server is in suspended state prior to test
+ *
+ * @param server
+ * The server to ensure is suspended
+ * @throws ZoneException
+ * If the server can't be operated upon for some reason
+ */
+ @SuppressWarnings("nls")
+ private static void ensureSuspended(Server server) throws ZoneException {
+ switch (server.getStatus()) {
+ case SUSPENDED:
+ break;
+
+ case PENDING:
+ waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
+ Server.Status.SUSPENDED, Server.Status.ERROR);
+ ensureSuspended(server);
+ break;
+
+ case PAUSED:
+ server.unpause();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.suspend();
+ waitForStateChange(server, Server.Status.SUSPENDED);
+ break;
+
+ case READY:
+ server.start();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.suspend();
+ waitForStateChange(server, Server.Status.SUSPENDED);
+ break;
+
+ case RUNNING:
+ server.suspend();
+ waitForStateChange(server, Server.Status.SUSPENDED);
+ break;
+
+ case DELETED:
+ case ERROR:
+ default:
+ fail("Server state is not valid for test - " + server.getStatus().name());
+ }
+ }
+
+ /**
+ * This method makes sure that the indicated server is running before performing a test
+ *
+ * @param server
+ * The server to ensure is running
+ * @throws ZoneException
+ * If the server can't be operated upon
+ */
+ @SuppressWarnings("nls")
+ private static void ensureRunning(Server server) throws ZoneException {
+ switch (server.getStatus()) {
+ case RUNNING:
+ break;
+
+ case PENDING:
+ waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
+ Server.Status.SUSPENDED, Server.Status.ERROR);
+ ensureRunning(server);
+ break;
+
+ case PAUSED:
+ server.unpause();
+ waitForStateChange(server, Server.Status.RUNNING);
+ break;
+
+ case SUSPENDED:
+ server.resume();
+ waitForStateChange(server, Server.Status.RUNNING);
+ break;
+
+ case READY:
+ server.start();
+ waitForStateChange(server, Server.Status.RUNNING);
+ break;
+
+ case DELETED:
+ case ERROR:
+ default:
+ fail("Server state is not valid for test - " + server.getStatus().name());
+ }
+ }
+
+ /**
+ * This method will make sure that the server we are testing is paused
+ *
+ * @param server
+ * The server to make sure is paused for the test
+ * @throws ZoneException
+ * If anything fails
+ */
+ @SuppressWarnings("nls")
+ private static void ensurePaused(Server server) throws ZoneException {
+ switch (server.getStatus()) {
+ case PAUSED:
+ break;
+
+ case PENDING:
+ waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
+ Server.Status.SUSPENDED, Server.Status.ERROR);
+ ensurePaused(server);
+ break;
+
+ case READY:
+ server.start();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.pause();
+ waitForStateChange(server, Server.Status.PAUSED);
+ break;
+
+ case RUNNING:
+ server.pause();
+ waitForStateChange(server, Server.Status.PAUSED);
+ break;
+
+ case SUSPENDED:
+ server.resume();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.pause();
+ waitForStateChange(server, Server.Status.PAUSED);
+ break;
+
+ case ERROR:
+ case DELETED:
+ default:
+ fail("Server state is not valid for test - " + server.getStatus().name());
+ }
+ }
+
+ /**
+ * Enter a pool-wait loop checking the server state to see if it has entered one of the desired states or not.
+ * <p>
+ * This method checks the state of the server periodically for one of the desired states. When the server enters one
+ * of the desired states, the method returns a successful indication (true). If the server never enters one of the
+ * desired states within the alloted timeout period, then the method returns a failed response (false). No
+ * exceptions are thrown from this method.
+ * </p>
+ *
+ * @param server
+ * The server to wait on
+ * @param desiredStates
+ * A variable list of desired states, any one of which is allowed.
+ * @return True if the server entered one of the desired states, and false if not and the wait loop timed out.
+ */
+ private static boolean waitForStateChange(Server server, Server.Status... desiredStates) {
+ int timeout =
+ ConfigurationFactory.getConfiguration().getIntegerProperty(Constants.PROPERTY_SERVER_STATE_CHANGE_TIMEOUT);
+ long limit = System.currentTimeMillis() + (timeout * 1000);
+ Server vm = server;
+
+ try {
+ while (limit > System.currentTimeMillis()) {
+ vm.refresh();
+ for (Server.Status desiredState : desiredStates) {
+ if (server.getStatus().equals(desiredState)) {
+ return true;
+ }
+ }
+
+ try {
+ Thread.sleep(10000L);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ } catch (ZoneException e) {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+
+ /*
+ * @Test public void testTerminateStack() throws IllegalStateException, IllegalArgumentException, ZoneException,
+ * UnknownProviderException, IOException { Properties properties = new Properties();
+ * properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ * properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ * properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ * properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+ * properties.setProperty(ContextFactory.PROPERTY_DISABLE_PROXY, "true"); try (Context context =
+ * ContextFactory.getContext(PROVIDER_TYPE, properties)) { context.login(PRINCIPAL, CREDENTIAL); VMURL vm =
+ * VMURL.parseURL(SERVER_URL); ComputeService computeService = context.getComputeService(); Server server =
+ * computeService.getServer(vm.getServerId()); if (!server.getStatus().equals(Status.RUNNING)) { server.start();
+ * assertTrue(waitForStateChange(server, Status.RUNNING)); } Map<String, String> params = new HashMap<>();
+ * params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL); params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME,
+ * PROVIDER_NAME); SvcLogicContext svcContext = new SvcLogicContext(); Stack stack = adapter.terminateStack(params,
+ * svcContext); assertNotNull(stack); } }
+ */
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImplNoConnection.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImplNoConnection.java
new file mode 100644
index 000000000..d4683aa80
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImplNoConnection.java
@@ -0,0 +1,170 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import java.lang.reflect.Field;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.appc.adapter.iaas.impl.ProviderAdapterImpl;
+import org.openecomp.appc.adapter.iaas.impl.RequestContext;
+import org.openecomp.appc.adapter.iaas.impl.RequestFailedException;
+import org.openecomp.appc.adapter.iaas.impl.VMURL;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.slf4j.MDC;
+
+/**
+ * This class is used to test methods and functions of the adapter implementation that do not require and do not set up
+ * connections to any providers.
+ */
+
+public class TestProviderAdapterImplNoConnection {
+
+ private static Class<?> providerAdapterImplClass;
+ private static Class<?> configurationFactoryClass;
+ private static Field providerCacheField;
+ private static Field configField;
+
+ private ProviderAdapterImpl adapter;
+
+ /**
+ * Use reflection to locate fields and methods so that they can be manipulated during the test to change the
+ * internal state accordingly.
+ *
+ * @throws NoSuchFieldException
+ * if the field(s) dont exist
+ * @throws SecurityException
+ * if reflective access is not allowed
+ * @throws NoSuchMethodException
+ * If the method(s) dont exist
+ */
+ @SuppressWarnings("nls")
+ @BeforeClass
+ public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
+ providerAdapterImplClass = ProviderAdapterImpl.class;
+ configurationFactoryClass = ConfigurationFactory.class;
+
+ providerCacheField = providerAdapterImplClass.getDeclaredField("providerCache");
+ providerCacheField.setAccessible(true);
+
+ configField = configurationFactoryClass.getDeclaredField("config");
+ configField.setAccessible(true);
+ }
+
+ /**
+ * initialize the test cases
+ */
+ @Before
+ public void setup() {
+ adapter = new ProviderAdapterImpl(false);
+ }
+
+ /**
+ * This test expects a failure because the value to be validated is a null URL
+ *
+ * @throws RequestFailedException
+ * Expected
+ */
+ @SuppressWarnings("nls")
+ @Test(expected = RequestFailedException.class)
+ public void testValidateParameterPatternExpectFailNullValue() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link = null;
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+
+ /**
+ * This test expects a failure because the value to be validated is an empty URL
+ *
+ * @throws RequestFailedException
+ * Expected
+ */
+ @SuppressWarnings("nls")
+ @Test(expected = RequestFailedException.class)
+ public void testValidateParameterPatternExpectFailEmptyValue() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link = "";
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+
+ /**
+ * This test expects a failure because the value to be validated is a blank URL
+ *
+ * @throws RequestFailedException
+ * Expected
+ */
+ @SuppressWarnings("nls")
+ @Test(expected = RequestFailedException.class)
+ public void testValidateParameterPatternExpectFailBlankValue() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link = " ";
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+
+ /**
+ * This test expects a failure because the value to be validated is a bad URL
+ *
+ * @throws RequestFailedException
+ * Expected
+ */
+ @SuppressWarnings("nls")
+ @Test(expected = RequestFailedException.class)
+ public void testValidateParameterPatternExpectFailBadURL() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link = "http://some.host:1234/01d82c08594a4b23a0f9260c94be0c4d/";
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+
+ /**
+ * This test expects to pass
+ *
+ * @throws RequestFailedException
+ * Un-Expected
+ */
+ @SuppressWarnings("nls")
+ @Test
+ public void testValidateParameterPatternValidURL() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link =
+ "http://some.host:1234/v2/01d82c08594a4b23a0f9260c94be0c4d/servers/f888f89f-096b-421e-ba36-34f714071551";
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java
new file mode 100644
index 000000000..a7cc5dc3c
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java
@@ -0,0 +1,159 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.iaas.impl.RequestContext;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+
+/**
+ * Test the RequestContext object
+ * <p>
+ * The request context is used to track retries, recovery attempts, and time to live of the processing of a request.
+ * </p>
+ */
+
+public class TestRequestContext {
+
+ private RequestContext rc;
+ private Configuration config = ConfigurationFactory.getConfiguration();
+
+ /**
+ * Set up the test environment by forcing the retry delay and limit to small values for the test and setting up the
+ * request context object.
+ */
+ @Before
+ public void setup() {
+ config.setProperty(Constants.PROPERTY_RETRY_DELAY, "1");
+ config.setProperty(Constants.PROPERTY_RETRY_LIMIT, "3");
+ rc = new RequestContext(null);
+ rc.setTimeToLiveSeconds(2);
+ }
+
+ /**
+ * Ensure that we set up the property correctly
+ */
+ @Test
+ public void testRetryDelayProperty() {
+ assertEquals(1, rc.getRetryDelay());
+ }
+
+ /**
+ * Ensure that we set up the property correctly
+ */
+ @Test
+ public void testRetryLimitProperty() {
+ assertEquals(3, rc.getRetryLimit());
+ }
+
+ /**
+ * This test ensures that the retry attempt counter is zero on a new context
+ */
+ @Test
+ public void testRetryCountNoRetries() {
+ assertEquals(0, rc.getAttempts());
+ }
+
+ /**
+ * Test that the delay is accurate
+ */
+ @Test
+ public void testDelay() {
+ long future = System.currentTimeMillis() + (rc.getRetryDelay() * 1000L);
+
+ rc.delay();
+
+ assertTrue(System.currentTimeMillis() >= future);
+ }
+
+ /**
+ * The RequestContext tracks the number of retry attempts against the limit. This test verifies that tracking logic
+ * works correctly.
+ */
+ @Test
+ public void testCanRetry() {
+ assertEquals(0, rc.getAttempts());
+ assertTrue(rc.attempt());
+ assertEquals(1, rc.getAttempts());
+ assertTrue(rc.attempt());
+ assertEquals(2, rc.getAttempts());
+ assertTrue(rc.attempt());
+ assertEquals(3, rc.getAttempts());
+ assertFalse(rc.attempt());
+ assertEquals(3, rc.getAttempts());
+ assertFalse(rc.attempt());
+ assertEquals(3, rc.getAttempts());
+ assertFalse(rc.attempt());
+ assertEquals(3, rc.getAttempts());
+ }
+
+ /**
+ * The same RequestContext is used throughout the processing, and retries need to be reset once successfully
+ * connected so that any earlier (successful) recoveries are not considered when performing any new future
+ * recoveries. This test ensures that a reset clears the retry counter and that we can attempt retries again up to
+ * the limit.
+ */
+ @Test
+ public void testResetAndCanRetry() {
+ assertTrue(rc.attempt());
+ assertTrue(rc.attempt());
+ assertTrue(rc.attempt());
+ rc.reset();
+
+ assertTrue(rc.attempt());
+ assertTrue(rc.attempt());
+ assertTrue(rc.attempt());
+ assertFalse(rc.attempt());
+ assertFalse(rc.attempt());
+ assertFalse(rc.attempt());
+ }
+
+ /**
+ * This test is used to test tracking of time to live for the request context. Because time is inexact, the
+ * assertions can only be ranges of values, such as at least some value or greater. The total duration tracking in
+ * the request context is only updated on each call to {@link RequestContext#isAlive()}. Also, durations are NOT
+ * affected by calls to reset.
+ */
+ @Test
+ public void testTimeToLive() {
+ assertTrue(rc.getTotalDuration() == 0L);
+ assertTrue(rc.isAlive());
+ rc.reset();
+ rc.delay();
+ assertTrue(rc.isAlive());
+ assertTrue(rc.getTotalDuration() >= 1000L);
+ rc.reset();
+ rc.delay();
+ rc.isAlive();
+ assertTrue(rc.getTotalDuration() >= 2000L);
+ rc.reset();
+ rc.delay();
+ assertFalse(rc.isAlive());
+ assertTrue(rc.getTotalDuration() >= 3000L);
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java
new file mode 100644
index 000000000..ac8cde31a
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openecomp.appc.adapter.iaas.impl.ServiceCatalog;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import com.att.cdp.exceptions.ZoneException;
+
+import com.woorea.openstack.keystone.model.Access.Service;
+
+/**
+ * This class tests the service catalog against a known provider.
+ */
+@Ignore
+public class TestServiceCatalog {
+
+ // Number
+ private static int EXPECTED_REGIONS = 1;
+ private static int EXPECTED_ENDPOINTS = 1;
+
+ private static String PRINCIPAL;
+ private static String CREDENTIAL;
+ private static String TENANT_NAME;
+ private static String TENANT_ID;
+ private static String IDENTITY_URL;
+ private static String REGION_NAME;
+
+ private ServiceCatalog catalog;
+
+ private Properties properties;
+
+ @BeforeClass
+ public static void before() {
+ Properties props = ConfigurationFactory.getConfiguration().getProperties();
+ IDENTITY_URL = props.getProperty("provider1.identity");
+ PRINCIPAL = props.getProperty("provider1.tenant1.userid", "appc");
+ CREDENTIAL = props.getProperty("provider1.tenant1.password", "appc");
+ TENANT_NAME = props.getProperty("provider1.tenant1.name", "appc");
+ TENANT_ID =
+ props.getProperty("provider1.tenant1.id",
+ props.getProperty("test.tenantid", "abcde12345fghijk6789lmnopq123rst"));
+ REGION_NAME = props.getProperty("provider1.tenant1.region", "RegionOne");
+
+ EXPECTED_REGIONS = Integer.valueOf(props.getProperty("test.expected-regions", "0"));
+ EXPECTED_ENDPOINTS = Integer.valueOf(props.getProperty("test.expected-endpoints", "0"));
+ }
+
+ /**
+ * Setup the test environment by loading a new service catalog for each test
+ *
+ * @throws ZoneException
+ */
+ @Before
+ public void setup() throws ZoneException {
+ properties = new Properties();
+ catalog = new ServiceCatalog(IDENTITY_URL, TENANT_NAME, PRINCIPAL, CREDENTIAL, properties);
+ }
+
+ /**
+ * Test that the tenant name and ID are returned correctly
+ */
+ @Test
+ public void testKnownTenant() {
+ assertEquals(TENANT_NAME, catalog.getTenantName());
+ assertEquals(TENANT_ID, catalog.getTenantId());
+ }
+
+ /**
+ * Test that we find all of the expected region(s)
+ */
+ @Test
+ public void testKnownRegions() {
+ assertEquals(EXPECTED_REGIONS, catalog.getRegions().size());
+ // assertEquals(REGION_NAME, catalog.getRegions().toArray()[0]);
+ }
+
+ /**
+ * Test that we can check for published services correctly
+ */
+ @Test
+ public void testServiceTypesPublished() {
+ assertTrue(catalog.isServicePublished("compute"));
+ assertFalse(catalog.isServicePublished("bogus"));
+ }
+
+ /**
+ * Check that we can get the list of published services
+ */
+ @Test
+ public void testPublishedServicesList() {
+ List<String> services = catalog.getServiceTypes();
+
+ assertTrue(services.contains(ServiceCatalog.COMPUTE_SERVICE));
+ assertTrue(services.contains(ServiceCatalog.IDENTITY_SERVICE));
+ assertTrue(services.contains(ServiceCatalog.IMAGE_SERVICE));
+ assertTrue(services.contains(ServiceCatalog.NETWORK_SERVICE));
+ assertTrue(services.contains(ServiceCatalog.VOLUME_SERVICE));
+ }
+
+ /**
+ * Test that we can get the endpoint(s) for a service
+ */
+ @Test
+ public void testEndpointList() {
+ List<Service.Endpoint> endpoints = catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE);
+
+ assertNotNull(endpoints);
+ assertFalse(endpoints.isEmpty());
+ assertEquals(EXPECTED_ENDPOINTS, endpoints.size());
+
+ Service.Endpoint endpoint = endpoints.get(0);
+ // assertEquals(REGION_NAME, endpoint.getRegion());
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java
new file mode 100644
index 000000000..852bb4137
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.Properties;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.appc.adapter.iaas.impl.VMURL;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+
+public class TestVMURL {
+
+ private static String IP;
+ private static String PORT;
+ private static String TENANTID;
+ private static String VMID;
+ private static String URL;
+
+ @BeforeClass
+ public static void before() {
+ Properties props = ConfigurationFactory.getConfiguration().getProperties();
+ IP = props.getProperty("test.ip");
+ PORT = props.getProperty("test.port");
+ TENANTID = props.getProperty("test.tenantid");
+ VMID = props.getProperty("test.vmid");
+ URL = String.format("http://%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID);
+ }
+
+ /**
+ * Test that we can parse and interpret valid URLs
+ */
+ @Test
+ public void testValidURLs() {
+ VMURL url = VMURL.parseURL(URL);
+
+ assertEquals("http", url.getScheme());
+ assertEquals(IP, url.getHost());
+ assertEquals(PORT, url.getPort());
+ assertEquals(TENANTID, url.getTenantId());
+ assertEquals(VMID, url.getServerId());
+
+ url = VMURL.parseURL(String.format("http://%s/v2/%s/servers/%s", IP, TENANTID, VMID));
+ assertEquals("http", url.getScheme());
+ assertEquals(IP, url.getHost());
+ assertNull(url.getPort());
+ assertEquals(TENANTID, url.getTenantId());
+ assertEquals(VMID, url.getServerId());
+ }
+
+ /**
+ * Test that we ignore and return null for invalid URLs
+ */
+ @Test
+ public void testInvalidURLs() {
+ VMURL url = VMURL.parseURL(null);
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("http:/%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("http:///%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("http://v2/%s/servers/%s", TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/%s/servers/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/v2/servers/%s", IP, PORT, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/v2/%s/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/v2/%s/servers", IP, PORT, TENANTID));
+ assertNull(url);
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
new file mode 100644
index 000000000..d552edccf
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
@@ -0,0 +1,181 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.test;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.openecomp.appc.test.InterceptLogger;
+
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+/**
+ * This class is used as a test harness to wrap the call to an executor node.
+ */
+
+public class ExecutorHarness {
+
+ /**
+ * The executor to be tested
+ */
+ private SvcLogicJavaPlugin executor;
+
+ /**
+ * The collection of all exec methods found on the class
+ */
+ private Map<String, Method> methods;
+
+ /**
+ * The field of the class being tested that contains the reference to the logger to be used. This is modified to
+ * point to our interception logger for the test.
+ */
+ private Field contextLogger;
+
+ /**
+ * The interception logger that buffers all messages logged and allows us to look at them as part of the test case.
+ */
+ private InterceptLogger logger;
+
+ /**
+ * Create the harness and initialize it
+ *
+ * @throws SecurityException
+ * If a security manager, s, is present and any of the following conditions is met:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>the caller's class loader is not the same as or an ancestor of the class loader for the current
+ * class and invocation of s.checkPackageAccess() denies access to the package of this class</li>
+ * </ul>
+ * @throws NoSuchFieldException
+ * if a field with the specified name is not found.
+ * @throws IllegalAccessException
+ * if this Field object is enforcing Java language access control and the underlying field is either
+ * inaccessible or final.
+ * @throws IllegalArgumentException
+ * if the specified object is not an instance of the class or interface declaring the underlying field
+ * (or a subclass or implementor thereof), or if an unwrapping conversion fails.
+ */
+ @SuppressWarnings("nls")
+ public ExecutorHarness() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
+ IllegalAccessException {
+ methods = new HashMap<>();
+ new SvcLogicContext();
+
+ Class<?> contextClass = SvcLogicContext.class;
+ contextLogger = contextClass.getDeclaredField("LOG");
+ contextLogger.setAccessible(true);
+ logger = new InterceptLogger();
+ contextLogger.set(null, logger);
+ }
+
+ /**
+ * Convenience constructor
+ *
+ * @param executor
+ * The executor to be tested by the harness
+ * @throws SecurityException
+ * If a security manager, s, is present and any of the following conditions is met:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>the caller's class loader is not the same as or an ancestor of the class loader for the current
+ * class and invocation of s.checkPackageAccess() denies access to the package of this class</li>
+ * </ul>
+ * @throws NoSuchFieldException
+ * if a field with the specified name is not found.
+ * @throws IllegalAccessException
+ * if this Field object is enforcing Java language access control and the underlying field is either
+ * inaccessible or final.
+ * @throws IllegalArgumentException
+ * if the specified object is not an instance of the class or interface declaring the underlying field
+ * (or a subclass or implementor thereof), or if an unwrapping conversion fails.
+ */
+ public ExecutorHarness(SvcLogicJavaPlugin executor) throws NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException {
+ this();
+ setExecutor(executor);
+ }
+
+ /**
+ * @param executor
+ * The java plugin class to be executed
+ */
+ public void setExecutor(SvcLogicJavaPlugin executor) {
+ this.executor = executor;
+ scanExecutor();
+ }
+
+ /**
+ * @return The java plugin class to be executed
+ */
+ public SvcLogicJavaPlugin getExecutor() {
+ return executor;
+ }
+
+ /**
+ * @return The set of all methods that meet the signature requirements
+ */
+ public List<String> getExecMethodNames() {
+ List<String> names = new ArrayList<>();
+ names.addAll(methods.keySet());
+ return names;
+ }
+
+ /**
+ * Returns an indication if the named method is a valid executor method that could be called from a DG execute node
+ *
+ * @param methodName
+ * The method name to be validated
+ * @return True if the method name meets the signature requirements, false if the method either does not exist or
+ * does not meet the requirements.
+ */
+ public boolean isExecMethod(String methodName) {
+ return methods.containsKey(methodName);
+ }
+
+ /**
+ * This method scans the executor class hierarchy to locate all methods that match the required signature of the
+ * executor and records these methods in a map.
+ */
+ private void scanExecutor() {
+ methods.clear();
+ Class<?> executorClass = executor.getClass();
+ Method[] publicMethods = executorClass.getMethods();
+ for (Method method : publicMethods) {
+ if (method.getReturnType().equals(Void.class)) {
+ Class<?>[] paramTypes = method.getParameterTypes();
+ if (paramTypes.length == 2) {
+ if (Map.class.isAssignableFrom(paramTypes[0])
+ && SvcLogicContext.class.isAssignableFrom(paramTypes[1])) {
+ methods.put(method.getName(), method);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
new file mode 100644
index 000000000..394352136
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
@@ -0,0 +1,451 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.test;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Marker;
+
+import ch.qos.logback.classic.Level;
+
+/**
+ * This class is used as an intercept logger that can be used in testing to intercept and record all messages that are
+ * logged, thus allowing a junit test case to examine the log output and make assertions.
+ */
+public class InterceptLogger implements org.slf4j.Logger {
+
+ /**
+ * This inner class represents an intercepted log event.
+ */
+ public class LogRecord {
+ private Level level;
+ private String message;
+ private long timestamp;
+ private Throwable t;
+
+ public LogRecord(Level level, String message) {
+ setLevel(level);
+ setTimestamp(System.currentTimeMillis());
+ setMessage(message);
+ }
+
+ public LogRecord(Level level, String message, Throwable t) {
+ this(level, message);
+ setThrowable(t);
+ }
+
+ /**
+ * @return the value of level
+ */
+ public Level getLevel() {
+ return level;
+ }
+
+ /**
+ * @return the value of message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * @return the value of timestamp
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * @param level
+ * the value for level
+ */
+ public void setLevel(Level level) {
+ this.level = level;
+ }
+
+ /**
+ * @param message
+ * the value for message
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * @param timestamp
+ * the value for timestamp
+ */
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ /**
+ * @return the value of t
+ */
+ public Throwable getThrowable() {
+ return t;
+ }
+
+ /**
+ * @param t
+ * the value for t
+ */
+ public void setThrowable(Throwable t) {
+ this.t = t;
+ }
+
+ }
+
+ /**
+ * The list of all intercepted log events
+ */
+ private List<LogRecord> events;
+
+ /**
+ * Create the intercept logger
+ */
+ public InterceptLogger() {
+ events = new ArrayList<LogRecord>(1000);
+ }
+
+ /**
+ * @return Returns all intercepted log events
+ */
+ public List<LogRecord> getLogRecords() {
+ return events;
+ }
+
+ /**
+ * Clears all log events
+ */
+ public void clear() {
+ events.clear();
+ }
+
+ @Override
+ public void debug(Marker marker, String msg) {
+ debug(msg);
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object arg) {
+ debug(MessageFormat.format(format, arg));
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object... arguments) {
+ debug(MessageFormat.format(format, arguments));
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object arg1, Object arg2) {
+ debug(MessageFormat.format(format, arg1, arg2));
+ }
+
+ @Override
+ public void debug(Marker marker, String msg, Throwable t) {
+ debug(msg, t);
+ }
+
+ @Override
+ public void debug(String msg) {
+ events.add(new LogRecord(Level.DEBUG, msg));
+ }
+
+ @Override
+ public void debug(String format, Object arg) {
+ events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void debug(String format, Object... arguments) {
+ events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void debug(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void debug(String msg, Throwable t) {
+ events.add(new LogRecord(Level.DEBUG, msg, t));
+ }
+
+ @Override
+ public void error(Marker marker, String msg) {
+ error(msg);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object arg) {
+ error(format, arg);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object... arguments) {
+ error(format, arguments);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object arg1, Object arg2) {
+ error(format, arg1, arg2);
+ }
+
+ @Override
+ public void error(Marker marker, String msg, Throwable t) {
+ events.add(new LogRecord(Level.ERROR, msg, t));
+ }
+
+ @Override
+ public void error(String msg) {
+ events.add(new LogRecord(Level.ERROR, msg));
+ }
+
+ @Override
+ public void error(String format, Object arg) {
+ events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void error(String format, Object... arguments) {
+ events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void error(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void error(String msg, Throwable t) {
+ events.add(new LogRecord(Level.ERROR, msg, t));
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public void info(Marker marker, String msg) {
+ info(msg);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object arg) {
+ info(format, arg);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object... arguments) {
+ info(format, arguments);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object arg1, Object arg2) {
+ info(format, arg1, arg2);
+ }
+
+ @Override
+ public void info(Marker marker, String msg, Throwable t) {
+ events.add(new LogRecord(Level.INFO, msg, t));
+ }
+
+ @Override
+ public void info(String msg) {
+ events.add(new LogRecord(Level.INFO, msg));
+ }
+
+ @Override
+ public void info(String format, Object arg) {
+ events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void info(String format, Object... arguments) {
+ events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void info(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void info(String msg, Throwable t) {
+ events.add(new LogRecord(Level.INFO, msg, t));
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isDebugEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isErrorEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isInfoEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isTraceEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isWarnEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public void trace(Marker marker, String msg) {
+ trace(msg);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object arg) {
+ trace(format, arg);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object... argArray) {
+ trace(format, argArray);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object arg1, Object arg2) {
+ trace(format, arg1, arg2);
+ }
+
+ @Override
+ public void trace(Marker marker, String msg, Throwable t) {
+ trace(msg, t);
+ }
+
+ @Override
+ public void trace(String msg) {
+ events.add(new LogRecord(Level.TRACE, msg));
+ }
+
+ @Override
+ public void trace(String format, Object arg) {
+ events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void trace(String format, Object... arguments) {
+ events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void trace(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void trace(String msg, Throwable t) {
+ events.add(new LogRecord(Level.TRACE, msg, t));
+ }
+
+ @Override
+ public void warn(Marker marker, String msg) {
+ warn(msg);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object arg) {
+ warn(format, arg);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object... arguments) {
+ warn(format, arguments);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object arg1, Object arg2) {
+ warn(format, arg1, arg2);
+ }
+
+ @Override
+ public void warn(Marker marker, String msg, Throwable t) {
+ events.add(new LogRecord(Level.WARN, msg, t));
+ }
+
+ @Override
+ public void warn(String msg) {
+ events.add(new LogRecord(Level.WARN, msg));
+ }
+
+ @Override
+ public void warn(String format, Object arg) {
+ events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void warn(String format, Object... arguments) {
+ events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void warn(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void warn(String msg, Throwable t) {
+ events.add(new LogRecord(Level.WARN, msg, t));
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..2daa085ad
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,109 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#
+# Default properties for the APP-C Provider Adapter
+#
+# -------------------------------------------------------------------------------------------------
+#
+# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded
+# to supply configuration options
+org.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.openecomp.appc.resources=org/openecomp/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.openecomp.appc.provider.adaptor.name=org.openecomp.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.openecomp.appc.logging.file=org/openecomp/appc/logback.xml
+org.openecomp.appc.logging.path=${user.home};etc;../etc
+org.openecomp.appc.logger=org.openecomp.appc
+org.openecomp.appc.security.logger=org.openecomp.appc.security
+#
+# The minimum and maximum provider/tenant context pool sizes. Min=1 means that as soon
+# as the provider/tenant is referenced a Context is opened and added to the pool. Max=0
+# means that the upper bound on the pool is unbounded.
+org.openecomp.appc.provider.min.pool=1
+org.openecomp.appc.provider.max.pool=0
+
+#
+# The following properties are used to configure the retry logic for connection to the
+# IaaS provider(s). The retry delay property is the amount of time, in seconds, the
+# application waits between retry attempts. The retry limit is the number of retries
+# that are allowed before the request is failed.
+org.openecomp.appc.provider.retry.delay = 30
+org.openecomp.appc.provider.retry.limit = 10
+
+#
+# The trusted hosts list for SSL access when a certificate is not provided.
+#
+provider.trusted.hosts=*
+#
+# The amount of time, in seconds, to wait for a server state change (start->stop, stop->start, etc).
+# If the server does not change state to a valid state within the alloted time, the operation
+# fails.
+org.openecomp.appc.server.state.change.timeout=300
+#
+# The amount of time to wait, in seconds, between subsequent polls to the OpenStack provider
+# to refresh the status of a resource we are waiting on.
+#
+org.openecomp.appc.openstack.poll.interval=20
+#
+# The connection information to connect to the provider we are using. These properties
+# are "structured" properties, in that the name is a compound name, where the nodes
+# of the name can be ordered (1, 2, 3, ...). All of the properties with the same ordinal
+# position are defining the same entity. For example, provider1.type and provider1.name
+# are defining the same provider, whereas provider2.name and provider2.type are defining
+# the values for a different provider. Any number of providers can be defined in this
+# way.
+#
+
+
+# Don't change these 2 right now since they are hard coded in the DG
+provider1.type=appc
+provider1.name=appc
+
+#These you can change
+provider1.identity=appc
+provider1.tenant1.name=appc
+provider1.tenant1.userid=appc
+provider1.tenant1.password=appc
+
+# After a change to the provider make sure to recheck these values with an api call to provider1.identity/tokens
+test.expected-regions=1
+test.expected-endpoints=1
+
+#Your OpenStack IP
+test.ip=192.168.1.2
+# Your OpenStack Platform's Keystone Port (default is 5000)
+test.port=5000
+test.tenantid=abcde12345fghijk6789lmnopq123rst
+test.vmid=abc12345-1234-5678-890a-abcdefg12345
+# Port 8774 below is default port for OpenStack's Nova API Service
+test.url=http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345
+