Skip to content

Commit fd6b1da

Browse files
akashthawaitccpawankashyapolliontaherkl
authored
Reverse replication low priority integration tests (#2310)
* Reverse replication low priority integration tests * Reverse replication low it (#187) * Add Low Level IT in CassandraToSourceDbIT * Added Code Refectored * Removed Unwanted Files * Added Missing Schema * fix session file * fix tests * Added CopyRight Fixes * Adding Static VPC, SUBNET and REGION * Added Missing params * Added VPC Changes (#196) * Added VCP Changes * workerRegion instead of Region * Refactor VPC changes * revert VPC changes --------- Co-authored-by: pawankashyapollion <[email protected]> Co-authored-by: taherkl <[email protected]>
1 parent 5bd2576 commit fd6b1da

File tree

7 files changed

+356
-33
lines changed

7 files changed

+356
-33
lines changed

v2/spanner-to-sourcedb/src/test/java/com/google/cloud/teleport/v2/templates/SpannerToCassandraSourceDbIT.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public class SpannerToCassandraSourceDbIT extends SpannerToSourceDbITBase {
9393
private static final String ALL_DATA_TYPES_TABLE = "AllDatatypeColumns";
9494
private static final String ALL_DATA_TYPES_CUSTOM_CONVERSION_TABLE = "AllDatatypeTransformation";
9595
private static final String BOUNDARY_CONVERSION_TABLE = "BoundaryConversionTestTable";
96+
private static final String BOUNDARY_SIZE_TABLE = "testtable_03tpcovf16ed0klxm3v808ch3btgq0uk";
9697
private static final HashSet<SpannerToCassandraSourceDbIT> testInstances = new HashSet<>();
9798
private static PipelineLauncher.LaunchInfo jobInfo;
9899
public static SpannerResourceManager spannerResourceManager;
@@ -164,6 +165,36 @@ public static void cleanUp() throws IOException {
164165
pubsubResourceManager);
165166
}
166167

168+
@Test
169+
public void testSpannerToCassandraWithMaxColumnsAndTableName()
170+
throws InterruptedException, IOException {
171+
assertThatPipeline(jobInfo).isRunning();
172+
writeRowWithMaxColumnsNameAndTableInSpanner();
173+
assertRowWithMaxColumnsInCassandra();
174+
}
175+
176+
private void writeRowWithMaxColumnsNameAndTableInSpanner() {
177+
List<Mutation> mutations = new ArrayList<>();
178+
Mutation.WriteBuilder mutationBuilder =
179+
Mutation.newInsertOrUpdateBuilder(BOUNDARY_SIZE_TABLE).set("id").to(1);
180+
mutationBuilder.set("col_qcbf69rmxtre3b_03tpcovf16ed").to("SampleTestValue");
181+
182+
mutations.add(mutationBuilder.build());
183+
spannerResourceManager.write(mutations);
184+
LOG.info("Inserted row into Spanner using Mutations");
185+
}
186+
187+
private void assertRowWithMaxColumnsInCassandra() {
188+
189+
PipelineOperator.Result result =
190+
pipelineOperator()
191+
.waitForCondition(
192+
createConfig(jobInfo, Duration.ofMinutes(15)),
193+
() -> getRowCount(BOUNDARY_SIZE_TABLE) == 1);
194+
assertThatResult(result).meetsConditions();
195+
LOG.info("Successfully validated columns in Cassandra");
196+
}
197+
167198
/**
168199
* Tests the data flow from Spanner to Cassandra.
169200
*

v2/spanner-to-sourcedb/src/test/java/com/google/cloud/teleport/v2/templates/SpannerToSourceDbIT.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.google.pubsub.v1.SubscriptionName;
3030
import java.io.IOException;
3131
import java.time.Duration;
32+
import java.util.ArrayList;
3233
import java.util.HashSet;
3334
import java.util.List;
3435
import java.util.Map;
@@ -66,6 +67,8 @@ public class SpannerToSourceDbIT extends SpannerToSourceDbITBase {
6667
private static final String MYSQL_SCHEMA_FILE_RESOURCE = "SpannerToSourceDbIT/mysql-schema.sql";
6768

6869
private static final String TABLE = "Users";
70+
private static final String BOUNDARY_CHECK_TABLE =
71+
"testtable_03TpCoVF16ED0KLxM3v808cH3bTGQ0uK_FEXuZHbttvYZPAeGeqiO";
6972
private static final HashSet<SpannerToSourceDbIT> testInstances = new HashSet<>();
7073
private static PipelineLauncher.LaunchInfo jobInfo;
7174
public static SpannerResourceManager spannerResourceManager;
@@ -206,4 +209,36 @@ private void assertRowInMySQL() throws InterruptedException {
206209
assertThat(rows.get(0).get("name")).isEqualTo("FF");
207210
assertThat(rows.get(0).get("from")).isEqualTo("AA");
208211
}
212+
213+
@Test
214+
public void spannerToMySQLSourceDbMaxColAndTableNameTest()
215+
throws IOException, InterruptedException {
216+
assertThatPipeline(jobInfo).isRunning();
217+
// Write row in Spanner
218+
writeMaxColRowsInSpanner();
219+
// Assert events on Mysql
220+
assertBoundaryRowInMySQL();
221+
}
222+
223+
private void writeMaxColRowsInSpanner() {
224+
List<Mutation> mutations = new ArrayList<>();
225+
Mutation.WriteBuilder mutationBuilder =
226+
Mutation.newInsertOrUpdateBuilder(BOUNDARY_CHECK_TABLE).set("id").to(1);
227+
mutationBuilder
228+
.set("col_qcbF69RmXTRe3B_03TpCoVF16ED0KLxM3v808cH3bTGQ0uK_FEXuZHbttvY")
229+
.to("SampleTestValue");
230+
231+
mutations.add(mutationBuilder.build());
232+
spannerResourceManager.write(mutations);
233+
LOG.info("Inserted row into Spanner using Mutations");
234+
}
235+
236+
private void assertBoundaryRowInMySQL() throws InterruptedException {
237+
PipelineOperator.Result result =
238+
pipelineOperator()
239+
.waitForCondition(
240+
createConfig(jobInfo, Duration.ofMinutes(10)),
241+
() -> jdbcResourceManager.getRowCount(BOUNDARY_CHECK_TABLE) == 1);
242+
assertThatResult(result).meetsConditions();
243+
}
209244
}

v2/spanner-to-sourcedb/src/test/resources/SpannerToCassandraSourceIT/cassandra-schema.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,9 @@ CREATE TABLE EmptyStringJsonTable (
216216
duration_list_col LIST<TEXT>,
217217
frozen_ascii_set_col frozen<SET<ASCII>>
218218
);
219+
220+
CREATE TABLE testtable_03tpcovf16ed0klxm3v808ch3btgq0uk (
221+
id TEXT PRIMARY KEY,
222+
col_qcbf69rmxtre3b_03tpcovf16ed TEXT
223+
);
224+

v2/spanner-to-sourcedb/src/test/resources/SpannerToCassandraSourceIT/spanner-schema.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ CREATE TABLE IF NOT EXISTS emptystringjsontable (
228228
frozen_ascii_set_col JSON
229229
) PRIMARY KEY(varchar_column);
230230

231+
CREATE TABLE testtable_03tpcovf16ed0klxm3v808ch3btgq0uk (
232+
id STRING(100) NOT NULL,
233+
col_qcbf69rmxtre3b_03tpcovf16ed STRING(100)
234+
) PRIMARY KEY (id);
235+
231236

232237
CREATE CHANGE STREAM allstream
233238
FOR ALL OPTIONS (

v2/spanner-to-sourcedb/src/test/resources/SpannerToSourceDbIT/mysql-schema.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ CREATE TABLE Users (
22
id INT NOT NULL,
33
name VARCHAR(25),
44
`from` VARCHAR(25),
5+
PRIMARY KEY(id));
6+
7+
CREATE TABLE testtable_03TpCoVF16ED0KLxM3v808cH3bTGQ0uK_FEXuZHbttvYZPAeGeqiO(
8+
id INT NOT NULL,
9+
col_qcbF69RmXTRe3B_03TpCoVF16ED0KLxM3v808cH3bTGQ0uK_FEXuZHbttvY VARCHAR(25),
510
PRIMARY KEY(id));

0 commit comments

Comments
 (0)