aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test
diff options
context:
space:
mode:
authorVodafone <onap@vodafone.com>2019-03-18 15:08:33 +0530
committerOren Kleks <orenkle@amdocs.com>2019-04-01 09:09:37 +0000
commit84a209835820238f50d84ad5be5b9badaa5283c5 (patch)
tree19b986374820b4fb9ac723baf22a5161ceacf127 /openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test
parent8b8061e8b47703beb7a19174de5c9b29ccf1ca14 (diff)
List of Input Parameters for VSP
Change-Id: Ie913ead731e120bd69349a4ebec13f4521eaac4d Issue-ID: SDC-2049 Co-authored-by: jguistwite@iconectiv.com Signed-off-by: Vodafone <onap@vodafone.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test')
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/csar.zipbin0 -> 14993 bytes
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/fulldefinition.json26
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/managertestconfiguration.yaml13
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/notfound.json6
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/priorexecution.json21
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/runresult.json22
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/scenarios.json10
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testcase-sriov.json48
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testcases.json16
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testconfiguration.yaml11
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testsuites.json6
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testtree.json119
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ConfigurationTests.java78
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolverTest.java88
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImplTests.java283
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingTestSuite.java31
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/resources/logback-test.xml30
17 files changed, 808 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/csar.zip b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/csar.zip
new file mode 100644
index 0000000000..52de39a93e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/csar.zip
Binary files differ
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/fulldefinition.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/fulldefinition.json
new file mode 100644
index 0000000000..3d90bfd007
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/fulldefinition.json
@@ -0,0 +1,26 @@
+{
+ "id": "certquery",
+ "title": "VSP Certifications",
+ "parameters": [
+ {
+ "id": "vspId",
+ "label": "VSP ID",
+ "inputType": "text",
+ "maxLength": 36,
+ "minLength": 1,
+ "placeholder": "VSP ID",
+ "disabled": false,
+ "required": true
+ },
+ {
+ "id": "vspVersion",
+ "label": "VSP Version",
+ "inputType": "text",
+ "maxLength": 36,
+ "minLength": 1,
+ "placeholder": "VSP Version",
+ "disabled": false,
+ "required": true
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/managertestconfiguration.yaml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/managertestconfiguration.yaml
new file mode 100644
index 0000000000..d65becedf9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/managertestconfiguration.yaml
@@ -0,0 +1,13 @@
+externalTestingConfig:
+ client:
+ enabled: true
+ endpoints:
+ - id: vtp
+ enabled: true
+ url: http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com
+ apiKey: FOOBAR
+ scenarioFilter: c.*
+ - id: repository
+ url: http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com
+ enabled: true
+ apiKey: FOOBAR
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/notfound.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/notfound.json
new file mode 100644
index 0000000000..eef023da6c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/notfound.json
@@ -0,0 +1,6 @@
+{
+ "title": "Test not found.",
+ "error": "Test not found.",
+ "detail": "This is the detail error text.",
+ "message": "This is the message field."
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/priorexecution.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/priorexecution.json
new file mode 100644
index 0000000000..ca01d3676a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/priorexecution.json
@@ -0,0 +1,21 @@
+{
+ "scenario": "compliance",
+ "testCaseName": "compliance.compliancetests.sriov",
+ "testSuiteName": "compliancetests",
+ "executionId": "621c97a1-045c-48bd-baeb-3678b6a97080-1552081390570",
+ "parameters": {
+ "vspId": "e1b2ce6d61604a9db5c9845db3a7d6ab",
+ "vspVersion": "bc248d7f8af24d60a8dc3f0ddb98efca",
+ "allowSriov": "true",
+ "csar:MainServiceTemplate.yaml": "",
+ "csp": "ZZFT",
+ "profilespec": "gsmafnw14",
+ "vnftype": "B"
+ },
+ "results": {
+ "this is": "a fake result"
+ },
+ "status": "COMPLETED",
+ "startTime": "2019-03-08T21:43:10.527",
+ "endTime": "2019-03-08T21:43:10.617"
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/runresult.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/runresult.json
new file mode 100644
index 0000000000..f729f482ee
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/runresult.json
@@ -0,0 +1,22 @@
+[
+ {
+ "scenario": "compliance",
+ "testCaseName": "computeflavors",
+ "testSuiteName": "compliancetests",
+ "executionId": "3053ed10-84e6-4f21-aa62-4ca66242d8d8",
+ "parameters": {
+ "vspId": "VSP-ID",
+ "vspVersion": "VSP-VER",
+ "allowSriov": "true",
+ "csp": "ZZFT",
+ "profilespec": "gsmafnw14",
+ "vnftype": "B"
+ },
+ "results": {
+ "hello": "world"
+ },
+ "status": "SUCCESS",
+ "startTime": 1550780567585,
+ "endTime": 1550780567585
+ }
+] \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/scenarios.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/scenarios.json
new file mode 100644
index 0000000000..e345754e21
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/scenarios.json
@@ -0,0 +1,10 @@
+[
+ {
+ "name": "certification",
+ "description": "Available Certification Queries"
+ },
+ {
+ "name": "compliance",
+ "description": "Available Compliance Tests"
+ }
+] \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testcase-sriov.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testcase-sriov.json
new file mode 100644
index 0000000000..3264216bc3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testcase-sriov.json
@@ -0,0 +1,48 @@
+{
+ "scenario": "compliance",
+ "testCaseName": "sriov",
+ "testSuiteName": "compliancetests",
+ "description": "SR-IOV Test",
+ "author": "Jim",
+ "inputs": [
+ {
+ "name": "vspId",
+ "description": "VSP ID",
+ "type": "text",
+ "metadata": {
+ "isDisabled": true,
+ "maxLength": "36",
+ "minLength": "1"
+ }
+ },
+ {
+ "name": "vspVersion",
+ "description": "VSP Version",
+ "type": "text",
+ "metadata": {
+ "isDisabled": true,
+ "maxLength": "36",
+ "minLength": "1"
+ }
+ },
+ {
+ "name": "allowSriov",
+ "description": "Allow SRIOV?",
+ "type": "select",
+ "defaultValue": "false",
+ "metadata": {
+ "isDisabled": true,
+ "choices": [
+ {
+ "key": "true",
+ "label": "Yes"
+ },
+ {
+ "key": "false",
+ "label": "No"
+ }
+ ]
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testcases.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testcases.json
new file mode 100644
index 0000000000..2bb6414b89
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testcases.json
@@ -0,0 +1,16 @@
+[
+ {
+ "scenario": "compliance",
+ "testCaseName": "sriov",
+ "testSuiteName": "compliancetests",
+ "description": "SR-IOV Test",
+ "author": "Jim"
+ },
+ {
+ "scenario": "compliance",
+ "testCaseName": "computeflavors",
+ "testSuiteName": "compliancetests",
+ "description": "Compute Flavours Test",
+ "author": "Jim"
+ }
+] \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testconfiguration.yaml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testconfiguration.yaml
new file mode 100644
index 0000000000..1bf800b8f2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testconfiguration.yaml
@@ -0,0 +1,11 @@
+ client:
+ enabled: true
+ endpoints:
+ - id: vtp
+ enabled: false
+ url: http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com
+ apiKey: FOOBAR
+ - id: repository
+ url: http://bogus.ec2-34-237-35-152.compute-1.amazonaws.com
+ enabled: true
+ apiKey: FOOBAR
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testsuites.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testsuites.json
new file mode 100644
index 0000000000..05d6c50366
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testsuites.json
@@ -0,0 +1,6 @@
+[
+ {
+ "name": "compliancetests",
+ "description": "Compliance Tests"
+ }
+] \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testtree.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testtree.json
new file mode 100644
index 0000000000..06b021077f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/data/testtree.json
@@ -0,0 +1,119 @@
+{
+ "name": "root",
+ "description": "root",
+ "tests": [],
+ "children": [
+ {
+ "name": "certification",
+ "description": "Available Certification Queries",
+ "children": [
+ {
+ "name": "certificationtests",
+ "description": "Certification Tests",
+ "tests": [
+ {
+ "scenario": "certification",
+ "testCaseName": "certquery",
+ "testSuiteName": "certificationtests",
+ "description": "VSP Certifications",
+ "author": "jguistwite@iconectiv.com",
+ "inputs": [
+ {
+ "name": "vspId",
+ "description": "VSP ID",
+ "type": "text",
+ "defaultValue": "",
+ "isOptional": false,
+ "metadata": {
+ "maxLength": 36.0,
+ "minLength": 1.0,
+ "disabled": true
+ }
+ },
+ {
+ "name": "vspVersion",
+ "description": "Previous VSP Version",
+ "type": "text",
+ "defaultValue": "",
+ "isOptional": false,
+ "metadata": {
+ "maxLength": 36.0,
+ "minLength": 1.0,
+ "disabled": true
+ }
+ }
+ ],
+ "endpoint": "opnfv"
+ }
+ ],
+ "children": []
+ }
+ ]
+ },
+ {
+ "name": "compliance",
+ "description": "Available Compliance Tests",
+ "tests": [],
+ "children": [
+ {
+ "name": "compliancetests",
+ "description": "Compliance Tests",
+ "tests": [
+ {
+ "scenario": "compliance",
+ "testCaseName": "sriov",
+ "testSuiteName": "compliancetests",
+ "description": "SR-IOV Test",
+ "author": "Jim",
+ "inputs": [
+ {
+ "name": "vspId",
+ "description": "VSP ID",
+ "type": "text",
+ "isOptional": false,
+ "metadata": {
+ "isDisabled": true,
+ "maxLength": "36",
+ "minLength": "1"
+ }
+ },
+ {
+ "name": "vspVersion",
+ "description": "VSP Version",
+ "type": "text",
+ "isOptional": false,
+ "metadata": {
+ "isDisabled": true,
+ "maxLength": "36",
+ "minLength": "1"
+ }
+ },
+ {
+ "name": "allowSriov",
+ "description": "Allow SRIOV?",
+ "type": "select",
+ "defaultValue": "false",
+ "isOptional": false,
+ "metadata": {
+ "isDisabled": true,
+ "choices": [
+ {
+ "key": "true",
+ "label": "Yes"
+ },
+ {
+ "key": "false",
+ "label": "No"
+ }
+ ]
+ }
+ }
+ ],
+ "endpoint": "vtp"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ConfigurationTests.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ConfigurationTests.java
new file mode 100644
index 0000000000..6b530daa09
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ConfigurationTests.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright © 2019 iconectiv
+ *
+ * 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.
+ */
+
+package org.openecomp.core.externaltesting.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.sdc.tosca.services.YamlUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+public class ConfigurationTests {
+
+ @Test
+ public void testClientConfig() {
+ // a brain dead test of the setter and getter.
+ // future tests for more complex config to come.
+ ClientConfiguration cc = new ClientConfiguration();
+ cc.setEnabled(true);
+ Assert.assertTrue("client configuration setter", cc.isEnabled());
+ cc.setEnabled(false);
+ Assert.assertFalse("client configuration setter", cc.isEnabled());
+ }
+
+ @Test
+ public void testConfig() throws Exception {
+ try (InputStream fileInput = new FileInputStream(new File("src/test/data/testconfiguration.yaml"))) {
+ YamlUtil yamlUtil = new YamlUtil();
+ Object raw = yamlUtil.yamlToMap(fileInput);
+ TestingAccessConfig accessConfig = new ObjectMapper().convertValue(raw, TestingAccessConfig.class);
+ Assert.assertNotNull("client config available", accessConfig.getClient());
+ }
+ }
+
+ @Test
+ public void testEndpointDefinition() {
+ RemoteTestingEndpointDefinition def = new RemoteTestingEndpointDefinition();
+ def.setId("vtp");
+ def.setEnabled(true);
+ def.setTitle("VTP");
+ def.setApiKey("FOOBARBAZ");
+ def.setUrl("http://example.com/vtptesting");
+ def.setScenarioFilter("c.*");
+
+ RemoteTestingEndpointDefinition def2 = new RemoteTestingEndpointDefinition();
+ def2.setId("vtp");
+ def2.setEnabled(true);
+ def2.setTitle("VTP");
+ def2.setUrl("http://example.com/vtptesting");
+ def2.setApiKey("FOOBARBAZ");
+ def2.setScenarioFilter("c.*");
+
+ Assert.assertEquals("code", "VTP", def.getTitle());
+ Assert.assertEquals("API keys equals", def.getApiKey(), def2.getApiKey());
+ Assert.assertEquals("code equals", def.getTitle(), def2.getTitle());
+ Assert.assertEquals("url equals", def.getUrl(), def2.getUrl());
+
+ boolean matches = def.getScenarioFilterPattern().matcher("certification").matches();
+ Assert.assertTrue("pattern", matches);
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolverTest.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolverTest.java
new file mode 100644
index 0000000000..b8471eb77b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolverTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2019 iconectiv
+ *
+ * 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.
+ */
+
+package org.openecomp.core.externaltesting.impl;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.core.externaltesting.api.VtpTestExecutionRequest;
+import org.openecomp.core.externaltesting.errors.ExternalTestingException;
+import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+
+import java.io.FileInputStream;
+import java.util.*;
+
+public class CsarMetadataVariableResolverTest {
+
+ @Mock
+ private VersioningManager versioningManager;
+
+ @Mock
+ private VendorSoftwareProductManager vendorSoftwareProductManager;
+
+ @Mock
+ private OrchestrationTemplateCandidateManager candidateManager;
+
+ @Test
+ public void testResolverResolves() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ CsarMetadataVariableResolver resolver = new CsarMetadataVariableResolver(versioningManager,
+ vendorSoftwareProductManager, candidateManager);
+ resolver.init();
+
+ VtpTestExecutionRequest doesNotResolve = new VtpTestExecutionRequest();
+ Assert.assertFalse("should not resolve empty request", resolver.resolvesVariablesForRequest(doesNotResolve));
+
+ doesNotResolve.setParameters(new HashMap<>());
+ Assert.assertFalse("should not resolve empty parameters", resolver.resolvesVariablesForRequest(doesNotResolve));
+
+
+
+ VtpTestExecutionRequest resolves = new VtpTestExecutionRequest();
+ resolves.setParameters(new HashMap<>());
+ resolves.getParameters().put(CsarMetadataVariableResolver.VSP_VERSION, "1.0");
+ resolves.getParameters().put(CsarMetadataVariableResolver.VSP_ID, "vspid");
+ resolves.getParameters().put(CsarMetadataVariableResolver.CSAR_PREFIX + "MainServiceTemplate.yaml", "");
+ Assert.assertTrue("should resolve", resolver.resolvesVariablesForRequest(resolves));
+
+ MultiValueMap<String,Object> fakeRequestBody = new LinkedMultiValueMap<>();
+
+ try {
+ resolver.resolve(resolves, fakeRequestBody);
+ }
+ catch (ExternalTestingException e) {
+ // exception expected.
+ }
+
+ // test the metadata extraction on a know CSAR zip.
+ byte[] zip = IOUtils.toByteArray(new FileInputStream("src/test/data/csar.zip"));
+ resolver.processArchive(resolves, fakeRequestBody, zip);
+ Assert.assertTrue("body contains file", fakeRequestBody.containsKey("file"));
+ LinkedList ll = (LinkedList)fakeRequestBody.get("file");
+ Assert.assertEquals("body contains one file", 1, ll.size());
+ ByteArrayResource res = (ByteArrayResource)ll.get(0);
+ Assert.assertEquals("file should have matching name", "MainServiceTemplate.yaml", res.getFilename());
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImplTests.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImplTests.java
new file mode 100644
index 0000000000..be328ea73f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImplTests.java
@@ -0,0 +1,283 @@
+/*
+ * Copyright © 2019 iconectiv
+ *
+ * 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.
+ */
+
+package org.openecomp.core.externaltesting.impl;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.io.FileUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.core.externaltesting.api.*;
+import org.openecomp.core.externaltesting.errors.ExternalTestingException;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.*;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.HttpServerErrorException;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.ResourceAccessException;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ExternalTestingManagerImplTests {
+
+ @Mock
+ private RestTemplate restTemplate;
+
+ static {
+ System.setProperty("configuration.yaml", "src/test/data/testconfiguration.yaml");
+ }
+
+ class JUnitExternalTestingManagerImpl extends ExternalTestingManagerImpl {
+ JUnitExternalTestingManagerImpl() {
+ super(Collections.singletonList(
+ new VariableResolver() {
+
+ @Override
+ public boolean resolvesVariablesForRequest(VtpTestExecutionRequest requestItem) {
+ return false;
+ }
+
+ @Override
+ public void resolve(VtpTestExecutionRequest requestItem, MultiValueMap<String, Object> body) {
+
+ // unit test resolver does nothing for this case. See specific test for resolver.
+ }
+ }));
+ }
+ }
+
+ @InjectMocks
+ private ExternalTestingManager mgr = new JUnitExternalTestingManagerImpl();
+
+ @SuppressWarnings("unchecked")
+ private ExternalTestingManager configTestManager(boolean loadConfig) throws IOException {
+ if (loadConfig) {
+ ((ExternalTestingManagerImpl) mgr).loadConfig();
+ }
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ // read mock data for API calls.
+
+ File scenarioFile = new File("src/test/data/scenarios.json");
+ TypeReference<List<VtpNameDescriptionPair>> typ = new TypeReference<List<VtpNameDescriptionPair>>(){};
+ List<VtpNameDescriptionPair> scenarios = mapper.readValue(scenarioFile, typ);
+
+ File testSuitesFile = new File("src/test/data/testsuites.json");
+ List<VtpNameDescriptionPair> testSuites = mapper.readValue(testSuitesFile, new TypeReference<List<VtpNameDescriptionPair>>(){});
+
+ File testCasesFile = new File("src/test/data/testcases.json");
+ List<VtpTestCase> testCases = mapper.readValue(testCasesFile, new TypeReference<List<VtpTestCase>>(){});
+
+ File testCaseFile = new File("src/test/data/testcase-sriov.json");
+ VtpTestCase testCase = mapper.readValue(testCaseFile, VtpTestCase.class);
+
+ File runResultFile = new File("src/test/data/runresult.json");
+ List<VtpTestExecutionResponse> runResults = mapper.readValue(runResultFile, new TypeReference<List<VtpTestExecutionResponse>>(){});
+
+ File priorExecutionFile = new File("src/test/data/priorexecution.json");
+ VtpTestExecutionResponse priorExecution = mapper.readValue(priorExecutionFile, VtpTestExecutionResponse.class);
+
+ // create an error response as well
+ String notFound = FileUtils.readFileToString(new File("src/test/data/notfound.json"), "UTF-8");
+
+ ParameterizedTypeReference<List<VtpNameDescriptionPair>> listOfPairType = new ParameterizedTypeReference<List<VtpNameDescriptionPair>>() {};
+ ParameterizedTypeReference<List<VtpTestCase>> listOfCasesType = new ParameterizedTypeReference<List<VtpTestCase>>() {};
+ ParameterizedTypeReference<VtpTestCase> caseType = new ParameterizedTypeReference<VtpTestCase>() {};
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.parseMediaType("application/problem+json"));
+ HttpStatusCodeException missingException = new HttpServerErrorException(HttpStatus.NOT_FOUND, "Not Found", headers, notFound.getBytes(), Charset.defaultCharset());
+
+ Mockito
+ .when(restTemplate.exchange(
+ ArgumentMatchers.endsWith("/scenarios"),
+ ArgumentMatchers.eq(HttpMethod.GET),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(listOfPairType)))
+ .thenReturn(new ResponseEntity(scenarios, HttpStatus.OK));
+
+ Mockito
+ .when(restTemplate.exchange(
+ ArgumentMatchers.endsWith("/testsuites"),
+ ArgumentMatchers.eq(HttpMethod.GET),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(listOfPairType)))
+ .thenReturn(new ResponseEntity(testSuites, HttpStatus.OK));
+
+ Mockito
+ .when(restTemplate.exchange(
+ ArgumentMatchers.endsWith("/testcases"),
+ ArgumentMatchers.eq(HttpMethod.GET),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(listOfCasesType)))
+ .thenReturn(new ResponseEntity(testCases, HttpStatus.OK));
+
+ Mockito
+ .when(restTemplate.exchange(
+ ArgumentMatchers.endsWith("/sriov"),
+ ArgumentMatchers.eq(HttpMethod.GET),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(caseType)))
+ .thenReturn(new ResponseEntity(testCase, HttpStatus.OK));
+
+
+ // POST for execution
+
+ Mockito
+ .when(restTemplate.exchange(
+ ArgumentMatchers.contains("executions"),
+ ArgumentMatchers.eq(HttpMethod.POST),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(new ParameterizedTypeReference<List<VtpTestExecutionResponse>>() {})))
+ .thenReturn(new ResponseEntity(runResults, HttpStatus.OK));
+
+
+ Mockito
+ .when(restTemplate.exchange(
+ ArgumentMatchers.contains("/executions/"),
+ ArgumentMatchers.eq(HttpMethod.GET),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(new ParameterizedTypeReference<VtpTestExecutionResponse>() {})))
+ .thenReturn(new ResponseEntity(priorExecution, HttpStatus.OK));
+
+ Mockito
+ .when(restTemplate.exchange(
+ ArgumentMatchers.endsWith("/missing"),
+ ArgumentMatchers.eq(HttpMethod.GET),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(caseType)))
+ .thenThrow(missingException);
+
+ Mockito
+ .when(restTemplate.exchange(
+ ArgumentMatchers.endsWith("/sitedown"),
+ ArgumentMatchers.eq(HttpMethod.GET),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.eq(caseType)))
+ .thenThrow(new ResourceAccessException("Remote site is down"));
+
+ return mgr;
+ }
+
+ @Test
+ public void testManager() throws IOException {
+ System.setProperty("configuration.yaml", "src/test/data/managertestconfiguration.yaml");
+ ExternalTestingManager m = configTestManager(true);
+
+ String config = m.getConfig();
+ Assert.assertNotNull(config);
+
+ List<VtpNameDescriptionPair> endpoints = m.getEndpoints();
+ Assert.assertEquals("two endpoints", 2, endpoints.size());
+
+
+ // this will exercise the internal APIs as well.
+ TestTreeNode root = m.getTestCasesAsTree();
+ Assert.assertEquals("two scenarios", 2, root.getChildren().size());
+
+
+ // handle case where remote endpoint is down.
+ try {
+ m.getTestCase("repository", "scen", "suite", "sitedown");
+ Assert.fail("not expected to retrieve sitedown test case");
+ }
+ catch (ExternalTestingException e) {
+ // expecting this exception.
+ Assert.assertNotNull(e.getDetail());
+ Assert.assertNotEquals(0, e.getCode());
+ Assert.assertNotNull(e.getTitle());
+ }
+
+ // get a particular test case
+ try {
+ m.getTestCase("repository", "scen", "suite", "missing");
+ Assert.fail("not expected to retrieve missing test case");
+ }
+ catch (ExternalTestingException e) {
+ // expecting this exception.
+ Assert.assertNotNull(e.getDetail());
+ Assert.assertNotEquals(0, e.getCode());
+ Assert.assertNotNull(e.getTitle());
+ }
+
+
+ // execute a test.
+ List<VtpTestExecutionRequest> requests = new ArrayList<>();
+ VtpTestExecutionRequest req = new VtpTestExecutionRequest();
+ req.setEndpoint("repository");
+ requests.add(req);
+
+ // send a request with the endpoint defined.
+ List<VtpTestExecutionResponse> responses = m.execute( requests, "rid");
+ Assert.assertEquals(1,responses.size());
+
+ // send a request for a prior execution.
+ VtpTestExecutionResponse execRsp = m.getExecution("repository", "execId");
+ Assert.assertEquals("COMPLETED", execRsp.getStatus());
+ }
+
+ @Test
+ public void testManagerErrorCases() throws IOException {
+ ExternalTestingManager m = configTestManager(false);
+ Map<String,Object> expectedEmptyConfig = new HashMap<>();
+ expectedEmptyConfig.put("enabled", false);
+ String expected = new ObjectMapper().writeValueAsString(expectedEmptyConfig);
+ String emptyConfig = m.getConfig();
+ Assert.assertEquals(expected, emptyConfig);
+
+ try {
+ m.getEndpoints();
+ Assert.assertTrue("should have exception here", true);
+ }
+ catch (ExternalTestingException e) {
+ // eat the exception cause this is what should happen.
+ }
+ }
+
+ @Test
+ public void testExecutionDistribution() throws IOException {
+ System.setProperty("configuration.yaml", "src/test/data/managertestconfiguration.yaml");
+ ExternalTestingManager m = configTestManager(true);
+
+ VtpTestExecutionRequest r1 = new VtpTestExecutionRequest();
+ r1.setScenario("scenario1");
+ r1.setEndpoint("vtp");
+
+ VtpTestExecutionRequest r2 = new VtpTestExecutionRequest();
+ r2.setScenario("scenario2");
+ r2.setEndpoint("vtp");
+
+ VtpTestExecutionRequest r3 = new VtpTestExecutionRequest();
+ r3.setScenario("scenario3");
+ r3.setEndpoint("repository");
+
+ List<VtpTestExecutionResponse> results = m.execute(Arrays.asList(r1,r2,r3), "rid");
+ Assert.assertEquals("three in two out merged", 2, results.size());
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingTestSuite.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingTestSuite.java
new file mode 100644
index 0000000000..31346a135e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/java/org/openecomp/core/externaltesting/impl/ExternalTestingTestSuite.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2019 iconectiv
+ *
+ * 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.
+ */
+
+package org.openecomp.core.externaltesting.impl;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ CsarMetadataVariableResolverTest.class,
+ ExternalTestingManagerImplTests.class,
+ ConfigurationTests.class
+})
+public class ExternalTestingTestSuite {
+ // nothing to do - just a placeholder.
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/resources/logback-test.xml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/resources/logback-test.xml
new file mode 100644
index 0000000000..e0498971dc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/test/resources/logback-test.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2019 iconectiv
+ ~
+ ~ 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.
+ -->
+
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d{dd-MMM-yyyy HH:mm:ss:SSS} %-5level %logger{36}.%M\(%line\) - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="DEBUG">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>