raghavan-arvind commented on PR #71625:
URL: https://github.com/apache/airflow/pull/71625#issuecomment-5295363027
Verified all these sensors return the correct result:
```
# Datadog sensor canaries: every (case x mode) combination, alerting when
# the outcome differs from the expected one encoded in the task name.
DATADOG_CANARY_CASES = {
# name -> (monitor_id, target_states, soft_fail, expected outcome)
'ok_should_pass': (DATADOG_OK_MONITOR_ID, ('OK',), False, 'success'),
'alert_timeout_should_fail': (DATADOG_OK_MONITOR_ID, ('Alert',), False,
'failed'),
'alert_timeout_soft_fail_should_skip': (DATADOG_OK_MONITOR_ID,
('Alert',), True, 'skipped'),
'missing_should_fail': (DATADOG_INVALID_MONITOR_ID, ('OK',), False,
'failed'),
'missing_soft_fail_should_fail': (DATADOG_INVALID_MONITOR_ID, ('OK',),
True, 'failed'),
}
for case_name, (monitor_id, target_states, soft_fail, expected) in
DATADOG_CANARY_CASES.items():
for sensor_mode in ('poke', 'reschedule', 'deferrable'):
callbacks = {
'success': {},
'failed': {
'on_failure_callback': None,
'on_success_callback': alert_on_failure,
'on_skipped_callback': alert_on_failure,
},
'skipped': {'on_success_callback': alert_on_failure},
}[expected]
DatadogMonitorSensor(
dag=dag,
task_id=f'datadog_monitor_{case_name}_{sensor_mode}',
monitor_id=monitor_id,
target_states=target_states,
soft_fail=soft_fail,
timeout=timedelta(seconds=90),
poke_interval=30,
deferrable=sensor_mode == 'deferrable',
**({'mode': sensor_mode} if sensor_mode != 'deferrable' else {}),
**callbacks,
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]