From 89cee540d93fae618902dce2030c1f1f526193b0 Mon Sep 17 00:00:00 2001 From: Deep1998 Date: Tue, 30 Jul 2024 18:06:13 +0530 Subject: [PATCH] Add string mapper case for IT (#1757) --- .../templates/SourceDbToSpannerSimpleIT.java | 18 ++++++++++++------ .../spanner-schema.sql | 5 +++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/templates/SourceDbToSpannerSimpleIT.java b/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/templates/SourceDbToSpannerSimpleIT.java index c46c937b5f..d4f6aba794 100644 --- a/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/templates/SourceDbToSpannerSimpleIT.java +++ b/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/templates/SourceDbToSpannerSimpleIT.java @@ -59,17 +59,19 @@ public class SourceDbToSpannerSimpleIT extends SourceDbToSpannerITBase { private static final String SPANNER_DDL_RESOURCE = "SourceDbToSpannerSimpleIT/spanner-schema.sql"; - private static final String TABLE = "SimpleTable"; + private static final String TABLE1 = "SimpleTable"; + + private static final String TABLE2 = "StringTable"; private static final String ID = "id"; private static final String NAME = "name"; - private JDBCResourceManager.JDBCSchema getMySQLSchema() { + private JDBCResourceManager.JDBCSchema getMySQLSchema(String idCol) { HashMap columns = new HashMap<>(); columns.put(ID, "INTEGER NOT NULL"); columns.put(NAME, "VARCHAR(200)"); - return new JDBCResourceManager.JDBCSchema(columns, ID); + return new JDBCResourceManager.JDBCSchema(columns, idCol); } private List> getMySQLData() { @@ -101,8 +103,10 @@ public void cleanUp() { @Test public void simpleTest() throws IOException { List> mySQLData = getMySQLData(); - mySQLResourceManager.createTable(TABLE, getMySQLSchema()); - mySQLResourceManager.write(TABLE, mySQLData); + mySQLResourceManager.createTable(TABLE1, getMySQLSchema(ID)); + mySQLResourceManager.createTable(TABLE2, getMySQLSchema(NAME)); + mySQLResourceManager.write(TABLE1, mySQLData); + mySQLResourceManager.write(TABLE2, mySQLData); createSpannerDDL(spannerResourceManager, SPANNER_DDL_RESOURCE); jobInfo = launchDataflowJob( @@ -115,7 +119,9 @@ public void simpleTest() throws IOException { null); PipelineOperator.Result result = pipelineOperator().waitUntilDone(createConfig(jobInfo)); assertThatResult(result).isLaunchFinished(); - SpannerAsserts.assertThatStructs(spannerResourceManager.readTableRecords(TABLE, ID, NAME)) + SpannerAsserts.assertThatStructs(spannerResourceManager.readTableRecords(TABLE1, ID, NAME)) + .hasRecordsUnorderedCaseInsensitiveColumns(mySQLData); + SpannerAsserts.assertThatStructs(spannerResourceManager.readTableRecords(TABLE2, ID, NAME)) .hasRecordsUnorderedCaseInsensitiveColumns(mySQLData); } } diff --git a/v2/sourcedb-to-spanner/src/test/resources/SourceDbToSpannerSimpleIT/spanner-schema.sql b/v2/sourcedb-to-spanner/src/test/resources/SourceDbToSpannerSimpleIT/spanner-schema.sql index 5c0b19acf4..42b58b54e6 100644 --- a/v2/sourcedb-to-spanner/src/test/resources/SourceDbToSpannerSimpleIT/spanner-schema.sql +++ b/v2/sourcedb-to-spanner/src/test/resources/SourceDbToSpannerSimpleIT/spanner-schema.sql @@ -2,3 +2,8 @@ CREATE TABLE IF NOT EXISTS SimpleTable ( id INT64 NOT NULL, name STRING(200), ) PRIMARY KEY(id); + +CREATE TABLE IF NOT EXISTS StringTable ( + id INT64 NOT NULL, + name STRING(200), +) PRIMARY KEY(name);