recon_gen._dev.cleanup

QuickSight resource sweep helpers (Y.2.gate.f.9).

Lifted from tests/e2e/_harness_cleanup.py (originally M.4.1.a) so the runner’s cmd_sweep can import them without the sys.path-into-tests/e2e/ dance the harness layer required. The harness layer drops with f.9; these helpers stay because production e2e tests (test_l1_*, test_inv_*, test_exec_*, test_l2ft_*) still tag their per-test resources with Harness:e2e (the tag name is historical; the new name “harness” just means “ephemeral test resource” now).

Two surfaces:

  1. sweep_qs_resources_by_tag(client, account_id, tag_key, tag_value) — list every QuickSight resource (dashboard / analysis / dataset / theme / datasource), filter by an (extra_tag_key, extra_tag_value) pair the test fixture injects via cfg.extra_tags, and delete in dependency order. Returns a count of deletions for triage.

  2. _collect_resources_matching_tag — same walk without the delete, for dry-run mode.

Dropped from the original module: drop_prefixed_schema (DB-side cleanup that only the legacy harness used; teardown of per-test schemas now happens via the test’s own DROP statements or the container’s auto-teardown).

Functions

sweep_qs_resources_by_tag(client, ...)

Delete every QS resource carrying tag_key == tag_value.

recon_gen._dev.cleanup.sweep_qs_resources_by_tag(client, account_id, *, tag_key, tag_value)[source]

Delete every QS resource carrying tag_key == tag_value.

Walks dashboards / analyses / datasets / datasources / themes; for each, calls list_tags_for_resource on its ARN; if the tag matches, deletes.

Returns a dict {resource_type: deletion_count} for triage.

Robust against partial failures: a delete that errors out is logged to stderr but does not abort the sweep — the next test needs the rest of the sweep to land or its deploy collides on leftover IDs.

Return type:

dict[str, int]

Parameters:
  • client (Any)

  • account_id (str)

  • tag_key (str)

  • tag_value (str)