def test_command_stop_tap(self): """Test stop tap command""" args = CliArgs(target='target_one', tap='tap_one') pipelinewise = PipelineWise(args, CONFIG_DIR, VIRTUALENVS_DIR) # Tap is not running, pid file not exist, should exit with error with pytest.raises(SystemExit) as pytest_wrapped_e: pipelinewise.stop_tap() assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 1 # Stop tap command should stop all the child processes # 1. Start the pipelinewise mock executable that's running # linux piped dummy tap and target connectors with pidfile.PIDFile(pipelinewise.tap['files']['pidfile']): os.spawnl(os.P_NOWAIT, f'{RESOURCES_DIR}/test_stop_tap/scheduler-mock.sh', 'test_stop_tap/scheduler-mock.sh') # Wait 5 seconds making sure the dummy tap is running time.sleep(5) # Send the stop_tap command with pytest.raises(SystemExit): pipelinewise.stop_tap() # Should not have any remaining Pipelinewise related linux process for proc in psutil.process_iter(['cmdline']): full_command = ' '.join(proc.info['cmdline']) assert re.match('scheduler|pipelinewise|tap|target', full_command) is None
def test_command_stop_tap(self): """Test stop tap command""" args = CliArgs(target='target_one', tap='tap_one') pipelinewise = PipelineWise(args, CONFIG_DIR, VIRTUALENVS_DIR) # Tap is not running, pid file not exist, should exit with error with pytest.raises(SystemExit) as pytest_wrapped_e: pipelinewise.stop_tap() assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 1