Ejemplo n.º 1
0
    def __mark_job_run_as(self, run_id, action, at=None):
        Utils.is_valid_uuid(run_id, 'run_id')

        return self._post(
            self._url('/jobs/runs/{0}/{1}?at={2}', run_id, action,
                      at if at else Utils.utc_now())
        )
Ejemplo n.º 2
0
def test_mark_job_run_as_aborted(wo_client):
    aborted_at = Utils.utc_now()

    wo_client.mark_job_run_as_aborted(
        run_id='71feb41b-be50-428c-8470-37b9c292f787', at=aborted_at)

    wo_client._backend.post.assert_called_once_with(
        path=MarquezWriteOnlyClient._path(
            '/jobs/runs/71feb41b-be50-428c-8470-37b9c292f787/abort?at={0}',
            aborted_at),
        headers=mock.ANY)
Ejemplo n.º 3
0
def test_mark_job_run_as_failed(mock_post, client):
    mock_post.return_value.status_code.return_value = HTTPStatus.OK
    mock_post.return_value.json.return_value = FAILED

    now = Utils.utc_now()
    run = client.mark_job_run_as_failed(RUN_ID, at=now)

    assert run['id'] == RUN_ID
    assert run['nominalStartTime'] == NOMINAL_START_TIME
    assert run['nominalEndTime'] == NOMINAL_END_TIME
    assert run['state'] == RunState.FAILED
    assert run['startedAt'] == START_AT
    assert run['endedAt'] == ENDED_AT
    assert run['durationMs'] == DURATION_MS

    mock_post.assert_called_once_with(url=client._url(
        '/jobs/runs/{0}/fail?at={1}', RUN_ID, now),
                                      headers=mock.ANY,
                                      json=None,
                                      timeout=mock.ANY)
Ejemplo n.º 4
0
    def test_create_job_run(self, mock_post):
        run_id = str(uuid.uuid4())
        action_at = Utils.utc_now()

        job_name = "my-job"
        run_args = {
            "email": "*****@*****.**",
            "emailOnFailure": "true",
            "emailOnRetry": "true",
            "retries": "1"
        }

        mock_post.return_value = {
            'id': f'{run_id}',
            'createdAt': '2020-08-12T22:33:02.787228Z',
            'updatedAt': '2020-08-12T22:33:02.787228Z',
            'nominalStartTime': None,
            'nominalEndTime': None,
            'state': 'NEW',
            'startedAt': f'{action_at}',
            'endedAt': None,
            'durationMs': None,
            'args': {
                "email": "*****@*****.**",
                "emailOnFailure": "true",
                "emailOnRetry": "true",
                "retries": "1"
            }
        }

        response = self.client.create_job_run(namespace_name=_NAMESPACE,
                                              job_name=job_name,
                                              run_id=run_id,
                                              nominal_start_time=None,
                                              nominal_end_time=None,
                                              run_args=run_args,
                                              mark_as_running=True)

        assert response['id'] is not None
        assert str(response['args']) == str(run_args)
        assert str(response['startedAt']) == action_at
Ejemplo n.º 5
0
    def test_mark_job_run_as_aborted(self, mock_post):
        run_id = str(uuid.uuid4())
        action_at = Utils.utc_now()

        mock_post.return_value = {
            'id': f'{run_id}',
            'createdAt': '2020-08-12T22:36:50.739951Z',
            'updatedAt': '2020-08-13T17:56:39.516802Z',
            'nominalStartTime': None,
            'nominalEndTime': None,
            'state': 'ABORTED',
            'startedAt': f'{action_at}',
            'endedAt': None,
            'durationMs': None,
            'args': {}
        }

        response = self.client.mark_job_run_as_aborted(run_id=run_id,
                                                       action_at=action_at)

        assert str(response['id']) == run_id
        assert str(response['state']) == RunState.ABORTED.value
        assert str(response['startedAt']) == action_at
Ejemplo n.º 6
0
    def test_mark_job_run_as_aborted(self):
        run_id = str(uuid.uuid4())
        aborted_at = Utils.utc_now()

        self.client_wo_file.mark_job_run_as_aborted(run_id=run_id,
                                                    at=aborted_at)
Ejemplo n.º 7
0
    def test_mark_job_run_as_aborted(self, mock_post):
        run_id = str(uuid.uuid4())
        aborted_at = Utils.utc_now()

        self.client_wo_http.mark_job_run_as_aborted(run_id=run_id,
                                                    at=aborted_at)
Ejemplo n.º 8
0
    def test_mark_job_run_as_failed(self):
        run_id = str(uuid.uuid4())
        action_at = Utils.utc_now()

        self.client_wo_file.mark_job_run_as_failed(run_id=run_id,
                                                   action_at=action_at)
    def test_mark_job_run_as_completed(self, mock_post):
        run_id = str(uuid.uuid4())
        action_at = Utils.utc_now()

        self.client_wo_http.mark_job_run_as_completed(run_id=run_id,
                                                      action_at=action_at)