Example #1
0
File: cli.py Project: gfalcone/klio
def stop_job(config_file):
    job_dir = os.path.abspath(os.getcwd())
    config_file = config_file or "klio-job.yaml"
    config_path = os.path.join(job_dir, config_file)
    config_data = _get_config(config_path)
    conf_obj = config.KlioConfig(config_data)
    # TODO: make this a click option once draining is supported @lynn
    strategy = "cancel"
    stop.stop(conf_obj, strategy)
Example #2
0
def test_stop(has_running_job, config, mocker, monkeypatch, job):
    mock_set_dataflow_client = mocker.Mock()
    monkeypatch.setattr(stop, "_set_dataflow_client", mock_set_dataflow_client)

    ret_val = None
    if has_running_job:
        ret_val = job
    mock_check_job_running = mocker.Mock(return_value=ret_val)
    monkeypatch.setattr(stop, "_check_job_running", mock_check_job_running)
    mock_update_job_state = mocker.Mock()
    monkeypatch.setattr(stop, "_update_job_state", mock_update_job_state)
    mock_watch_job_state = mocker.Mock()
    monkeypatch.setattr(stop, "_watch_job_state", mock_watch_job_state)

    stop.stop(config, "cancel")

    mock_set_dataflow_client.assert_called_once_with()
    mock_check_job_running.assert_called_once_with(config)
    if has_running_job:
        mock_update_job_state.assert_called_once_with(job, req_state="cancel")
        mock_watch_job_state.assert_called_once_with(job)
    else:
        mock_update_job_state.assert_not_called()
        mock_watch_job_state.assert_not_called()