aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-06-18 12:42:58 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-06-18 12:42:58 +0200
commit10ed88c266c0305d0b79c013a80b9dde38b0a7d7 (patch)
treec850d76841bd5f5cc2a58b478ee9ec34dbb2080d
parentd35d3b8c0ca5784e0ffd7cebad0fa68631f767ab (diff)
Start/stop the 3GPP measurements file generator at simulator start/stop
Change-Id: I6976168afc7cad2a44333e33632775dbb63aec12 Issue-ID: INT-1630 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
-rwxr-xr-xtest/mocks/mass-pnf-sim/MassPnfSim.py18
-rw-r--r--test/mocks/mass-pnf-sim/test_lifecycle.py9
2 files changed, 21 insertions, 6 deletions
diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py
index dd6509430..395477cee 100755
--- a/test/mocks/mass-pnf-sim/MassPnfSim.py
+++ b/test/mocks/mass-pnf-sim/MassPnfSim.py
@@ -300,8 +300,6 @@ class MassPnfSim:
self._generate_config_file(self.sim_sftp_script_template, self.sim_sftp_script,
I = i, FILESERV_USER = self.args.user)
chmod(f'{self.sim_dirname_pattern}{i}/{self.sim_sftp_script}', 0o755)
- # Run the 3GPP measurements file generator
- self._run_cmd(f'./ROP_file_creator.sh {i} &', f"{self.sim_dirname_pattern}{i}")
ftps_pasv_port_start += ftps_pasv_port_num_of_ports + 1
ftps_pasv_port_end += ftps_pasv_port_num_of_ports + 1
@@ -332,6 +330,22 @@ class MassPnfSim:
@_MassPnfSim_Decorators.validate_subcommand
def start(self, args): # pylint: disable=W0613
for i in range(*self._get_iter_range()):
+ # Start measurements file generator if not running
+ rop_running = False
+ for ps_line in iter(popen(f'ps --no-headers -C {self.rop_script_name} -o pid,cmd').readline, ''):
+ # try getting ROP script pid
+ try:
+ ps_line_arr = ps_line.split()
+ assert self.rop_script_name in ps_line_arr[2]
+ assert ps_line_arr[3] == str(i)
+ except AssertionError:
+ pass
+ else:
+ self.logger.warning(f'3GPP measurements file generator for instance {i} is already running')
+ rop_running = True
+ if not rop_running:
+ self._run_cmd(f'./ROP_file_creator.sh {i} &', f"{self.sim_dirname_pattern}{i}")
+ self.logger.info(f'ROP_file_creator.sh {i} successfully started')
# If container is not running
if f"{self.sim_container_name}-{i}" not in self._get_docker_containers():
self.logger.info(f'Starting {self.sim_dirname_pattern}{i} instance:')
diff --git a/test/mocks/mass-pnf-sim/test_lifecycle.py b/test/mocks/mass-pnf-sim/test_lifecycle.py
index 0452c3298..1309ef077 100644
--- a/test/mocks/mass-pnf-sim/test_lifecycle.py
+++ b/test/mocks/mass-pnf-sim/test_lifecycle.py
@@ -41,10 +41,6 @@ def test_bootstrap(args_bootstrap, caplog):
sim_dirname_pattern = MassPnfSim().sim_dirname_pattern
assert len(glob(f"{sim_dirname_pattern}*")) == SIM_INSTANCES
- # Verify ROP_file_creator.sh running
- for instance in range(SIM_INSTANCES):
- assert f"ROP_file_creator.sh {instance}" in popen('ps afx').read()
-
# Verify simulators configs content is valid
start_port = 2000
for instance in range(SIM_INSTANCES):
@@ -79,6 +75,10 @@ def test_start(args_start, caplog):
assert f'Starting pnf-sim-lw-{instance} instance:' in caplog.text
assert f'PNF-Sim IP: {str(ip_address(IPSTART) + ip_offset + instance_ip_offset)}' in caplog.text
assert 'Starting simulator containers' in caplog.text
+ assert f"ROP_file_creator.sh {instance} successfully started" in caplog.text
+ assert f"3GPP measurements file generator for instance {instance} is already running" not in caplog.text
+ # Verify ROP_file_creator.sh running
+ assert f"ROP_file_creator.sh {instance}" in popen('ps afx').read()
caplog.clear()
def test_start_status(args_status, docker_containers, caplog):
@@ -95,6 +95,7 @@ def test_start_idempotence(args_start, caplog):
MassPnfSim().start(args_start)
assert 'containers are already up' in caplog.text
assert 'Starting simulator containers' not in caplog.text
+ assert f"is already running" in caplog.text
caplog.clear()
def test_trigger(args_trigger, caplog):