Commit 72a145d
authored
[spanner-to-sourcedb] Add Integration Tests for retryDLQ and retryAllDLQ mode for sharded and non-sharded setup (#3564)
b/457948107
This PR introduces comprehensive integration tests for the Dead Letter Queue (DLQ) retry mechanisms in the Spanner-to-Source Dataflow template. It adds end-to-end verification for both the concurrent batch retry flow (`retryDLQ`) and the streaming retry flow (`retryAllDLQ`), covering both non-sharded and multi-shard schema routing scenarios.
### Tests Added
1. **`SpannerToSourceDBMySQLRetryDLQIT`**: Tests the `retryDLQ` batch job. Validates that it correctly processes and retries DLQ events *alongside* an actively running streaming pipeline by utilizing the active `dlqPubSubConsumer` flow. Uses the overrides file.
2. **`SpannerToSourceDBMySQLRetryAllDLQIT`**: Tests the `retryAllDLQ` batch job. Validates that it correctly processes and retries ALL DLQ events offline when the main pipeline has been safely drained or stopped, utilizing the file-based consumer. Uses the overrides file.
3. **`SpannerToSourceDBShardedMySQLRetryDLQIT`**: The sharded equivalent of `retryDLQ`. Validates that the pipeline successfully evaluates native `migration_shard_id` columns in the source Spanner database to reliably route DLQ/retry events across multiple distributed target instances. Uses session file.
4. **`SpannerToSourceDBShardedMySQLRetryAllDLQIT`**: The sharded equivalent of `retryAllDLQ`. Validates the behavior of dynamic custom shard routing (where ShardIdColumn is not present) by relying on a custom Java shard ID fetcher. Uses overrides file.
### Features & Edge Cases Covered
* **DLQ State Integrity:** Consistently verifying that *fixed* items successfully rewrite to MySQL upon retry, while genuinely *un-fixable* items explicitly route back into their appropriate (`severe/` or `retry/`) error buckets without stalling progress.
* **Handling Database Constraints:** Generating and resolving retriable database exceptions, including testing resilience against missing parent rows (Foreign Key Violations).
* **Handling Logic/Processing Errors:** Simulating unrecoverable severe errors originating inside the runtime execution pipeline (failed custom transformations).
* **Active User-Intervention Simulation:** Orchestrating mid-flight environmental repairs. Before retry pipelines are run, the tests actively "fix" the previously generated errors by manually injecting parent rows via JDBC queries and swapping the custom pipeline transformer from `bad` mode to `semi-fixed` mode.
* **Multi-Shard Target Routing:** Validating sharding logic by testing both ShardIdColumn flow and Custom Sharding Jar flow.
### Test Setup & Simulated Schema Divergences
To accurately simulate volatile production environments, these integration tests operate against highly divergent test schemas between the Spanner source and MySQL target:
* Robust type mapping validations utilizing a heavily populated, extensive `AllDataTypes` reference table layout.
* **Mismatched Primary Keys**: Guaranteeing successful execution logic in pipelines where the Spanner structure and downstream Source primary keys intentionally diverge.
* **Altered / Divergent Columns**: Accommodating architectures where columns have been asynchronously added, deleted, or explicitly renamed across Spanner / Source database platforms.1 parent d871e1e commit 72a145d
19 files changed
Lines changed: 7345 additions & 1 deletion
File tree
- v2
- spanner-custom-shard/src/main/java/com/custom
- spanner-to-sourcedb/src/test
- java/com/google/cloud/teleport/v2/templates
- resources
- SpannerToSourceDBMySQLRetryAllDLQIT
- SpannerToSourceDBMySQLRetryDLQIT
- SpannerToSourceDBShardedMySQLRetryAllDLQIT
- SpannerToSourceDBShardedMySQLRetryDLQIT
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
Lines changed: 123 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
0 commit comments