diff --git a/src/e2e-test/features/bigquery/multitablesink/BigQueryMultiTableAdditional.feature b/src/e2e-test/features/bigquery/multitablesink/BigQueryMultiTableAdditional.feature index d035dc8c6a..16df401b41 100644 --- a/src/e2e-test/features/bigquery/multitablesink/BigQueryMultiTableAdditional.feature +++ b/src/e2e-test/features/bigquery/multitablesink/BigQueryMultiTableAdditional.feature @@ -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" @@ -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" @@ -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" @@ -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" diff --git a/src/e2e-test/java/io/cdap/plugin/bigquery/runners/sinkrunner/TestRunner.java b/src/e2e-test/java/io/cdap/plugin/bigquery/runners/sinkrunner/TestRunner.java index b6085ccb1e..23d3955010 100644 --- a/src/e2e-test/java/io/cdap/plugin/bigquery/runners/sinkrunner/TestRunner.java +++ b/src/e2e-test/java/io/cdap/plugin/bigquery/runners/sinkrunner/TestRunner.java @@ -27,7 +27,7 @@ features = {"src/e2e-test/features"}, glue = {"io.cdap.plugin.bigquery.stepsdesign", "io.cdap.plugin.gcs.stepsdesign", "stepsdesign", "io.cdap.plugin.common.stepsdesign"}, - tags = {"@BigQuery_Sink and not @CDAP-20830"}, + tags = {"@BigQuery_Sinkz and not @CDAP-20830"}, //TODO: Enable test once issue is fixed https://cdap.atlassian.net/browse/CDAP-20830 monochrome = true, plugin = {"pretty", "html:target/cucumber-html-report/bigquery-sink", diff --git a/src/e2e-test/java/io/cdap/plugin/bigquery/runners/sourcerunner/TestRunner.java b/src/e2e-test/java/io/cdap/plugin/bigquery/runners/sourcerunner/TestRunner.java index 82893e8733..3332830537 100644 --- a/src/e2e-test/java/io/cdap/plugin/bigquery/runners/sourcerunner/TestRunner.java +++ b/src/e2e-test/java/io/cdap/plugin/bigquery/runners/sourcerunner/TestRunner.java @@ -27,7 +27,7 @@ features = {"src/e2e-test/features"}, glue = {"io.cdap.plugin.bigquery.stepsdesign", "io.cdap.plugin.gcs.stepsdesign", "stepsdesign", "io.cdap.plugin.common.stepsdesign", "io.cdap.plugin.pubsub.stepsdesign"}, - tags = {"@BigQuery_Source"}, + tags = {"@BigQuery_Sourcez"}, monochrome = true, plugin = {"pretty", "html:target/cucumber-html-report/bigquery-source", "json:target/cucumber-reports/cucumber-bigquery-source.json", diff --git a/src/e2e-test/java/io/cdap/plugin/bigquery/stepsdesign/BigQueryMultiTable.java b/src/e2e-test/java/io/cdap/plugin/bigquery/stepsdesign/BigQueryMultiTable.java index d6c877c38d..5adb6cf092 100644 --- a/src/e2e-test/java/io/cdap/plugin/bigquery/stepsdesign/BigQueryMultiTable.java +++ b/src/e2e-test/java/io/cdap/plugin/bigquery/stepsdesign/BigQueryMultiTable.java @@ -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; @@ -35,8 +36,7 @@ public void validateDataTransferredFromBigQueryToBigQueryMultiTableIsEqual() List sourceTables = Arrays.asList(PluginPropertyUtils.pluginProp("bqSourceTable"), PluginPropertyUtils.pluginProp("bqSourceTable2")); - List targetTables = Arrays.asList(PluginPropertyUtils.pluginProp("bqTargetTable"), - PluginPropertyUtils.pluginProp("bqTargetTable2")); + List targetTables = Arrays.asList(TestSetupHooks.bqmtTargetTable, TestSetupHooks.bqmtTargetTable2); 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); @@ -46,8 +46,8 @@ 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(TestSetupHooks.bqmtTargetTable)); Assert.assertTrue("Value of records transferred to the BQ sink should be equal to the value " + "of the records in the source table", recordsMatched); } diff --git a/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java b/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java index 367e9272f3..50b4f62d68 100644 --- a/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java +++ b/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java @@ -65,6 +65,8 @@ public class TestSetupHooks { public static String gcsSourceBucketName = StringUtils.EMPTY; public static String gcsTargetBucketName = StringUtils.EMPTY; public static String bqTargetTable = StringUtils.EMPTY; + public static String bqmtTargetTable = StringUtils.EMPTY; + public static String bqmtTargetTable2 = StringUtils.EMPTY; public static String bqSourceTable = StringUtils.EMPTY; public static String bqSourceTable2 = StringUtils.EMPTY; public static String bqTargetTable2 = StringUtils.EMPTY; @@ -294,16 +296,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; } /** @@ -1554,20 +1556,22 @@ 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"); - io.cdap.e2e.utils.BigQueryClient.getSoleQueryResult("create table `" + datasetName + "." + bqTargetTable + "` " + + bqmtTargetTable = PluginPropertyUtils.pluginProp("bqmtTargetTable"); + bqmtTargetTable2 = PluginPropertyUtils.pluginProp("bqmtTargetTable2"); + io.cdap.e2e.utils.BigQueryClient.getSoleQueryResult("create table `" + datasetName + "." + bqmtTargetTable + "` " + "(ID INT64, tablename STRING," + "Price FLOAT64, Customer_Exists BOOL ) "); - io.cdap.e2e.utils.BigQueryClient.getSoleQueryResult("create table `" + datasetName + "." + bqTargetTable2 + "` " + + io.cdap.e2e.utils.BigQueryClient.getSoleQueryResult("create table `" + datasetName + "." + bqmtTargetTable + "` " + "(ID INT64, tablename STRING," + "Price FLOAT64, Customer_Exists BOOL ) "); - PluginPropertyUtils.addPluginProp("bqTargetTable", bqTargetTable); - PluginPropertyUtils.addPluginProp("bqTargetTable2", bqTargetTable2); + PluginPropertyUtils.addPluginProp("bqmtTargetTable", bqmtTargetTable); + PluginPropertyUtils.addPluginProp("bqmtTargetTable2", bqmtTargetTable2); + BeforeActions.scenario.write("BQ Target table - " + bqmtTargetTable + " created successfully"); + BeforeActions.scenario.write("BQ Target table2 - " + bqmtTargetTable2 + " created successfully"); } @Before(order = 1, value = "@BQ_SOURCE_UPDATE_TEST") public static void createSourceTables() throws IOException, InterruptedException { @@ -1602,48 +1606,87 @@ public static void createSourceTables() throws IOException, InterruptedException PluginPropertyUtils.addPluginProp("bqSourceTable", bqSourceTable); PluginPropertyUtils.addPluginProp("bqSourceTable2", bqSourceTable2); + BeforeActions.scenario.write("BQ Source table - " + bqSourceTable + " created successfully"); + BeforeActions.scenario.write("BQ Source table2 - " + bqSourceTable2 + " created successfully"); + } + +// @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 { + bqmtTargetTable = PluginPropertyUtils.pluginProp("bqmtTargetTable"); + BigQueryClient.dropBqQuery(bqmtTargetTable); + BeforeActions.scenario.write("BQ Target table - " + bqmtTargetTable + " deleted successfully"); + } catch (BigQueryException e) { + if (e.getMessage().contains("Not found: Table")) { + BeforeActions.scenario.write("BQ Target Table " + bqmtTargetTable + " does not exist"); + } else { + Assert.fail(e.getMessage()); + } + } } - @After(order = 1, value = "@BQ_DELETE_TABLES_TEST") - public static void deleteAllBqTables() throws IOException, InterruptedException { - BigQueryClient.dropBqQuery(bqSourceTable); + @After(order = 1, value = "@BQ_SECONDARY_RECORD_SOURCE_TEST") + public static void deleteTempSource2BQTable() throws IOException, InterruptedException { BigQueryClient.dropBqQuery(bqSourceTable2); - bqTargetTable = PluginPropertyUtils.pluginProp("bqTargetTable"); - bqTargetTable2 = PluginPropertyUtils.pluginProp("bqTargetTable2"); - BigQueryClient.dropBqQuery(bqTargetTable); - BigQueryClient.dropBqQuery(bqTargetTable2); - PluginPropertyUtils.removePluginProp("bqSourceTable"); + bqSourceTable2 = PluginPropertyUtils.pluginProp("bqSourceTable2"); 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") - public static void deleteTargetBqmtTable() throws IOException, InterruptedException { + @After(order = 2, value = "@BQ_TWO_SOURCE_BQMT_TEST or @BQ_SOURCE_UPDATE_TEST") + public static void deleteTwoSourceTables() throws IOException, InterruptedException { try { - bqTargetTable = PluginPropertyUtils.pluginProp("bqTargetTable"); - BigQueryClient.dropBqQuery(bqTargetTable); BigQueryClient.dropBqQuery(bqSourceTable); - BeforeActions.scenario.write("BQ Target table - " + bqTargetTable + " deleted successfully"); + BigQueryClient.dropBqQuery(bqSourceTable2); BeforeActions.scenario.write("BQ Source table - " + bqSourceTable + " deleted successfully"); - bqTargetTable = StringUtils.EMPTY; + 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 Target Table " + bqTargetTable + " does not exist"); 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 = 1, value = "@BQ_SECONDARY_RECORD_SOURCE_TEST") - public static void deleteTempSource2BQTable() throws IOException, InterruptedException { - BigQueryClient.dropBqQuery(bqSourceTable2); - bqSourceTable2 = PluginPropertyUtils.pluginProp("bqSourceTable2"); - PluginPropertyUtils.removePluginProp("bqSourceTable2"); - BeforeActions.scenario.write("BQ source Table2 " + bqSourceTable2 + " deleted successfully"); + @After(order = 2, value = "@BQ_TWO_SINK_BQMT_TEST") + public static void deleteTwoTargetTables() throws IOException, InterruptedException { + try { + bqmtTargetTable = PluginPropertyUtils.pluginProp("bqmtTargetTable"); + bqmtTargetTable2 = PluginPropertyUtils.pluginProp("bqmtTargetTable2"); + BigQueryClient.dropBqQuery(bqmtTargetTable); + BigQueryClient.dropBqQuery(bqmtTargetTable2); + BeforeActions.scenario.write("BQ Target table - " + bqmtTargetTable + " deleted successfully"); + BeforeActions.scenario.write("BQ Target table2 - " + bqmtTargetTable2 + " deleted successfully"); + + } catch (BigQueryException e) { + if (e.getMessage().contains("Not found: Table")) { + BeforeActions.scenario.write("BQ Target Table " + bqmtTargetTable + " does not exist"); + BeforeActions.scenario.write("BQ Target Table2 " + bqmtTargetTable2 + " does not exist"); + } else { + Assert.fail(e.getMessage()); + } + } } + } diff --git a/src/e2e-test/resources/pluginParameters.properties b/src/e2e-test/resources/pluginParameters.properties index e17200842b..aae33e0e89 100644 --- a/src/e2e-test/resources/pluginParameters.properties +++ b/src/e2e-test/resources/pluginParameters.properties @@ -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 @@ -350,8 +350,10 @@ dsExpectedFile=testdata/BQValidationExpectedFiles/datastoreexpectedfile ## BQMT-PLUGIN-PROPERTIES-START bqmtCreateTableQueryFile=testdata/BigQuery/BqmtCreateTableQuery.txt bqmtInsertDataQueryFile=testdata/BigQuery/BqmtInsertDataQuery.txt -bqTargetTable=tabA -bqTargetTable2=tabB +bqTargetTable=dummy +bqTargetTable2=dummy +bqmtTargetTable=tabA +bqmtTargetTable2=tabB ## BQMT-PLUGIN-PROPERTIES-END ##CLOUDBIGTABLE-PLUGIN-PROPERTIES-START