diff --git a/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlDesignTimeValidation.feature b/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlDesignTimeValidation.feature index adf99440c..46355d179 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlDesignTimeValidation.feature +++ b/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlDesignTimeValidation.feature @@ -130,3 +130,66 @@ Feature: CloudMySql sink- Verify CloudsqlMysql sink plugin design time validatio Then Enter input plugin property: "tableName" with value: "mytable" Then Click on the Validate button Then Verify that the Plugin Property: "connectionName" is displaying an in-line error message: "errorMessageConnectionName" + + @CloudMySql_Required + Scenario: Verify CloudSQLMySQL source plugin validation errors for mandatory fields + Given Open Datafusion Project to configure pipeline + When Expand Plugin group in the LHS plugins list: "Sink" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Sink" + Then Navigate to the properties page of plugin: "CloudSQL MySQL" + Then Click on the Validate button + Then Verify mandatory property error for below listed properties: + | jdbcPluginName | + | connectionName | + | database | + | referenceName | + | tableName | + + @CloudMySql_Required + Scenario: To verify CloudSQLMySQL source plugin validation error message with invalid connection name with private instance + Given Open Datafusion Project to configure pipeline + When Expand Plugin group in the LHS plugins list: "Sink" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Sink" + Then Navigate to the properties page of plugin: "CloudSQL MySQL" + Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName" + Then Select radio button plugin property: "instanceType" with value: "private" + Then Enter input plugin property: "connectionName" with value: "invalidConnectionName" + Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields + Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter input plugin property: "database" with value: "TestDatabase" + Then Enter input plugin property: "tableName" with value: "mytable" + Then Click on the Validate button + Then Verify that the Plugin Property: "connectionName" is displaying an in-line error message: "errorMessagePrivateConnectionName" + + @CLOUDMYSQL_SOURCE_TEST @CLOUDMYSQL_TARGET_TEST @CloudMySql_Required + Scenario: To verify CloudMySql sink plugin validation error message with blank password + Given Open Datafusion Project to configure pipeline + When Expand Plugin group in the LHS plugins list: "Source" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Source" + When Expand Plugin group in the LHS plugins list: "Sink" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Sink" + Then Connect plugins: "CloudSQL MySQL" and "CloudSQL MySQL2" to establish connection + Then Navigate to the properties page of plugin: "CloudSQL MySQL" + Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName" + Then Select radio button plugin property: "instanceType" with value: "public" + Then Replace input plugin property: "connectionName" with value: "connectionName" for Credentials and Authorization related fields + Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields + Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter input plugin property: "database" with value: "DatabaseName" + Then Enter textarea plugin property: "importQuery" with value: "selectQuery" + Then Click on the Get Schema button + Then Verify the Output Schema matches the Expected Schema: "datatypesSchema" + Then Validate "CloudSQL MySQL" plugin properties + Then Close the Plugin Properties page + Then Navigate to the properties page of plugin: "CloudSQL MySQL2" + Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName" + Then Select radio button plugin property: "instanceType" with value: "public" + Then Replace input plugin property: "connectionName" with value: "connectionName" for Credentials and Authorization related fields + Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter input plugin property: "database" with value: "DatabaseName" + Then Enter input plugin property: "tableName" with value: "mytable" + Then Click on the Validate button + Then Verify that the Plugin is displaying an error message: "errorMessageWithBlankPassword" on the header diff --git a/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlRunTime.feature b/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlRunTime.feature index e2f1eb1fe..1aaa6175a 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlRunTime.feature +++ b/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlRunTime.feature @@ -148,3 +148,151 @@ Feature: CloudMySql Sink - Run time scenarios Then Verify the pipeline status is "Succeeded" Then Close the pipeline logs Then Validate the values of records transferred to target CloudSQLMySql table is equal to the values from source BigQuery table + + @CLOUDMYSQL_SOURCE_TABLE @CLOUDMYSQL_TARGET_TABLE @CONNECTION @CloudMySql_Required @PLUGIN-1854 + Scenario: To verify data is getting transferred from CloudMySql source to CloudMySql sink successfully with use connection + Given Open Datafusion Project to configure pipeline + When Expand Plugin group in the LHS plugins list: "Source" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Source" + When Expand Plugin group in the LHS plugins list: "Sink" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Sink" + Then Connect plugins: "CloudSQL MySQL" and "CloudSQL MySQL2" to establish connection + Then Navigate to the properties page of plugin: "CloudSQL MySQL" + And Click plugin property: "switch-useConnection" + And Click on the Browse Connections button + And Click on the Add Connection button + Then Click plugin property: "connector-CloudSQLMySQL" + And Enter input plugin property: "name" with value: "connection.name" + Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName" + Then Enter input plugin property with value: "DatabaseName" + Then Select radio button plugin property: "instanceType" with value: "public" + Then Replace input plugin property: "connectionName" with value: "connectionName" for Credentials and Authorization related fields + Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields + Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields + Then Click on the Test Connection button + And Verify the test connection is successful + Then Click on the Create button + Then Select connection: "connection.name" + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter input plugin property: "database" with value: "DatabaseName" + Then Enter textarea plugin property: "importQuery" with value: "selectQuery" + Then Click on the Get Schema button + Then Verify the Output Schema matches the Expected Schema: "CloudMySqlSchema" + Then Validate "CloudSQL MySQL" plugin properties + Then Close the Plugin Properties page + Then Navigate to the properties page of plugin: "CloudSQL MySQL2" + And Click plugin property: "switch-useConnection" + And Click on the Browse Connections button + Then Select connection: "connection.name" + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter input plugin property: "database" with value: "DatabaseName" + Then Replace input plugin property: "tableName" with value: "targetTable" + Then Validate "CloudSQL MySQL" plugin properties + Then Close the Plugin Properties page + Then Save the pipeline + Then Preview and run the pipeline + Then Wait till pipeline preview is in running state + Then Open and capture pipeline preview logs + Then Verify the preview run status of pipeline in the logs is "succeeded" + Then Close the pipeline logs + Then Close the preview + Then Deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Open and capture logs + Then Verify the pipeline status is "Succeeded" + Then Close the pipeline logs + Then Validate the values of records transferred to target table is equal to the values from source table + + @CLOUDMYSQL_SOURCE_TABLE @CLOUDMYSQL_TARGET_TABLE @CloudMySql_Required @PLUGIN-1854 + Scenario: To verify data is getting transferred from CloudMySql source to CloudMySql sink successfully + Given Open Datafusion Project to configure pipeline + When Expand Plugin group in the LHS plugins list: "Source" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Source" + When Expand Plugin group in the LHS plugins list: "Sink" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Sink" + Then Connect plugins: "CloudSQL MySQL" and "CloudSQL MySQL2" to establish connection + Then Navigate to the properties page of plugin: "CloudSQL MySQL" + Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName" + Then Select radio button plugin property: "instanceType" with value: "public" + Then Replace input plugin property: "connectionName" with value: "connectionName" for Credentials and Authorization related fields + Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields + Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter input plugin property: "database" with value: "DatabaseName" + Then Enter textarea plugin property: "importQuery" with value: "selectQuery" + Then Click on the Get Schema button + Then Verify the Output Schema matches the Expected Schema: "CloudMySqlSchema" + Then Validate "CloudSQL MySQL" plugin properties + Then Close the Plugin Properties page + Then Navigate to the properties page of plugin: "CloudSQL MySQL2" + Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName" + Then Select radio button plugin property: "instanceType" with value: "public" + Then Replace input plugin property: "connectionName" with value: "connectionName" for Credentials and Authorization related fields + Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields + Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter input plugin property: "database" with value: "DatabaseName" + Then Replace input plugin property: "tableName" with value: "targetTable" + Then Validate "CloudSQL MySQL2" plugin properties + Then Close the Plugin Properties page + Then Save the pipeline + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Close the preview + Then Deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Open and capture logs + 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 + + @CLOUDSQLMYSQL_SOURCE_TEST @CLOUDSQLMYSQL_TARGET_TEST @CloudMySql_Required + Scenario Outline: To verify data is getting transferred from CloudMySql source to CloudMySql sink successfully with different isolation levels + Given Open Datafusion Project to configure pipeline + When Expand Plugin group in the LHS plugins list: "Source" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Source" + When Expand Plugin group in the LHS plugins list: "Sink" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Sink" + Then Connect plugins: "CloudSQL MySQL" and "CloudSQL MySQL2" to establish connection + Then Navigate to the properties page of plugin: "CloudSQL MySQL" + Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName" + Then Select radio button plugin property: "instanceType" with value: "public" + Then Replace input plugin property: "connectionName" with value: "connectionName" for Credentials and Authorization related fields + Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields + Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter input plugin property: "database" with value: "DatabaseName" + Then Enter textarea plugin property: "importQuery" with value: "selectQuery" + Then Click on the Get Schema button + Then Verify the Output Schema matches the Expected Schema: "outputSourceSchema" + Then Validate "CloudSQL MySQL" plugin properties + Then Close the Plugin Properties page + Then Navigate to the properties page of plugin: "CloudSQL MySQL2" + Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName" + Then Select radio button plugin property: "instanceType" with value: "public" + Then Replace input plugin property: "connectionName" with value: "connectionName" for Credentials and Authorization related fields + Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields + Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter input plugin property: "database" with value: "DatabaseName" + Then Replace input plugin property: "tableName" with value: "targetTable" + Then Select dropdown plugin property: "transactionIsolationLevel" with option value: "" + Then Validate "CloudSQL MySQL2" plugin properties + Then Close the Plugin Properties page + Then Save the pipeline + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Close the preview + Then Deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Open and capture logs + 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 + Examples: + | TransactionIsolationLevels | + | TRANSACTION_REPEATABLE_READ | + | TRANSACTION_READ_UNCOMMITTED | + | TRANSACTION_READ_COMMITTED | + | TRANSACTION_SERIALIZABLE | \ No newline at end of file diff --git a/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlRunTimeMacro.feature b/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlRunTimeMacro.feature index 5ab8b4727..663dd9017 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlRunTimeMacro.feature +++ b/cloudsql-mysql-plugin/src/e2e-test/features/sink/CloudMySqlRunTimeMacro.feature @@ -190,3 +190,66 @@ Feature: CloudMySql Sink - Run time scenarios (macro) | Level | Message | | ERROR | errorLogsMessageInvalidCredentials | + @CLOUDSQLMYSQL_SOURCE_TEST @CLOUDSQLMYSQL_TARGET_TEST @CloudMySql_Required + Scenario: To verify data is getting transferred from CloudMySql to CloudMySql successfully using macro enabled + Given Open Datafusion Project to configure pipeline + When Expand Plugin group in the LHS plugins list: "Source" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Source" + When Expand Plugin group in the LHS plugins list: "Sink" + When Select plugin: "CloudSQL MySQL" from the plugins list as: "Sink" + Then Connect plugins: "CloudSQL MySQL" and "CloudSQL MySQL2" to establish connection + Then Navigate to the properties page of plugin: "CloudSQL MySQL" + Then Select dropdown plugin property: "select-jdbcPluginName" with option value: "driverName" + Then Select radio button plugin property: "instanceType" with value: "public" + Then Replace input plugin property: "connectionName" with value: "connectionName" for Credentials and Authorization related fields + Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields + Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Enter textarea plugin property: "importQuery" with value: "selectQuery" + Then Enter input plugin property: "database" with value: "DatabaseName" + Then Click on the Get Schema button + Then Verify the Output Schema matches the Expected Schema: "outputSourceSchema" + Then Validate "CloudSQL MySQL" plugin properties + Then Close the Plugin Properties page + Then Navigate to the properties page of plugin: "CloudSQL MySQL2" + Then Click on the Macro button of Property: "jdbcPluginName" and set the value to: "cloudSQLMySQLDriverName" + Then Select radio button plugin property: "instanceType" with value: "public" + Then Click on the Macro button of Property: "connectionName" and set the value to: "cloudSQLMySQLConnectionName" + Then Click on the Macro button of Property: "user" and set the value to: "cloudSQLMySQLUsername" + Then Click on the Macro button of Property: "password" and set the value to: "cloudSQLMySQLPassword" + Then Click on the Macro button of Property: "connectionArguments" and set the value to: "connArgumentsSink" + Then Enter input plugin property: "referenceName" with value: "RefName" + Then Click on the Macro button of Property: "database" and set the value to: "cloudSQLMySQLDatabaseName" + Then Click on the Macro button of Property: "tableName" and set the value to: "cloudSQLMySQLTableName" + Then Validate "CloudSQL MySQL2" plugin properties + Then Close the Plugin Properties page + Then Save the pipeline + Then Preview and run the pipeline + Then Enter runtime argument value "driverName" for key "cloudSQLMySQLDriverName" + Then Enter runtime argument value from environment variable "connectionName" for key "cloudSQLMySQLConnectionName" + Then Enter runtime argument value from environment variable "username" for key "cloudSQLMySQLUsername" + Then Enter runtime argument value from environment variable "password" for key "cloudSQLMySQLPassword" + Then Enter runtime argument value "connectionArguments" for key "connArgumentsSink" + Then Enter runtime argument value "DatabaseName" for key "cloudSQLMySQLDatabaseName" + Then Enter runtime argument value "targetTable" for key "cloudSQLMySQLTableName" + Then Run the preview of pipeline with runtime arguments + Then Wait till pipeline preview is in running state + Then Open and capture pipeline preview logs + Then Verify the preview run status of pipeline in the logs is "succeeded" + Then Close the pipeline logs + Then Close the preview + Then Deploy the pipeline + Then Run the Pipeline in Runtime + Then Enter runtime argument value "driverName" for key "cloudSQLMySQLDriverName" + Then Enter runtime argument value from environment variable "connectionName" for key "cloudSQLMySQLConnectionName" + Then Enter runtime argument value from environment variable "username" for key "cloudSQLMySQLUsername" + Then Enter runtime argument value from environment variable "password" for key "cloudSQLMySQLPassword" + Then Enter runtime argument value "connectionArguments" for key "connArgumentsSink" + Then Enter runtime argument value "DatabaseName" for key "cloudSQLMySQLDatabaseName" + Then Enter runtime argument value "targetTable" for key "cloudSQLMySQLTableName" + Then Run the Pipeline in Runtime with runtime arguments + Then Wait till pipeline is in running state + Then Open and capture logs + Then Verify the pipeline status is "Succeeded" + Then Close the pipeline logs + Then Validate the values of records transferred to target table is equal to the values from source table diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/CloudMySqlClient.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/CloudMySqlClient.java index 29ef9faa8..4e35ce45d 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/CloudMySqlClient.java +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/CloudMySqlClient.java @@ -211,4 +211,23 @@ public static void createTargetTestTable(String targetTable) throws SQLException statement.executeUpdate(truncateTargetTableQuery); } } + + public static void createCloudMysqlSourceTable(String sourceTable) throws SQLException, ClassNotFoundException { + try (Connection connect = getCloudSqlConnection(); Statement statement = connect.createStatement()) { + String datatypesColumns = PluginPropertyUtils.pluginProp("CloudMySqlColumns"); + String createSourceTableQuery = "CREATE TABLE " + sourceTable + " " + datatypesColumns; + statement.executeUpdate(createSourceTableQuery); + // Insert dummy data. + String datatypesValues = PluginPropertyUtils.pluginProp("CloudMySqlValue"); + String datatypesColumnsList = PluginPropertyUtils.pluginProp("CloudMySqlColumnsList"); + statement.executeUpdate("INSERT INTO " + sourceTable + " " + datatypesColumnsList + " " + datatypesValues); + } + } + + public static void createCloudMysqlTargetTable(String targetTable) throws SQLException, ClassNotFoundException { + try (Connection connect = getCloudSqlConnection(); Statement statement = connect.createStatement()) { + String createTargetTableQuery = "CREATE TABLE " + targetTable + " " + dataTypesColumns; + statement.executeUpdate(createTargetTableQuery); + } + } } diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/actions/CloudSQLMySQLActions.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/actions/CloudSQLMySQLActions.java new file mode 100644 index 000000000..39b28cb25 --- /dev/null +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/actions/CloudSQLMySQLActions.java @@ -0,0 +1,30 @@ +/* + * Copyright © 2025 Cask Data, Inc. + * + * 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 io.cdap.plugin.cloudmysql.actions; +import io.cdap.e2e.utils.ElementHelper; +import io.cdap.e2e.utils.SeleniumHelper; +import io.cdap.plugin.cloudmysql.locators.CloudSQLMySQLLocators; +/** + * ClouSQLMySQL Connection - Properties page - Actions. + */ +public class CloudSQLMySQLActions { + static { + SeleniumHelper.getPropertiesLocators(CloudSQLMySQLLocators.class); + } + public static void enterValueInInputProperty(String database) { + ElementHelper.sendKeys(CloudSQLMySQLLocators.database, database); + } +} diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/actions/package-info.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/actions/package-info.java new file mode 100644 index 000000000..fc3627674 --- /dev/null +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/actions/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright © 2025 Cask Data, Inc. + * + * 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 contains the actions for CloudSQLMySQL features. + */ +package io.cdap.plugin.cloudmysql.actions; diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/locators/CloudSQLMySQLLocators.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/locators/CloudSQLMySQLLocators.java new file mode 100644 index 000000000..c7802ff86 --- /dev/null +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/locators/CloudSQLMySQLLocators.java @@ -0,0 +1,26 @@ +/* + * Copyright © 2025 Cask Data, Inc. + * + * 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 io.cdap.plugin.cloudmysql.locators; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.How; +/** + * CloudSQLMySQL - Connection Properties page - Locators. + */ +public class CloudSQLMySQLLocators { + @FindBy(how = How.XPATH, using = "//div[@data-testid='tab-content-Configuration']//input[@data-testid='database']") + public static WebElement database; +} diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/locators/package-info.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/locators/package-info.java new file mode 100644 index 000000000..e014e9b8d --- /dev/null +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/locators/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright © 2025 Cask Data, Inc. + * + * 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 contains the locators for CloudSQLMySQL features. + */ +package io.cdap.plugin.cloudmysql.locators; diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/runners/TestRunner.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/runners/TestRunner.java index 92285248f..099241cad 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/runners/TestRunner.java +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/runners/TestRunner.java @@ -26,9 +26,9 @@ @CucumberOptions( features = {"src/e2e-test/features"}, glue = {"stepsdesign", "io.cdap.plugin.common.stepsdesign", "io.cdap.plugin.cloudmysql.stepsdesign"}, - tags = {"@CloudMySql and not @PLUGIN-20670 and not @PLUGIN-1633"}, + tags = {"@CloudMySql and not @PLUGIN-20670 and not @PLUGIN-1633 and not @PLUGIN-1854"}, /* TODO :Enable tests once issue fixed https://cdap.atlassian.net/browse/CDAP-20670, - https://cdap.atlassian.net/browse/PLUGIN-1633 + https://cdap.atlassian.net/browse/PLUGIN-1633, https://cdap.atlassian.net/browse/PLUGIN-1854 */ plugin = {"pretty", "html:target/cucumber-html-report/CloudMySql", "json:target/cucumber-reports/cucumber-mysql.json", diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/runners/TestRunnerRequired.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/runners/TestRunnerRequired.java index 8f3a7e27f..a665f7be5 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/runners/TestRunnerRequired.java +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/runners/TestRunnerRequired.java @@ -26,8 +26,9 @@ @CucumberOptions( features = {"src/e2e-test/features"}, glue = {"stepsdesign", "io.cdap.plugin.common.stepsdesign", "io.cdap.plugin.cloudmysql.stepsdesign"}, - tags = {"@CloudMySql_Required and not @PLUGIN-20670"}, - /* TODO :Enable tests once issue fixed https://cdap.atlassian.net/browse/CDAP-20670 + tags = {"@CloudMySql_Required and not @PLUGIN-20670 and not @PLUGIN-1854"}, + /* TODO :Enable tests once issue fixed https://cdap.atlassian.net/browse/CDAP-20670, + https://cdap.atlassian.net/browse/PLUGIN-1854 */ monochrome = true, plugin = {"pretty", "html:target/cucumber-html-report/CloudMySql", diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/stepsdesign/CloudMysql.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/stepsdesign/CloudMysql.java index 4a2dd235b..0b17bb116 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/stepsdesign/CloudMysql.java +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/cloudmysql/stepsdesign/CloudMysql.java @@ -21,6 +21,7 @@ import io.cdap.e2e.utils.PluginPropertyUtils; import io.cdap.plugin.CloudMySqlClient; import io.cdap.plugin.cloudmysql.BQValidation; +import io.cdap.plugin.cloudmysql.actions.CloudSQLMySQLActions; import io.cucumber.java.en.Then; import org.junit.Assert; import stepsdesign.BeforeActions; @@ -82,4 +83,9 @@ public void validateTheValuesOfRecordsTransferredToTargetCloudSQLMySqlTableIsEqu Assert.assertTrue("Value of records transferred to the target table should be equal to the value " + "of the records in the source table", recordsMatched); } + + @Then("Enter input plugin property with value: {string}") + public void enterInputPluginPropertyWithValue(String database) { + CloudSQLMySQLActions.enterValueInInputProperty(PluginPropertyUtils.pluginProp(database)); + } } diff --git a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java index 85c9c62de..14af5bdf3 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java +++ b/cloudsql-mysql-plugin/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java @@ -16,6 +16,8 @@ package io.cdap.plugin.common.stepsdesign; import com.google.cloud.bigquery.BigQueryException; +import io.cdap.e2e.pages.actions.CdfConnectionActions; +import io.cdap.e2e.pages.actions.CdfPluginPropertiesActions; import io.cdap.e2e.utils.BigQueryClient; import io.cdap.e2e.utils.PluginPropertyUtils; import io.cdap.plugin.CloudMySqlClient; @@ -131,6 +133,55 @@ public static void dropCloudMysqlTestTable() throws SQLException, ClassNotFoundE PluginPropertyUtils.pluginProp("targetTable") + " deleted successfully"); } + @Before(order = 2, value = "@CLOUDMYSQL_SOURCE_TABLE") + public static void createCloudMysqlSourceTable() throws SQLException, ClassNotFoundException { + CloudMySqlClient.createCloudMysqlSourceTable(PluginPropertyUtils.pluginProp("sourceTable")); + BeforeActions.scenario.write("CLOUDMYSQL Source DataTypes table - " + + PluginPropertyUtils.pluginProp("sourceTable") + " created successfully"); + } + + @After(order = 2, value = "@CLOUDMYSQL_SOURCE_TABLE") + public static void deleteCloudMysqlSourceTable() throws SQLException, ClassNotFoundException { + CloudMySqlClient.deleteTable(PluginPropertyUtils.pluginProp("sourceTable")); + BeforeActions.scenario.write("CLOUDMYSQL Source DataTypes table - " + + PluginPropertyUtils.pluginProp("sourceTable") + " deleted successfully"); + } + + @Before(order = 2, value = "@CLOUDMYSQL_TARGET_TABLE") + public static void createCloudMysqlTargetTable() throws SQLException, ClassNotFoundException { + CloudMySqlClient.createCloudMysqlTargetTable(PluginPropertyUtils.pluginProp("targetTable")); + BeforeActions.scenario.write("CLOUDMYSQL Target DataTypes table - " + + PluginPropertyUtils.pluginProp("targetTable") + " created successfully"); + } + + @After(order = 2, value = "@CLOUDMYSQL_TARGET_TABLE") + public static void deleteCloudMysqlTargetTable() throws SQLException, ClassNotFoundException { + CloudMySqlClient.deleteTable(PluginPropertyUtils.pluginProp("targetTable")); + BeforeActions.scenario.write("CLOUDMYSQL Target DataTypes Table - " + + PluginPropertyUtils.pluginProp("targetTable") + " deleted successfully"); + } + + @Before(order = 1, value = "@CONNECTION") + public static void setNewConnectionName() { + String connectionName = "CloudSQLMySQL" + RandomStringUtils.randomAlphanumeric(10); + PluginPropertyUtils.addPluginProp("connection.name", connectionName); + BeforeActions.scenario.write("New Connection name: " + connectionName); + } + + private static void deleteConnection(String connectionType, String connectionName) throws IOException { + CdfConnectionActions.openWranglerConnectionsPage(); + CdfConnectionActions.expandConnections(connectionType); + CdfConnectionActions.openConnectionActionMenu(connectionType, connectionName); + CdfConnectionActions.selectConnectionAction(connectionType, connectionName, "Delete"); + CdfPluginPropertiesActions.clickPluginPropertyButton("Delete"); + } + + @After(order = 1, value = "@CONNECTION") + public static void deleteTestConnection() throws IOException { + deleteConnection("CloudSQLMySQL", "connection.name"); + PluginPropertyUtils.removePluginProp("connection.name"); + } + @Before(order = 1, value = "@BQ_SINK_TEST") public static void setTempTargetBQTableName() { String bqTargetTableName = "E2E_TARGET_" + UUID.randomUUID().toString().replaceAll("-", "_"); diff --git a/cloudsql-mysql-plugin/src/e2e-test/resources/errorMessage.properties b/cloudsql-mysql-plugin/src/e2e-test/resources/errorMessage.properties index 4ccfa1f56..99a51422a 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/resources/errorMessage.properties +++ b/cloudsql-mysql-plugin/src/e2e-test/resources/errorMessage.properties @@ -23,3 +23,4 @@ errorLogsMessageInvalidBoundingQuery=Spark program 'phase-1' failed with error: check the manual that corresponds to your MySQL server version for the right syntax to use near 'table' at line 1. Please check the system logs for more details. errorMessageInvalidPassword=SQL error while getting query schema: Error: Access denied for user errorMessagePrivateConnectionName=Enter the internal IP address of the Compute Engine VM cloudsql proxy is running on, to connect to a private +errorMessageWithBlankPassword=Exception while trying to validate schema of database table diff --git a/cloudsql-mysql-plugin/src/e2e-test/resources/pluginParameters.properties b/cloudsql-mysql-plugin/src/e2e-test/resources/pluginParameters.properties index 374e9c38b..04fdc9ece 100644 --- a/cloudsql-mysql-plugin/src/e2e-test/resources/pluginParameters.properties +++ b/cloudsql-mysql-plugin/src/e2e-test/resources/pluginParameters.properties @@ -88,6 +88,10 @@ connectionArgumentsForBooleanDataType=[{"key":"tinyInt1isBit","value":"true"}] connectionArguments=queryTimeout=50 outputSchema=[{"key":"id","value":"int"},{"key":"lastName","value":"string"},{"key":"is_active","value":"int"}] outputSourceSchema=[{"key":"id","value":"int"},{"key":"lastName","value":"string"},{"key":"is_active","value":"boolean"}] +CloudMySqlColumns=(ID varchar(100) PRIMARY KEY, COL1 bit(1), COL2 year) +CloudMySqlColumnsList=(ID,COL1,COL2) +CloudMySqlValue=VALUES ('User1',1,2025) +CloudMySqlSchema=[{"key":"ID","value":"string"},{"key":"COL1","value":"boolean"},{"key":"COL2","value":"date"}] #bq queries file path CreateBQTableQueryFile=BigQuery/BigQueryCreateTableQuery.txt InsertBQDataQueryFile=BigQuery/BigQueryInsertDataQuery.txt