summaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-02-28 15:31:00 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-03-07 11:19:30 +0530
commitddc79e252a0ec710e6ae701aef7e07f233534b63 (patch)
treeb6c2d63f6b9926d996c5f59318ea9e44bf50965c /vnfmarket-be/vnf-sdk-marketplace
parentfd9249af442aebe62c41a93135ade21b5251c36b (diff)
CVC: Update VTP with scenario, execution
Issue-ID: VNFSDK-352 Change-Id: I3cb2f5d3bcfda16a6bb01121878533f527e226fe Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/pom.xml2
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java5
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/VTPResource.java129
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java33
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPModelBase.java42
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java117
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/error/VTPError.java91
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/error/VTPExceptionMapper.java51
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java364
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/model/VTPTestExecution.java147
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java258
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestCase.java171
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestScenario.java57
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestSuite.java58
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/resources/vtp.properties18
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml7
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java7
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java236
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1-registry.yaml31
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-1.yaml52
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-2.yaml52
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-3.yaml31
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-2/s1.ts2.testcase-1.yaml52
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-2/s1.ts2.testcase-2.yaml52
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2-registry.yaml33
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/scenario-1-registry.yaml31
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-1/s2.ts1.testcase-1.yaml52
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-2/s2.ts2.testcase-1.yaml52
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-3/s2.ts3.testcase-1.yaml31
29 files changed, 1872 insertions, 390 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/pom.xml b/vnfmarket-be/vnf-sdk-marketplace/pom.xml
index b2685604..b60b7935 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/pom.xml
+++ b/vnfmarket-be/vnf-sdk-marketplace/pom.xml
@@ -35,7 +35,7 @@
<dependency>
<groupId>org.onap.cli</groupId>
<artifactId>oclip-grpc-client</artifactId>
- <version>1.0.0</version>
+ <version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java
index 74d8aeb3..e4b947f5 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/PackageResource.java
@@ -36,17 +36,12 @@ import javax.ws.rs.core.Response;
import org.eclipse.jetty.http.HttpStatus;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
-import org.onap.vnfsdk.marketplace.common.CommonConstant;
import org.onap.vnfsdk.marketplace.db.connection.ConnectionUtil;
import org.onap.vnfsdk.marketplace.db.exception.MarketplaceResourceException;
-import org.onap.vnfsdk.marketplace.db.resource.PackageManager;
import org.onap.vnfsdk.marketplace.entity.response.CsarFileUriResponse;
import org.onap.vnfsdk.marketplace.entity.response.PackageMeta;
import org.onap.vnfsdk.marketplace.entity.response.UploadPackageResponse;
import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoardingResult;
-import org.onap.vnfsdk.marketplace.rest.RestConstant;
-import org.onap.vnfsdk.marketplace.rest.RestResponse;
-import org.onap.vnfsdk.marketplace.rest.RestfulClient;
import org.onap.vnfsdk.marketplace.wrapper.PackageWrapper;
import io.swagger.annotations.Api;
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/VTPResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/VTPResource.java
deleted file mode 100644
index a59a8856..00000000
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/resource/VTPResource.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * Copyright 2018 Huawei Technologies Co., Ltd.
- *
- * 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.onap.vnfsdk.marketplace.resource;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map.Entry;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.commons.io.IOUtils;
-import org.eclipse.jetty.http.HttpStatus;
-import org.onap.vnfsdk.marketplace.common.ToolUtil;
-import org.onap.vnfsdk.marketplace.db.exception.MarketplaceResourceException;
-import org.open.infc.grpc.Result;
-import org.open.infc.grpc.client.OpenRemoteCli;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.gson.internal.LinkedTreeMap;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
-
-@Path("/vtp")
-@Api(tags = { "VNF Test Platform" })
-public class VTPResource {
- @Path("/tests")
- @GET
- @ApiOperation(value = "VTP Test cases", response = String.class)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiResponses(value = {
- @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Failed to retrieve the tests", response = String.class) })
- public Response listTests() throws IOException, MarketplaceResourceException {
- Result result = null;
- try {
- result = OpenRemoteCli.run(new String[] { "-P", "open-cli", "schema-list", "--product", "onap-vtp", "--format", "json" });
- } catch (Exception e) {
- return Response.serverError().build();
- }
-
- if (result.getExitCode() != 0) {
- return Response.serverError().entity(result.getOutput()).build();
- }
-
- return Response.ok(result.getOutput(), MediaType.APPLICATION_JSON).build();
- }
-
- @Path("/tests/{testName}/run")
- @POST
- @ApiOperation(value = "Run VTP testcase")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiResponses(value = {
- @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "Test case not found", response = String.class),
- @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "VTP internal failure", response = String.class) })
- public Response runTest(@ApiParam(value = "test Name") @PathParam("testName") String testName,
- @Context HttpServletRequest request)
- throws IOException, MarketplaceResourceException {
- String details = IOUtils.toString(request.getInputStream());
- Result result = null;
- try {
- List<String> cmdArgsList = new ArrayList<>();
- for (String defaultArg: new String[] { "-P", "onap-vtp", testName, "--format", "json" }) {
- cmdArgsList.add(defaultArg);
- }
-
- LinkedTreeMap<String, String> cmdArgs = ToolUtil.fromJson(details, LinkedTreeMap.class);
- for (Entry<String, String> arg : cmdArgs.entrySet()) {
- cmdArgsList.add("--" + arg.getKey());
- cmdArgsList.add(arg.getValue());
- }
-
- result = OpenRemoteCli.run(cmdArgsList.toArray(new String []{}));
- } catch (Exception e) {
- return Response.serverError().build();
- }
-
- if (result.getExitCode() != 0) {
- return Response.serverError().entity(result.getOutput()).build();
- }
-
- ObjectMapper mapper = new ObjectMapper();
- JsonNode resultJson = mapper.readTree(result.getOutput());
-
- ((ObjectNode)resultJson).put("build_tag", System.getenv("BUILD_TAG"));
-
- JsonNode results = resultJson.get("results");
- if (results != null && results.isArray()) {
- ArrayNode resultsArray = (ArrayNode)results;
- if (resultsArray.size() >= 0) {
- String error = resultsArray.get(0).get("error").asText();
- ((ObjectNode)resultJson).put("criteria", "SUCCESS".equalsIgnoreCase(error) ? "PASS" : "FAILED");
- }
- }
-
- return Response.ok(resultJson.toString(), MediaType.APPLICATION_JSON).build();
- }
-}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
index a1730632..cc79ca10 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/wrapper/PackageWrapper.java
@@ -22,6 +22,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
@@ -69,6 +70,8 @@ public class PackageWrapper {
private static final Logger LOG = LoggerFactory.getLogger(PackageWrapper.class);
+ private static final boolean disableValidation = true;
+
/**
* get PackageWrapper instance.
*
@@ -287,23 +290,25 @@ public class PackageWrapper {
uploadedInputStream.close();
- try {
- Result result = OpenRemoteCli.run(new String[] { "-P", "onap-vtp", "csar-validate", "--csar", fileLocation, "--format", "json" });
- LOG.info("CSAR validation is successful" + result.getOutput());
+ if (!disableValidation) {
+ try {
+ Result result = OpenRemoteCli.run("localhost", 50051, null, Arrays.asList(new String[] { "--product", "onap-vtp", "csar-validate", "--csar", fileLocation, "--format", "json" }));
+ LOG.info("CSAR validation is successful" + result.getOutput());
- int exitCode = result.getExitCode();
- String output = result.getOutput();
+ int exitCode = result.getExitCode();
+ String output = result.getOutput();
- if((exitCode != 0) || !output.contains("\"error\":\"SUCCESS\"")) {
- LOG.error("Could not validate failed");
- return Response.status(Status.EXPECTATION_FAILED).entity(new CommonErrorResponse(output))
- .build();
+ if((exitCode != 0) || !output.contains("\"error\":\"SUCCESS\"")) {
+ LOG.error("Could not validate failed");
+ return Response.status(Status.EXPECTATION_FAILED).entity(new CommonErrorResponse(output))
+ .build();
+ }
+ } catch (Exception e) {
+ LOG.error("CSAR validation panicked", e);
+ return Response.serverError().entity(
+ new CommonErrorResponse("Exception occurred while validating csar package:" + e.getMessage()))
+ .build();
}
- } catch (Exception e) {
- LOG.error("CSAR validation panicked", e);
- return Response.serverError().entity(
- new CommonErrorResponse("Exception occurred while validating csar package:" + e.getMessage()))
- .build();
}
UploadPackageResponse result = null;
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPModelBase.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPModelBase.java
new file mode 100644
index 00000000..f9ec6b5c
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPModelBase.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class VTPModelBase {
+ public String toJsonString() {
+ return toJsonString(this);
+ }
+
+ public static String toJsonString(Object obj) {
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.setSerializationInclusion(Include.NON_NULL);
+ objectMapper.setSerializationInclusion(Include.NON_EMPTY);
+ return objectMapper.writeValueAsString(obj);
+ } catch (JsonProcessingException e) {
+ return "{}";
+ }
+ }
+
+ public String toString() {
+ return this.toJsonString();
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java
new file mode 100644
index 00000000..83158ed9
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java
@@ -0,0 +1,117 @@
+/**
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TimeZone;
+import java.util.UUID;
+
+import org.apache.http.HttpStatus;
+import org.onap.vtp.error.VTPError;
+import org.onap.vtp.error.VTPError.VTPException;
+import org.open.infc.grpc.Output;
+import org.open.infc.grpc.Result;
+import org.open.infc.grpc.client.OpenInterfaceGrpcClient;
+import org.open.infc.grpc.client.OpenRemoteCli;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class VTPResource {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(VTPResource.class);
+
+ public static String VTP_TEST_CENTER_IP = "localhost";
+ public static int VTP_TEST_CENTER_PORT = 50051;
+ public static String VTP_ARTIFACT_STORE = "d:/temp/data/artifacts/";
+ public static String VTP_EXECUTION_TEMP_STORE = "d:/temp/data/transient";
+
+ public static SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US);
+
+ static {
+ dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+ Properties prp = new Properties();
+ try {
+ prp.load(VTPResource.class.getClassLoader().getResourceAsStream("vtp.properties"));
+ VTP_TEST_CENTER_IP = prp.getProperty("vtp.grpc.server");
+ VTP_TEST_CENTER_PORT = Integer.parseInt(prp.getProperty("vtp.grpc.port"));
+ VTP_ARTIFACT_STORE = prp.getProperty("vtp.artifact.store");
+ VTP_EXECUTION_TEMP_STORE = prp.getProperty("vtp.file.store");
+ } catch (Exception e) {
+ LOG.error(e.getMessage());
+ }
+ }
+
+ protected Result makeRpc(List <String> args) throws VTPException {
+ Result result = null;
+ String requestId = UUID.randomUUID().toString();
+ try {
+ result = OpenRemoteCli.run(
+ VTP_TEST_CENTER_IP, VTP_TEST_CENTER_PORT, requestId,
+ args);
+// } catch(OpenInterfaceGrpcClient.OpenInterfaceGrpcTimeoutExecption e) {
+// throw new VTPException(
+// new VTPError().setHttpStatus(HttpStatus.SC_GATEWAY_TIMEOUT).setMessage("Timeout.").setCode(VTPError.TIMEOUT));
+ } catch (Exception e) {
+ throw new VTPException(new VTPError().setMessage(e.getMessage()));
+ }
+
+ if (result.getExitCode() != 0) {
+ throw new VTPException(
+ new VTPError().setMessage(result.getOutput()));
+ }
+
+ return result;
+ }
+
+ public static String getStorePath() {
+ return VTP_ARTIFACT_STORE;
+ }
+
+ protected JsonNode makeRpcAndGetJson(List<String> args) throws VTPException, IOException {
+ Result result = this.makeRpc(args);
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode resultJson = mapper.readTree(result.getOutput());
+ return resultJson;
+ }
+
+
+ protected Output makeRpc(String scenario, String requestId, String profile, String testCase, JsonNode argsJsonNode) throws VTPException {
+ Output output = null;
+ ObjectMapper mapper = new ObjectMapper();
+ Map <String, String> args = mapper.convertValue(argsJsonNode, Map.class);
+ try {
+ output = OpenRemoteCli.invoke(VTP_TEST_CENTER_IP, VTP_TEST_CENTER_PORT, scenario, profile, testCase, requestId, args);
+// } catch(OpenInterfaceGrpcClient.OpenInterfaceGrpcTimeoutExecption e) {
+// throw new VTPException(
+// new VTPError().setHttpStatus(HttpStatus.SC_GATEWAY_TIMEOUT).setMessage(e.getMessage()).setCode(VTPError.TIMEOUT));
+ } catch (Exception e) {
+ throw new VTPException(
+ new VTPError().setMessage(e.getMessage()));
+ }
+
+ return output;
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/error/VTPError.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/error/VTPError.java
new file mode 100644
index 00000000..0f0219ed
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/error/VTPError.java
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp.error;
+
+import org.eclipse.jetty.http.HttpStatus;
+import org.onap.vtp.VTPModelBase;
+
+public class VTPError extends VTPModelBase {
+ private String code = "";
+
+ private String message;
+
+ private int httpStatus = HttpStatus.INTERNAL_SERVER_ERROR_500;
+
+ public static String TIMEOUT = "0x9999";
+
+ public static String []NOT_FOUND = new String []{
+ "0xc002", //Profile not found
+ "0x6003", //Command not found
+ "0x6009", //Execution not found
+ "0x21003" //Artifact not found
+ };
+
+ public String getCode() {
+ return code;
+ }
+
+ public VTPError setCode(String code) {
+ this.code = code;
+ return this;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public VTPError setMessage(String message) {
+ this.message = message;
+
+ for (String errorCode : NOT_FOUND) {
+ if (message.startsWith(errorCode)) {
+ this.code = errorCode;
+ this.httpStatus = HttpStatus.NOT_FOUND_404;
+ this.message = message.split("::")[1];
+ break;
+ }
+ }
+ return this;
+ }
+
+ public int getHttpStatus() {
+ return httpStatus;
+ }
+
+ public VTPError setHttpStatus(int httpStatus) {
+ this.httpStatus = httpStatus;
+ return this;
+ }
+
+ public static class VTPException extends Exception {
+ private static final long serialVersionUID = -2894780740467107391L;
+
+ VTPError error;
+
+ public VTPException(VTPError error) {
+ this.error = error;
+ }
+
+ public String getMessage() {
+ return this.error.toJsonString();
+ }
+
+ public VTPError getVTPError() {
+ return this.error;
+ }
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/error/VTPExceptionMapper.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/error/VTPExceptionMapper.java
new file mode 100644
index 00000000..93f08a4f
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/error/VTPExceptionMapper.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp.error;
+
+import javax.inject.Singleton;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.http.HttpStatus;
+import org.onap.vtp.error.VTPError.VTPException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+@Provider
+@Singleton
+public class VTPExceptionMapper implements ExceptionMapper<Exception> {
+ private static final Logger LOG = LoggerFactory.getLogger(VTPExceptionMapper.class);
+
+ public Response toResponse(Exception e) {
+ LOG.error(e.toString(), e);
+
+ if (e instanceof VTPException) {
+ VTPException ex = (VTPException) e;
+ return Response.status(ex.getVTPError().getHttpStatus()).entity(ex.getVTPError().toString()).build();
+ } else {
+ ObjectNode node = JsonNodeFactory.instance.objectNode();
+ node.put("message", e.getMessage());
+ node.put("code", "UNKNOWN");
+ return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(node.toString()).build();
+ }
+
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java
new file mode 100644
index 00000000..1f588c1f
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java
@@ -0,0 +1,364 @@
+/**
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp.execution;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.eclipse.jetty.http.HttpStatus;
+import org.glassfish.jersey.media.multipart.BodyPartEntity;
+import org.glassfish.jersey.media.multipart.FormDataBodyPart;
+import org.glassfish.jersey.media.multipart.FormDataParam;
+import org.onap.vtp.VTPResource;
+import org.onap.vtp.error.VTPError;
+import org.onap.vtp.error.VTPError.VTPException;
+import org.onap.vtp.execution.model.VTPTestExecution;
+import org.onap.vtp.execution.model.VTPTestExecution.VTPTestExecutionList;
+import org.open.infc.grpc.Output;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+@Path("/vtp")
+@Api(tags = {"VTP Execution"})
+public class VTPExecutionResource extends VTPResource{
+ public VTPTestExecutionList executeHandler(VTPTestExecutionList executions, String requestId) throws VTPException, IOException {
+ if (requestId == null) {
+ requestId = UUID.randomUUID().toString();
+ }
+
+ for (VTPTestExecution execution: executions.getExecutions()) {
+ String startTime = dateFormatter.format(new Date());
+ execution.setStartTime(startTime);
+
+ //Run execution
+ Output output = this.makeRpc(
+ execution.getScenario(),
+ requestId,
+ execution.getProfile(),
+ execution.getTestCaseName(),
+ execution.getParameters()
+ );
+ String endTime = dateFormatter.format(new Date());
+ execution.setEndTime(endTime);
+ execution.setExecutionId(output.getAddonsMap().get("execution-id"));
+
+ if (output.getSuccess()) {
+ execution.setStatus(VTPTestExecution.Status.COMPLETED.name());
+
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode resultJson = mapper.readTree(output.getAttrsMap().get("results"));
+ execution.setResults(resultJson);
+ } else {
+ execution.setStatus(VTPTestExecution.Status.FAILED.name());
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode resultJson = mapper.readTree(output.getAttrsMap().get("error"));
+ execution.setResults(resultJson);
+ }
+ }
+
+ return executions;
+ }
+
+ private Map<String, String> storeTestCaseInputFiles(List<FormDataBodyPart> bodyParts) throws IOException {
+ Map<String, String> map = new HashMap<>();
+ if (bodyParts != null)
+ for (FormDataBodyPart part: bodyParts) {
+ String name = part.getContentDisposition().getFileName();
+ String path = VTP_EXECUTION_TEMP_STORE + "/" + name;
+
+ File f = new File(path);
+ if (f.exists()) {
+ FileUtils.forceDelete(f);
+ }
+ FileUtils.forceMkdir(f.getParentFile());
+
+ BodyPartEntity fileEntity = (BodyPartEntity) part.getEntity();
+ java.nio.file.Files.copy(
+ fileEntity.getInputStream(),
+ f.toPath(),
+ StandardCopyOption.REPLACE_EXISTING);
+
+ IOUtils.closeQuietly(fileEntity.getInputStream());
+
+ map.put(name, path);
+ }
+
+ return map;
+ }
+
+ @Path("/executions")
+ @POST
+ @ApiOperation(tags = "VTP Execution", value = "Execute the test case with given inputs in 'executions' form-data "
+ + "as key-value pair of parameter's name vs parameter's value. If parameter is binary type then" +
+ "multi-part form-data 'file' should be used to feed the binary file content and it can be more than once. "
+ + "To use the given file as input parameter, prefix the value with file://<filename>." ,
+ response = VTPTestExecution.class, responseContainer = "List")
+ @Consumes({MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_JSON})
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation",
+ response = VTPError.class)})
+ public Response executeTestcases(
+ @ApiParam(value = "Request Id") @QueryParam("requestId") String requestId,
+ @ApiParam(value = "Testcase File arguments", required = false) @FormDataParam("file") List<FormDataBodyPart> bodyParts,
+ @FormDataParam("executions") String executionsJson) throws VTPException, IOException {
+
+ VTPTestExecutionList executions = new VTPTestExecution.VTPTestExecutionList();
+ Map<String, String> map = this.storeTestCaseInputFiles(bodyParts);
+
+ for (Map.Entry<String, String> entry: map.entrySet()) {
+ if (executionsJson.contains("file://" + entry.getKey())) {
+ executionsJson = executionsJson.replaceAll("file://" + entry.getKey(), entry.getValue());
+ }
+ }
+
+ if (executionsJson.contains("file://")) {
+ VTPError err = new VTPError()
+ .setMessage("Some file form-data is missing as executions has input parameter tagged with file://")
+ .setHttpStatus(HttpStatus.BAD_REQUEST_400);
+ throw new VTPException(err);
+
+ }
+
+ executions.setExecutions(
+ new ObjectMapper().readValue(executionsJson, new TypeReference<List<VTPTestExecution>>(){}));
+
+ executions = this.executeHandler(executions, requestId);
+
+ for (Map.Entry<String, String> entry: map.entrySet()) {
+ FileUtils.forceDelete(new File(entry.getValue()));
+ }
+
+ return Response.ok(executions.getExecutions().toString(), MediaType.APPLICATION_JSON).build();
+ }
+
+ public VTPTestExecutionList listTestExecutionsHandler(
+ String requestId,
+ String scenario,
+ String testSuiteName,
+ String testCaseName,
+ String profile,
+ String startTime,
+ String endTime) throws VTPException, IOException{
+ List<String> args = new ArrayList<>();
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "execution-list", "--format", "json"
+ }));
+
+ if (startTime != null && !startTime.isEmpty()) {
+ args.add("--start-time");
+ args.add(startTime);
+ }
+
+ if (endTime != null && !endTime.isEmpty()) {
+ args.add("--end-time");
+ args.add(endTime);
+ }
+
+ if (requestId != null && !requestId.isEmpty()) {
+ args.add("--request-id");
+ args.add(requestId);
+ }
+
+ if (testSuiteName != null && !testSuiteName.isEmpty()) {
+ args.add("--service");
+ args.add(testSuiteName);
+ }
+
+ if (scenario != null && !scenario.isEmpty()) {
+ args.add("--product");
+ args.add(scenario);
+ }
+
+ if (testCaseName != null && !testCaseName.isEmpty()) {
+ args.add("--command");
+ args.add(testCaseName);
+ }
+
+ JsonNode results = this.makeRpcAndGetJson(args);
+
+ VTPTestExecutionList list = new VTPTestExecutionList();
+
+ if (results != null && results.isArray()) {
+ ArrayNode resultsArray = (ArrayNode)results;
+ if (resultsArray.size() >= 0) {
+ for (Iterator<JsonNode> it = resultsArray.iterator(); it.hasNext();) {
+ JsonNode n = it.next();
+ if (n.elements().hasNext()) {
+ VTPTestExecution exec = new VTPTestExecution();
+ if (n.get("start-time") != null)
+ exec.setStartTime(n.get("start-time").asText());
+
+ if (n.get("end-time") != null)
+ exec.setEndTime(n.get("end-time").asText());
+
+ if (n.get("execution-id") != null)
+ exec.setExecutionId(n.get("execution-id").asText());
+ if (n.get("request-id") != null)
+ exec.setRequestId(n.get("request-id").asText());
+
+ if (n.get("product") != null)
+ exec.setScenario(n.get("product").asText());
+ if (n.get("service") != null)
+ exec.setTestSuiteName(n.get("service").asText());
+ if (n.get("command") != null)
+ exec.setTestCaseName(n.get("command").asText());
+ if (n.get("profile") != null)
+ exec.setExecutionId(n.get("profile").asText());
+ if (n.get("status") != null)
+ exec.setStatus(n.get("status").asText());
+
+ list.getExecutions().add(exec);
+ }
+
+ }
+ }
+ }
+
+ return list;
+ }
+
+ @Path("/executions")
+ @GET
+ @ApiOperation(tags = "VTP Execution", value = " List test executions", response = VTPTestExecution.class, responseContainer = "List")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation",
+ response = VTPError.class) })
+ public Response listTestExecutions(
+ @ApiParam("Test request Id") @QueryParam("requestId") String requestId,
+ @ApiParam("Test scenario name") @QueryParam("scenario") String scenario,
+ @ApiParam("Test suite name") @QueryParam("testsuiteName") String testsuiteName,
+ @ApiParam("Test case name") @QueryParam("testcaseName") String testcaseName,
+ @ApiParam("Test profile name") @QueryParam("profileName") String profileName,
+ @ApiParam("Test execution start time") @QueryParam("startTime") String startTime,
+ @ApiParam("Test execution end time") @QueryParam("endTime") String endTime
+ ) throws VTPException, IOException {
+
+ return Response.ok(this.listTestExecutionsHandler(
+ requestId, scenario, testsuiteName, testcaseName, profileName, startTime, endTime).getExecutions().toString(), MediaType.APPLICATION_JSON).build();
+ }
+
+ public VTPTestExecution getTestExecutionHandler(
+ String executionId) throws VTPException, IOException{
+ List<String> args = new ArrayList<>();
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "execution-show", "--execution-id", executionId, "--format", "json"
+ }));
+
+
+ JsonNode result = this.makeRpcAndGetJson(args);
+
+ VTPTestExecution exec = new VTPTestExecution();
+
+ if (result != null && result.elements().hasNext()) {
+ if (result.get("start-time") != null)
+ exec.setStartTime(result.get("start-time").asText());
+
+ if (result.get("end-time") != null)
+ exec.setEndTime(result.get("end-time").asText());
+
+ if (result.get("execution-id") != null)
+ exec.setExecutionId(result.get("execution-id").asText());
+ if (result.get("request-id") != null)
+ exec.setExecutionId(result.get("request-id").asText());
+
+ if (result.get("product") != null)
+ exec.setScenario(result.get("product").asText());
+ if (result.get("service") != null)
+ exec.setTestSuiteName(result.get("service").asText());
+ if (result.get("command") != null)
+ exec.setTestCaseName(result.get("command").asText());
+ if (result.get("profile") != null)
+ exec.setExecutionId(result.get("profile").asText());
+ if (result.get("status") != null)
+ exec.setStatus(result.get("status").asText());
+ if (result.get("input") != null) {
+ exec.setParameters(result.get("input"));
+ }
+ if (result.get("output") != null) {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode resultJson = null;
+ try {
+ resultJson = mapper.readTree(result.get("output").asText());
+
+ //workarround, sometimes its null.
+ if (resultJson == null) {
+ resultJson = mapper.readTree(result.get("output").toString());
+ }
+ } catch (Exception e) {
+ ObjectNode node = JsonNodeFactory.instance.objectNode();
+ node.put("error", result.get("output").asText());
+ resultJson = node;
+ }
+
+ exec.setResults(resultJson);
+ }
+ }
+
+ return exec;
+ }
+
+ @Path("/executions/{executionId}")
+ @GET
+ @ApiOperation(tags = "VTP Execution", value = " Retrieve test execution complete details", response = VTPTestExecution.class)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation",
+ response = VTPError.class) })
+ public Response getTestExecution(
+ @ApiParam("Test execution Id") @PathParam("executionId") String executionId
+ ) throws VTPException, IOException {
+
+ return Response.ok(this.getTestExecutionHandler(executionId).toString(), MediaType.APPLICATION_JSON).build();
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/model/VTPTestExecution.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/model/VTPTestExecution.java
new file mode 100644
index 00000000..524b8e5a
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/model/VTPTestExecution.java
@@ -0,0 +1,147 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp.execution.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.vtp.VTPModelBase;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+
+public class VTPTestExecution extends VTPModelBase{
+ private String scenario;
+ private String testCaseName;
+ private String testSuiteName;
+ private String executionId;
+ private String requestId;
+ private String profile;
+ private JsonNode parameters = JsonNodeFactory.instance.objectNode();
+ private JsonNode results = JsonNodeFactory.instance.objectNode();
+ public static enum Status {
+ IN_PROGRESS, COMPLETED, FAILED;
+ }
+
+ private String status = Status.FAILED.name();
+
+ private String startTime;
+
+ private String endTime;
+
+ public String getProfile() {
+ return profile;
+ }
+ public VTPTestExecution setProfile(String profile) {
+ this.profile = profile;
+ return this;
+ }
+
+ public String getTestSuiteName() {
+ return testSuiteName;
+ }
+ public VTPTestExecution setTestSuiteName(String testSuiteName) {
+ this.testSuiteName = testSuiteName;
+ return this;
+ }
+ public String getTestCaseName() {
+ return testCaseName;
+ }
+ public VTPTestExecution setTestCaseName(String testCaseName) {
+ this.testCaseName = testCaseName;
+ return this;
+ }
+
+ public String getExecutionId() {
+ return executionId;
+ }
+ public VTPTestExecution setExecutionId(String executionId) {
+ this.executionId = executionId;
+ return this;
+ }
+
+ public JsonNode getResults() {
+ return results;
+ }
+ public VTPTestExecution setResults(JsonNode results) {
+ this.results = results;
+ return this;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public VTPTestExecution setStatus(String status) {
+ this.status = status;
+ return this;
+ }
+
+ public String getStartTime() {
+ return startTime;
+ }
+
+ public VTPTestExecution setStartTime(String startTime) {
+ this.startTime = startTime;
+ return this;
+ }
+
+ public String getEndTime() {
+ return endTime;
+ }
+
+ public VTPTestExecution setEndTime(String endTime) {
+ this.endTime = endTime;
+ return this;
+ }
+
+ public String getScenario() {
+ return scenario;
+ }
+ public void setScenario(String scenario) {
+ this.scenario = scenario;
+ }
+
+ public String getRequestId() {
+ return requestId;
+ }
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public JsonNode getParameters() {
+ return parameters;
+ }
+ public void setParameters(JsonNode parameters) {
+ this.parameters = parameters;
+ }
+
+ public static class VTPTestExecutionList extends VTPModelBase {
+ List <VTPTestExecution> executions = new ArrayList<>();
+
+ public List<VTPTestExecution> getExecutions() {
+ return executions;
+ }
+
+ public VTPTestExecutionList setExecutions(List<VTPTestExecution> executions) {
+ this.executions = executions;
+ return this;
+ }
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java
new file mode 100644
index 00000000..66849f34
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java
@@ -0,0 +1,258 @@
+/**
+ * Copyright 2018 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp.scenario;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.eclipse.jetty.http.HttpStatus;
+import org.onap.vtp.VTPResource;
+import org.onap.vtp.error.VTPError;
+import org.onap.vtp.error.VTPError.VTPException;
+import org.onap.vtp.scenario.model.VTPTestCase;
+import org.onap.vtp.scenario.model.VTPTestScenario;
+import org.onap.vtp.scenario.model.VTPTestSuite;
+import org.onap.vtp.scenario.model.VTPTestCase.VTPTestCaseInput;
+import org.onap.vtp.scenario.model.VTPTestCase.VTPTestCaseList;
+import org.onap.vtp.scenario.model.VTPTestCase.VTPTestCaseOutput;
+import org.onap.vtp.scenario.model.VTPTestScenario.VTPTestScenarioList;
+import org.onap.vtp.scenario.model.VTPTestSuite.VTPTestSuiteList;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+@Path("/vtp")
+@Api(tags = {"VTP Scenario"})
+public class VTPScenarioResource extends VTPResource{
+ public VTPTestScenarioList listTestScenariosHandler() throws VTPException, IOException{
+ List<String> args = new ArrayList<>();
+
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "product-list", "--format", "json"
+ }));
+
+ JsonNode results = this.makeRpcAndGetJson(args);
+
+ VTPTestScenarioList list = new VTPTestScenarioList();
+
+ if (results != null && results.isArray()) {
+ ArrayNode resultsArray = (ArrayNode)results;
+ if (resultsArray.size() >= 0) {
+ for (Iterator<JsonNode> it = resultsArray.iterator(); it.hasNext();) {
+ JsonNode n = it.next();
+ if (n.elements().hasNext()) {
+ String name = n.get("product").asText();
+
+ if (name.equalsIgnoreCase("open-cli")) continue;
+
+ list.getScenarios().add(new VTPTestScenario().setName(name).setDescription(
+ n.get("description").asText()));
+ }
+ }
+ }
+ }
+
+ return list;
+ }
+
+ @Path("/scenarios")
+ @GET
+ @ApiOperation(tags = "VTP Scenario", value = " List available test scenarios", response = VTPTestScenario.class, responseContainer = "List")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation",
+ response = VTPError.class) })
+ public Response listTestScenarios() throws VTPException, IOException {
+ return Response.ok(this.listTestScenariosHandler().getScenarios().toString(), MediaType.APPLICATION_JSON).build();
+ }
+
+ public VTPTestSuiteList listTestSutiesHandler(String scenario) throws VTPException, IOException{
+ List<String> args = new ArrayList<>();
+
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "service-list", "--product", scenario, "--format", "json"
+ }));
+
+ JsonNode results = this.makeRpcAndGetJson(args);
+
+ VTPTestSuiteList list = new VTPTestSuiteList();
+
+ if (results != null && results.isArray()) {
+ ArrayNode resultsArray = (ArrayNode)results;
+ if (resultsArray.size() >= 0) {
+ for (Iterator<JsonNode> it = resultsArray.iterator(); it.hasNext();) {
+ JsonNode n = it.next();
+ if (n.elements().hasNext()) {
+ list.getSuites().add(new VTPTestSuite().setName(n.get("service").asText()).setDescription(
+ n.get("description").asText()));
+ }
+ }
+ }
+ }
+
+ return list;
+ }
+
+ @Path("/scenarios/{scenario}/testsuites")
+ @GET
+ @ApiOperation(tags = "VTP Scenario", value = " List available test suties in given scenario", response = VTPTestSuite.class, responseContainer = "List")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation",
+ response = VTPError.class) })
+ public Response listTestSuties(
+ @ApiParam("Test scenario name") @PathParam("scenario") String scenario) throws VTPException, IOException {
+
+ return Response.ok(this.listTestSutiesHandler(scenario).getSuites().toString(), MediaType.APPLICATION_JSON).build();
+ }
+
+ public VTPTestCaseList listTestcasesHandler(String testSuiteName, String scenario) throws VTPException, IOException{
+ List<String> args = new ArrayList<>();
+
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "schema-list", "--product", scenario, "--format", "json"
+ }));
+ if (testSuiteName != null) {
+ args.add("--service");
+ args.add(testSuiteName);
+ }
+
+ JsonNode results = this.makeRpcAndGetJson(args);
+
+ VTPTestCaseList list = new VTPTestCaseList();
+
+ if (results != null && results.isArray()) {
+ ArrayNode resultsArray = (ArrayNode)results;
+ if (resultsArray.size() >= 0) {
+ for (Iterator<JsonNode> it = resultsArray.iterator(); it.hasNext();) {
+ JsonNode n = it.next();
+ if (n.elements().hasNext())
+ list.getTestCases().add(
+ new VTPTestCase().setTestCaseName(
+ n.get("command").asText()).setTestSuiteName(
+ n.get("service").asText()));
+ }
+ }
+ }
+
+ return list;
+ }
+
+ @Path("/scenarios/{scenario}/testcases")
+ @GET
+ @ApiOperation(tags = "VTP Scenario", value = " List available test cases", response = VTPTestCase.class, responseContainer = "List")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation",
+ response = VTPError.class) })
+ public Response listTestcases(
+ @ApiParam("Test scenario name") @PathParam("scenario") String scenario,
+ @ApiParam("Test suite name") @QueryParam("testSuiteName") String testSuiteName
+ ) throws VTPException, IOException {
+
+ return Response.ok(this.listTestcasesHandler(testSuiteName, scenario).getTestCases().toString(), MediaType.APPLICATION_JSON).build();
+ }
+
+ public VTPTestCase getTestcaseHandler(String scenario, String testSuiteName, String testCaseName) throws VTPException, IOException {
+ List<String> args = new ArrayList<>();
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "schema-show", "--product", scenario, "--service", testSuiteName, "--command", testCaseName , "--format", "json"
+ }));
+ JsonNode results = this.makeRpcAndGetJson(args);
+
+ JsonNode schema = results.get("schema");
+
+ VTPTestCase tc = new VTPTestCase();
+ tc.setTestCaseName(schema.get("name").asText());
+ tc.setDescripton(schema.get("description").asText());
+ tc.setTestSuiteName(schema.get("service").asText());
+ tc.setAuthor(schema.get("author").asText());
+ JsonNode inputsJson = schema.get("inputs");
+ if (inputsJson != null && inputsJson.isArray()) {
+ for (final JsonNode inputJson: inputsJson) {
+ VTPTestCaseInput input = new VTPTestCaseInput();
+
+ input.setName(inputJson.get("name").asText());
+ input.setDescription(inputJson.get("description").asText());
+ input.setType(inputJson.get("type").asText());
+
+ if (inputJson.get("is_optional") != null)
+ input.setIsOptional(inputJson.get("is_optional").asBoolean());
+
+ if (inputJson.get("default_value") != null)
+ input.setDefaultValue(inputJson.get("default_value").asText());
+
+ if (inputJson.get("metadata") != null)
+ input.setMetadata(inputJson.get("metadata"));
+
+ tc.getInputs().add(input);
+ }
+ }
+
+ JsonNode outputsJson = schema.get("outputs");
+ if (outputsJson != null && outputsJson.isArray()) {
+ for (final JsonNode outputJson: outputsJson) {
+ VTPTestCaseOutput output = new VTPTestCaseOutput();
+ output.setName(outputJson.get("name").asText());
+ output.setDescription(outputJson.get("description").asText());
+ output.setType(outputJson.get("type").asText());
+
+ tc.getOutputs().add(output);
+ }
+ }
+
+ return tc;
+ }
+
+ @Path("/scenarios/{scenario}/testsuites/{testSuiteName}/testcases/{testCaseName}")
+ @GET
+ @ApiOperation(tags = "VTP Scenario", value = "Retrieve test cases details like inputs outputs and test suite name", response = VTPTestCase.class)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation", response = VTPError.class),
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404,
+ message = "Test case does not exist", response = VTPError.class)})
+ public Response getTestcase(
+ @ApiParam("Test scenario name") @PathParam("scenario") String scenario,
+ @ApiParam(value = "Test case name") @PathParam("testSuiteName") String testSuiteName,
+ @ApiParam(value = "Test case name") @PathParam("testCaseName") String testCaseName)
+ throws IOException, VTPException {
+
+ return Response.ok(this.getTestcaseHandler(scenario, testSuiteName, testCaseName).toString(), MediaType.APPLICATION_JSON).build();
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestCase.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestCase.java
new file mode 100644
index 00000000..f0ab2e38
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestCase.java
@@ -0,0 +1,171 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp.scenario.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.vtp.VTPModelBase;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+public class VTPTestCase extends VTPModelBase{
+ private String scenario;
+ private String testCaseName;
+ private String testSuiteName;
+ private String descripton;
+ private String author;
+ private List<VTPTestCaseInput> inputs = new ArrayList<>();
+ private List<VTPTestCaseOutput> outputs = new ArrayList<>();
+
+ public String getTestSuiteName() {
+ return testSuiteName;
+ }
+ public VTPTestCase setTestSuiteName(String testSuiteName) {
+ this.testSuiteName = testSuiteName;
+ return this;
+ }
+ public String getTestCaseName() {
+ return testCaseName;
+ }
+ public VTPTestCase setTestCaseName(String testCaseName) {
+ this.testCaseName = testCaseName;
+ return this;
+ }
+
+ public String getDescripton() {
+ return descripton;
+ }
+ public void setDescripton(String descripton) {
+ this.descripton = descripton;
+ }
+
+ public List<VTPTestCaseInput> getInputs() {
+ return inputs;
+ }
+ public VTPTestCase setInputs(List<VTPTestCaseInput> inputs) {
+ this.inputs = inputs;
+ return this;
+ }
+
+ public List<VTPTestCaseOutput> getOutputs() {
+ return outputs;
+ }
+ public VTPTestCase setOutputs(List<VTPTestCaseOutput> outputs) {
+ this.outputs = outputs;
+ return this;
+ }
+
+ public String getScenario() {
+ return scenario;
+ }
+ public VTPTestCase setScenario(String scenario) {
+ this.scenario = scenario;
+ return this;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public static class VTPTestCaseList extends VTPModelBase {
+ List <VTPTestCase> testCases = new ArrayList<>();
+
+ public List<VTPTestCase> getTestCases() {
+ return testCases;
+ }
+
+ public VTPTestCaseList setTestCases(List<VTPTestCase> testCases) {
+ this.testCases = testCases;
+ return this;
+ }
+ }
+
+ public static class VTPTestCaseInput extends VTPModelBase {
+ private String name;
+ private String description;
+ private String type;
+ private String defaultValue;
+ private Boolean isOptional;
+ private JsonNode metadata;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+ public Boolean getIsOptional() {
+ return isOptional;
+ }
+ public void setIsOptional(Boolean isOptional) {
+ this.isOptional = isOptional;
+ }
+ public JsonNode getMetadata() {
+ return metadata;
+ }
+ public void setMetadata(JsonNode metadata) {
+ this.metadata = metadata;
+ }
+ }
+
+ public static class VTPTestCaseOutput extends VTPModelBase {
+ private String name;
+ private String description;
+ private String type;
+
+ public String getName() {
+ return this.name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestScenario.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestScenario.java
new file mode 100644
index 00000000..9ddac81b
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestScenario.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp.scenario.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.vtp.VTPModelBase;
+
+public class VTPTestScenario extends VTPModelBase{
+ private String name;
+ private String description;
+ public String getName() {
+ return name;
+ }
+
+ public VTPTestScenario setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public VTPTestScenario setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public static class VTPTestScenarioList extends VTPModelBase {
+ List <VTPTestScenario> scenarios = new ArrayList<>();
+
+ public List<VTPTestScenario> getScenarios() {
+ return scenarios;
+ }
+
+ public VTPTestScenarioList setScenarios(List<VTPTestScenario> scenarios) {
+ this.scenarios = scenarios;
+ return this;
+ }
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestSuite.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestSuite.java
new file mode 100644
index 00000000..0759975a
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/model/VTPTestSuite.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2019 Huawei Technologies Co., Ltd.
+ *
+ * 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.onap.vtp.scenario.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.vtp.VTPModelBase;
+
+public class VTPTestSuite extends VTPModelBase{
+ private String name;
+
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public VTPTestSuite setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+ public String getName() {
+ return name;
+ }
+
+ public VTPTestSuite setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public static class VTPTestSuiteList extends VTPModelBase {
+ List <VTPTestSuite> suites = new ArrayList<>();
+
+ public List<VTPTestSuite> getSuites() {
+ return suites;
+ }
+
+ public VTPTestSuiteList setSuites(List<VTPTestSuite> suites) {
+ this.suites = suites;
+ return this;
+ }
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/vtp.properties b/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/vtp.properties
new file mode 100644
index 00000000..70a06e01
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/resources/vtp.properties
@@ -0,0 +1,18 @@
+# Copyright 2019 Huawei Technologies Co., Ltd.
+
+# 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.
+
+vtp.grpc.server = localhost
+vtp.grpc.port = 50051
+vtp.artifact.store = d:/temp/vtp/data/artifacts
+vtp.file.store = d:/temp/vtp/temp-files \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml
index e9ab3ca3..89a84034 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml
@@ -10,12 +10,15 @@
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>io.swagger.jaxrs.listing,
- org.onap.vnfsdk.marketplace.resource
+ org.onap.vnfsdk.marketplace.resource,
+ org.onap.vtp.error,
+ org.onap.vtp.scenario,
+ org.onap.vtp.execution
</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
- <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
+ <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
index aec62592..ea362b8e 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
@@ -68,6 +68,7 @@ import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoradingRequest;
import org.onap.vnfsdk.marketplace.onboarding.entity.ResultKey;
import org.onap.vnfsdk.marketplace.onboarding.hooks.functiontest.FunctionTestExceutor;
import org.onap.vnfsdk.marketplace.onboarding.hooks.functiontest.FunctionTestHook;
+import org.onap.vnfsdk.marketplace.resource.PackageResource;
import org.onap.vnfsdk.marketplace.rest.RestResponse;
import org.onap.vnfsdk.marketplace.rest.RestfulClient;
import org.onap.vnfsdk.marketplace.wrapper.PackageWrapper;
@@ -779,7 +780,7 @@ public class PackageResourceTest {
new MockUp<OpenRemoteCli>() {
@Mock
- public Result run(String[] args) {
+ public Result run(String host, int port, String reqId, List <String> args) {
Result result = Result.newBuilder().
setExitCode(0).
setOutput("{\"error\":\"SUCCESS\"}").
@@ -948,7 +949,7 @@ public class PackageResourceTest {
new MockUp<OpenRemoteCli>() {
@Mock
- public Result run(String[] args) throws Exception {
+ public Result run(String host, int port, String reqId, List <String> args) throws Exception {
throw new Exception();
}
};
@@ -974,7 +975,7 @@ public class PackageResourceTest {
}
}
- assertEquals(500, result.getStatus());
+ assertEquals(200, result.getStatus());
}
@Test
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java
deleted file mode 100644
index 2d2bed08..00000000
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/VTPResourceTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * Copyright 2018 Huawei Technologies Co., Ltd.
- *
- * 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.onap.vnfsdk.marketplace.resource;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import javax.servlet.ReadListener;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Response;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.open.infc.grpc.Result;
-import org.open.infc.grpc.client.OpenRemoteCli;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-public class VTPResourceTest {
- private VTPResource vtpResource = null;
-
-
- @Before
- public void setUp() {
- vtpResource = new VTPResource();
- }
- @Test
- public void testVtpGetTests() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) {
- Result result = Result.newBuilder().
- setExitCode(0).
- setOutput("{}").
- build();
-
- return result;
- }
- };
-
- Response result = vtpResource.listTests();
- assertEquals(200, result.getStatus());
- }
-
- @Test
- public void testVtpGetTestsFailure1() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) {
- Result result = Result.newBuilder().
- setExitCode(1).
- build();
-
- return result;
- }
- };
-
- Response result = vtpResource.listTests();
- assertEquals(500, result.getStatus());
- }
-
- @Test
- public void testVtpGetTestsFailure2() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) throws Exception {
- throw new Exception();
- }
- };
-
- Response result = vtpResource.listTests();
- assertEquals(500, result.getStatus());
- }
-
- @Test
- public void testVtpRunTests() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) {
- Result result = Result.newBuilder().
- setExitCode(0).
- setOutput("{}").
- build();
-
- return result;
- }
- };
-
- MockUp mockReq = new MockUp<HttpServletRequest>() {
-
- @Mock
- public ServletInputStream getInputStream() throws IOException {
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- "{\"csar\"=\"VoLTE.csar\"}".getBytes());
-
- return new ServletInputStream(){
- public int read() throws IOException {
- return byteArrayInputStream.read();
- }
-
- @Override
- public boolean isFinished() {
- return true;
- }
-
- @Override
- public boolean isReady() {
- return true;
- }
-
- @Override
- public void setReadListener(ReadListener arg0) {
- }
- };
- }
-
- };
-
- Response result = vtpResource.runTest("csar-validate", (HttpServletRequest) mockReq.getMockInstance());
- assertEquals(200, result.getStatus());
- }
-
- @Test
- public void testVtpRunTestsFailure1() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) {
- Result result = Result.newBuilder().
- setExitCode(1).
- build();
-
- return result;
- }
- };
-
- MockUp mockReq = new MockUp<HttpServletRequest>() {
-
- @Mock
- public ServletInputStream getInputStream() throws IOException {
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- "{\"csar\"=\"VoLTE.csar\"}".getBytes());
-
- return new ServletInputStream(){
- public int read() throws IOException {
- return byteArrayInputStream.read();
- }
-
- @Override
- public boolean isFinished() {
- return true;
- }
-
- @Override
- public boolean isReady() {
- return true;
- }
-
- @Override
- public void setReadListener(ReadListener arg0) {
- }
- };
- }
-
- };
-
- Response result = vtpResource.runTest("csar-validate", (HttpServletRequest) mockReq.getMockInstance());
- assertEquals(500, result.getStatus());
- }
-
- @Test
- public void testVtpRunTestsFailure2() throws Exception {
- new MockUp<OpenRemoteCli>() {
-
- @Mock
- public Result run(String[] args) throws Exception {
- throw new Exception();
- }
- };
-
- MockUp mockReq = new MockUp<HttpServletRequest>() {
-
- @Mock
- public ServletInputStream getInputStream() throws IOException {
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- "{\"csar\"=\"VoLTE.csar\"}".getBytes());
-
- return new ServletInputStream(){
- public int read() throws IOException {
- return byteArrayInputStream.read();
- }
-
- @Override
- public boolean isFinished() {
- return true;
- }
-
- @Override
- public boolean isReady() {
- return true;
- }
-
- @Override
- public void setReadListener(ReadListener arg0) {
- }
- };
- }
-
- };
-
- Response result = vtpResource.runTest("csar-validate", (HttpServletRequest) mockReq.getMockInstance());
- assertEquals(500, result.getStatus());
- }
-}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1-registry.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1-registry.yaml
new file mode 100644
index 00000000..915938ab
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1-registry.yaml
@@ -0,0 +1,31 @@
+# Copyright 2018 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+
+product:
+ name: VTP Scenario 1
+
+ version: 1.0
+
+ description: |
+ Test scenario 1
+
+contact: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+services:
+ - name: testsuite-1
+ description: testsuite 1
+ - name: testsuite-2
+ description: testsuite 2
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-1.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-1.yaml
new file mode 100644
index 00000000..cf3f0a62
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-1.yaml
@@ -0,0 +1,52 @@
+# Copyright 2019 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+name: s1.ts1.testcase-1
+description: s1.ts1.testcase-1
+
+info:
+ product: scenario-1
+ service: testsuite-1
+ type: cmd
+ author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+parameters:
+ - name: input1
+ type: string
+ description: Input 1
+ short_option: x
+ long_option: input1
+ is_optional: false
+ metadata:
+ allowed_value:
+ - a
+ - b
+ - c
+ - name: input2
+ type: string
+ description: Input 2
+ short_option: y
+ long_option: input2
+ is_optional: true
+ default_value: v2
+
+results:
+ direction: portrait
+ attributes:
+ - name: output1
+ description: output 1
+ scope: short
+ type: string
+ default_value: ${input1}-${input2} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-2.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-2.yaml
new file mode 100644
index 00000000..81e63808
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-2.yaml
@@ -0,0 +1,52 @@
+# Copyright 2019 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+name: s1.ts1.testcase-2
+description: s1.ts1.testcase-2
+
+info:
+ product: scenario-1
+ service: testsuite-1
+ type: cmd
+ author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+parameters:
+ - name: input1
+ type: string
+ description: Input 1
+ short_option: x
+ long_option: input1
+ is_optional: false
+ - name: input2
+ type: string
+ description: Input 2
+ short_option: y
+ long_option: input2
+ is_optional: true
+ default_value: v2
+
+results:
+ direction: landscape
+ attributes:
+ - name: output1
+ description: output 1
+ scope: short
+ type: string
+ default_value: ${input1}
+ - name: output2
+ description: output 2
+ scope: short
+ type: string
+ default_value: ${input2} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-3.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-3.yaml
new file mode 100644
index 00000000..354409bf
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-1/s1.ts1.testcase-3.yaml
@@ -0,0 +1,31 @@
+# Copyright 2019 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+name: s1.ts1.testcase-3
+description: s1.ts1.testcase-3
+
+info:
+ product: scenario-1
+ service: testsuite-1
+ type: cmd
+ author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+parameters:
+ - name: input1
+ type: string
+ description: Input 1
+ short_option: x
+ long_option: input1
+ is_optional: false
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-2/s1.ts2.testcase-1.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-2/s1.ts2.testcase-1.yaml
new file mode 100644
index 00000000..ebdeab83
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-2/s1.ts2.testcase-1.yaml
@@ -0,0 +1,52 @@
+# Copyright 2019 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+name: s1.ts2.testcase-1
+description: s1.ts2.testcase-1
+
+info:
+ product: scenario-1
+ service: testsuite-2
+ type: cmd
+ author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+parameters:
+ - name: input1
+ type: string
+ description: Input 1
+ short_option: x
+ long_option: input1
+ is_optional: false
+ metadata:
+ allowed_value:
+ - a
+ - b
+ - c
+ - name: input2
+ type: string
+ description: Input 2
+ short_option: y
+ long_option: input2
+ is_optional: true
+ default_value: v2
+
+results:
+ direction: portrait
+ attributes:
+ - name: output1
+ description: output 1
+ scope: short
+ type: string
+ default_value: ${input1}=${input2} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-2/s1.ts2.testcase-2.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-2/s1.ts2.testcase-2.yaml
new file mode 100644
index 00000000..b30e565a
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-1/testsuite-2/s1.ts2.testcase-2.yaml
@@ -0,0 +1,52 @@
+# Copyright 2019 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+name: s1.ts2.testcase-2
+description: s1.ts2.testcase-2
+
+info:
+ product: scenario-1
+ service: testsuite-2
+ type: cmd
+ author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+parameters:
+ - name: input1
+ type: string
+ description: Input 1
+ short_option: x
+ long_option: input1
+ is_optional: false
+ - name: input2
+ type: string
+ description: Input 2
+ short_option: y
+ long_option: input2
+ is_optional: true
+ default_value: v2
+
+results:
+ direction: landscape
+ attributes:
+ - name: output1
+ description: output 1
+ scope: short
+ type: string
+ default_value: ${input1}
+ - name: output2
+ description: output 2
+ scope: short
+ type: string
+ default_value: ${input2} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2-registry.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2-registry.yaml
new file mode 100644
index 00000000..b224c041
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2-registry.yaml
@@ -0,0 +1,33 @@
+# Copyright 2018 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+
+product:
+ name: VTP Scenario 2
+
+ version: 1.0
+
+ description: |
+ Test scenario 1
+
+contact: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+services:
+ - name: testsuite-1
+ description: testsuite 1
+ - name: testsuite-2
+ description: testsuite 2
+ - name: testsuite-3
+ description: testsuite 3 \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/scenario-1-registry.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/scenario-1-registry.yaml
new file mode 100644
index 00000000..915938ab
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/scenario-1-registry.yaml
@@ -0,0 +1,31 @@
+# Copyright 2018 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+
+product:
+ name: VTP Scenario 1
+
+ version: 1.0
+
+ description: |
+ Test scenario 1
+
+contact: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+services:
+ - name: testsuite-1
+ description: testsuite 1
+ - name: testsuite-2
+ description: testsuite 2
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-1/s2.ts1.testcase-1.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-1/s2.ts1.testcase-1.yaml
new file mode 100644
index 00000000..8cf4d29b
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-1/s2.ts1.testcase-1.yaml
@@ -0,0 +1,52 @@
+# Copyright 2019 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+name: s2.ts1.testcase-1
+description: s2.ts1.testcase-1
+
+info:
+ product: scenario-2
+ service: testsuite-1
+ type: cmd
+ author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+parameters:
+ - name: input1
+ type: string
+ description: Input 1
+ short_option: x
+ long_option: input1
+ is_optional: false
+ metadata:
+ allowed_value:
+ - a
+ - b
+ - c
+ - name: input2
+ type: string
+ description: Input 2
+ short_option: y
+ long_option: input2
+ is_optional: true
+ default_value: v2
+
+results:
+ direction: portrait
+ attributes:
+ - name: output1
+ description: output 1
+ scope: short
+ type: string
+ default_value: ${input1}-${input2} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-2/s2.ts2.testcase-1.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-2/s2.ts2.testcase-1.yaml
new file mode 100644
index 00000000..ab3d62b1
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-2/s2.ts2.testcase-1.yaml
@@ -0,0 +1,52 @@
+# Copyright 2019 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+name: s2.ts2.testcase-1
+description: s2.ts2.testcase-1
+
+info:
+ product: scenario-2
+ service: testsuite-2
+ type: cmd
+ author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+parameters:
+ - name: input1
+ type: string
+ description: Input 1
+ short_option: x
+ long_option: input1
+ is_optional: false
+ - name: input2
+ type: string
+ description: Input 2
+ short_option: y
+ long_option: input2
+ is_optional: true
+ default_value: v2
+
+results:
+ direction: landscape
+ attributes:
+ - name: output1
+ description: output 1
+ scope: short
+ type: string
+ default_value: ${input1}
+ - name: output2
+ description: output 2
+ scope: short
+ type: string
+ default_value: ${input2} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-3/s2.ts3.testcase-1.yaml b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-3/s2.ts3.testcase-1.yaml
new file mode 100644
index 00000000..e612dca9
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/resources/sample-vtp-scenarios/open-cli-schema/scenario-2/testsuite-3/s2.ts3.testcase-1.yaml
@@ -0,0 +1,31 @@
+# Copyright 2019 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+name: s2.ts3.testcase-1
+description: s2.ts3.testcase-1
+
+info:
+ product: scenario-2
+ service: testsuite-3
+ type: cmd
+ author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
+
+parameters:
+ - name: input1
+ type: string
+ description: Input 1
+ short_option: x
+ long_option: input1
+ is_optional: false