Skip to content

Commit

Permalink
Tests: Adding Reverse Replication Tests (GoogleCloudPlatform#1951)
Browse files Browse the repository at this point in the history
* changes

* changes

* changes

* change

* change

* change

* change

* change

* changes
  • Loading branch information
asthamohta authored Nov 18, 2024
1 parent b7e6db7 commit b04de34
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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=
Expand All @@ -171,14 +178,14 @@ private void writeRowInSpanner() {
.run(
(TransactionCallable<Void>)
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;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"Id": "c142"
},
"c143": {
"Name": "name",
"Name": "full_name",
"T": {
"Name": "STRING",
"Len": 25,
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit b04de34

Please sign in to comment.