Skip to content

Commit

Permalink
bqmt fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psainics authored and AnkitCLI committed Nov 27, 2024
1 parent 601f62b commit d6c1956
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@BigQueryMultiTable_Sink
Feature: BigQueryMultiTable sink -Verification of BigQuery to BigQueryMultiTable successful data transfer

@BQ_TWO_SOURCE_BQMT_TEST @BQ_DELETE_TABLES_TEST
@BQ_TWO_SOURCE_BQMT_TEST @BQ_TWO_SINK_BQMT_TEST
Scenario: Verify data successfully transferred from BigQuery To BigQueryMultiTable in two new tables
Given Open Datafusion Project to configure pipeline
When Expand Plugin group in the LHS plugins list: "Source"
Expand Down Expand Up @@ -89,7 +89,7 @@ Feature: BigQueryMultiTable sink -Verification of BigQuery to BigQueryMultiTable
Then Verify the pipeline status is "Succeeded"
Then Validate data transferred from BigQuery To BigQueryMultiTable in one table is equal

@BQ_TWO_SOURCE_BQMT_TEST @BQ_EXISTING_TARGET_TEST @BQ_DELETE_TABLES_TEST
@BQ_TWO_SOURCE_BQMT_TEST @BQ_EXISTING_TARGET_TEST @BQ_TWO_SINK_BQMT_TEST
Scenario: Verify data successfully transferred from BigQuery To BigQueryMultiTable in two existing tables
Given Open Datafusion Project to configure pipeline
When Expand Plugin group in the LHS plugins list: "Source"
Expand Down Expand Up @@ -131,7 +131,7 @@ Feature: BigQueryMultiTable sink -Verification of BigQuery to BigQueryMultiTable
Then Verify the pipeline status is "Succeeded"
Then Validate data transferred from BigQuery To BigQueryMultiTable is equal

@BQ_TWO_SOURCE_BQMT_TEST @BQ_EXISTING_TARGET_TEST @BQ_DELETE_TABLES_TEST
@BQ_TWO_SOURCE_BQMT_TEST @BQ_EXISTING_TARGET_TEST @BQ_TWO_SINK_BQMT_TEST
Scenario: Verify data successfully transferred from BigQuery To BigQueryMultiTable in two existing tables using truncate
Given Open Datafusion Project to configure pipeline
When Expand Plugin group in the LHS plugins list: "Source"
Expand Down Expand Up @@ -174,7 +174,7 @@ Feature: BigQueryMultiTable sink -Verification of BigQuery to BigQueryMultiTable
Then Verify the pipeline status is "Succeeded"
Then Validate data transferred from BigQuery To BigQueryMultiTable is equal

@BQ_SOURCE_UPDATE_TEST @BQ_EXISTING_TARGET_TEST @BQ_DELETE_TABLES_TEST
@BQ_SOURCE_UPDATE_TEST @BQ_EXISTING_TARGET_TEST @BQ_TWO_SINK_BQMT_TEST
Scenario: Verify data successfully transferred from BigQuery To BigQueryMultiTable in two existing tables after updating schema
Given Open Datafusion Project to configure pipeline
When Expand Plugin group in the LHS plugins list: "Source"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.cdap.plugin.bigquery.stepsdesign;

import io.cdap.e2e.utils.PluginPropertyUtils;
import io.cdap.plugin.common.stepsdesign.TestSetupHooks;
import io.cucumber.java.en.Then;
import org.junit.Assert;

Expand All @@ -36,7 +37,7 @@ public void validateDataTransferredFromBigQueryToBigQueryMultiTableIsEqual()
PluginPropertyUtils.pluginProp("bqSourceTable2"));

List<String> targetTables = Arrays.asList(PluginPropertyUtils.pluginProp("bqTargetTable"),
PluginPropertyUtils.pluginProp("bqTargetTable2"));
PluginPropertyUtils.pluginProp("bqTargetTable2"));
boolean recordsMatched = BigQueryMultiTableValidation.validateBQToBigQueryMultiTable(sourceTables, targetTables);
Assert.assertTrue("Value of records transferred to the BQ sink should be equal to the value " +
"of the records in the source table", recordsMatched);
Expand All @@ -46,8 +47,9 @@ public void validateDataTransferredFromBigQueryToBigQueryMultiTableIsEqual()
public void validateDataTransferredFromBigQueryToBigQueryMultiTableInOneTableIsEqual()
throws IOException, InterruptedException {
boolean recordsMatched = BigQueryMultiTableValidation.
validateBQToBigQueryMultiTable(Collections.singletonList(PluginPropertyUtils.pluginProp("bqSourceTable")),
Collections.singletonList(PluginPropertyUtils.pluginProp("bqTargetTable")));
validateBQToBigQueryMultiTable(Collections.singletonList(TestSetupHooks.bqSourceTable),
Collections.singletonList(PluginPropertyUtils.pluginProp
("bqTargetTable")));
Assert.assertTrue("Value of records transferred to the BQ sink should be equal to the value " +
"of the records in the source table", recordsMatched);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,16 @@ public static void createTempSourceBQTable() throws IOException, InterruptedExce
BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " created successfully");
}

