def test_ignore_values(): args = "--ignore execution-details times host-nodes " \ "used-resources requested-resources allocated-resources " \ "all-resources errors ram-history -as " \ "tests/test_logs/valid_logs/gpu_usage.log".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0
def test_show_values(): # analyze args = "tests/test_logs/valid_logs/normal_log.log " \ "tests/test_logs/valid_logs/gpu_usage.log " \ "--show htc-err htc-out -a".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0 # no valid file is given
def test_analyzed_summary(): args = "--mode analyzed-summary " \ "tests/test_logs/valid_logs/aborted_before_submission.log".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0 args = "-m analyzed-summary tests/test_logs/valid_logs".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0
def _all_modes_by_logfiles(logfile, return_value): args = [logfile, "--no-config", "-v"] with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == return_value ht.input = lambda x: 'y' args = ["-a", logfile, "--no-config"] with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == return_value args = ["-s", logfile, "--no-config"] with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == return_value args = ["-as", logfile, "--no-config"] with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == return_value
def test_filter_mode(): args = "tests/test_logs/valid_logs --filter err --extend".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0 args = "--filter err -a tests/test_logs/valid_logs/gpu_usage.log".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0 args = "--filter err -as tests/test_logs/valid_logs/gpu_usage.log".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0 args = "--filter err -s tests/test_logs/valid_logs/gpu_usage.log".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0
def test_summarize_mode(): # single files args = "--mode summarize tests/test_" \ "logs/valid_logs/aborted_before_submission.log".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0 # dictionary args = "-m s tests/test_logs/valid_logs/".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0
def test_analyze_mode(): args = "--mode analyze tests/test_logs/valid_" \ "logs/aborted_before_submission.log".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0 # dictionary sys.stdout = open('test_output.txt', 'w') args = "-m a tests/test_logs/valid_logs/normal_log.log".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0
def test_independent_opts(): args = "--ext-log=.log --ext-out=.output " \ "--ext-err=.error --rdns-lookup".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 1 # no valid file is given args = "--ext-log log --ext-out output " \ "--ext-err error " \ "--rdns-lookup tests/test_logs/valid_logs".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0 args = "--recursive --bad-usage 0.3 --tolerated-usage 0.1" \ " tests/test_logs".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0
def run_htcanalyze(paths, *args): cli_args = paths if isinstance(paths, str): cli_args = [paths] cli_args.extend(list(*args)) run(cli_args)
def test_wrong_opts_or_args(): args = "--abs" # not a list with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 2 args = "--abc".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 2 args = "--mode=None".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 2 # wrong ignore value args = "--ignore None ".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 2 # wrong show value args = "--show None ".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 2 # Argument starts with -, # this will not raise an error, but is considered sceptical args = "--ext-log -log".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 2
def _version(): args = "--version".split() with pytest.raises(SystemExit) as pytest_wrapped_e: ht.run(args) assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0