aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/main/java')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPResource.java111
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java22
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/DistManager.java303
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/Manager.java37
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/model/Tester.java56
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java2
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/scenario/VTPScenarioResource.java44
7 files changed, 541 insertions, 34 deletions
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
index 9e1a9c80..a756cb02 100644
--- 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
@@ -18,16 +18,14 @@ 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 java.util.*;
+import com.google.gson.*;
import org.apache.http.HttpStatus;
import org.onap.vtp.error.VTPError;
import org.onap.vtp.error.VTPError.VTPException;
+import org.onap.vtp.manager.DistManager;
+import org.onap.vtp.manager.model.Tester;
import org.open.infc.grpc.Output;
import org.open.infc.grpc.Result;
import org.open.infc.grpc.client.OpenInterfaceGrpcClient;
@@ -35,13 +33,15 @@ import org.open.infc.grpc.client.OpenRemoteCli;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+
public class VTPResource {
protected static final Logger LOG = LoggerFactory.getLogger(VTPResource.class);
@@ -54,9 +54,10 @@ public class VTPResource {
protected static int VTP_EXECUTION_GRPC_TIMEOUT; // NOSONAR
protected static String VTP_YAML_STORE; // NOSONAR
protected static String VTP_SCRIPT_STORE; // NOSONAR
-
+ public static boolean mode=false;
protected static final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); // NOSONAR
-
+ DistManager distManager = null;
+ Tester tester = null;
static {
dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
@@ -70,6 +71,8 @@ public class VTPResource {
VTP_EXECUTION_GRPC_TIMEOUT = Integer.parseInt(prp.getProperty("vtp.grpc.timeout")) * 1000 ;
VTP_YAML_STORE = prp.getProperty("vtp.yaml.store");
VTP_SCRIPT_STORE = prp.getProperty("vtp.script.store");
+ if (prp.getProperty("vtp.execution.mode").equals("dist"))
+ mode=true;
} catch (Exception e) { // NOSONAR
LOG.error(e.getMessage());
}
@@ -80,6 +83,24 @@ public class VTPResource {
}
protected Result makeRpc(List <String> args, int timeout) throws VTPException {
+ String executionId=args.get(4);
+ if(isDistMode() && (executionId.contains("-") || args.contains("schema-show"))) {
+ distManager =new DistManager();
+
+ if (executionId.contains("-")){
+ tester = distManager.httpRequestExecutions(executionId);
+ }
+ else {
+ String scenario=args.get(4);
+ String testSuiteName=args.get(6);
+ String testCaseName=args.get(8);
+ tester = distManager.httpRequestTestcase(testSuiteName,scenario,testCaseName);
+ }
+
+ VTP_TEST_CENTER_IP = tester.getIp();
+ VTP_TEST_CENTER_PORT = tester.getPort();
+
+ }
Result result = null;
String requestId = UUID.randomUUID().toString();
try {
@@ -119,11 +140,17 @@ public class VTPResource {
return jsonParser.parse(result.getOutput());
}
- protected Output makeRpc(String scenario, String requestId, String profile, String testCase, JsonElement argsJsonNode) throws VTPException {
- return this.makeRpc(scenario, requestId, profile, testCase, argsJsonNode, VTP_EXECUTION_GRPC_TIMEOUT);
+ protected Output makeRpc(String testSuite,String scenario, String requestId, String profile, String testCase, JsonElement argsJsonNode) throws VTPException {
+ return this.makeRpc(testSuite,scenario, requestId, profile, testCase, argsJsonNode, VTP_EXECUTION_GRPC_TIMEOUT);
}
- protected Output makeRpc(String scenario, String requestId, String profile, String testCase, JsonElement argsJsonNode, int timeout) throws VTPException {
+ protected Output makeRpc(String testSuite,String scenario, String requestId, String profile, String testCase, JsonElement argsJsonNode, int timeout) throws VTPException {
+ if (isDistMode()){
+ distManager =new DistManager();
+ tester = distManager.httpRequestTestcase(testSuite,scenario,testCase);
+ VTP_TEST_CENTER_IP =tester.getIp();
+ VTP_TEST_CENTER_PORT = tester.getPort();
+ }
Output output = null;
Map <String, String> args = gson.fromJson(argsJsonNode, new TypeToken<Map<String,String>>(){}.getType());
try {
@@ -141,7 +168,12 @@ public class VTPResource {
throw new VTPException(
new VTPError().setMessage(e.getMessage()));
}
-
+ if (isDistMode())
+ {
+ String executionId= output.getAddonsMap().get("execution-id");
+ assert distManager != null;
+ distManager.postDataToManager(executionId,tester.getId(),tester.getTesterId());
+ }
return output;
}
@@ -156,4 +188,53 @@ public class VTPResource {
dumperOptions.setPrettyFlow(false);
return new Yaml(dumperOptions);
}
+ public boolean isDistMode() {
+ return mode;
+ }
+ protected JsonElement makeRpcAndGetJson(List<String> args,int count,int index) throws VTPException, IOException {
+ return this.makeRpcAndGetJson(args,count,index, VTP_EXECUTION_GRPC_TIMEOUT);
+ }
+
+ protected JsonElement makeRpcAndGetJson(List<String> args,int count,int index, int timeout) throws VTPException {
+ List<String> result = this.makeRpc(args,count,index, timeout);
+ JsonArray jsonArray = new JsonArray();
+ for (String jsonString : result) {
+ JsonElement obj = new JsonParser().parse(jsonString);
+ jsonArray.add(obj);
+ }
+ return jsonArray;
+ }
+
+ protected List<String> makeRpc(List<String> args, int count, int index, int timeout) {
+ distManager = new DistManager();
+ JsonElement jsonElement = distManager.getExecutionJson(count, index);
+ List<String> resultList = new ArrayList<>();
+ if (jsonElement != null && jsonElement.isJsonArray() && jsonElement.getAsJsonArray().size() > 0) {
+ JsonArray resultsArray = jsonElement.getAsJsonArray();
+ Client client = ClientBuilder.newClient();
+ for (JsonElement jElement : resultsArray) {
+ JsonObject jsonObject = jElement.getAsJsonObject();
+ String testerId = null;
+ String executionId = null;
+ if (jsonObject.has("tester_id"))
+ testerId = jsonObject.get("tester_id").getAsString();
+ if (jsonObject.has("execution_id"))
+ executionId = jsonObject.get("execution_id").getAsString();
+ if (testerId == null || executionId == null)
+ throw new IllegalArgumentException("testerId: " + testerId + " and " + " executionId: " + executionId + " should not be null");
+
+ String testerPath = "/manager/tester/" + testerId;
+ JsonObject jObject = distManager.getResponseFromTester(client, distManager.getManagerURL(), testerPath).getAsJsonObject();
+ String vtpTestCenterIp = jObject.get("iP").getAsString();
+ int vtpTestCenterPort = Integer.parseInt(jObject.get("port").getAsString());
+ args.set(4, executionId);
+ try {
+ resultList.add(distManager.getExecutionDetails(vtpTestCenterIp, vtpTestCenterPort, args, timeout).getOutput());
+ } catch (Exception e) {
+ LOG.error("executionId : " + executionId + " not valid::: " + e.getMessage());
+ }
+ }
+ }
+ return resultList;
+ }
}
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
index 2b06fe8f..313206eb 100644
--- 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
@@ -103,6 +103,7 @@ public class VTPExecutionResource extends VTPResource{
//Run execution
Output output = this.makeRpc(
+ execution.getTestSuiteName(),
execution.getScenario(),
requestId,
execution.getProfile(),
@@ -244,7 +245,9 @@ public class VTPExecutionResource extends VTPResource{
String testCaseName,
String profile, //NOSONAR
String startTime,
- String endTime) throws VTPException, IOException {
+ String endTime,
+ int count,
+ int index) throws VTPException, IOException {
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList(
PRODUCT_ARG, OPEN_CLI, "execution-list", FORMAT, "json"
@@ -279,8 +282,15 @@ public class VTPExecutionResource extends VTPResource{
args.add("--command");
args.add(testCaseName);
}
-
- JsonElement results = this.makeRpcAndGetJson(args);
+ JsonElement results =null;
+ if (isDistMode() && !(count==0 && index==0) ){
+ List<String> argsDistMode = new ArrayList<>(Arrays.asList(
+ PRODUCT_ARG, OPEN_CLI, "execution-show", "--execution-id", null, FORMAT, "json"
+ ));
+ results = this.makeRpcAndGetJson(argsDistMode,count,index);
+ }else{
+ results = this.makeRpcAndGetJson(args);
+ }
VTPTestExecutionList list = new VTPTestExecutionList();
@@ -349,11 +359,13 @@ public class VTPExecutionResource extends VTPResource{
@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
+ @ApiParam("Test execution end time") @QueryParam("endTime") String endTime,
+ @ApiParam(value = "count", required = false) @QueryParam("count") int count,
+ @ApiParam(value = "index", required = false) @QueryParam("index") int index
) throws VTPException, IOException {
return Response.ok(this.listTestExecutionsHandler(
- requestId, scenario, testsuiteName, testcaseName, profileName, startTime, endTime).getExecutions().toString(), MediaType.APPLICATION_JSON).build();
+ requestId, scenario, testsuiteName, testcaseName, profileName, startTime, endTime,count,index).getExecutions().toString(), MediaType.APPLICATION_JSON).build();
}
public VTPTestExecution getTestExecutionHandler(
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/DistManager.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/DistManager.java
new file mode 100644
index 00000000..63118e02
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/DistManager.java
@@ -0,0 +1,303 @@
+/**
+ * Copyright 2021 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.manager;
+
+
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonArray;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.onap.vtp.VTPResource;
+import org.onap.vtp.error.VTPError;
+import org.onap.vtp.manager.model.Tester;
+import org.onap.vtp.scenario.model.VTPTestCase;
+import org.onap.vtp.scenario.model.VTPTestScenario;
+import org.onap.vtp.scenario.model.VTPTestSuite;
+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 javax.ws.rs.NotFoundException;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.UUID;
+
+
+public class DistManager implements Manager {
+ private static final Logger LOG = LoggerFactory.getLogger(DistManager.class);
+ private static Gson gson = new Gson();
+ private Client client = ClientBuilder.newClient();
+
+ public Tester httpRequestTestcase(String testSuite, String scenario, String testCase) {
+ String testcasePath = "manager/testcase";
+ JsonElement jsonElement = getResponseForTestcase(client, getManagerURL(), testcasePath, testSuite, scenario, testCase);
+ return getTester(jsonElement);
+ }
+
+ private Tester getTester(JsonElement jsonElement) {
+ Tester tester = new Tester();
+ JsonObject jsonObject = jsonElement.getAsJsonArray().get(0).getAsJsonObject();
+ String testerId = null;
+ if (jsonObject.has("testerId"))
+ testerId = jsonObject.get("testerId").getAsString();
+ else if (jsonObject.has("tester_id"))
+ testerId = jsonObject.get("tester_id").getAsString();
+ String testcaseId = jsonObject.get("id").getAsString();
+ if (testerId == null || testcaseId == null)
+ throw new IllegalArgumentException("testerId or testcaseId should not be empty or null "
+ + " testerId: " + testerId + ", testcaseId:" + testcaseId);
+
+ String testerPath = "manager/tester/" + testerId;
+ JsonObject responseJson = getResponseFromTester(client, getManagerURL(), testerPath).getAsJsonObject();
+ if (responseJson.has("iP") && responseJson.has("port")) {
+ tester.setIp(responseJson.get("iP").getAsString());
+ tester.setPort(responseJson.get("port").getAsInt());
+ tester.setId(testcaseId);
+ tester.setTesterId(testerId);
+ } else {
+ throw new NotFoundException("Ip or port not exist ");
+ }
+ return tester;
+ }
+
+ public JsonElement getResponseFromTester(Client client, String managerURL, String testerPath) {
+ WebTarget webTarget = client.target(managerURL).path(testerPath);
+ return getJsonResponse(webTarget);
+ }
+
+ private JsonElement getResponseForTestcase(Client client, String uri, String path, String testSuite, String scenario, String testCase) {
+ WebTarget webTarget = client.target(uri).path(path)
+ .queryParam("scenario", scenario)
+ .queryParam("testcase", testCase)
+ .queryParam("testsuite", testSuite);
+
+ return getJsonResponse(webTarget);
+ }
+
+ public JsonElement getJsonResponse(WebTarget webTarget) {
+ Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
+ Response response = invocationBuilder.get();
+ if (response.getStatus() != 200 && response.getStatus() != 201) {
+ throw new NotFoundException("Status code is not 200 or 201");
+ }
+ String jsonResult = response.readEntity(String.class);
+ if (jsonResult.isEmpty())
+ throw new NotFoundException("require values are not exist on manager server");
+ return new JsonParser().parse(jsonResult);
+ }
+
+ public void postDataToManager(String executionId, String id, String testerId) {
+ ExecutionsResult executionsResult = new ExecutionsResult();
+ executionsResult.setExecutionId(executionId);
+ executionsResult.setTesterId(Integer.parseInt(testerId));
+ executionsResult.setTestcaseId(Integer.parseInt(id));
+
+ String executionsUrl = getManagerURL() + "/manager/executions";
+ HttpClient httpClient = HttpClientBuilder.create().build();
+ HttpPost postRequest = new HttpPost(executionsUrl);
+ postRequest.addHeader("content-type", "application/json");
+ StringEntity userEntity = null;
+ try {
+ userEntity = new StringEntity(gson.toJson(executionsResult));
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ postRequest.setEntity(userEntity);
+
+ HttpResponse response = null;
+ try {
+ response = httpClient.execute(postRequest);
+ } catch (IOException e) {
+ LOG.error("error during post execution data in manager ::" + e);
+ }
+
+ assert response != null;
+ if (response.getStatusLine().getStatusCode() == 201 || response.getStatusLine().getStatusCode() == 200)
+ LOG.info("========= data post successfully in manager ==========");
+ else
+ LOG.error("====== data post failed in manager =====");
+ }
+
+ public String getManagerURL() {
+ String managerIP = null;
+ int managerPort = 0;
+ Properties prp = new Properties();
+ try {
+ prp.load(Objects.requireNonNull(VTPResource.class.getClassLoader().getResourceAsStream("vtp.properties")));
+ return prp.getProperty("vtp.manager.url");
+ } catch (Exception e) { // NOSONAR
+ LOG.error(e.getMessage());
+ }
+ return null;
+ }
+
+ public JsonElement getExecutionJson(int count, int index) {
+ String executionsPath = "manager/executions";
+ JsonElement jsonElement = getResponseForExecution(client, getManagerURL(), executionsPath, count, index);
+ return jsonElement;
+ }
+
+ public Result getExecutionDetails(String vtpTestCenterIp, int vtpTestCenterPort, List<String> args, int timeout) throws VTPError.VTPException {
+ String requestId = UUID.randomUUID().toString();
+ Result result = null;
+ try {
+ result = new OpenRemoteCli(
+ vtpTestCenterIp,
+ vtpTestCenterPort,
+ timeout,
+ requestId).run(args);
+ } catch (OpenInterfaceGrpcClient.OpenInterfaceGrpcTimeoutExecption e) {
+ LOG.info("Timed out.", e);
+ throw new VTPError.VTPException(
+ new VTPError().setHttpStatus(HttpStatus.SC_GATEWAY_TIMEOUT).setMessage("Timed out. Please use request-id to track the progress.").setCode(VTPError.TIMEOUT));
+ } catch (Exception e) {
+ LOG.info("Exception occurs.", e);
+ throw new VTPError.VTPException(new VTPError().setMessage(e.getMessage()));
+ }
+
+ if (result.getExitCode() != 0) {
+ throw new VTPError.VTPException(
+ new VTPError().setMessage(result.getOutput()));
+ }
+ return result;
+ }
+
+ private JsonElement getResponseForExecution(Client client, String managerURL, String executionsPath, int count, int index) {
+ WebTarget webTarget = client.target(managerURL).path(executionsPath)
+ .queryParam("count", count)
+ .queryParam("index", index);
+
+ return getJsonResponse(webTarget);
+ }
+
+ public Tester httpRequestExecutions(String executionId) {
+ String testcasePath = "manager/executions";
+ JsonElement jsonElement = getResponseFromTestcase(client, getManagerURL(), testcasePath, executionId);
+ return getTester(jsonElement);
+ }
+
+ private JsonElement getResponseFromTestcase(Client client, String managerURL, String testcasePath, String executionId) {
+ WebTarget webTarget = client.target(managerURL).path(testcasePath).queryParam("execution_id", executionId);
+ return getJsonResponse(webTarget);
+ }
+
+ public VTPTestSuite.VTPTestSuiteList getSuiteListFromManager(String url) {
+ JsonElement results = getJsonResult(url);
+ try {
+ VTPTestSuite.VTPTestSuiteList list = new VTPTestSuite.VTPTestSuiteList();
+ JsonArray resultsArray = results.getAsJsonArray();
+ for (JsonElement jsonElement : resultsArray) {
+ JsonObject n = jsonElement.getAsJsonObject();
+ if (n.entrySet().iterator().hasNext())
+ list.getSuites().add(gson.fromJson(n, VTPTestSuite.class));
+ }
+ return list;
+ } catch (Exception e) {
+ LOG.error("exception occurs during communication with manager for SuiteList :: ", e);
+ }
+ return null;
+ }
+
+ public VTPTestScenario.VTPTestScenarioList getScenarioListFromManager(String url) {
+ JsonElement results = getJsonResult(url);
+ try {
+ VTPTestScenario.VTPTestScenarioList list = new VTPTestScenario.VTPTestScenarioList();
+ JsonArray resultsArray = results.getAsJsonArray();
+ for (JsonElement jsonElement : resultsArray) {
+ JsonObject n = jsonElement.getAsJsonObject();
+ if (n.entrySet().iterator().hasNext())
+ list.getScenarios().add(gson.fromJson(n, VTPTestScenario.class));
+ }
+ return list;
+ } catch (Exception e) {
+ LOG.error("exception occurs during communication with manager for ScenarioList:: ", e);
+ }
+ return null;
+ }
+
+ public VTPTestCase.VTPTestCaseList getTestCaseListFromManager(String url) {
+ JsonElement results = getJsonResult(url);
+ try {
+ VTPTestCase.VTPTestCaseList list = new VTPTestCase.VTPTestCaseList();
+ JsonArray resultsArray = results.getAsJsonArray();
+ for (JsonElement jsonElement : resultsArray) {
+ JsonObject n = jsonElement.getAsJsonObject();
+ if (n.entrySet().iterator().hasNext())
+ list.getTestCases().add(gson.fromJson(n, VTPTestCase.class));
+ }
+ return list;
+ } catch (
+ Exception e) {
+ LOG.error("exception occurs during communication with manager for TestCaseList:: ", e);
+ }
+ return null;
+ }
+
+ private JsonElement getJsonResult(String url) {
+ WebTarget webTarget = client.target(getManagerURL()).path(url);
+ String jsonResult = webTarget.request(MediaType.APPLICATION_JSON).get().readEntity(String.class);
+ return new JsonParser().parse(jsonResult);
+ }
+
+
+ static class ExecutionsResult {
+ private int tester_id;
+ private int testcase_id;
+ private String execution_id;
+
+ public int getTesterId() {
+ return tester_id;
+ }
+
+ public void setTesterId(int tester_id) {
+ this.tester_id = tester_id;
+ }
+
+ public int getTestcaseId() {
+ return testcase_id;
+ }
+
+ public void setTestcaseId(int testcase_id) {
+ this.testcase_id = testcase_id;
+ }
+
+ public String getExecutionId() {
+ return execution_id;
+ }
+
+ public void setExecutionId(String execution_id) {
+ this.execution_id = execution_id;
+ }
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/Manager.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/Manager.java
new file mode 100644
index 00000000..924ed610
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/Manager.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2021 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.manager;
+
+import com.google.gson.JsonElement;
+import org.onap.vtp.error.VTPError;
+import org.onap.vtp.manager.model.Tester;
+import org.onap.vtp.scenario.model.VTPTestCase;
+import org.onap.vtp.scenario.model.VTPTestScenario;
+import org.onap.vtp.scenario.model.VTPTestSuite;
+import org.open.infc.grpc.Result;
+
+import java.util.List;
+
+public interface Manager {
+ Tester httpRequestTestcase(String testSuite, String scenario, String testCase);
+ void postDataToManager(String executionId, String id, String testerId);
+ JsonElement getExecutionJson(int count, int index);
+ Result getExecutionDetails(String vtpTestCenterIp, int vtpTestCenterPort, List<String> args, int timeout) throws VTPError.VTPException;
+ Tester httpRequestExecutions(String executionId);
+ VTPTestSuite.VTPTestSuiteList getSuiteListFromManager(String url);
+ VTPTestScenario.VTPTestScenarioList getScenarioListFromManager(String url);
+ VTPTestCase.VTPTestCaseList getTestCaseListFromManager(String url);
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/model/Tester.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/model/Tester.java
new file mode 100644
index 00000000..23f50e14
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/manager/model/Tester.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2021 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.manager.model;
+
+public class Tester {
+ String ip;
+ int port;
+ String testerId;
+ String id;
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getTesterId() {
+ return testerId;
+ }
+
+ public void setTesterId(String testerId) {
+ this.testerId = testerId;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+} \ No newline at end of file
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java
index cbb01a8d..ca046b5a 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java
@@ -77,7 +77,7 @@ public class VTPProfileResource extends VTPResource {
JsonElement jsonElement = it.next();
JsonObject n = jsonElement.getAsJsonObject();
if (n.has("profile")){
- list.getTestProfiles().add(new VTPTestProfile().setName(n.get("profile").getAsString()));
+ list.getTestProfiles().add(new VTPTestProfile().setName(n.get("profile").getAsString()));
}
}
}
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
index 274cacd9..4ea509aa 100644
--- 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
@@ -52,6 +52,7 @@ import org.onap.vnfsdk.marketplace.common.ToolUtil;
import org.onap.vtp.VTPResource;
import org.onap.vtp.error.VTPError;
import org.onap.vtp.error.VTPError.VTPException;
+import org.onap.vtp.manager.DistManager;
import org.onap.vtp.scenario.model.VTPTestCase;
import org.onap.vtp.scenario.model.VTPTestScenario;
import org.onap.vtp.scenario.model.VTPTestSuite;
@@ -80,6 +81,7 @@ public class VTPScenarioResource extends VTPResource{
private static final String FORMAT="--format";
private static final String IO_EXCEPTION_OCCURS ="IOException occurs";
private static final String SERVICE="service";
+ private DistManager distManager = new DistManager();
public VTPTestScenarioList listTestScenariosHandler() throws VTPException {
List<String> args = new ArrayList<>();
@@ -89,10 +91,16 @@ public class VTPScenarioResource extends VTPResource{
JsonElement results = null;
- try {
- results = this.makeRpcAndGetJson(args);
- } catch (IOException e) {
- LOG.error(IO_EXCEPTION_OCCURS,e);
+ if (isDistMode()) {
+ String endPoint="/manager/scenarios";
+ return distManager.getScenarioListFromManager(endPoint);
+ }
+ else{
+ try {
+ results = this.makeRpcAndGetJson(args);
+ } catch (IOException e) {
+ LOG.error(IO_EXCEPTION_OCCURS, e);
+ }
}
VTPTestScenarioList list = new VTPTestScenarioList();
@@ -137,10 +145,15 @@ public class VTPScenarioResource extends VTPResource{
));
JsonElement results = null;
- try {
- results = this.makeRpcAndGetJson(args);
- } catch (IOException e) {
- LOG.error(IO_EXCEPTION_OCCURS,e);
+ if (isDistMode()) {
+ String url="/manager/scenarios/"+scenario+"/testsuites";
+ return distManager.getSuiteListFromManager(url);
+ }else {
+ try {
+ results = this.makeRpcAndGetJson(args);
+ } catch (IOException e) {
+ LOG.error(IO_EXCEPTION_OCCURS,e);
+ }
}
VTPTestSuiteList list = new VTPTestSuiteList();
@@ -186,10 +199,15 @@ public class VTPScenarioResource extends VTPResource{
}
JsonElement results = null;
- try {
- results = this.makeRpcAndGetJson(args);
- } catch (IOException e) {
- LOG.error(IO_EXCEPTION_OCCURS,e);
+ if (isDistMode()) {
+ String url = "/manager/scenarios/" + scenario + "/testcases";
+ return distManager.getTestCaseListFromManager(url);
+ } else {
+ try {
+ results = this.makeRpcAndGetJson(args);
+ } catch (IOException e) {
+ LOG.error(IO_EXCEPTION_OCCURS, e);
+ }
}
VTPTestCaseList list = new VTPTestCaseList();
@@ -441,4 +459,4 @@ public class VTPScenarioResource extends VTPResource{
});
return Response.ok("Save success", MediaType.APPLICATION_JSON).build();
}
-} \ No newline at end of file
+}