Пример #1
0
    def test_sync_job(self) -> None:
        self.run_model.dataflow_job_id = None

        with self.assertRaisesRegexp(
                ValueError,
                'must not be None'):  # type: ignore[no-untyped-call]
            jobs_manager.cancel_job(self.run_model)
Пример #2
0
    def test_failed_api_call_logs_the_exception(self) -> None:
        self.dataflow_client_mock.update_job.side_effect = Exception('uh-oh')

        with self.capture_logging() as logs:
            jobs_manager.cancel_job(self.run_model)

        self.assertGreater(len(logs), 0)
        self.assertIn('uh-oh', logs[0])
Пример #3
0
def cancel_beam_job(job_id: str) -> beam_job_domain.BeamJobRun:
    """Cancels an existing Apache Beam job and returns its updated metadata.

    Args:
        job_id: str. The Oppia-provided ID of the job.

    Returns:
        BeamJobRun. Metadata about the updated run's execution.
    """
    beam_job_run_model = (beam_job_models.BeamJobRunModel.get(job_id,
                                                              strict=False))

    if beam_job_run_model is None:
        raise ValueError('No such job with id="%s"' % job_id)

    if beam_job_run_model.dataflow_job_id is None:
        raise ValueError('Job with id="%s" cannot be cancelled' % job_id)

    jobs_manager.cancel_job(beam_job_run_model)
    return get_beam_job_run_from_model(beam_job_run_model)
Пример #4
0
    def test_job_with_cancelling_status(self) -> None:
        self.run_model.latest_job_state = 'RUNNING'

        jobs_manager.cancel_job(self.run_model)

        self.assertEqual(self.run_model.latest_job_state, 'CANCELLING')