aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/mass-pnf-sim/pnf-sim-lightweight
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocks/mass-pnf-sim/pnf-sim-lightweight')
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.yml10
-rwxr-xr-xtest/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh14
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/ConfigurationProvider.java13
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/PnfSimConfig.java52
-rw-r--r--test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java18
5 files changed, 64 insertions, 43 deletions
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.yml b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.yml
index 206d918a6..06c832099 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.yml
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.yml
@@ -1,7 +1,9 @@
---
-vesip: http://localhost:10000
-ipftps: 10.11.0.67
-ipsftp: 10.11.0.68
+urlves: http://localhost:10000/eventListener/v7
+urlftps: ftps://onap:pano@10.11.0.67
+urlsftp: sftp://onap:pano@10.11.0.68
#when run in simulator, it does not have own IP
-ippnfsim: localhost
+ippnfsim: localhost
+defaultfileserver: sftp
+#defaultfileserver: ftps
...
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
index 86f15a8e2..4c5d9f062 100755
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
@@ -27,6 +27,11 @@ function main(){
"start")
start $COMPOSE_FILE_NAME;;
"stop")
+ if [[ -z ${2+x} ]]
+ then
+ echo "Error: action 'stop' requires the instance identifier"
+ exit
+ fi
stop $2;;
"run-simulator")
run_simulator;;
@@ -101,10 +106,11 @@ function set_vsftpd_file_owner() {
function write_config(){
#building a YML file for usage in Java
- echo "vesip: $1" > config/config.yml
- echo "ipsftp: $2:$3" >> config/config.yml
- echo "ipftps: $2:$4" >> config/config.yml
+ echo "urlves: $1" > config/config.yml
+ echo "urlsftp: sftp://onap:pano@$2:$3" >> config/config.yml
+ echo "urlftps: ftps://onap:pano@$2:$4" >> config/config.yml
echo "ippnfsim: $5" >> config/config.yml
+ echo "defaultfileserver: sftp" >> config/config.yml
}
function start(){
@@ -127,7 +133,7 @@ function running_containers(){
function stop(){
get_pnfsim_ip
- kill $(ps -a | grep "[.]/ROP_file_creator.sh $1" | awk '{print $1}')
+ kill $(ps -ef | grep "[.]/ROP_file_creator.sh $1" | head -n 1 | awk '{print $2}')
if [[ $(running_containers) ]]; then
docker-compose -f $RUNNING_COMPOSE_CONFIG down
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/ConfigurationProvider.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/ConfigurationProvider.java
index 4b293e897..15c687e2c 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/ConfigurationProvider.java
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/ConfigurationProvider.java
@@ -7,11 +7,6 @@ import java.io.File;
public class ConfigurationProvider {
static PnfSimConfig conf = null;
- String IpVes = null;
- String IpSftp = null;
- String IpFtps = null;
- String IpPnfsim = null;
-
public static PnfSimConfig getConfigInstance() {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
@@ -19,10 +14,10 @@ public class ConfigurationProvider {
File file = new File("./config/config.yml");
conf = mapper.readValue(file, PnfSimConfig.class);
- System.out.println("Ves IP: " + conf.getVesip());
- System.out.println("SFTP IP: " + conf.getIpsftp());
- System.out.println("FTPS IP: " + conf.getIpftps());
- System.out.println("FTPS IP: " + conf.getIppnfsim());
+ System.out.println("Ves URL: " + conf.getUrlves());
+ System.out.println("SFTP URL: " + conf.getUrlsftp());
+ System.out.println("FTPS URL: " + conf.getUrlftps());
+ System.out.println("PNF sim IP: " + conf.getIppnfsim());
} catch (Exception e) {
e.printStackTrace();
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/PnfSimConfig.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/PnfSimConfig.java
index 4931b5759..89f59a391 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/PnfSimConfig.java
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/PnfSimConfig.java
@@ -1,49 +1,59 @@
package org.onap.pnfsimulator;
public class PnfSimConfig {
- private String vesip;
- private String ipftps;
- private String ipsftp;
+ private String urlves;
+ private String urlftps;
+ private String urlsftp;
private String ippnfsim;
+ private String defaultfileserver;
- public String getVesip() {
- return vesip;
+ public String getDefaultfileserver() {
+ return defaultfileserver;
}
- public void setVesip(String vesip) {
- this.vesip = vesip;
+ public void setDefaultfileserver(String defaultfileserver) {
+ this.defaultfileserver = defaultfileserver;
}
- public String getIpftps() {
- return ipftps;
+
+ public String getUrlves() {
+ return urlves;
}
- public void setIpftps(String ipftps) {
- this.ipftps = ipftps;
+ public void setUrlves(String urlves) {
+ this.urlves = urlves;
}
- public String getIpsftp() {
- return ipsftp;
+ public String getUrlftps() {
+ return urlftps;
}
- public void setIpsftp(String ipsftp) {
- this.ipsftp = ipsftp;
+ public void setUrlftps(String urlftps) {
+ this.urlftps = urlftps;
}
- public void setIppnfsim(String ippnfsim) {
- this.ippnfsim = ippnfsim;
+ public String getUrlsftp() {
+ return urlsftp;
}
- @Override
- public String toString() {
- return "PnfSimConfig [vesip=" + vesip + ", ipftps=" + ipftps + ", ippnfsim=" + ippnfsim + ", ipsftp=" + ipsftp
- + "]";
+ public void setUrlsftp(String urlsftp) {
+ this.urlsftp = urlsftp;
+ }
+
+ public void setIppnfsim(String ippnfsim) {
+ this.ippnfsim = ippnfsim;
}
public String getIppnfsim() {
return ippnfsim;
}
+ @Override
+ public String toString() {
+ return "PnfSimConfig [vesip=" + urlves + ", urlftps=" + urlftps + ", ippnfsim=" + ippnfsim + ", urlsftp="
+ + urlsftp + "]";
+ }
+
}
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
index cb58e3c7a..54af2b9a0 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
@@ -53,18 +53,26 @@ public class SimulatorFactory {
Optional<JSONObject> pnfRegistrationParams, Optional<JSONObject> notificationParams)
throws ProcessingException, IOException, ValidationException {
PnfSimConfig configuration = ConfigurationProvider.getConfigInstance();
- String xnfUrl = "sftp://onap:pano@" + configuration.getIpsftp() + "/";
- String vesUrl = configuration.getVesip() + "/eventListener/v7";
+
+ String xnfUrl = null;
+
+ if (configuration.getDefaultfileserver().equals("sftp")) {
+ xnfUrl = configuration.getUrlsftp() + "/";
+ } else if (configuration.getDefaultfileserver().equals("ftps")) {
+ xnfUrl = configuration.getUrlftps() + "/";
+ }
+
+ String urlVes = configuration.getUrlves();
Duration duration = Duration.ofSeconds(parseInt(simulatorParams.getString(TEST_DURATION)));
Duration interval = Duration.ofSeconds(parseInt(simulatorParams.getString(MESSAGE_INTERVAL)));
List<String> fileList = FileProvider.getFiles();
- JSONObject messageBody = messageProvider
- .createMessage(commonEventHeaderParams, pnfRegistrationParams, notificationParams, fileList, xnfUrl);
+ JSONObject messageBody = messageProvider.createMessage(commonEventHeaderParams, pnfRegistrationParams,
+ notificationParams, fileList, xnfUrl);
validator.validate(messageBody.toString(), DEFAULT_OUTPUT_SCHEMA_PATH);
- return Simulator.builder().withVesUrl(vesUrl).withDuration(duration).withInterval(interval)
+ return Simulator.builder().withVesUrl(urlVes).withDuration(duration).withInterval(interval)
.withMessageBody(messageBody).build();
}