Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,28 @@ public void backfill100Gb() throws IOException, ParseException, InterruptedExcep
JDBCSource mySQLSource = getMySQLSource(hostIp, username, password);
runLoadTest(tables100GB, mySQLSource);
}

@Test
public void crossDbTxn_backfill100Gb() throws IOException, ParseException, InterruptedException {
setUpResourceManagers(
"DataStreamToSpanner100GbLT/spanner-schema.sql", /* separateShadowTableDb= */ true);
HashMap<String, Integer> tables100GB = new HashMap<>();
for (int i = 1; i <= 10; i++) {
tables100GB.put("person" + i, 6500000);
}

// Setup Datastream
String hostIp =
secretClient.accessSecret(
"projects/269744978479/secrets/nokill-datastream-mysql-to-spanner-cloudsql-ip-address/versions/1");
String username =
secretClient.accessSecret(
"projects/269744978479/secrets/nokill-datastream-mysql-to-spanner-cloudsql-username/versions/1");
String password =
secretClient.accessSecret(
"projects/269744978479/secrets/nokill-datastream-mysql-to-spanner-cloudsql-password/versions/1");

JDBCSource mySQLSource = getMySQLSource(hostIp, username, password);
runLoadTest(tables100GB, mySQLSource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,22 @@ public class DataStreamToSpannerLTBase extends TemplateLoadTestBase {
protected final int numWorkers = 50;
public PubsubResourceManager pubsubResourceManager;
public SpannerResourceManager spannerResourceManager;
protected SpannerResourceManager shadowTableSpannerResourceManager = null;
protected GcsResourceManager gcsResourceManager;
public DatastreamResourceManager datastreamResourceManager;
protected SecretManagerResourceManager secretClient;

public void setUpResourceManagers(String spannerDdlResource) throws IOException {
setUpResourceManagers(spannerDdlResource, false);
}

/**
* Setup resource managers.
*
* @throws IOException
*/
public void setUpResourceManagers(String spannerDdlResource) throws IOException {
public void setUpResourceManagers(String spannerDdlResource, boolean separateShadowTableDb)
throws IOException {
testRootDir = getClass().getSimpleName();
spannerResourceManager =
SpannerResourceManager.builder(testName, project, region)
Expand All @@ -98,6 +104,18 @@ public void setUpResourceManagers(String spannerDdlResource) throws IOException
.setCredentialsProvider(CREDENTIALS_PROVIDER)
.build();
secretClient = SecretManagerResourceManager.builder(project, CREDENTIALS_PROVIDER).build();

// Initialize shadowTableSpannerResourceManager only if separateShadowTableDb is true
if (separateShadowTableDb) {
shadowTableSpannerResourceManager =
SpannerResourceManager.builder("shadow_" + testName, project, region)
.maybeUseStaticInstance()
.setNodeCount(10)
.setMonitoringClient(monitoringClient)
.build();
shadowTableSpannerResourceManager.ensureUsableAndCreateResources();
}

createSpannerDDL(spannerResourceManager, spannerDdlResource);
}

Expand Down Expand Up @@ -148,6 +166,21 @@ public void runLoadTest(
put("inputFileFormat", "avro");
}
};

// Add shadow table parameters if shadowTableSpannerResourceManager is not null
if (shadowTableSpannerResourceManager != null) {
params.putAll(
new HashMap<>() {
{
put(
"shadowTableSpannerInstanceId",
shadowTableSpannerResourceManager.getInstanceId());
put(
"shadowTableSpannerDatabaseId",
shadowTableSpannerResourceManager.getDatabaseId());
}
});
}
// Add all parameters for the template
params.putAll(templateParameters);

Expand Down Expand Up @@ -206,6 +239,7 @@ public void cleanUp() throws IOException {
ResourceManagerUtils.cleanResources(
secretClient,
spannerResourceManager,
shadowTableSpannerResourceManager,
pubsubResourceManager,
gcsResourceManager,
datastreamResourceManager);
Expand Down
Loading