diff options
author | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2020-06-08 14:39:01 +0200 |
---|---|---|
committer | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2020-06-10 06:39:05 +0000 |
commit | 09b5a6f268238c554493d7a9e21b5f676b848b64 (patch) | |
tree | 3e2b5df829037ad7afca5e0915b4e93b2b057f03 /test/mocks | |
parent | 81287bce75c81fdcbcf5f7c16a6454960e200d38 (diff) |
Setup and start docker-compose simulator app directly in Python module
Change-Id: I5efaaa69a0c78d9ae9594d1e59d57dd9315613af
Issue-ID: INT-1617
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks')
-rwxr-xr-x | test/mocks/mass-pnf-sim/MassPnfSim.py | 13 | ||||
-rw-r--r-- | test/mocks/mass-pnf-sim/test_lifecycle.py | 15 |
2 files changed, 18 insertions, 10 deletions
diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py index 023c4cbf4..c8d255fd5 100755 --- a/test/mocks/mass-pnf-sim/MassPnfSim.py +++ b/test/mocks/mass-pnf-sim/MassPnfSim.py @@ -296,9 +296,18 @@ class MassPnfSim: for sim_id in range(self.existing_sim_instances): rmtree(f"{self.sim_dirname_pattern}{sim_id}") - @_MassPnfSim_Decorators.do_action('Starting', './simulator.sh start') def start(self): - pass + for i in range(*self._get_iter_range()): + # 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:') + self.logger.info(f' PNF-Sim IP: {self._get_sim_instance_data(i)}') + #Move logs to archive + self._archive_logs(self.sim_dirname_pattern + str(i)) + self.logger.info(' Starting simulator containers using netconf model specified in config/netconf.env') + self._run_cmd('docker-compose up -d', self.sim_dirname_pattern + str(i)) + else: + self.logger.warning(f'Instance {self.sim_dirname_pattern}{i} containers are already up') def status(self): for i in range(*self._get_iter_range()): diff --git a/test/mocks/mass-pnf-sim/test_lifecycle.py b/test/mocks/mass-pnf-sim/test_lifecycle.py index 9bfb3dc7a..dcd89c440 100644 --- a/test/mocks/mass-pnf-sim/test_lifecycle.py +++ b/test/mocks/mass-pnf-sim/test_lifecycle.py @@ -71,15 +71,14 @@ def test_bootstrap_status(args_status, caplog): assert 'Simulator response' not in caplog.text caplog.clear() -def test_start(args_start, caplog, capfd): +def test_start(args_start, caplog): MassPnfSim(args_start).start() - msg = capfd.readouterr() for instance in range(SIM_INSTANCES): instance_ip_offset = instance * 16 ip_offset = 2 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 msg.out - assert 'Starting simulator containers' in msg.out + assert f'PNF-Sim IP: {str(ip_address(IPSTART) + ip_offset + instance_ip_offset)}' in caplog.text + assert 'Starting simulator containers' in caplog.text caplog.clear() def test_start_status(args_status, docker_containers, caplog): @@ -91,12 +90,12 @@ def test_start_status(args_status, docker_containers, caplog): assert f"{PNF_SIM_CONTAINER_NAME}{instance}" in docker_containers caplog.clear() -def test_start_idempotence(args_start, capfd): +def test_start_idempotence(args_start, caplog): '''Verify start idempotence''' MassPnfSim(args_start).start() - msg = capfd.readouterr() - assert 'Simulator containers are already up' in msg.out - assert 'Starting simulator containers' not in msg.out + assert 'containers are already up' in caplog.text + assert 'Starting simulator containers' not in caplog.text + caplog.clear() def test_trigger(args_trigger, caplog): MassPnfSim(args_trigger).trigger() |