Repository navigation
Commit a472174
LAV-4373: support CREATE OR ALTER ALERT core lifecycle semantics (#4626)
Carry OR ALTER through the alert AST and DDL rewrite into the existing
creation UDF. Lock and update an existing live alert in place, preserving
creation time, owner, grants, execution history and lifecycle bookkeeping.
Replace condition/action verbatim, reset omitted warehouse to serverless and
omitted comment to the empty string, and reuse schedule validation. Map Cloud's
started-target and scheduled/streaming conversion errors through the existing
wire-error registry. Fresh targets retain ordinary CREATE behavior and status.
Capture 23 new default-account Cloud cases for qualified and quoted names,
core definition updates and omissions, scheduleless metadata, lifecycle
restrictions, transferred ownership, grants and execution-time body handling.
Existing tests and snapshots are unchanged. CONFIG, RUNBOOK, thresholds and
tag-specific OR ALTER behavior remain the sibling's work.
Co-authored-by: Przemek Denkiewicz <przemyslaw.denkiewicz@localstack.cloud>
## Testing
- Captured all new snapshots against SNOWFLAKE_CLOUD, serially.
- make check passed before this commit.
- Focused new-file replay: 23 passed.
- Serial replay of the new file and eight existing alert files: 433 passed.
- ruff check tests/queries/test_create_or_alter_alert.py passed.
The first four-worker regression run passed 409 tests and failed the existing
test_execute_alert_condition_false_resets_failure_counter. Its alert was
created/resumed at 22:09:37 UTC while another worker advanced the shared test
clock by 70 seconds at 22:09:38 UTC, allowing an extra scheduled failure.
The complete serial replay avoids that interference without changing the test.
## Test matrix
Qualified target / absent creation status -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core[False]
Quoted mixed-case target / absent creation status -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core[True]
Qualified target / existing update status -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core[False]
Quoted mixed-case target / existing update status -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core[True]
Scheduled creation / omitted warehouse and comment defaults -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_defaults[SCHEDULE='1 MINUTE']
Scheduleless creation / explicit NULL and omitted warehouse/comment defaults -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_defaults[SCHEDULE=NULL]
Scheduleless creation / omitted schedule -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_conversion[None-None]
Condition and action / existing definition replacement -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
Condition/action / single-quoted keyword and semicolon preservation -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
Condition/action / dollar-quoted keyword and semicolon preservation -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_defaults
Condition/action / execution-time transformation after alteration -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_grants_history
SCHEDULE / explicit existing-target replacement -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
WAREHOUSE / explicit accepted existing warehouse -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
WAREHOUSE / omitted value resets to serverless -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
COMMENT / explicit replacement -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
COMMENT / omitted value resets to empty string -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
COMMENT / explicit empty string boundary -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
WAREHOUSE and COMMENT / jointly omitted -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
Object identity / creation timestamp preserved -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
SHOW and DESC / updated core metadata -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
GET_DDL / updated core metadata and verbatim bodies -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_core
Scheduled to scheduled / accepted -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_conversion[2 MINUTES-1 MINUTE]
Scheduled to scheduleless / omitted schedule rejected atomically -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_conversion[None-1 MINUTE]
Scheduled to scheduleless / explicit NULL rejected atomically -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_conversion[NULL-1 MINUTE]
Scheduleless to scheduled / rejected atomically -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_conversion[2 MINUTES-None]
Scheduleless to scheduleless / omitted schedule accepted -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_conversion[None-None]
Scheduleless to scheduleless / explicit NULL accepted -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_conversion[NULL-None]
Suspended target / update keeps suspended state -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_lifecycle[suspended]
Started target / update rejected and definition/state unchanged -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_lifecycle[started]
ALTER SUSPEND after RESUME / update accepted and auto-suspend flag preserved -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_lifecycle[started]
STARTED token / rejected, not a creation state setter -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_state_tokens[STARTED]
SUSPENDED token / rejected, not a creation state setter -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_state_tokens[SUSPENDED]
Ownership and MONITOR grants / preserved before and after alteration -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_grants_history
Transferred ownership / role hierarchy and owner/grant preservation -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_transferred_ownership
Prior execution history / old bodies and outcome preserved -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_grants_history
Subsequent execution history / new bodies and exact action results -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_grants_history
10 seconds schedule / absent and existing minimum boundary accepted -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_validation[10 seconds]
192 H schedule / absent and existing maximum boundary accepted -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_validation[192 H]
Last-day cron schedule / absent and existing accepted -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_validation[USING CRON 0 0 L * * UTC]
1 SECOND schedule / absent and existing too-short rejection -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_validation[1 SECOND]
193 HOUR schedule / absent and existing too-long rejection -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_validation[193 HOUR]
Invalid cron timezone / absent and existing rejection -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_validation[USING CRON 0 0 * * * Not/A_Zone]
Malformed schedule / absent and existing rejection -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_validation[bogus]
Rejected schedule / existing definition unchanged -> tests/queries/test_create_or_alter_alert.py::test_create_or_alter_alert_schedule_validation
Ordinary CREATE/ALTER / accepted interval and calendar regression -> tests/queries/test_alert_schedules.py::test_alert_schedule_readback
Ordinary CREATE/REPLACE/ALTER / rejected schedules and atomicity regression -> tests/queries/test_alert_schedule_errors.py::test_alert_schedule_error_atomicity
Ordinary lifecycle / resume, suspend, execution and history regression -> tests/queries/test_alerts.py
Literal body and property forms / unchanged regression -> tests/queries/test_alert_literals.py
Ordinary alert grants / unchanged regression -> tests/queries/access_control/test_alert_grants.py
Clone caller / ordinary creation remains compatible with default OR ALTER flag -> tests/queries/test_alert_clone.py
Ordinary RUNBOOK / unchanged regression -> tests/queries/test_alert_runbook.py
Ordinary ALTER property validation / unchanged regression -> tests/queries/test_alter_alert_properties.py
CONFIG/RUNBOOK/threshold/TAG-specific OR ALTER cells -> uncovered: explicitly deferred to LAV-4374
FROM TEMPLATE and warehouse-catalog rejection policy -> uncovered: explicitly reserved to LAV-4377
Co-authored-by: spiral <spiral@localhost>
Co-authored-by: Przemek Denkiewicz <przemyslaw.denkiewicz@localstack.cloud>1 parent 9fc6e79 commit a472174
2 files changed
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5424 | 5424 | | |
5425 | 5425 | | |
5426 | 5426 | | |
| 5427 | + | |
| 5428 | + | |
5427 | 5429 | | |
5428 | 5430 | | |
5429 | 5431 | | |
| |||
9184 | 9186 | | |
9185 | 9187 | | |
9186 | 9188 | | |
| 9189 | + | |
9187 | 9190 | | |
9188 | 9191 | | |
9189 | 9192 | | |
| |||
9197 | 9200 | | |
9198 | 9201 | | |
9199 | 9202 | | |
9200 | | - | |
| 9203 | + | |
9201 | 9204 | | |
| 9205 | + | |
9202 | 9206 | | |
9203 | 9207 | | |
9204 | 9208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5906 | 5906 | | |
5907 | 5907 | | |
5908 | 5908 | | |
5909 | | - | |
| 5909 | + | |
5910 | 5910 | | |
5911 | 5911 | | |
5912 | 5912 | | |
| |||
6490 | 6490 | | |
6491 | 6491 | | |
6492 | 6492 | | |
6493 | | - | |
| 6493 | + | |
| 6494 | + | |
| 6495 | + | |
| 6496 | + | |
| 6497 | + | |
6494 | 6498 | | |
6495 | 6499 | | |
6496 | 6500 | | |
| |||
6556 | 6560 | | |
6557 | 6561 | | |
6558 | 6562 | | |
| 6563 | + | |
6559 | 6564 | | |
6560 | 6565 | | |
6561 | 6566 | | |
| |||
0 commit comments