Skip to content
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

Bigquery multitable e2e fix #1463

Closed
wants to merge 1 commit into from
Closed
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 @@ -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 Down Expand Up @@ -46,7 +47,7 @@ public void validateDataTransferredFromBigQueryToBigQueryMultiTableIsEqual()
public void validateDataTransferredFromBigQueryToBigQueryMultiTableInOneTableIsEqual()
throws IOException, InterruptedException {
boolean recordsMatched = BigQueryMultiTableValidation.
validateBQToBigQueryMultiTable(Collections.singletonList(PluginPropertyUtils.pluginProp("bqSourceTable")),
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 @@ -1604,35 +1604,15 @@ 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 = 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 +1626,44 @@ 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());
}
}
}
}
Loading