From 8681acf8b667ac23d810f1c4b1f79ead6635cd85 Mon Sep 17 00:00:00 2001 From: suryakumari Date: Wed, 5 Jul 2023 16:16:48 +0530 Subject: [PATCH] Fix MySQL E2E test hooks --- .../features/mysqlsink/DesignTime.feature | 6 +- .../mysqlsink/DesignTimeValidation.feature | 10 ++-- .../mysqlsink/DesignTimeWithMacros.feature | 4 +- .../features/mysqlsink/RunTime.feature | 4 +- .../mysqlsink/RunTimeWithMacros.feature | 2 +- .../features/mysqlsource/Datatypes.feature | 4 +- .../features/mysqlsource/MySql.feature | 2 +- .../features/mysqlsource/RunTime.feature | 6 +- .../mysqlsource/RunTimeWithMacros.feature | 8 +-- .../common/stepsdesign/TestSetupHooks.java | 59 ++++++++++++++++--- 10 files changed, 73 insertions(+), 32 deletions(-) diff --git a/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTime.feature b/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTime.feature index 008a8e4dc..4041fafb8 100644 --- a/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTime.feature +++ b/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTime.feature @@ -15,7 +15,7 @@ @Mysql Feature: MySQL Sink - Design time scenarios - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify user can validate successfully when sink plugin is configured for table with basic details Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Sink" @@ -31,7 +31,7 @@ Feature: MySQL Sink - Design time scenarios Then Enter input plugin property: "referenceName" with value: "targetRef" Then Validate "MySQL2" plugin properties - @MYSQL_SOURCE_TEST @CONNECTION @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_TARGET_TEST @CONNECTION @Mysql_Required Scenario: Verify the MySQL Sink plugin using connection manager functionality Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Sink" @@ -58,7 +58,7 @@ Feature: MySQL Sink - Design time scenarios Then Validate "MySQL" plugin properties Then Close the Plugin Properties page - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify user should be able to validate sink plugin successfully by setting the advanced section fields Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Sink" diff --git a/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTimeValidation.feature b/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTimeValidation.feature index 26e80bd39..839752ae9 100644 --- a/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTimeValidation.feature +++ b/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTimeValidation.feature @@ -15,7 +15,7 @@ @Mysql Feature: MySQL Sink - Design time validation scenarios - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify Database field validation error message with invalid test data Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -46,7 +46,7 @@ Feature: MySQL Sink - Design time validation scenarios Then Click on the Validate button Then Verify that the Plugin is displaying an error message: "invalid.sink.database.message" on the header - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify Table Name Field validation error message with invalid test data Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -77,7 +77,7 @@ Feature: MySQL Sink - Design time validation scenarios Then Click on the Validate button Then Verify that the Plugin Property: "tableName" is displaying an in-line error message: "invalidtableName.error.message" - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify Reference Name field validation error message with invalid test data Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -108,7 +108,7 @@ Feature: MySQL Sink - Design time validation scenarios Then Click on the Validate button Then Verify that the Plugin Property: "referenceName" is displaying an in-line error message: "invalidreferenceName.error.message" - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify the Username field validation error message with blank value Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -138,7 +138,7 @@ Feature: MySQL Sink - Design time validation scenarios Then Click on the Validate button Then Verify that the Plugin Property: "user" is displaying an in-line error message: "blank.username.message" - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify the host validation error message with blank value Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" diff --git a/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTimeWithMacros.feature b/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTimeWithMacros.feature index ddc7cfb14..93ba3ac68 100644 --- a/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTimeWithMacros.feature +++ b/mysql-plugin/src/e2e-test/features/mysqlsink/DesignTimeWithMacros.feature @@ -15,7 +15,7 @@ @Mysql Feature: MySQL Sink - Design time scenarios (macro) - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify user should be able to validate sink plugin with macros for Connection section Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -45,7 +45,7 @@ Feature: MySQL Sink - Design time scenarios (macro) Then Replace input plugin property: "tableName" with value: "targetTable" Then Click on the Validate button - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify user should be able to validate sink plugin with macros for Basic section Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" diff --git a/mysql-plugin/src/e2e-test/features/mysqlsink/RunTime.feature b/mysql-plugin/src/e2e-test/features/mysqlsink/RunTime.feature index 2bcca67c2..833b6b946 100644 --- a/mysql-plugin/src/e2e-test/features/mysqlsink/RunTime.feature +++ b/mysql-plugin/src/e2e-test/features/mysqlsink/RunTime.feature @@ -55,7 +55,7 @@ Feature: MySQL Sink - Run time scenarios Then Verify the pipeline status is "Succeeded" Then Validate the values of records transferred to target MySQL table is equal to the values from source BigQuery table - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: To verify data is getting transferred from Mysql to Mysql successfully Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -100,7 +100,7 @@ Feature: MySQL Sink - Run time scenarios Then Verify the pipeline status is "Succeeded" Then Validate the values of records transferred to target table is equal to the values from source table - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: To verify data is getting transferred from Mysql to Mysql successfully when advance section details are set Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" diff --git a/mysql-plugin/src/e2e-test/features/mysqlsink/RunTimeWithMacros.feature b/mysql-plugin/src/e2e-test/features/mysqlsink/RunTimeWithMacros.feature index 233226ea4..0c4a5995e 100644 --- a/mysql-plugin/src/e2e-test/features/mysqlsink/RunTimeWithMacros.feature +++ b/mysql-plugin/src/e2e-test/features/mysqlsink/RunTimeWithMacros.feature @@ -65,7 +65,7 @@ Feature: MySQL Sink - Run time scenarios (macro) Then Verify the pipeline status is "Succeeded" Then Validate the values of records transferred to target Big Query table is equal to the values from source table - @BQ_SOURCE_TEST @MYSQL_TARGET_TABLE @Mysql_Required + @BQ_SOURCE_TEST @Mysql_Required Scenario: Verify that the pipeline fails when user provides invalid Table Name of plugin with Macros Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" diff --git a/mysql-plugin/src/e2e-test/features/mysqlsource/Datatypes.feature b/mysql-plugin/src/e2e-test/features/mysqlsource/Datatypes.feature index 03421d527..cffeb6d07 100644 --- a/mysql-plugin/src/e2e-test/features/mysqlsource/Datatypes.feature +++ b/mysql-plugin/src/e2e-test/features/mysqlsource/Datatypes.feature @@ -17,7 +17,7 @@ @Mysql Feature: Mysql - Verify Mysql source data transfer for different datatype - @MYSQL_SOURCE_DATATYPES_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_DATATYPES_TEST @MYSQL_TARGET_DATATYPES_TEST @Mysql_Required Scenario: To verify data is getting transferred from Mysql to Mysql successfully Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -61,7 +61,7 @@ Feature: Mysql - Verify Mysql source data transfer for different datatype Then Verify the pipeline status is "Succeeded" Then Validate the values of records transferred to target table is equal to the values from source table - @MYSQL_SOURCE_DATATYPES_TEST @BQ_SINK @Mysql_Required @Plugin-20670 + @MYSQL_SOURCE_DATATYPES_TEST @BQ_SINK @BQ_SINK_CLEANUP @Mysql_Required @Plugin-20670 Scenario: To verify data is getting transferred from Mysql to BigQuery successfully Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" diff --git a/mysql-plugin/src/e2e-test/features/mysqlsource/MySql.feature b/mysql-plugin/src/e2e-test/features/mysqlsource/MySql.feature index c2244174b..ab9c1a9ed 100644 --- a/mysql-plugin/src/e2e-test/features/mysqlsource/MySql.feature +++ b/mysql-plugin/src/e2e-test/features/mysqlsource/MySql.feature @@ -17,7 +17,7 @@ @Mysql Feature: Mysql - Verify Mysql source data transfer - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: To verify data is getting transferred from Mysql to Mysql successfully Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" diff --git a/mysql-plugin/src/e2e-test/features/mysqlsource/RunTime.feature b/mysql-plugin/src/e2e-test/features/mysqlsource/RunTime.feature index 8d5e5a40e..096de1f62 100644 --- a/mysql-plugin/src/e2e-test/features/mysqlsource/RunTime.feature +++ b/mysql-plugin/src/e2e-test/features/mysqlsource/RunTime.feature @@ -60,7 +60,7 @@ Feature: MySQL Source - Run time scenarios Then Validate OUT record count is equal to records transferred to target BigQuery table Then Validate the values of records transferred to target Big Query table is equal to the values from source table - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required @test + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required @test Scenario: To verify data is getting transferred from Mysql to Mysql successfully when advance section details are set Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -105,7 +105,7 @@ Feature: MySQL Source - Run time scenarios Then Verify the pipeline status is "Succeeded" Then Validate the values of records transferred to target table is equal to the values from source table - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify the pipeline fails when plugin is configured with invalid bounding query Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -145,7 +145,7 @@ Feature: MySQL Source - Run time scenarios Then Wait till pipeline preview is in running state Then Verify the preview run status of pipeline in the logs is "failed" - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: To verify data is getting transferred from Mysql to Mysql successfully when connection arguments are set Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" diff --git a/mysql-plugin/src/e2e-test/features/mysqlsource/RunTimeWithMacros.feature b/mysql-plugin/src/e2e-test/features/mysqlsource/RunTimeWithMacros.feature index 88d5b5b41..2ae314de8 100644 --- a/mysql-plugin/src/e2e-test/features/mysqlsource/RunTimeWithMacros.feature +++ b/mysql-plugin/src/e2e-test/features/mysqlsource/RunTimeWithMacros.feature @@ -15,7 +15,7 @@ @Mysql Feature: MySQL Source - Run time scenarios (macro) - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: To verify data is getting transferred from Mysql to Mysql successfully using macros for Connection section Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -68,7 +68,7 @@ Feature: MySQL Source - Run time scenarios (macro) Then Verify the pipeline status is "Succeeded" Then Validate the values of records transferred to target table is equal to the values from source table - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: To verify data is getting transferred from Mysql to Mysql successfully using macros for Basic section Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -166,7 +166,7 @@ Feature: MySQL Source - Run time scenarios (macro) Then Verify the pipeline status is "Succeeded" Then Validate the values of records transferred to target Big Query table is equal to the values from source table - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify that pipeline fails when user provides invalid Table name in importQuery of plugin with Macros Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" @@ -203,7 +203,7 @@ Feature: MySQL Source - Run time scenarios (macro) And Wait till pipeline is in running state And Verify the pipeline status is "Failed" - @MYSQL_SOURCE_TEST @MYSQL_SINK_TEST @Mysql_Required + @MYSQL_SOURCE_TEST @MYSQL_TARGET_TEST @Mysql_Required Scenario: Verify that pipeline fails when user provides invalid Credentials for connection with Macros Given Open Datafusion Project to configure pipeline When Expand Plugin group in the LHS plugins list: "Source" diff --git a/mysql-plugin/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java b/mysql-plugin/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java index 4c7ba05ae..2a86269b5 100644 --- a/mysql-plugin/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java +++ b/mysql-plugin/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java @@ -64,21 +64,59 @@ public static void initializeDBProperties() { } @Before(order = 2, value = "@MYSQL_SOURCE_TEST") - public static void createTables() throws SQLException, ClassNotFoundException { + public static void createSourceTables() throws SQLException, ClassNotFoundException { MysqlClient.createSourceTable(PluginPropertyUtils.pluginProp("sourceTable")); + BeforeActions.scenario.write("MYSQL Source table - " + PluginPropertyUtils.pluginProp("sourceTable") + + " created successfully"); + } + + @Before(order = 2, value = "@MYSQL_TARGET_TEST") + public static void createTargetTables() throws SQLException, ClassNotFoundException { MysqlClient.createTargetTable(PluginPropertyUtils.pluginProp("targetTable")); + BeforeActions.scenario.write("MYSQL Target table - " + PluginPropertyUtils.pluginProp("targetTable") + + " created successfully"); } @Before(order = 2, value = "@MYSQL_SOURCE_DATATYPES_TEST") - public static void createDatatypesTable() throws SQLException, ClassNotFoundException { + public static void createSourceDatatypesTable() throws SQLException, ClassNotFoundException { MysqlClient.createSourceDatatypesTable(PluginPropertyUtils.pluginProp("sourceTable")); + BeforeActions.scenario.write("MYSQL Source Table - " + PluginPropertyUtils.pluginProp("sourceTable") + + " created successfully"); + } + + @Before(order = 2, value = "@MYSQL_TARGET_DATATYPES_TEST") + public static void createTargetDatatypesTable() throws SQLException, ClassNotFoundException { MysqlClient.createTargetDatatypesTable(PluginPropertyUtils.pluginProp("targetTable")); + BeforeActions.scenario.write("MYSQL Target table - " + PluginPropertyUtils.pluginProp("targetTable") + + " created successfully"); } - @After(order = 2, value = "@MYSQL_SINK_TEST") - public static void dropTables() throws SQLException, ClassNotFoundException { - MysqlClient.dropTables(new String[]{PluginPropertyUtils.pluginProp("sourceTable"), - PluginPropertyUtils.pluginProp("targetTable")}); + @After(order = 2, value = "@MYSQL_SOURCE_TEST") + public static void dropSourceTables() throws SQLException, ClassNotFoundException { + MysqlClient.dropTable(PluginPropertyUtils.pluginProp("sourceTable")); + BeforeActions.scenario.write("MYSQL Source Table - " + PluginPropertyUtils.pluginProp("sourceTable") + + " deleted successfully"); + } + + @After(order = 2, value = "@MYSQL_TARGET_TEST") + public static void dropTargetTables() throws SQLException, ClassNotFoundException { + MysqlClient.dropTable(PluginPropertyUtils.pluginProp("targetTable")); + BeforeActions.scenario.write("MYSQL Target table - " + PluginPropertyUtils.pluginProp("targetTable") + + " deleted successfully"); + } + + @After(order = 2, value = "@MYSQL_SOURCE_DATATYPES_TEST") + public static void dropSourceDatatypeTables() throws SQLException, ClassNotFoundException { + MysqlClient.dropTable(PluginPropertyUtils.pluginProp("sourceTable")); + BeforeActions.scenario.write("MYSQL Source Table - " + PluginPropertyUtils.pluginProp("sourceTable") + + " deleted successfully"); + } + + @After(order = 2, value = "@MYSQL_TARGET_DATATYPES_TEST") + public static void dropTargetDatatypeTables() throws SQLException, ClassNotFoundException { + MysqlClient.dropTable(PluginPropertyUtils.pluginProp("targetTable")); + BeforeActions.scenario.write("MYSQL Target table - " + PluginPropertyUtils.pluginProp("targetTable") + + " deleted successfully"); } @Before(order = 1, value = "@BQ_SINK") @@ -103,18 +141,20 @@ public static void deleteTempTargetBQTable() throws IOException, InterruptedExce } } - @Before(order = 1, value = "@MYSQL_TARGET_TABLE") + @Before(order = 2, value = "@MYSQL_TARGET_TABLE") public static void createMysqlTargetTable() throws SQLException, ClassNotFoundException { MysqlClient.createTargetTable1(PluginPropertyUtils.pluginProp("targetTable")); + BeforeActions.scenario.write("MYSQL Target table - " + PluginPropertyUtils.pluginProp("targetTable") + + " created successfully"); } @After(order = 2, value = "@MYSQL_TARGET_TABLE") public static void dropTargetTable() throws SQLException, ClassNotFoundException { MysqlClient.dropTable(PluginPropertyUtils.pluginProp("targetTable")); + BeforeActions.scenario.write("MYSQL Target table - " + PluginPropertyUtils.pluginProp("targetTable") + + " deleted successfully"); } - - /** * Create BigQuery table. */ @@ -173,3 +213,4 @@ public static void setNewConnectionName() { BeforeActions.scenario.write("New Connection name: " + connectionName); } } +