Add functional tests for 'stop' subcommand
Change-Id: Id3640c494f21fb4869fcf412dc83824dc8670d12
Issue-ID: INT-1577
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
diff --git a/test/mocks/mass-pnf-sim/test_lifecycle.py b/test/mocks/mass-pnf-sim/test_lifecycle.py
index 1ae696c..9c5ff89 100644
--- a/test/mocks/mass-pnf-sim/test_lifecycle.py
+++ b/test/mocks/mass-pnf-sim/test_lifecycle.py
@@ -88,6 +88,7 @@
assert f'Triggering 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 'Simulator started' in msg.out
+ caplog.clear()
def test_trigger_idempotence(args_trigger, capfd):
MassPnfSim(args_trigger).trigger()
@@ -105,3 +106,23 @@
assert f'PNF-Sim IP: {str(ip_address(IPSTART) + ip_offset + instance_ip_offset)}' in msg.out
assert 'Simulator started' not in msg.out
assert "Cannot start simulator since it's already running" in msg.out
+ caplog.clear()
+
+def test_stop(args_stop, caplog, capfd):
+ MassPnfSim(args_stop).stop()
+ msg = capfd.readouterr()
+ for instance in range(SIM_INSTANCES):
+ instance_ip_offset = instance * 16
+ ip_offset = 2
+ assert f'Stopping 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 f"ROP_file_creator.sh {instance}" not in popen('ps afx').read()
+ caplog.clear()
+
+def test_stop_idempotence(args_stop, caplog, capfd):
+ MassPnfSim(args_stop).stop()
+ msg = capfd.readouterr()
+ for instance in range(SIM_INSTANCES):
+ assert f'Stopping pnf-sim-lw-{instance} instance:' in caplog.text
+ assert 'ROP_file_creator.sh already not running' in msg.out
+ assert 'Simulator containers are already down' in msg.out