def test_re_init(restore_cron_tab): # pylint:disable=unused-argument,redefined-outer-name with TemporaryDirectory() as tempdir: instance = define_scheduler_instance(tempdir) with get_test_external_repo() as external_repo: now = get_current_datetime_in_utc() # Start schedule schedule_state = instance.start_schedule_and_update_storage_state( external_repo.get_external_schedule("no_config_pipeline_every_min_schedule") ) assert ( schedule_state.job_specific_data.start_timestamp == get_timestamp_from_utc_datetime(now) ) # Check schedules are saved to disk assert "schedules" in os.listdir(tempdir) schedule_states = instance.all_stored_job_state(job_type=JobType.SCHEDULE) for state in schedule_states: assert state.job_specific_data.scheduler == "SystemCronScheduler" if state.name == "no_config_pipeline_every_min_schedule": assert state == schedule_state
def test_reconcile_schedule_without_start_time(): with TemporaryDirectory() as tempdir: instance = define_scheduler_instance(tempdir) external_repo = get_test_external_repo() external_schedule = external_repo.get_external_schedule( "no_config_pipeline_daily_schedule") legacy_schedule_state = ScheduleState( external_schedule.get_origin(), ScheduleStatus.RUNNING, external_schedule.cron_schedule, None, ) instance.add_schedule_state(legacy_schedule_state) instance.reconcile_scheduler_state(external_repository=external_repo) reconciled_schedule_state = instance.get_schedule_state( external_schedule.get_origin_id()) assert reconciled_schedule_state.status == ScheduleStatus.RUNNING assert reconciled_schedule_state.start_timestamp == get_timestamp_from_utc_datetime( get_current_datetime_in_utc())