aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
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
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')
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/pom.xml61
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ExternalTestingManager.java87
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestErrorBody.java50
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestTreeNode.java64
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpNameDescriptionPair.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCase.java42
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseInput.java42
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseOutput.java31
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionRequest.java39
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionResponse.java53
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingException.java51
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingInitializationException.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/factory/ExternalTestingManagerFactory.java30
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/resources/factoryConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/executionrequest.json12
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/priorexecution.json20
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/testcase.json58
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/testtree.json119
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ErrorBodyTests.java42
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ExecutionRequestTests.java110
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ExternalTestingApiTests.java30
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/pom.xml114
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ClientConfiguration.java29
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolver.java210
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImpl.java610
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/RemoteTestingEndpointDefinition.java39
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/TestingAccessConfig.java30
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/VariableResolver.java27
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/resources/factoryConfiguration.json3
-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
-rw-r--r--openecomp-be/lib/openecomp-sdc-externaltesting-lib/pom.xml21
-rw-r--r--openecomp-be/lib/pom.xml1
48 files changed, 2907 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/pom.xml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/pom.xml
new file mode 100644
index 0000000000..63e9b38625
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/pom.xml
@@ -0,0 +1,61 @@
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-externaltesting-api</name>
+ <artifactId>openecomp-sdc-externaltesting-api</artifactId>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>${swagger.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-datatypes-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-logging-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-logging-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ExternalTestingManager.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ExternalTestingManager.java
new file mode 100644
index 0000000000..dc9b09c767
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/ExternalTestingManager.java
@@ -0,0 +1,87 @@
+/*
+ * 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.api;
+
+
+import java.util.List;
+
+public interface ExternalTestingManager {
+
+ /**
+ * Return the configuration of this feature that we want to
+ * expose to the client. Treated as a JSON blob for flexibility.
+ */
+ String getConfig();
+
+ /**
+ * Build a tree of all test cases for the client including all
+ * defined endpoints, scenarios, and test suites.
+ * @return test case tree.
+ */
+ TestTreeNode getTestCasesAsTree();
+
+ /**
+ * Get a list of testing endpoints with name and description.
+ */
+ List<VtpNameDescriptionPair> getEndpoints();
+
+ /**
+ * Get a list of scenarios from and endpoint.
+ */
+ List<VtpNameDescriptionPair> getScenarios(String endpoint);
+
+ /**
+ * Get a list of test suites given the endpoint and scenario.
+ */
+ List<VtpNameDescriptionPair> getTestSuites(String endpoint, String scenario);
+
+ /**
+ * Get a list of test cases.
+ * @param endpoint endpoint to contact (e.g. VTP)
+ * @param scenario test scenario to get tests for
+ * @return list of test cases.
+ */
+ List<VtpTestCase> getTestCases(String endpoint, String scenario);
+
+ /**
+ * Get the details about a particular test case.
+ * @param endpoint endpoint to contact (e.g. VTP)
+ * @param scenario test scenario to get tests for
+ * @param testSuite suite to get tests for
+ * @param testCaseName test case name to query.
+ * @return details about the test case.
+ */
+ VtpTestCase getTestCase(String endpoint, String scenario, String testSuite, String testCaseName);
+
+ /**
+ * Execute a collection of tests where the manager must distribute
+ * the tests to the appropriate endpoint and correlate the responses.
+ * @param requests collection of request items.
+ * @param requestId optional request ID provided from client.
+ * @return response from endpoint (don't bother to parse).
+ */
+ List<VtpTestExecutionResponse> execute(List<VtpTestExecutionRequest> requests, String requestId);
+
+ /**
+ * Return a previous results.
+ * @param endpoint endpoint to query
+ * @param executionId execution to query.
+ * @return response from endpoint.
+ */
+ VtpTestExecutionResponse getExecution(String endpoint, String executionId);
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestErrorBody.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestErrorBody.java
new file mode 100644
index 0000000000..79a3765596
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestErrorBody.java
@@ -0,0 +1,50 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Error body to return to client per IETF RFC 7807.
+ */
+@SuppressWarnings("unused")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@ApiModel("Body for errors such as http 500")
+@Data
+public class TestErrorBody implements Serializable {
+
+ private static final long serialVersionUID = 3504501412736665763L;
+
+ private String code;
+ private Integer httpStatus;
+ private String message;
+
+ TestErrorBody() {
+
+ }
+
+ public TestErrorBody(String code, Integer httpStatus, String message) {
+ this();
+ this.code = code;
+ this.httpStatus = httpStatus;
+ this.message = message;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestTreeNode.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestTreeNode.java
new file mode 100644
index 0000000000..42fa330d33
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/TestTreeNode.java
@@ -0,0 +1,64 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tree structure of tests. VTP does not provide an organized
+ * tree of tests. Here we define a tree node with tests and
+ * child nodes to represent our tree.
+ */
+@SuppressWarnings("unused")
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+@Data()
+@EqualsAndHashCode(callSuper=true)
+public class TestTreeNode extends VtpNameDescriptionPair {
+
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private List<VtpTestCase> tests;
+
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private List<TestTreeNode> children;
+
+ public TestTreeNode() {
+ super();
+ }
+
+ public TestTreeNode(String name, String description) {
+ super(name, description);
+ }
+
+ public void addTest(VtpTestCase test) {
+ if (tests == null) {
+ tests = new ArrayList<>();
+ }
+ tests.add(test);
+ }
+
+ public void addChild(TestTreeNode child) {
+ if (children == null) {
+ children = new ArrayList<>();
+ }
+ children.add(child);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpNameDescriptionPair.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpNameDescriptionPair.java
new file mode 100644
index 0000000000..9a435de4ae
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpNameDescriptionPair.java
@@ -0,0 +1,38 @@
+/*
+ * 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.api;
+
+import lombok.Data;
+
+/**
+ * Scenarios and Test Suites are simple name/description pairs.
+ */
+@Data
+public class VtpNameDescriptionPair {
+ private String name;
+ private String description;
+
+ VtpNameDescriptionPair() {
+
+ }
+
+ public VtpNameDescriptionPair(String name, String description) {
+ this();
+ this.name = name;
+ this.description = description;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCase.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCase.java
new file mode 100644
index 0000000000..ae39159f32
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCase.java
@@ -0,0 +1,42 @@
+/*
+ * 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.api;
+
+import lombok.Data;
+
+import java.util.List;
+
+
+@Data
+public class VtpTestCase {
+
+ private String scenario;
+ private String testCaseName;
+ private String testSuiteName;
+ private String description;
+ private String author;
+ private List<VtpTestCaseInput> inputs;
+ private List<VtpTestCaseOutput> outputs;
+
+ /**
+ * Extends VTP test case content with location where test case is defined.
+ * This value is populated by the SDC-BE for consumption by the front end.
+ * This allows the front end to tell the back end where to run the test.
+ */
+ private String endpoint;
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseInput.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseInput.java
new file mode 100644
index 0000000000..5c6db8eb72
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseInput.java
@@ -0,0 +1,42 @@
+/*
+ * 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.api;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Map;
+
+
+@Data
+@EqualsAndHashCode(callSuper=true)
+public class VtpTestCaseInput extends VtpNameDescriptionPair {
+
+ private String type;
+ private String defaultValue;
+ private boolean isOptional;
+ private Map<String,Object> metadata;
+
+ /**
+ * The VTP API has a field called isOptional, not just optional so
+ * we need to add getter and setter.
+ */
+ @SuppressWarnings({"unused", "WeakerAccess"})
+ public boolean getIsOptional() {
+ return isOptional;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseOutput.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseOutput.java
new file mode 100644
index 0000000000..b7b66b7b0b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestCaseOutput.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.api;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@ApiModel("VtpTestSuite")
+@Data
+@EqualsAndHashCode(callSuper=true)
+class VtpTestCaseOutput extends VtpNameDescriptionPair {
+
+ private String type;
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionRequest.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionRequest.java
new file mode 100644
index 0000000000..481fd46906
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionRequest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.util.Map;
+
+@Data
+public class VtpTestExecutionRequest {
+
+ private String scenario;
+ private String testSuiteName;
+ private String testCaseName;
+
+ @JsonInclude(value = JsonInclude.Include.NON_NULL)
+ private String profile;
+
+ @JsonInclude(value = JsonInclude.Include.NON_NULL)
+ private Map<String,String> parameters;
+
+ @JsonInclude(value = JsonInclude.Include.NON_NULL)
+ private String endpoint;
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionResponse.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionResponse.java
new file mode 100644
index 0000000000..add85210cb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/api/VtpTestExecutionResponse.java
@@ -0,0 +1,53 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.util.Map;
+
+@Data
+public class VtpTestExecutionResponse {
+ private String scenario;
+ private String testCaseName;
+ private String testSuiteName;
+ private String executionId;
+ private Map<String,String> parameters;
+ private Object results;
+ private String status;
+ private String startTime; // don't bother to convert various ISO8601 formats.
+ private String endTime; // don't bother to convert various ISO8601 formats.
+
+ /**
+ * In the event on an error, code provided.
+ */
+ @JsonInclude(value= JsonInclude.Include.NON_NULL)
+ private String code;
+
+ /**
+ * Error message
+ */
+ @JsonInclude(value= JsonInclude.Include.NON_NULL)
+ private String message;
+
+ /**
+ * In the event of an unexpected status.
+ */
+ @JsonInclude(value= JsonInclude.Include.NON_NULL)
+ private Integer httpStatus;
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingException.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingException.java
new file mode 100644
index 0000000000..33fa0f4477
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingException.java
@@ -0,0 +1,51 @@
+/*
+ * 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.errors;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+@Data
+@EqualsAndHashCode(callSuper=false)
+public class ExternalTestingException extends RuntimeException {
+
+ private static final long serialVersionUID = -4357810130868566088L;
+
+ private final String title;
+ private final int code;
+ private final String detail;
+
+ public ExternalTestingException(String title, int code, String detail) {
+ super(title);
+ this.title = title;
+ this.code = code;
+ this.detail = detail;
+ }
+
+ public ExternalTestingException(String title, int code, String detail, Throwable parent) {
+ super(title, parent);
+ this.title = title;
+ this.code = code;
+ this.detail = detail;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingInitializationException.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingInitializationException.java
new file mode 100644
index 0000000000..28f40199ca
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/errors/ExternalTestingInitializationException.java
@@ -0,0 +1,33 @@
+/*
+ * 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.errors;
+
+import java.io.IOException;
+
+@SuppressWarnings("unused")
+public class ExternalTestingInitializationException extends IOException {
+
+ private static final long serialVersionUID = -2422448175010311433L;
+
+ public ExternalTestingInitializationException(String message) {
+ super(message);
+ }
+
+ public ExternalTestingInitializationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/factory/ExternalTestingManagerFactory.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/factory/ExternalTestingManagerFactory.java
new file mode 100644
index 0000000000..e84a4c86a1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/java/org/openecomp/core/externaltesting/factory/ExternalTestingManagerFactory.java
@@ -0,0 +1,30 @@
+/*
+ * 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.factory;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.core.externaltesting.api.ExternalTestingManager;
+
+
+@SuppressWarnings("unused")
+public abstract class ExternalTestingManagerFactory extends AbstractComponentFactory<ExternalTestingManager> {
+
+ public static ExternalTestingManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ExternalTestingManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..10449038bf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.core.externaltesting.factory.ExternalTestingManagerFactory":"org.openecomp.sdc.externaltesting.impl.ExternalTestingManagerFactoryImpl"
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/executionrequest.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/executionrequest.json
new file mode 100644
index 0000000000..05750b4aed
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/executionrequest.json
@@ -0,0 +1,12 @@
+{
+ "scenario": "compliance",
+ "testCaseName": "sriov",
+ "testSuiteName": "compliancetests",
+ "profile": "compliance",
+ "parameters": {
+ "vspId": "VSP-ID",
+ "vspVersion": "VSP-VER",
+ "allowSriov": "true"
+ },
+ "endpoint": "repository"
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/priorexecution.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/priorexecution.json
new file mode 100644
index 0000000000..f8e1db85df
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/priorexecution.json
@@ -0,0 +1,20 @@
+{
+ "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": "COMPLETED",
+ "startTime": 1550780567585,
+ "endTime": 1550780567585
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/testcase.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/testcase.json
new file mode 100644
index 0000000000..9a6a166b51
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/data/testcase.json
@@ -0,0 +1,58 @@
+{
+ "scenario": "compliance",
+ "testCaseName": "sriov",
+ "testSuiteName": "compliancetests",
+ "description": "SR-IOV Test",
+ "author": "Jim",
+ "endpoint": "vtp",
+ "outputs": [
+ {
+ "name": "something",
+ "description": "is produced",
+ "type": "integer"
+ }
+ ],
+ "inputs": [
+ {
+ "name": "vspId",
+ "description": "VSP ID",
+ "type": "text",
+ "defaultValue": "",
+ "metadata": {
+ "isDisabled": true,
+ "maxLength": "36",
+ "minLength": "1"
+ }
+ },
+ {
+ "name": "vspVersion",
+ "description": "VSP Version",
+ "type": "text",
+ "defaultValue": "",
+ "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-api/src/test/data/testtree.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/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-api/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-api/src/test/java/org/openecomp/core/externaltesting/api/ErrorBodyTests.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ErrorBodyTests.java
new file mode 100644
index 0000000000..216ff3599f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ErrorBodyTests.java
@@ -0,0 +1,42 @@
+/*
+ * 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.api;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ErrorBodyTests {
+
+ @Test
+ public void testErrorBody() {
+ TestErrorBody b = new TestErrorBody();
+ b.setHttpStatus(404);
+ b.setMessage("message");
+ b.setCode("code");
+
+ Assert.assertEquals("code match", new Integer(404), b.getHttpStatus());
+ Assert.assertEquals("code message", "message", b.getMessage());
+ Assert.assertEquals("code code", "code", b.getCode());
+
+ TestErrorBody b2 = new TestErrorBody("code", 404, "message");
+
+ Assert.assertEquals("code match", new Integer(404), b2.getHttpStatus());
+ Assert.assertEquals("code message", "message", b2.getMessage());
+ Assert.assertEquals("code code", "code", b2.getCode());
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ExecutionRequestTests.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ExecutionRequestTests.java
new file mode 100644
index 0000000000..b10d3079d2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ExecutionRequestTests.java
@@ -0,0 +1,110 @@
+/*
+ * 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.api;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+import java.util.UUID;
+
+public class ExecutionRequestTests {
+
+ @Test
+ public void testTestCase() throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ VtpTestCase req = mapper.readValue(new File("src/test/data/testcase.json"), VtpTestCase.class);
+
+ Assert.assertEquals("Scenario must match", "compliance", req.getScenario());
+ Assert.assertEquals("Suite name must match", "compliancetests", req.getTestSuiteName());
+ Assert.assertEquals("Test case name must match", "sriov", req.getTestCaseName());
+ Assert.assertEquals("Description must match", "SR-IOV Test", req.getDescription());
+ Assert.assertEquals("Author must match", "Jim", req.getAuthor());
+ Assert.assertEquals("Endpoint must match", "vtp", req.getEndpoint());
+ Assert.assertEquals("Test must contain two inputs", 3, req.getInputs().size());
+ Assert.assertEquals("Test must contain one outputs", 1, req.getOutputs().size());
+
+ VtpTestCaseInput input1 = req.getInputs().get(0);
+ Assert.assertEquals("Name match", "vspId", input1.getName());
+ Assert.assertEquals("Description match", "VSP ID", input1.getDescription());
+ Assert.assertEquals("Input type match", "text", input1.getType());
+ Assert.assertEquals("Input default match", "", input1.getDefaultValue());
+ Assert.assertFalse("Input optional match", input1.getIsOptional());
+
+ VtpTestCaseOutput output1 = req.getOutputs().get(0);
+ Assert.assertEquals("Name match", "something", output1.getName());
+ Assert.assertEquals("Description match", "is produced", output1.getDescription());
+ Assert.assertEquals("Output type match", "integer", output1.getType());
+
+
+ Map<String,Object> meta = input1.getMetadata();
+ Assert.assertEquals("Metadata count", 3, meta.size());
+
+ VtpTestCase req2 = mapper.readValue(new File("src/test/data/testcase.json"), VtpTestCase.class);
+
+ Assert.assertEquals("test equality", req, req2);
+
+ }
+
+ @Test
+ public void testExecutionRequest() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ VtpTestExecutionRequest req = mapper.readValue(new File("src/test/data/executionrequest.json"), VtpTestExecutionRequest.class);
+ Assert.assertEquals("compliance", req.getScenario());
+ Assert.assertEquals("compliance", req.getProfile());
+ Assert.assertEquals("sriov", req.getTestCaseName());
+ Assert.assertEquals("compliancetests", req.getTestSuiteName());
+ Assert.assertEquals("repository", req.getEndpoint());
+
+ Assert.assertEquals(3, req.getParameters().size());
+ }
+
+ @Test
+ public void testExecutionResponse() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ VtpTestExecutionResponse rsp = mapper.readValue(new File("src/test/data/priorexecution.json"), VtpTestExecutionResponse.class);
+ Assert.assertEquals("compliance", rsp.getScenario());
+ Assert.assertEquals("computeflavors", rsp.getTestCaseName());
+ Assert.assertEquals("compliancetests", rsp.getTestSuiteName());
+ Assert.assertTrue(UUID.fromString(rsp.getExecutionId()).getLeastSignificantBits() != 0);
+ Assert.assertEquals("parameters", 6, rsp.getParameters().size());
+ Assert.assertNotNull(rsp.getResults());
+ Assert.assertEquals("COMPLETED", rsp.getStatus());
+ Assert.assertNotNull(rsp.getStartTime());
+ Assert.assertNotNull(rsp.getEndTime());
+ }
+
+ @Test
+ public void testTree() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ TestTreeNode tree = mapper.readValue(new File("src/test/data/testtree.json"), TestTreeNode.class);
+
+ Assert.assertEquals(2, tree.getChildren().size());
+ Assert.assertEquals(0, tree.getTests().size());
+
+ TestTreeNode manual = new TestTreeNode("root", "Root");
+
+ manual.addChild(new TestTreeNode("child", "child"));
+ manual.addTest(new VtpTestCase());
+ Assert.assertEquals(1, manual.getChildren().size());
+ Assert.assertEquals(1, manual.getTests().size());
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ExternalTestingApiTests.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ExternalTestingApiTests.java
new file mode 100644
index 0000000000..62b129c7c0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-api/src/test/java/org/openecomp/core/externaltesting/api/ExternalTestingApiTests.java
@@ -0,0 +1,30 @@
+/*
+ * 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.api;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ ExecutionRequestTests.class,
+ ErrorBodyTests.class
+})
+public class ExternalTestingApiTests {
+ // nothing to do - just a placeholder.
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/pom.xml
new file mode 100644
index 0000000000..7411cf5cc1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/pom.xml
@@ -0,0 +1,114 @@
+<!--
+ ~ 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.
+ -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-externaltesting-impl</name>
+ <artifactId>openecomp-sdc-externaltesting-impl</artifactId>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-logging-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-logging-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-utilities-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-externaltesting-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-common-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-heat-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>${commons.io.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all-minimal</artifactId>
+ <version>${groovy.minimal.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ClientConfiguration.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ClientConfiguration.java
new file mode 100644
index 0000000000..2787e7e97f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ClientConfiguration.java
@@ -0,0 +1,29 @@
+/*
+ * 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 lombok.Data;
+
+@Data
+public class ClientConfiguration {
+ /**
+ * Enable/disable state for the feature. Client can use this
+ * to show/hide menu items.
+ */
+ private boolean enabled;
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolver.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolver.java
new file mode 100644
index 0000000000..191fff0c6c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/CsarMetadataVariableResolver.java
@@ -0,0 +1,210 @@
+/*
+ * 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 lombok.EqualsAndHashCode;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+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.OrchestrationTemplateCandidateManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.util.MultiValueMap;
+
+import javax.annotation.PostConstruct;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * The CSAR Metadata variable resolver is responsible for processing of
+ * variables in the test request. It looks for variables with the "csar:" prefix
+ * and extracts the contents of the uploaded CSAR file for a VSP.
+ */
+public class CsarMetadataVariableResolver implements VariableResolver {
+
+ private Logger logger = LoggerFactory.getLogger(CsarMetadataVariableResolver.class);
+
+ static final String VSP_ID = "vspId";
+ static final String VSP_VERSION = "vspVersion";
+ static final String CSAR_PREFIX = "csar:";
+
+ private VersioningManager versioningManager;
+ private VendorSoftwareProductManager vendorSoftwareProductManager;
+ private OrchestrationTemplateCandidateManager candidateManager;
+
+ CsarMetadataVariableResolver(VersioningManager versioningManager,
+ VendorSoftwareProductManager vendorSoftwareProductManager,
+ OrchestrationTemplateCandidateManager candidateManager) {
+ this();
+ this.versioningManager = versioningManager;
+ this.vendorSoftwareProductManager = vendorSoftwareProductManager;
+ this.candidateManager = candidateManager;
+ }
+
+ CsarMetadataVariableResolver() {
+
+ }
+
+ @PostConstruct
+ public void init() {
+ if (versioningManager == null) {
+ versioningManager = VersioningManagerFactory.getInstance().createInterface();
+ }
+ if (vendorSoftwareProductManager == null) {
+ vendorSoftwareProductManager =
+ VspManagerFactory.getInstance().createInterface();
+ }
+ if (candidateManager == null) {
+ candidateManager =
+ OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface();
+ }
+ }
+
+ @Override
+ public boolean resolvesVariablesForRequest(VtpTestExecutionRequest requestItem) {
+ Map<String,String> params = requestItem.getParameters();
+
+ // no params, quickly return.
+ if (params == null) {
+ return false;
+ }
+
+ // no match, quickly return
+ if (!params.containsKey(VSP_ID) || !params.containsKey(VSP_VERSION)) {
+ return false;
+ }
+
+ return (params.keySet().stream().anyMatch(s -> StringUtils.startsWith(s, CSAR_PREFIX)));
+ }
+
+ @Override
+ public void resolve(VtpTestExecutionRequest requestItem, MultiValueMap<String, Object> body) {
+ logger.debug("run {} variable resolver...", this.getClass().getSimpleName());
+ Map<String,String> params = requestItem.getParameters();
+ String vspId = params.get(VSP_ID);
+ String version = params.get(VSP_VERSION);
+
+ try {
+ extractMetadata(requestItem, body, vspId, version);
+ }
+ catch (IOException ex) {
+ logger.error("metadata extraction failed", ex);
+ }
+ }
+
+ /**
+ * Extract the metadata from the VSP CSAR file.
+ * @param requestItem item to add metadata to for processing
+ * @param vspId VSP identifier
+ * @param version VSP version
+ */
+ @SuppressWarnings("WeakerAccess")
+ protected void extractMetadata(VtpTestExecutionRequest requestItem, MultiValueMap<String, Object> body, String vspId, String version) throws IOException {
+
+ Version ver = new Version(version);
+ logger.debug("attempt to retrieve archive for VSP {} version {}", vspId, ver.getId());
+
+ Optional<Pair<String, byte[]>> ozip = candidateManager.get(vspId, new Version(version));
+ if (!ozip.isPresent()) {
+ ozip = vendorSoftwareProductManager.get(vspId, ver);
+ }
+
+ if (!ozip.isPresent()) {
+ List<Version> versions = versioningManager.list(vspId);
+ String knownVersions = versions
+ .stream()
+ .map(v -> String.format("%d.%d: %s (%s)", v.getMajor(), v.getMinor(), v.getStatus(), v.getId()))
+ .collect(Collectors.joining("\n"));
+
+ String detail = String.format("Unable to find archive for VSP ID %s and Version %s. Known versions are:\n%s",
+ vspId, version, knownVersions);
+
+ throw new ExternalTestingException("Archive Processing Failed", 500, detail);
+ }
+
+ // safe here to do get.
+ Pair<String, byte[]> zip = ozip.get();
+ processArchive(requestItem, body, zip.getRight());
+ }
+
+ @EqualsAndHashCode(callSuper = false)
+ private class NamedByteArrayResource extends ByteArrayResource {
+ private String filename;
+ private NamedByteArrayResource(byte[] bytes, String filename) {
+ super(bytes, filename);
+ this.filename = filename;
+ }
+ @Override
+ public String getFilename() {
+ return this.filename;
+ }
+
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ protected void processArchive(VtpTestExecutionRequest requestItem, MultiValueMap<String, Object> body, byte[] zip) {
+ try {
+ ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(zip));
+ ZipEntry entry;
+ while ((entry = zipStream.getNextEntry()) != null) {
+ String entryName = entry.getName();
+ logger.debug("csar contains entry {}", entryName);
+ Map<String,String> params = requestItem.getParameters();
+ params.forEach((key,val) -> {
+ if (key.startsWith(CSAR_PREFIX)) {
+ addToBody(requestItem, body, zipStream, entryName, key);
+ }
+ });
+ }
+ } catch (IOException ex) {
+ logger.error("IO Exception parsing zip", ex);
+ }
+ }
+
+ private void addToBody(VtpTestExecutionRequest requestItem, MultiValueMap<String, Object> body, ZipInputStream zipStream, String entryName, String key) {
+ String filename = key.substring(CSAR_PREFIX.length());
+ logger.debug("match {} with {}", entryName, filename);
+ if (StringUtils.equals(entryName, filename)) {
+ try {
+ NamedByteArrayResource res = new NamedByteArrayResource(IOUtils.toByteArray(zipStream), filename);
+ body.add("file", res);
+
+ // we've added the file to the body. need to replace the value in the request for this
+ // parameter to match the VTP requirement that it start with a file URL protocol handler.
+ requestItem.getParameters().put(key, "file://" + entryName);
+
+ } catch (IOException ex) {
+ logger.error("failed to read zip entry content for {}", entryName, ex);
+ }
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImpl.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImpl.java
new file mode 100644
index 0000000000..38fb11c6ae
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/ExternalTestingManagerImpl.java
@@ -0,0 +1,610 @@
+/*
+ * 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.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.sdc.tosca.services.YamlUtil;
+import org.openecomp.core.externaltesting.api.*;
+import org.openecomp.core.externaltesting.errors.ExternalTestingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.*;
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.ResourceAccessException;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import javax.annotation.PostConstruct;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class ExternalTestingManagerImpl implements ExternalTestingManager {
+
+ private Logger logger = LoggerFactory.getLogger(ExternalTestingManagerImpl.class);
+
+ private static final String HTTP_STATUS = "httpStatus";
+ private static final String CODE = "code";
+ private static final String ERROR = "error";
+ private static final String MESSAGE = "message";
+ private static final String DETAIL = "detail";
+ private static final String PATH = "path";
+
+ private static final String CONFIG_FILE_PROPERTY = "configuration.yaml";
+ private static final String CONFIG_SECTION = "externalTestingConfig";
+
+ private static final String VTP_SCENARIOS_URI = "%s/v1/vtp/scenarios";
+ private static final String VTP_TESTSUITE_URI = "%s/v1/vtp/scenarios/%s/testsuites";
+ private static final String VTP_TESTCASES_URI = "%s/v1/vtp/scenarios/%s/testcases";
+ private static final String VTP_TESTCASE_URI = "%s/v1/vtp/scenarios/%s/testsuites/%s/testcases/%s";
+ private static final String VTP_EXECUTIONS_URI = "%s/v1/vtp/executions";
+ private static final String VTP_EXECUTION_URI = "%s/v1/vtp/executions/%s";
+
+ private static final String INVALIDATE_STATE_ERROR = "Invalid State";
+ private static final String NO_ACCESS_CONFIGURATION_DEFINED = "No access configuration defined";
+
+ private TestingAccessConfig accessConfig;
+ private Map<String, RemoteTestingEndpointDefinition> endpoints = new HashMap<>();
+
+ private RestTemplate restTemplate;
+
+ private List<VariableResolver> variableResolvers;
+
+ public ExternalTestingManagerImpl(@Autowired(required=false) List<VariableResolver> variableResolvers) {
+ this.variableResolvers = variableResolvers;
+ // nothing to do at the moment.
+ restTemplate = new RestTemplate();
+ }
+
+ /**
+ * Read the configuration from the yaml file for this bean. If we get an exception during load,
+ * don't force an error starting SDC but log a warning. Do no warm...
+ */
+ @PostConstruct
+ public void loadConfig() {
+
+ String file = Objects.requireNonNull(System.getProperty(CONFIG_FILE_PROPERTY),
+ "Config file location must be specified via system property " + CONFIG_FILE_PROPERTY);
+ try {
+ Object rawConfig = getExternalTestingAccessConfiguration(file);
+ if (rawConfig != null) {
+ accessConfig = new ObjectMapper().convertValue(rawConfig, TestingAccessConfig.class);
+ accessConfig.getEndpoints()
+ .stream()
+ .filter(RemoteTestingEndpointDefinition::isEnabled)
+ .forEach(e -> endpoints.put(e.getId(), e));
+ }
+ }
+ catch (IOException ex) {
+ logger.warn("Unable to initialize external testing configuration. Add '" + CONFIG_SECTION + "' to configuration.yaml with url value. Feature will be hobbled with results hardcoded to empty values.", ex);
+ }
+ }
+
+ /**
+ * Return the configuration of this feature that we want to
+ * expose to the client. Treated as a JSON blob for flexibility.
+ */
+ @Override
+ public String getConfig() {
+ ClientConfiguration cc = null;
+ if (accessConfig != null) {
+ cc = accessConfig.getClient();
+ }
+ if (cc == null) {
+ cc = new ClientConfiguration();
+ cc.setEnabled(false);
+ }
+ try {
+ return new ObjectMapper().writeValueAsString(cc);
+ } catch (JsonProcessingException e) {
+ logger.error("failed to write client config", e);
+ return "{\"enabled\":false}";
+ }
+ }
+
+ @Override
+ public TestTreeNode getTestCasesAsTree() {
+ TestTreeNode root = new TestTreeNode("root", "root");
+
+ // quick out in case of non-configured SDC
+ if (accessConfig == null) {
+ return root;
+ }
+
+ for (RemoteTestingEndpointDefinition ep : accessConfig.getEndpoints()) {
+ if (ep.isEnabled()) {
+ buildTreeFromEndpoint(ep, root);
+ }
+ }
+ return root;
+ }
+
+ private void buildTreeFromEndpoint(RemoteTestingEndpointDefinition ep, TestTreeNode root) {
+ try {
+ logger.debug("process endpoint {}", ep.getId());
+ getScenarios(ep.getId()).stream().filter(s ->
+ ((ep.getScenarioFilter() == null) || ep.getScenarioFilterPattern().matcher(s.getName()).matches()))
+ .forEach(s -> {
+ addScenarioToTree(root, s);
+ getTestSuites(ep.getId(), s.getName()).forEach(suite -> addSuiteToTree(root, s, suite));
+ getTestCases(ep.getId(), s.getName()).forEach(tc -> {
+ try {
+ VtpTestCase details = getTestCase(ep.getId(), s.getName(), tc.getTestSuiteName(), tc.getTestCaseName());
+ addTestCaseToTree(root, ep.getId(), s.getName(), tc.getTestSuiteName(), details);
+ }
+ catch (@SuppressWarnings("squid:S1166") ExternalTestingException ex) {
+ // Not logging stack trace on purpose. VTP was throwing exceptions for certain test cases.
+ logger.warn("failed to load test case {}", tc.getTestCaseName());
+ }
+ });
+ });
+ }
+ catch (ExternalTestingException ex) {
+ logger.error("unable to contact testing endpoint {}", ep.getId(), ex);
+ }
+ }
+
+ private Optional<TestTreeNode> findNamedChild(TestTreeNode root, String name) {
+ if (root.getChildren() == null) {
+ return Optional.empty();
+ }
+ return root.getChildren().stream().filter(n->n.getName().equals(name)).findFirst();
+ }
+
+ /**
+ * Find the place in the tree to add the test case.
+ * @param root root of the tree.
+ * @param endpointName name of the endpoint to assign to the test case.
+ * @param scenarioName scenario to add this case to
+ * @param testSuiteName suite in the scenario to add this case to
+ * @param tc test case to add.
+ */
+ private void addTestCaseToTree(TestTreeNode root, String endpointName, String scenarioName, String testSuiteName, VtpTestCase tc) {
+ // return quickly.
+ if (tc == null) {
+ return;
+ }
+ findNamedChild(root, scenarioName)
+ .ifPresent(scenarioNode -> findNamedChild(scenarioNode, testSuiteName)
+ .ifPresent(suiteNode -> {
+ massageTestCaseForUI(tc, endpointName, scenarioName);
+ if (suiteNode.getTests() == null) {
+ suiteNode.setTests(new ArrayList<>());
+ }
+ suiteNode.getTests().add(tc);
+ }));
+ }
+
+ private void massageTestCaseForUI(VtpTestCase testcase, String endpoint, String scenario) {
+ testcase.setEndpoint(endpoint);
+ // VTP workaround.
+ if (testcase.getScenario() == null) {
+ testcase.setScenario(scenario);
+ }
+
+ // if no inputs, return.
+ if (testcase.getInputs() == null) {
+ return;
+ }
+
+ // to work around a VTP limitation,
+ // any inputs that are marked as internal should not be sent to the client.
+ testcase.setInputs(testcase.getInputs()
+ .stream()
+ .filter(input -> (input.getMetadata() == null) ||
+ (!input.getMetadata().containsKey("internal")) ||
+ !"true".equals(input.getMetadata().get("internal").toString())).collect(Collectors.toList()));
+ }
+
+ /**
+ * Add the test suite to the tree at the appropriate place if it does not already exist in the tree.
+ * @param root root of the tree.
+ * @param scenario scenario under which this suite should be placed
+ * @param suite test suite to add.
+ */
+ private void addSuiteToTree(final TestTreeNode root, final VtpNameDescriptionPair scenario, final VtpNameDescriptionPair suite) {
+ findNamedChild(root, scenario.getName()).ifPresent(parent -> {
+ if (parent.getChildren() == null) {
+ parent.setChildren(new ArrayList<>());
+ }
+ if (parent.getChildren().stream().noneMatch(n -> StringUtils.equals(n.getName(), suite.getName()))) {
+ parent.getChildren().add(new TestTreeNode(suite.getName(), suite.getDescription()));
+ }
+ });
+ }
+
+ /**
+ * Add the scenario to the tree if it does not already exist.
+ * @param root root of the tree.
+ * @param s scenario to add.
+ */
+ private void addScenarioToTree(TestTreeNode root, VtpNameDescriptionPair s) {
+ logger.debug("addScenario {} to {} with {}", s.getName(), root.getName(), root.getChildren());
+ if (root.getChildren() == null) {
+ root.setChildren(new ArrayList<>());
+ }
+ if (root.getChildren().stream().noneMatch(n->StringUtils.equals(n.getName(),s.getName()))) {
+ logger.debug("createScenario {} in {}", s.getName(), root.getName());
+ root.getChildren().add(new TestTreeNode(s.getName(), s.getDescription()));
+ }
+ }
+
+ /**
+ * Get the list of endpoints defined to the testing manager.
+ * @return list of endpoints or empty list if the manager is not configured.
+ */
+ public List<VtpNameDescriptionPair> getEndpoints() {
+ if (accessConfig != null) {
+ return accessConfig.getEndpoints().stream()
+ .filter(RemoteTestingEndpointDefinition::isEnabled)
+ .map(e -> new VtpNameDescriptionPair(e.getId(), e.getTitle()))
+ .collect(Collectors.toList());
+ }
+ else {
+ return new ArrayList<>();
+ }
+ }
+
+ /**
+ * Get the list of scenarios at a given endpoint.
+ */
+ public List<VtpNameDescriptionPair> getScenarios(final String endpoint) {
+ String url = buildEndpointUrl(VTP_SCENARIOS_URI, endpoint, ArrayUtils.EMPTY_STRING_ARRAY);
+ ParameterizedTypeReference<List<VtpNameDescriptionPair>> t = new ParameterizedTypeReference<List<VtpNameDescriptionPair>>() {};
+ List<VtpNameDescriptionPair> rv = proxyGetRequestToExternalTestingSite(url, t);
+ if (rv == null) {
+ rv = new ArrayList<>();
+ }
+ return rv;
+ }
+
+ /**
+ * Get the list of test suites for an endpoint for the given scenario.
+ */
+ public List<VtpNameDescriptionPair> getTestSuites(final String endpoint, final String scenario) {
+ String url = buildEndpointUrl(VTP_TESTSUITE_URI, endpoint, new String[] {scenario});
+ ParameterizedTypeReference<List<VtpNameDescriptionPair>> t = new ParameterizedTypeReference<List<VtpNameDescriptionPair>>() {};
+ List<VtpNameDescriptionPair> rv = proxyGetRequestToExternalTestingSite(url, t);
+ if (rv == null) {
+ rv = new ArrayList<>();
+ }
+ return rv;
+ }
+
+ /**
+ * Get the list of test cases under a scenario. This is the VTP API. It would
+ * seem better to get the list of cases under a test suite but that is not supported.
+ */
+ @Override
+ public List<VtpTestCase> getTestCases(String endpoint, String scenario) {
+ String url = buildEndpointUrl(VTP_TESTCASES_URI, endpoint, new String[] {scenario});
+ ParameterizedTypeReference<List<VtpTestCase>> t = new ParameterizedTypeReference<List<VtpTestCase>>() {};
+ List<VtpTestCase> rv = proxyGetRequestToExternalTestingSite(url, t);
+ if (rv == null) {
+ rv = new ArrayList<>();
+ }
+ return rv;
+ }
+
+ /**
+ * Get a test case definition.
+ */
+ @Override
+ public VtpTestCase getTestCase(String endpoint, String scenario, String testSuite, String testCaseName) {
+ String url = buildEndpointUrl(VTP_TESTCASE_URI, endpoint, new String[] {scenario, testSuite, testCaseName});
+ ParameterizedTypeReference<VtpTestCase> t = new ParameterizedTypeReference<VtpTestCase>() {};
+ return proxyGetRequestToExternalTestingSite(url, t);
+ }
+
+ /**
+ * Return the results of a previous test execution.
+ * @param endpoint endpoint to query
+ * @param executionId execution to query.
+ * @return execution response from testing endpoint.
+ */
+ @Override
+ public VtpTestExecutionResponse getExecution(String endpoint,String executionId) {
+ String url = buildEndpointUrl(VTP_EXECUTION_URI, endpoint, new String[] {executionId});
+ ParameterizedTypeReference<VtpTestExecutionResponse> t = new ParameterizedTypeReference<VtpTestExecutionResponse>() {};
+ return proxyGetRequestToExternalTestingSite(url, t);
+ }
+
+ /**
+ * Execute a set of tests at a given endpoint.
+ * @param endpointName name of the endpoint
+ * @param testsToRun set of tests to run
+ * @return list of execution responses.
+ */
+ private List<VtpTestExecutionResponse> execute(final String endpointName, final List<VtpTestExecutionRequest> testsToRun, String requestId) {
+ if (accessConfig == null) {
+ throw new ExternalTestingException(INVALIDATE_STATE_ERROR, 500, NO_ACCESS_CONFIGURATION_DEFINED);
+ }
+
+ RemoteTestingEndpointDefinition endpoint = accessConfig.getEndpoints().stream()
+ .filter(e -> StringUtils.equals(endpointName, e.getId()))
+ .findFirst()
+ .orElseThrow(() -> new ExternalTestingException("No such endpoint", 500, "No endpoint named " + endpointName + " is defined"));
+
+ // if the endpoint requires an API key, specify it in the headers.
+ HttpHeaders headers = new HttpHeaders();
+ if (endpoint.getApiKey() != null) {
+ headers.add("X-API-Key", endpoint.getApiKey());
+ }
+ headers.setContentType(MediaType.MULTIPART_FORM_DATA);
+
+ // build the body.
+ MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
+ try {
+ // remove the endpoint from the test request since that is a FE/BE attribute
+ // add the execution profile configured for the endpoint.
+ testsToRun.forEach(t -> {
+ t.setEndpoint(null);
+ t.setProfile(t.getScenario()); // VTP wants a profile. Use the scenario name.
+ });
+
+ body.add("executions", new ObjectMapper().writeValueAsString(testsToRun));
+ }
+ catch (Exception ex) {
+ logger.error("exception converting tests to string", ex);
+ VtpTestExecutionResponse err = new VtpTestExecutionResponse();
+ err.setHttpStatus(500);
+ err.setCode("500");
+ err.setMessage("Execution failed due to " + ex.getMessage());
+ return Collections.singletonList(err);
+ }
+
+ for(VtpTestExecutionRequest test: testsToRun) {
+ runVariableResolvers(test, body);
+ }
+
+
+ // form and send request.
+ HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
+ String url = buildEndpointUrl(VTP_EXECUTIONS_URI, endpointName, ArrayUtils.EMPTY_STRING_ARRAY);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
+ if (requestId != null) {
+ builder = builder.queryParam("requestId", requestId);
+ }
+ ParameterizedTypeReference<List<VtpTestExecutionResponse>> t = new ParameterizedTypeReference<List<VtpTestExecutionResponse>>() {};
+ try {
+ return proxyRequestToExternalTestingSite(builder.toUriString(), requestEntity, t);
+ }
+ catch (ExternalTestingException ex) {
+ logger.error("exception caught invoking endpoint {}", endpointName, ex);
+ VtpTestExecutionResponse err = new VtpTestExecutionResponse();
+ err.setHttpStatus(ex.getCode());
+ err.setCode(""+ex.getCode());
+ err.setMessage(ex.getTitle() + ": " + ex.getDetail());
+ return Collections.singletonList(err);
+ }
+ }
+
+ /**
+ * Execute tests splitting them across endpoints and collecting the results.
+ * @param testsToRun list of tests to be executed.
+ * @return collection of result objects.
+ */
+ @Override
+ public List<VtpTestExecutionResponse> execute(final List<VtpTestExecutionRequest> testsToRun, String requestId) {
+ if (accessConfig == null) {
+ throw new ExternalTestingException(INVALIDATE_STATE_ERROR, 500, NO_ACCESS_CONFIGURATION_DEFINED);
+ }
+
+ // partition the requests by endpoint.
+ Map<String, List<VtpTestExecutionRequest>> partitions =
+ testsToRun.stream().collect(Collectors.groupingBy(VtpTestExecutionRequest::getEndpoint));
+
+ // process each group and collect the results.
+ return partitions.entrySet().stream()
+ .flatMap(e -> execute(e.getKey(), e.getValue(), requestId).stream())
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Load the external testing access configuration from the SDC onboarding yaml configuration file.
+ * @param file filename to retrieve data from
+ * @return parsed YAML object
+ * @throws IOException thrown if failure in reading YAML content.
+ */
+ private Object getExternalTestingAccessConfiguration(String file) throws IOException {
+ Map<?, ?> configuration = Objects.requireNonNull(readConfigurationFile(file), "Configuration cannot be empty");
+ Object testingConfig = configuration.get(CONFIG_SECTION);
+ if (testingConfig == null) {
+ logger.warn("Unable to initialize external testing access configuration. Add 'testingConfig' to configuration.yaml with url value. Feature will be hobbled with results hardcoded to empty values.");
+ }
+
+ return testingConfig;
+ }
+
+ /**
+ * Load the onboarding yaml config file.
+ * @param file name of file to load
+ * @return map containing YAML properties.
+ * @throws IOException thrown in the event of YAML parse or IO failure.
+ */
+ private static Map<?, ?> readConfigurationFile(String file) throws IOException {
+ try (InputStream fileInput = new FileInputStream(file)) {
+ YamlUtil yamlUtil = new YamlUtil();
+ return yamlUtil.yamlToMap(fileInput);
+ }
+ }
+
+
+ /**
+ * Return URL with endpoint url as prefix.
+ * @param format format string.
+ * @param endpointName endpoint to address
+ * @param args args for format.
+ * @return qualified url.
+ */
+ private String buildEndpointUrl(String format, String endpointName, String[] args) {
+ if (accessConfig != null) {
+ RemoteTestingEndpointDefinition ep = endpoints.values().stream()
+ .filter(e -> e.getId().equals(endpointName))
+ .findFirst()
+ .orElseThrow(() -> new ExternalTestingException("No such endpoint", 500, "No endpoint named " + endpointName + " is defined")
+ );
+
+ Object[] newArgs = ArrayUtils.add(args, 0, ep.getUrl());
+ return String.format(format, newArgs);
+ }
+ throw new ExternalTestingException(INVALIDATE_STATE_ERROR, 500, NO_ACCESS_CONFIGURATION_DEFINED);
+ }
+
+ /**
+ * Proxy a get request to a testing endpoint.
+ * @param url URL to invoke.
+ * @param responseType type of response expected.
+ * @param <T> type of response expected
+ * @return instance of <T> parsed from the JSON response from endpoint.
+ */
+ private <T> T proxyGetRequestToExternalTestingSite(String url, ParameterizedTypeReference<T> responseType) {
+ return proxyRequestToExternalTestingSite(url, null, responseType);
+ }
+
+ /**
+ * Make the actual HTTP post (using Spring RestTemplate) to an endpoint.
+ * @param url URL to the endpoint
+ * @param request optional request body to send
+ * @param responseType expected type
+ * @param <T> extended type
+ * @return instance of expected type
+ */
+ private <R,T> T proxyRequestToExternalTestingSite(String url, HttpEntity<R> request, ParameterizedTypeReference<T> responseType) {
+ if (request != null) {
+ logger.debug("POST request to {} with {} for {}", url, request, responseType.getType().getTypeName());
+ }
+ else {
+ logger.debug("GET request to {} for {}", url, responseType.getType().getTypeName());
+ }
+ SimpleClientHttpRequestFactory rf =
+ (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
+ if (rf != null) {
+ rf.setReadTimeout(10000);
+ rf.setConnectTimeout(10000);
+ }
+ ResponseEntity<T> re;
+ try {
+ if (request != null) {
+ re = restTemplate.exchange(url, HttpMethod.POST, request, responseType);
+ } else {
+ re = restTemplate.exchange(url, HttpMethod.GET, null, responseType);
+ }
+ }
+ catch (HttpStatusCodeException ex) {
+ // make my own exception out of this.
+ logger.warn("Unexpected HTTP Status from endpoint {}", ex.getRawStatusCode());
+ if ((ex.getResponseHeaders().getContentType() != null) &&
+ ((ex.getResponseHeaders().getContentType().isCompatibleWith(MediaType.APPLICATION_JSON)) ||
+ (ex.getResponseHeaders().getContentType().isCompatibleWith(MediaType.parseMediaType("application/problem+json"))))) {
+ String s = ex.getResponseBodyAsString();
+ logger.warn("endpoint body content is {}", s);
+ try {
+ JsonObject o = new GsonBuilder().create().fromJson(s, JsonObject.class);
+ throw buildTestingException(ex.getRawStatusCode(), o);
+ }
+ catch (JsonParseException e) {
+ logger.warn("unexpected JSON response", e);
+ throw new ExternalTestingException(ex.getStatusText(), ex.getStatusCode().value(), ex.getResponseBodyAsString(), ex);
+ }
+ }
+ else {
+ throw new ExternalTestingException(ex.getStatusText(), ex.getStatusCode().value(), ex.getResponseBodyAsString(), ex);
+ }
+ }
+ catch (ResourceAccessException ex) {
+ throw new ExternalTestingException("IO Error at Endpoint", 500, ex.getMessage(), ex);
+ }
+ catch (Exception ex) {
+ throw new ExternalTestingException(ex.getMessage(), 500, "Generic Exception", ex);
+ }
+ if (re != null) {
+ logger.debug("http status of {} from external testing entity {}", re.getStatusCodeValue(), url);
+ return re.getBody();
+ }
+ else {
+ logger.error("null response from endpoint");
+ return null;
+ }
+ }
+
+ /**
+ * Errors from the endpoint could conform to the expected ETSI body or not.
+ * Here we try to handle various response body elements.
+ * @param statusCode http status code in response.
+ * @param o JSON object parsed from the http response body
+ * @return Testing error body that should be returned to the caller
+ */
+ private ExternalTestingException buildTestingException(int statusCode, JsonObject o) {
+ String code = null;
+ String message = null;
+
+ if (o.has(CODE)) {
+ code = o.get(CODE).getAsString();
+ }
+ else if (o.has(ERROR)) {
+ code = o.get(ERROR).getAsString();
+ }
+ else {
+ if (o.has(HTTP_STATUS)) {
+ code = o.get(HTTP_STATUS).getAsJsonPrimitive().getAsString();
+ }
+ }
+ if (o.has(MESSAGE)) {
+ if (!o.get(MESSAGE).isJsonNull()) {
+ message = o.get(MESSAGE).getAsString();
+ }
+ }
+ else if (o.has(DETAIL)) {
+ message = o.get(DETAIL).getAsString();
+ }
+ if (o.has(PATH)) {
+ if (message == null) {
+ message = o.get(PATH).getAsString();
+ }
+ else {
+ message = message + " " + o.get(PATH).getAsString();
+ }
+ }
+ return new ExternalTestingException(code, statusCode, message);
+ }
+
+ /**
+ * Resolve variables in the request calling the built-in variable resolvers.
+ * @param item test execution request item to be resolved.
+ */
+ private void runVariableResolvers(final VtpTestExecutionRequest item, final MultiValueMap<String, Object> body) {
+ variableResolvers.forEach(vr -> {
+ if (vr.resolvesVariablesForRequest(item)) {
+ vr.resolve(item, body);
+ }
+ });
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/RemoteTestingEndpointDefinition.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/RemoteTestingEndpointDefinition.java
new file mode 100644
index 0000000000..205ca29680
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/RemoteTestingEndpointDefinition.java
@@ -0,0 +1,39 @@
+/*
+ * 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 lombok.Data;
+
+import java.util.regex.Pattern;
+
+@Data
+class RemoteTestingEndpointDefinition {
+ private boolean enabled;
+ private String title;
+ private String url;
+ private String id;
+ private String apiKey;
+ private String scenarioFilter;
+ private Pattern scenarioFilterPattern;
+
+ Pattern getScenarioFilterPattern() {
+ if ((scenarioFilterPattern == null) && (scenarioFilter != null)) {
+ scenarioFilterPattern = Pattern.compile(scenarioFilter);
+ }
+ return scenarioFilterPattern;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/TestingAccessConfig.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/TestingAccessConfig.java
new file mode 100644
index 0000000000..f9df5ac81d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/TestingAccessConfig.java
@@ -0,0 +1,30 @@
+/*
+ * 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 lombok.Data;
+
+import java.util.List;
+
+@SuppressWarnings({"unused", "WeakerAccess"})
+@Data
+public class TestingAccessConfig {
+
+ private ClientConfiguration client;
+ private List<RemoteTestingEndpointDefinition> endpoints;
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/VariableResolver.java b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/VariableResolver.java
new file mode 100644
index 0000000000..3079898bff
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/java/org/openecomp/core/externaltesting/impl/VariableResolver.java
@@ -0,0 +1,27 @@
+/*
+ * 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.openecomp.core.externaltesting.api.VtpTestExecutionRequest;
+import org.springframework.util.MultiValueMap;
+
+public interface VariableResolver {
+
+ boolean resolvesVariablesForRequest(VtpTestExecutionRequest requestItem);
+
+ void resolve(VtpTestExecutionRequest requestItem, MultiValueMap<String, Object> body);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..10449038bf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/openecomp-sdc-externaltesting-impl/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.core.externaltesting.factory.ExternalTestingManagerFactory":"org.openecomp.sdc.externaltesting.impl.ExternalTestingManagerFactoryImpl"
+}
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>
diff --git a/openecomp-be/lib/openecomp-sdc-externaltesting-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/pom.xml
new file mode 100644
index 0000000000..75ab9a54b0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-externaltesting-lib/pom.xml
@@ -0,0 +1,21 @@
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-externaltesting-lib</name>
+ <artifactId>openecomp-sdc-externaltesting-lib</artifactId>
+
+ <packaging>pom</packaging>
+ <parent>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <groupId>org.openecomp.sdc</groupId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+
+ <modules>
+ <module>openecomp-sdc-externaltesting-api</module>
+ <module>openecomp-sdc-externaltesting-impl</module>
+ </modules>
+
+</project>
diff --git a/openecomp-be/lib/pom.xml b/openecomp-be/lib/pom.xml
index 86787b5bc4..a0def39002 100644
--- a/openecomp-be/lib/pom.xml
+++ b/openecomp-be/lib/pom.xml
@@ -23,6 +23,7 @@
<module>openecomp-sdc-model-lib</module>
<module>openecomp-sdc-validation-lib</module>
<module>openecomp-sdc-datatypes-lib</module>
+ <module>openecomp-sdc-externaltesting-lib</module>
<module>openecomp-heat-lib</module>
<module>openecomp-tosca-lib</module>
<module>openecomp-sdc-action-lib</module>