diff options
Diffstat (limited to 'test')
9 files changed, 128 insertions, 63 deletions
diff --git a/test/mocks/mass-pnf-sim/README.md b/test/mocks/mass-pnf-sim/README.md index ffa82c118..507a6920e 100644 --- a/test/mocks/mass-pnf-sim/README.md +++ b/test/mocks/mass-pnf-sim/README.md @@ -15,7 +15,10 @@ The ipstart should align to a /28 Ip address range start (e.g. 10.11.0.16, 10.11 For debug purposes, you can use your own IP address as VES collector, use "ip" command to determine it. Example: -./mass-pnf-sim.py --bootstrap 2 --ipves http://10.148.95.??:10000 --ipfileserver 10.148.95.??? --ipstart 10.11.0.16 +./mass-pnf-sim.py --bootstrap 2 --urlves http://10.148.95.??:10000/eventListener/v7 --ipfileserver 10.148.95.??? --ipstart 10.11.0.16 + +Note that the file creator is started at a time of the bootstrapping. +Stop/start will not re-launch it. ###Replacing VES for test purposes `sudo nc -vv -l -k -p 10000` @@ -24,7 +27,7 @@ Example: Define the amount of simulators to be launched ./mass-pnf-sim.py --start 2 -###Trigger +###Trigger ./mass-pnf-sim.py --trigger 2 ###Stop and clean diff --git a/test/mocks/mass-pnf-sim/clean.sh b/test/mocks/mass-pnf-sim/clean.sh new file mode 100755 index 000000000..28df0ef78 --- /dev/null +++ b/test/mocks/mass-pnf-sim/clean.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +killall ROP_file_creator.sh + +docker stop $(docker ps -aq); docker rm $(docker ps -aq) + +./mass-pnf-sim.py --clean + diff --git a/test/mocks/mass-pnf-sim/diagnostic.sh b/test/mocks/mass-pnf-sim/diagnostic.sh new file mode 100755 index 000000000..99e35cd0a --- /dev/null +++ b/test/mocks/mass-pnf-sim/diagnostic.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +echo "======= docker ps" +docker ps + +echo "======= Docker image cache" +docker images nexus3.onap.org:10003/onap/masspnf-simulator + +export NUM_OF_SIMS=`find pnf-sim-lw* -maxdepth 0 | wc -l` +echo $NUM_OF_SIMS + +if [ "$NUM_OF_SIMS" -gt 0 ]; +then + echo "======= docker-compose, first instance" + cat pnf-sim-lw-0/docker-compose.yml + + echo "======= Java config.yml, first instance" + cat pnf-sim-lw-0/config/config.yml +fi + +if (("$NUM_OF_SIMS" > 2)); +then + echo "======= docker-compose, last instance" + cat pnf-sim-lw-$(($NUM_OF_SIMS-1))/docker-compose.yml + + echo "======= Java config.yml, last instance" + cat pnf-sim-lw-$(($NUM_OF_SIMS-1))/config/config.yml +fi + + diff --git a/test/mocks/mass-pnf-sim/mass-pnf-sim.py b/test/mocks/mass-pnf-sim/mass-pnf-sim.py index 898cd650f..8a4f390aa 100755 --- a/test/mocks/mass-pnf-sim/mass-pnf-sim.py +++ b/test/mocks/mass-pnf-sim/mass-pnf-sim.py @@ -19,8 +19,8 @@ parser.add_argument( ) parser.add_argument( - '--ipves', - help='IP of the VES collector', + '--urlves', + help='URL of the VES collector', ) parser.add_argument( @@ -56,7 +56,7 @@ parser.add_argument( args = parser.parse_args() -if args.bootstrap and args.ipstart and args.ipves: +if args.bootstrap and args.ipstart and args.urlves: print("Bootstrap:") start_port=2000 @@ -81,11 +81,11 @@ if args.bootstrap and args.ipstart and args.ipves: PortSftp=start_port +1 PortFtps=start_port +2 start_port +=2 - IpFtps = ipaddress.ip_address(args.ipstart) + int(3 + (i * 16)) - print("\tIp Ftps: " + str(IpFtps)) + UrlFtps = str(ipaddress.ip_address(args.ipstart) + int(3 + (i * 16))) + print("\tUrl Ftps: " + str(UrlFtps)) - IpSftp = ipaddress.ip_address(args.ipstart) + int(4 + (i * 16)) - print("\tIp Sftp:" + str(IpSftp)) + UrlSftp = str(ipaddress.ip_address(args.ipstart) + int(4 + (i * 16))) + print("\tUrl Sftp: " + str(UrlSftp)) foldername = "pnf-sim-lw-" + str(i) completed = subprocess.run('mkdir ' + foldername, shell=True) @@ -96,17 +96,17 @@ if args.bootstrap and args.ipstart and args.ipves: shell=True) print('\tCloning folder:', completed.stdout) - composercmd = "./simulator.sh compose " +\ - str(ip_gw) + " " +\ - str(ip_subnet) + " " +\ - str(i) + " " +\ - str(args.ipves) + " " +\ - str(IpPnfSim) + " " +\ - str(IpFileServer) + " " +\ - str(PortSftp) + " " +\ - str(PortFtps) + " " +\ - str(IpFtps) + " " +\ - str(IpSftp) + composercmd = "./simulator.sh compose " + \ + str(ip_gw) + " " + \ + str(ip_subnet) + " " + \ + str(i) + " " + \ + str(args.urlves) + " " + \ + str(IpPnfSim) + " " + \ + str(IpFileServer) + " " + \ + str(PortSftp) + " " + \ + str(PortFtps) + " " + \ + str(UrlFtps) + " " + \ + str(UrlSftp) completed = subprocess.run( 'set -x; cd ' + @@ -116,6 +116,9 @@ if args.bootstrap and args.ipstart and args.ipves: shell=True) print('Cloning:', completed.stdout) + completed = subprocess.run('set -x; cd pnf-sim-lightweight; ./simulator.sh build ', shell=True) + print("Build docker image: ", completed.stdout) + sys.exit() if args.clean: 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(); } |