-
Notifications
You must be signed in to change notification settings - Fork 1.1k
added oracle support to data validation #4173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bharadwaj-aditya
merged 6 commits into
GoogleCloudPlatform:main
from
bharadwaj-aditya:dv_add_oracle_support
Aug 28, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
74477cc
added oracle support to data validation
6ae4981
fixed pr issues
d0a17ee
added check for json handling
4cddf18
standardized the flow for oracle tests similar to other sources
b39c064
improved test coverage
33dd397
improved test coverage
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
...oud/teleport/v2/templates/endtoend/BulkMigrationAndValidationOracleAllDataTypesE2EIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| /* | ||
| * Copyright (C) 2026 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
| * use this file except in compliance with the License. You may obtain a copy of | ||
| * the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations under | ||
| * the License. | ||
| */ | ||
| package com.google.cloud.teleport.v2.templates.endtoend; | ||
|
|
||
| import static com.google.common.truth.Truth.assertThat; | ||
| import static org.apache.beam.it.truthmatchers.PipelineAsserts.assertThatPipeline; | ||
|
|
||
| import com.google.cloud.teleport.metadata.SkipDirectRunnerTest; | ||
| import com.google.cloud.teleport.metadata.TemplateIntegrationTest; | ||
| import com.google.cloud.teleport.v2.templates.GCSSpannerDV; | ||
| import com.google.cloud.teleport.v2.templates.GCSSpannerDVTestAsserts; | ||
| import com.google.cloud.teleport.v2.templates.GCSSpannerDVTestAsserts.TableValidationStatsDto; | ||
| import com.google.cloud.teleport.v2.templates.GCSSpannerDVTestAsserts.ValidationSummaryDto; | ||
| import java.io.IOException; | ||
| import java.util.Collections; | ||
| import java.util.TimeZone; | ||
| import org.apache.beam.it.common.PipelineLauncher.LaunchConfig; | ||
| import org.apache.beam.it.common.PipelineLauncher.LaunchInfo; | ||
| import org.apache.beam.it.common.utils.ResourceManagerUtils; | ||
| import org.apache.beam.it.gcp.cloudsql.CloudOracleResourceManager; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
| import org.junit.runner.RunWith; | ||
| import org.junit.runners.JUnit4; | ||
|
|
||
| /** | ||
| * End-to-End Integration test validating the migration and validation of all supported data types | ||
| * from Oracle to Spanner. | ||
| * | ||
| * <p>This test verifies the entire lifecycle of data types across two pipelines (Bulk Migration and | ||
| * Data Validation). Specifically, it evaluates how the bulk migration pipeline maps each Oracle | ||
| * data type to Avro and Spanner, and subsequently, how the validation pipeline uses those Avro | ||
| * files to perform end-to-end data validation. | ||
| * | ||
| * <p>The test is driven by schemas that reflect real-world mappings: | ||
| * | ||
| * <ul> | ||
| * <li>The Oracle schema contains all supported Oracle data types. | ||
| * <li>The Spanner schema utilizes the default data type mapping provided by Spanner Migration | ||
| * Tool (SMT). | ||
| * </ul> | ||
| * | ||
| * <p>To ensure comprehensive boundary coverage, the test injects and validates four distinct rows | ||
| * of data: | ||
| * | ||
| * <ul> | ||
| * <li><b>Standard Row:</b> Typical, everyday values. | ||
| * <li><b>Null Row:</b> Tests NULL value handling across all nullable columns. | ||
| * <li><b>Minimum Row:</b> Tests lower bounds, negative limits, and minimum string lengths. | ||
| * <li><b>Maximum Row:</b> Tests upper bounds, large text/blob limits, and maximum string sizes. | ||
| * </ul> | ||
| */ | ||
| @Category({TemplateIntegrationTest.class, SkipDirectRunnerTest.class}) | ||
| @RunWith(JUnit4.class) | ||
| @TemplateIntegrationTest(GCSSpannerDV.class) | ||
| public class BulkMigrationAndValidationOracleAllDataTypesE2EIT extends EndToEndTestingITBase { | ||
|
|
||
| private static final String SPANNER_DDL_RESOURCE = | ||
| "BulkMigrationAndValidationOracleAllDataTypesE2EIT/spanner-schema.sql"; | ||
| private static final String ORACLE_DDL_RESOURCE = | ||
| "BulkMigrationAndValidationOracleAllDataTypesE2EIT/oracle-schema.sql"; | ||
|
|
||
| private CloudOracleResourceManager oracleResourceManager; | ||
| private TimeZone originalTimeZone; | ||
|
|
||
| @Before | ||
| public void setUp() throws IOException { | ||
| originalTimeZone = TimeZone.getDefault(); | ||
| TimeZone.setDefault(TimeZone.getTimeZone("UTC")); | ||
| oracleResourceManager = CloudOracleResourceManager.builder(testName).build(); | ||
| spannerResourceManager = setUpSpannerResourceManager(); | ||
| bigQueryResourceManager = setUpBigQueryResourceManager(); | ||
| bigQueryResourceManager.createDataset(REGION); | ||
| } | ||
|
|
||
| @After | ||
| public void tearDown() { | ||
| if (originalTimeZone != null) { | ||
| TimeZone.setDefault(originalTimeZone); | ||
| } | ||
| ResourceManagerUtils.cleanResources( | ||
| oracleResourceManager, flexTemplateDataflowJobResourceManager); | ||
| // Spanner and BigQuery are automatically cleaned up in tearDownBase() | ||
| } | ||
|
|
||
| @Test | ||
| public void allDataTypesE2E() throws Exception { | ||
| /* | ||
| * Creates a table and inserts 4 boundary testing rows (Standard, NULL, Minimum, Maximum). | ||
| */ | ||
| executeSqlScript(oracleResourceManager, ORACLE_DDL_RESOURCE); | ||
| createSpannerDDL(spannerResourceManager, SPANNER_DDL_RESOURCE); | ||
|
|
||
| // 2. Launch Bulk Pipeline (SourceDbToSpanner) | ||
| String gcsOutputDirectory = "gs://" + artifactBucketName + "/" + testId; | ||
|
|
||
| // Launch Bulk Pipeline (SourceDbToSpanner) | ||
| LaunchInfo bulkJobInfo = | ||
| launchBulkDataflowJob( | ||
| testName, spannerResourceManager, gcsClient, oracleResourceManager, null, false); | ||
| assertThatPipeline(bulkJobInfo).isRunning(); | ||
| pipelineOperator().waitUntilDone(createConfig(bulkJobInfo)); | ||
|
|
||
| // 3. Assert on spanner rows to verify the bulk job was actually successful | ||
| assertThat(spannerResourceManager.getRowCount("AllDatatypes")).isEqualTo(4L); | ||
|
|
||
| // 4. Launch Validation Pipeline (GCSSpannerDV) | ||
| LaunchConfig.Builder dvOptions = LaunchConfig.builder(testName, specPath); | ||
| LaunchInfo validationJobInfo = | ||
| launchDataflowJob( | ||
| dvOptions, | ||
| testName, | ||
| PROJECT, | ||
| spannerResourceManager, | ||
| bigQueryResourceManager.getDatasetId(), | ||
| gcsOutputDirectory, | ||
| null, | ||
| null, | ||
| null, | ||
| null, | ||
| null, | ||
| null); | ||
|
|
||
| assertThatPipeline(validationJobInfo).isRunning(); | ||
| pipelineOperator().waitUntilDone(createConfig(validationJobInfo)); | ||
|
|
||
| // 5. Assert BigQuery Validation Results (Expect PERFECT MATCH) | ||
| GCSSpannerDVTestAsserts.assertValidationSummary( | ||
| bigQueryResourceManager, | ||
| Collections.singletonList( | ||
| new ValidationSummaryDto( | ||
| /* status= */ "MATCH", | ||
| /* totalTablesValidated= */ 1L, | ||
| /* totalRowsMatched= */ 4L, | ||
| /* totalRowsMismatched= */ 0L, | ||
| /* tablesWithMismatches= */ ""))); | ||
|
|
||
| GCSSpannerDVTestAsserts.assertTableValidationStats( | ||
| bigQueryResourceManager, | ||
| Collections.singletonList( | ||
| new TableValidationStatsDto( | ||
| /* schemaName= */ null, | ||
| /* tableName= */ "AllDatatypes", | ||
| /* status= */ "MATCH", | ||
| /* sourceRowCount= */ 4L, | ||
| /* destinationRowCount= */ 4L, | ||
| /* matchedRowCount= */ 4L, | ||
| /* mismatchRowCount= */ 0L))); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.