From b04de34e78d6cb8e232405cf1227b4be33fd32d7 Mon Sep 17 00:00:00 2001 From: Astha Mohta <35952883+asthamohta@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:57:30 +0530 Subject: [PATCH] Tests: Adding Reverse Replication Tests (#1951) * changes * changes * changes * change * change * change * change * change * changes --- .../v2/templates/SpannerToSourceDbIT.java | 23 ++++++++++++------- .../SpannerToSourceDbIT/session.json | 2 +- .../SpannerToSourceDbIT/spanner-schema.sql | 7 +++++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/v2/spanner-to-sourcedb/src/test/java/com/google/cloud/teleport/v2/templates/SpannerToSourceDbIT.java b/v2/spanner-to-sourcedb/src/test/java/com/google/cloud/teleport/v2/templates/SpannerToSourceDbIT.java index 718d97b184..0a97e21d00 100644 --- a/v2/spanner-to-sourcedb/src/test/java/com/google/cloud/teleport/v2/templates/SpannerToSourceDbIT.java +++ b/v2/spanner-to-sourcedb/src/test/java/com/google/cloud/teleport/v2/templates/SpannerToSourceDbIT.java @@ -49,7 +49,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Integration test for {@link SpannerToSourceDb} Flex template. */ +/** + * Integration test for {@link SpannerToSourceDb} Flex template for basic run including new spanner + * tables and column rename use-case. + */ @Category({TemplateIntegrationTest.class, SkipDirectRunnerTest.class}) @TemplateIntegrationTest(SpannerToSourceDb.class) @RunWith(JUnit4.class) @@ -134,7 +137,7 @@ public static void cleanUp() throws IOException { } @Test - public void spannerToSourceDbBasic() throws InterruptedException { + public void spannerToSourceDbBasic() throws InterruptedException, IOException { assertThatPipeline(jobInfo).isRunning(); // Write row in Spanner writeRowInSpanner(); @@ -144,16 +147,20 @@ public void spannerToSourceDbBasic() throws InterruptedException { private void writeRowInSpanner() { // Write a single record to Spanner - Mutation m = + Mutation m1 = Mutation.newInsertOrUpdateBuilder("Users") .set("id") .to(1) - .set("name") + .set("full_name") .to("FF") .set("from") .to("AA") .build(); - spannerResourceManager.write(m); + spannerResourceManager.write(m1); + + Mutation m2 = + Mutation.newInsertOrUpdateBuilder("Users2").set("id").to(2).set("name").to("B").build(); + spannerResourceManager.write(m2); // Write a single record to Spanner for the given logical shard // Add the record with the transaction tag as txBy= @@ -171,14 +178,14 @@ private void writeRowInSpanner() { .run( (TransactionCallable) transaction -> { - Mutation m2 = + Mutation m3 = Mutation.newInsertOrUpdateBuilder("Users") .set("id") .to(2) - .set("name") + .set("full_name") .to("GG") .build(); - transaction.buffer(m2); + transaction.buffer(m3); return null; }); } diff --git a/v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbIT/session.json b/v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbIT/session.json index 48749eebf6..6584d15d49 100644 --- a/v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbIT/session.json +++ b/v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbIT/session.json @@ -28,7 +28,7 @@ "Id": "c142" }, "c143": { - "Name": "name", + "Name": "full_name", "T": { "Name": "STRING", "Len": 25, diff --git a/v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbIT/spanner-schema.sql b/v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbIT/spanner-schema.sql index 820882cacb..d0bb0aebec 100644 --- a/v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbIT/spanner-schema.sql +++ b/v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbIT/spanner-schema.sql @@ -1,9 +1,14 @@ CREATE TABLE IF NOT EXISTS Users ( id INT64 NOT NULL, - name STRING(25), + full_name STRING(25), `from` STRING(25) ) PRIMARY KEY(id); +CREATE TABLE IF NOT EXISTS Users2 ( + id INT64 NOT NULL, + name STRING(25), + ) PRIMARY KEY(id); + CREATE CHANGE STREAM allstream FOR ALL OPTIONS ( value_capture_type = 'NEW_ROW',