@After(order = 1, value = "@BQ_SOURCE_TEST or @BQ_PARTITIONED_SOURCE_TEST or @BQ_SOURCE_DATATYPE_TEST or " +
@After(order = 2, value = "@BQ_SOURCE_TEST or @BQ_PARTITIONED_SOURCE_TEST or @BQ_SOURCE_DATATYPE_TEST or " +
"@BQ_INSERT_SOURCE_TEST or @BQ_UPDATE_SINK_TEST or @BQ_EXISTING_SOURCE_TEST or @BQ_EXISTING_SINK_TEST or " +
"@BQ_EXISTING_SOURCE_DATATYPE_TEST or @BQ_EXISTING_SINK_DATATYPE_TEST or @BQ_UPSERT_SOURCE_TEST or " +
"@BQ_NULL_MODE_SOURCE_TEST or @BQ_UPDATE_SOURCE_DEDUPE_TEST or @BQ_INSERT_INT_SOURCE_TEST or " +
"@BQ_TIME_SOURCE_TEST or @BQ_UPSERT_DEDUPE_SOURCE_TEST or @BQ_PRIMARY_RECORD_SOURCE_TEST")
"@BQ_TIME_SOURCE_TEST or @BQ_UPSERT_DEDUPE_SOURCE_TEST or @BQ_PRIMARY_RECORD_SOURCE_TEST or " +
"@BQ_SINGLE_SOURCE_BQMT_TEST")
public static void deleteTempSourceBQTable() throws IOException, InterruptedException {
BigQueryClient.dropBqQuery(bqSourceTable);
PluginPropertyUtils.removePluginProp("bqSourceTable");
BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " deleted successfully");
bqSourceTable = StringUtils.EMPTY;
}

