(c: Composition, parser: WorkflowArgumentParser)
| 634 | |
| 635 | |
| 636 | def workflow_test(c: Composition, parser: WorkflowArgumentParser) -> None: |
| 637 | # These replace the former `dbt test` data tests: every source is running, |
| 638 | # every replica is online, compute frontiers (and their imports) keep up, |
| 639 | # and every monitored object's write frontier keeps advancing (i.e. it is |
| 640 | # still sealing new output times — making progress). Unlike the dbt tests |
| 641 | # (which only checked the result was empty), each check reports the specific |
| 642 | # failing objects. |
| 643 | # |
| 644 | # The checks are independent (each opens its own connection), so they run |
| 645 | # concurrently and report as each finishes via run_parallel — the same |
| 646 | # spinner/✓/✗ output as bin/lint. |
| 647 | # |
| 648 | # Progress is measured by a write-frontier advance, NOT by a |
| 649 | # SUBSCRIBE(SNAPSHOT=false) emitting a row. A subscribe is the wrong probe |
| 650 | # for the big UPSERT source-tables: it emits nothing for a live source whose |
| 651 | # content happens not to change (customer re-sends no-op upserts), and it can |
| 652 | # take minutes just to hydrate a fresh dataflow over a ~1B-row persist shard |
| 653 | # — both false timeouts. A frozen write frontier, by contrast, is exactly |
| 654 | # "not making progress", and the sample is one cheap catalog query. |
| 655 | parser.add_argument( |
| 656 | "--progress-window", |
| 657 | default=15.0, |
| 658 | type=float, |
| 659 | help="Seconds to watch each object's write frontier; it must advance within this window.", |
| 660 | ) |
| 661 | args = parser.parse_args() |
| 662 | |
| 663 | # `stop` lets the frontier checks bail out promptly on Ctrl-C: signals go to |
| 664 | # the main thread, so the workers can't see the KeyboardInterrupt — they poll |
| 665 | # this event while waiting out the sample window. |
| 666 | stop = threading.Event() |
| 667 | |
| 668 | def task(fn: Callable[[], list[str]]) -> Callable[[], tuple[bool, str]]: |
| 669 | # Adapt a check (returns the list of failures) to run_parallel's |
| 670 | # (success, output) contract; the output is shown only on failure. |
| 671 | def run() -> tuple[bool, str]: |
| 672 | fails = fn() |
| 673 | return not fails, "\n".join(fails) |
| 674 | |
| 675 | return run |
| 676 | |
| 677 | checks: list[tuple[str, TaskSpec]] = [ |
| 678 | ("RDS Postgres replication-slot count", task(_check_rds_slots)), |
| 679 | ("all canary sources running", task(_check_sources_running)), |
| 680 | ("all canary cluster replicas online", task(_check_replicas_online)), |
| 681 | ("compute frontiers within 1 minute of now", task(_check_frontiers)), |
| 682 | ] |
| 683 | for obj in MONITORED_MVS + MONITORED_SOURCE_TABLES: |
| 684 | # Label with just the object name (the db/schema is always |
| 685 | # qa_canary_environment.public_*); the check uses the FQN. |
| 686 | checks.append( |
| 687 | ( |
| 688 | f"{obj.split('.')[-1]} makes progress", |
| 689 | task( |
| 690 | lambda obj=obj: _frontier_advances(obj, args.progress_window, stop) |
| 691 | ), |
| 692 | ) |
| 693 | ) |
nothing calls this directly
no test coverage detected