/**
Expand Down Expand Up @@ -1554,7 +1554,7 @@ public static void emptyExistingBigTableInstanceAndTableName() {
bigtableExistingTargetTable = StringUtils.EMPTY;
}

@Before(order = 1, value = "@BQ_EXISTING_TARGET_TEST")
@Before(order = 2, value = "@BQ_EXISTING_TARGET_TEST")
public static void createSinkTables() throws IOException, InterruptedException {
bqTargetTable = PluginPropertyUtils.pluginProp("bqTargetTable");
bqTargetTable2 = PluginPropertyUtils.pluginProp("bqTargetTable2");
Expand Down Expand Up @@ -1604,35 +1604,31 @@ public static void createSourceTables() throws IOException, InterruptedException
PluginPropertyUtils.addPluginProp("bqSourceTable2", bqSourceTable2);
}

@After(order = 1, value = "@BQ_DELETE_TABLES_TEST")
public static void deleteAllBqTables() throws IOException, InterruptedException {
BigQueryClient.dropBqQuery(bqSourceTable);
BigQueryClient.dropBqQuery(bqSourceTable2);
bqTargetTable = PluginPropertyUtils.pluginProp("bqTargetTable");
bqTargetTable2 = PluginPropertyUtils.pluginProp("bqTargetTable2");
BigQueryClient.dropBqQuery(bqTargetTable);
BigQueryClient.dropBqQuery(bqTargetTable2);
PluginPropertyUtils.removePluginProp("bqSourceTable");
PluginPropertyUtils.removePluginProp("bqSourceTable2");
BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " deleted successfully");
BeforeActions.scenario.write("BQ source Table2 " + bqSourceTable2 + " deleted successfully");
BeforeActions.scenario.write("BQ target Table " + bqTargetTable + " deleted successfully");
BeforeActions.scenario.write("BQ target Table2 " + bqTargetTable2 + " deleted successfully");
}

@After(order = 1, value = "@BQ_SINK_BQMT_TEST")
// @After(order = 1, value = "@BQ_DELETE_TABLES_TEST")
// public static void deleteAllBqTables() throws IOException, InterruptedException {
// BigQueryClient.dropBqQuery(bqSourceTable);
// BigQueryClient.dropBqQuery(bqSourceTable2);
// bqTargetTable = PluginPropertyUtils.pluginProp("bqTargetTable");
// bqTargetTable2 = PluginPropertyUtils.pluginProp("bqTargetTable2");
// BigQueryClient.dropBqQuery(bqTargetTable);
// BigQueryClient.dropBqQuery(bqTargetTable2);
// PluginPropertyUtils.removePluginProp("bqSourceTable");
// PluginPropertyUtils.removePluginProp("bqSourceTable2");
// BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " deleted successfully");
// BeforeActions.scenario.write("BQ source Table2 " + bqSourceTable2 + " deleted successfully");
// BeforeActions.scenario.write("BQ target Table " + bqTargetTable + " deleted successfully");
// BeforeActions.scenario.write("BQ target Table2 " + bqTargetTable2 + " deleted successfully");
// }

@After(order = 2, value = "@BQ_SINK_BQMT_TEST")
public static void deleteTargetBqmtTable() throws IOException, InterruptedException {
try {
bqTargetTable = PluginPropertyUtils.pluginProp("bqTargetTable");
BigQueryClient.dropBqQuery(bqTargetTable);
BigQueryClient.dropBqQuery(bqSourceTable);
BeforeActions.scenario.write("BQ Target table - " + bqTargetTable + " deleted successfully");
BeforeActions.scenario.write("BQ Source table - " + bqSourceTable + " deleted successfully");
bqTargetTable = StringUtils.EMPTY;
} catch (BigQueryException e) {
if (e.getMessage().contains("Not found: Table")) {
BeforeActions.scenario.write("BQ Target Table " + bqTargetTable + " does not exist");
BeforeActions.scenario.write("BQ Source Table " + bqSourceTable + " does not exist");
} else {
Assert.fail(e.getMessage());
}
Expand All @@ -1646,4 +1642,45 @@ public static void deleteTempSource2BQTable() throws IOException, InterruptedExc
PluginPropertyUtils.removePluginProp("bqSourceTable2");
BeforeActions.scenario.write("BQ source Table2 " + bqSourceTable2 + " deleted successfully");
}

@After(order = 2, value = "@BQ_TWO_SOURCE_BQMT_TEST or @BQ_SOURCE_UPDATE_TEST")
public static void deleteTwoSourceTables() throws IOException, InterruptedException {
try {
BigQueryClient.dropBqQuery(bqSourceTable);
BigQueryClient.dropBqQuery(bqSourceTable2);
BeforeActions.scenario.write("BQ Source table - " + bqSourceTable + " deleted successfully");
BeforeActions.scenario.write("BQ Source table2 - " + bqSourceTable2 + " deleted successfully");
PluginPropertyUtils.removePluginProp("bqSourceTable");
PluginPropertyUtils.removePluginProp("bqSourceTable2");

} catch (BigQueryException e) {
if (e.getMessage().contains("Not found: Table")) {
BeforeActions.scenario.write("BQ Source Table " + bqSourceTable + " does not exist");
BeforeActions.scenario.write("BQ Source Table2 " + bqSourceTable2 + " does not exist");
} else {
Assert.fail(e.getMessage());
}
}
}

@After(order = 2, value = "@BQ_TWO_SINK_BQMT_TEST")
public static void deleteTwoTargetTables() throws IOException, InterruptedException {
try {
bqTargetTable = PluginPropertyUtils.pluginProp("bqTargetTable");
bqTargetTable2 = PluginPropertyUtils.pluginProp("bqTargetTable2");
BigQueryClient.dropBqQuery(bqTargetTable);
BigQueryClient.dropBqQuery(bqTargetTable2);
BeforeActions.scenario.write("BQ Target table - " + bqTargetTable + " deleted successfully");
BeforeActions.scenario.write("BQ Target table2 - " + bqTargetTable2 + " deleted successfully");

} catch (BigQueryException e) {
if (e.getMessage().contains("Not found: Table")) {
BeforeActions.scenario.write("BQ Target Table " + bqTargetTable + " does not exist");
BeforeActions.scenario.write("BQ Target Table2 " + bqTargetTable2 + " does not exist");
} else {
Assert.fail(e.getMessage());
}
}
}

}
2 changes: 1 addition & 1 deletion src/e2e-test/resources/pluginParameters.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
projectId=cdf-athena
datasetprojectId=cdf-athena
dataset=testing_bqmt
dataset=testbq_bqmt
wrongSourcePath=gs://00000000-e2e-0014a44f-81be-4501-8360-0ddca192492
serviceAccountType=filePath
serviceAccount=auto-detect
Expand Down

0 comments on commit d6c1956

Please sign in to comment.