diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 93cd905a6e..1d865a1ac9 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -59,6 +59,10 @@ jobs: ${{ runner.os }}-maven-${{ github.workflow }} - name: Run tests run: python3 e2e/src/main/scripts/run_e2e_test.py + env: + Cloud_Psql_User_Name: ${{secrets.Cloud_Psql_User_Name}} + Cloud_Psql_Password: ${{secrets.Cloud_Psql_Password}} + Cloud_Psql_ConnectionName: ${{secrets.Cloud_Psql_ConnectionName}} - name: Upload report uses: actions/upload-artifact@v2.2.4 if: always() diff --git a/src/e2e-test/features/Cloudsqlpostgresql_sink_designtime.feature b/src/e2e-test/features/Cloudsqlpostgresql_sink_designtime.feature index 0999f61db9..4c8308c422 100755 --- a/src/e2e-test/features/Cloudsqlpostgresql_sink_designtime.feature +++ b/src/e2e-test/features/Cloudsqlpostgresql_sink_designtime.feature @@ -1,33 +1,33 @@ -Feature: CloudSQLPostGreSQL Sink Design Time +Feature: CloudSQLPostGreSQL Sink and Error Validation - @CLDPGSQL @TC-Mandatory-fields + @cloudSQLPostgreSQL Scenario Outline:Verify CloudSQLPostGreSQL Sink properties validation errors for mandatory fields Given Open DataFusion Project to configure pipeline When Target is CloudSQLPostGreSQL - Then Open CloudSQLPostGreSQL Properties + Then Open cloudSQLPostgreSQL Properties Then Enter the CloudSQLPostGreSQL Sink Properties with blank property "" Then Validate mandatory property error for "" Examples: - | property | - | referenceName | - | database | + | property | + | referenceName | + | database | | connectionName | - | tableName | + | tableName | | jdbcPluginName | - @CLDPGSQL @TC-Invalid-TestData-for-DriverName_Field: + @cloudSQLPostgreSQL Scenario: Verify Driver Name field validation error with invalid test data Given Open DataFusion Project to configure pipeline When Target is CloudSQLPostGreSQL - Then Open CloudSQLPostGreSQL Properties + Then Open cloudSQLPostgreSQL Properties Then Enter Reference Name & Database Name with Test Data - Then Enter Table Name "pSqlTableNameCS" and Connection Name "pSqlConnectionNameValid" + Then Enter Table Name "cloudPsqlTableName" and Connection Name Then Validate Connector properties Then Enter Driver Name with Invalid value Then Verify Driver Name field with Invalid value entered Then Close the CloudSQLPostGreSQL Properties - @CLDPGSQL @TC-Invalid-TestData-for-ReferenceName&ConnectionName + @cloudSQLPostgreSQL Scenario: User is able to Open and enter invalid test data for Reference Name & Connection Name Given Open DataFusion Project to configure pipeline When Target is CloudSQLPostGreSQL @@ -38,7 +38,3 @@ Feature: CloudSQLPostGreSQL Sink Design Time Then Verify Connection Name with private instance type Then Close the CloudSQLPostGreSQL Properties - - - - diff --git a/src/e2e-test/features/Cloudsqlpostgresql_source_designtime.feature b/src/e2e-test/features/Cloudsqlpostgresql_source_designtime.feature index 2c079ed4db..580375687f 100755 --- a/src/e2e-test/features/Cloudsqlpostgresql_source_designtime.feature +++ b/src/e2e-test/features/Cloudsqlpostgresql_source_designtime.feature @@ -1,10 +1,10 @@ -Feature: CloudSQLPostGreSQL Source Design Time +Feature: CloudSQLPostGreSQL Source Design Time and error validation - @CLDPGSQL @TC-Mandatory-fields + @cloudSQLPostgreSQL Scenario Outline:Verify CloudSQLPostGreSQL Source properties validation errors for mandatory fields Given Open DataFusion Project to configure pipeline When Source is CloudSQLPostGreSQL - Then Open CloudSQLPostGreSQL Properties + Then Open cloudSQLPostgreSQL Properties Then Enter the CloudSQLPostGreSQL Source Properties with blank property "" Then Validate mandatory property error for "" Examples: @@ -15,23 +15,23 @@ Feature: CloudSQLPostGreSQL Source Design Time | importQuery | | jdbcPluginName | - @CLDPGSQL @TC-Invalid-TestData-for-DriverName_Field: - Scenario: TC-CLDMYSQL-DSGN-03:Verify Driver Name field validation error with invalid test data + @cloudSQLPostgreSQL + Scenario:Verify Driver Name field validation error with invalid test data Given Open DataFusion Project to configure pipeline When Source is CloudSQLPostGreSQL - Then Open CloudSQLPostGreSQL Properties + Then Open cloudSQLPostgreSQL Properties Then Enter Reference Name & Database Name with Test Data - Then Enter Connection Name and Import Query "pSqlImportQuery" + Then Enter Connection Name and Import Query "cloudPsqlImportQuery" Then Validate Connector properties Then Enter Driver Name with Invalid value Then Verify Driver Name field with Invalid value entered Then Close the CloudSQLPostGreSQL Properties - @CLDPGSQL @TC-Invalid-TestData-for-ReferenceName&ConnectionName - Scenario: TC-CLDMYSQL-DSGN-04:Verify Reference Name & Connection Name field validation errors with invalid test data + @cloudSQLPostgreSQL + Scenario:Verify Reference Name & Connection Name field validation errors with invalid test data Given Open DataFusion Project to configure pipeline When Source is CloudSQLPostGreSQL - Then Enter Reference Name & Connection Name with Invalid Test Data and import query "pSqlImportQuery" + Then Enter Reference Name & Connection Name with Invalid Test Data and import query "cloudPsqlImportQuery" Then Verify Reference Name Connection Name Fields with Invalid Test Data Then Enter Connection Name with private instance type Then Verify Connection Name with private instance type diff --git a/src/e2e-test/features/cloudSqlPsqlEndtoEnd.feature b/src/e2e-test/features/cloudSqlPsqlEndtoEnd.feature new file mode 100644 index 0000000000..a7d5f87973 --- /dev/null +++ b/src/e2e-test/features/cloudSqlPsqlEndtoEnd.feature @@ -0,0 +1,264 @@ +Feature: End to End records transfer from cloudSQLPostgreSQL to BigQuery and GCS + + @cloudSQLPostgreSQL-e2e + Scenario:Verify all the records transfer from cloudSQLPostgreSQL to Bigquery supporting different data types + Given Open DataFusion Project to configure pipeline + When Source is CloudSQLPostGreSQL + When Target is BigQuery + Then Open cloudSQLPostgreSQL Properties + Then Enter the cloudSQLPostgreSQL properties for database "cloudPsqlDbName" using query "cloudPSQLDBImportQueryForAll" + Then Capture output schema + Then Validate cloudSQLPostgreSQL properties + Then Close the cloudSQLPostgreSQL properties + Then Open BigQuery Target Properties + Then Enter the BigQuery Target Properties for table "cloudPsqlBigQuery" + Then Validate Bigquery properties + Then Close the BigQuery properties + Then Connect Source as "CloudSQL-PostgreSQL" and sink as "BigQuery" to establish connection + Then Add pipeline name + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Click on PreviewData for cloudSQLPostgreSQL + Then Verify Preview output schema is not null + Then Close the Preview and deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Open the Logs and capture raw logs + Then Get Count of no of records transferred to BigQuery in "cloudPsqlBigQuery" + Then Validate records out from cloudSQLPostgreSQL is equal to records transferred in BigQuery "cloudPsqlBigQuery" output records + + @cloudSQLPostgreSQL-e2e + Scenario:Verify all the duplicate records are fetched and transferred to BigQuery + Given Open DataFusion Project to configure pipeline + When Source is CloudSQLPostGreSQL + When Target is BigQuery + Then Open cloudSQLPostgreSQL Properties + Then Enter the cloudSQLPostgreSQL properties for database "cloudPsqlDbName" using query "cloudPSQLDBImportQueryDuplicate" for duplicate values "cloudPSQLSplitColumnDuplicateValue" + Then Capture output schema + Then Validate cloudSQLPostgreSQL properties + Then Close the cloudSQLPostgreSQL properties + Then Open BigQuery Target Properties + Then Enter the BigQuery Target Properties for table "cloudPsqlBigQuery" + Then Validate Bigquery properties + Then Close the BigQuery properties + Then Connect Source as "CloudSQL-PostgreSQL" and sink as "BigQuery" to establish connection + Then Add pipeline name + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Click on PreviewData for cloudSQLPostgreSQL + Then Verify Preview output schema is not null + Then Close the Preview and deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Open the Logs and capture raw logs + Then Get Count of no of records transferred to BigQuery in "cloudPsqlBigQuery" + Then Validate records out from cloudSQLPostgreSQL is equal to records transferred in BigQuery "cloudPsqlBigQuery" output records + + @cloudSQLPostgreSQL-e2e + Scenario Outline: Verify records get transferred on combining different tables using joins + Given Open DataFusion Project to configure pipeline + When Source is CloudSQLPostGreSQL + When Target is BigQuery + Then Open cloudSQLPostgreSQL Properties + Then Enter the cloudSQLPostgreSQL properties for database "cloudPsqlDbName" using different join queries "" + Then Capture output schema + Then Validate cloudSQLPostgreSQL properties + Then Close the cloudSQLPostgreSQL properties + Then Open BigQuery Target Properties + Then Enter the BigQuery Target Properties for table "cloudPsqlBigQuery" + Then Validate Bigquery properties + Then Close the BigQuery properties + Then Connect Source as "CloudSQL-PostgreSQL" and sink as "BigQuery" to establish connection + Then Add pipeline name + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Click on PreviewData for cloudSQLPostgreSQL + Then Verify Preview output schema is not null + Then Close the Preview and deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Open the Logs and capture raw logs + Then Get Count of no of records transferred to BigQuery in "cloudPsqlBigQuery" + Then Validate records out from cloudSQLPostgreSQL is equal to records transferred in BigQuery "cloudPsqlBigQuery" output records + Examples: + | cloudPSQLDBImportQueryJoins | + | cloudPSQLDBImportQueryInnerJoin | + | cloudPSQLDBImportQueryLeftJoin | + | cloudPSQLDBImportQueryRightJoin | + | cloudPSQLDBImportQueryOuterJoin | + + @cloudSQLPostgreSQL-e2e + Scenario:Verify only distinct records are transferred + Given Open DataFusion Project to configure pipeline + When Source is CloudSQLPostGreSQL + When Target is BigQuery + Then Open cloudSQLPostgreSQL Properties + Then Enter the cloudSQLPostgreSQL properties for database "cloudPsqlDbName" using query "cloudPSQLDBImportQueryDistinct" for distinct values "cloudPSQLSplitColumnDistinctValue" + Then Capture output schema + Then Validate cloudSQLPostgreSQL properties + Then Close the cloudSQLPostgreSQL properties + Then Open BigQuery Target Properties + Then Enter the BigQuery Target Properties for table "cloudPsqlBigQuery" + Then Validate Bigquery properties + Then Close the BigQuery properties + Then Connect Source as "CloudSQL-PostgreSQL" and sink as "BigQuery" to establish connection + Then Add pipeline name + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Click on PreviewData for cloudSQLPostgreSQL + Then Verify Preview output schema is not null + Then Close the Preview and deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Open the Logs and capture raw logs + Then Get Count of no of records transferred to BigQuery in "cloudPsqlBigQuery" + Then Validate records out from cloudSQLPostgreSQL is equal to records transferred in BigQuery "cloudPsqlBigQuery" output records + + @cloudSQLPostgreSQL-e2e + Scenario:Verify records with maximum values are transferred from cloudPSQL to BigQuery + Given Open DataFusion Project to configure pipeline + When Source is CloudSQLPostGreSQL + When Target is BigQuery + Then Open cloudSQLPostgreSQL Properties + Then Enter the cloudSQLPostgreSQL properties for database "cloudPsqlDbName" using query "cloudPSQLDBImportQueryForMax" for max values "cloudPSQLSplitColumnMaxValue" + Then Capture output schema + Then Validate cloudSQLPostgreSQL properties + Then Close the cloudSQLPostgreSQL properties + Then Open BigQuery Target Properties + Then Enter the BigQuery Target Properties for table "cloudPsqlBigQuery" + Then Validate Bigquery properties + Then Close the BigQuery properties + Then Connect Source as "CloudSQL-PostgreSQL" and sink as "BigQuery" to establish connection + Then Add pipeline name + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Click on PreviewData for cloudSQLPostgreSQL + Then Verify Preview output schema is not null + Then Close the Preview and deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Open the Logs and capture raw logs + Then Get Count of no of records transferred to BigQuery in "cloudPsqlBigQuery" + Then Validate records out from cloudSQLPostgreSQL is equal to records transferred in BigQuery "cloudPsqlBigQuery" output records + + @cloudSQLPostgreSQL-e2e + Scenario:Verify records with minimum values are transferred from cloudPSQL to BigQuery + Given Open DataFusion Project to configure pipeline + When Source is CloudSQLPostGreSQL + When Target is BigQuery + Then Open cloudSQLPostgreSQL Properties + Then Enter the cloudSQLPostgreSQL properties for database "cloudPsqlDbName" using query "cloudPSQLDBImportQueryForMin" for min values "cloudPSQLSplitColumnMinValue" + Then Capture output schema + Then Validate cloudSQLPostgreSQL properties + Then Close the cloudSQLPostgreSQL properties + Then Open BigQuery Target Properties + Then Enter the BigQuery Target Properties for table "cloudPsqlBigQuery" + Then Validate Bigquery properties + Then Close the BigQuery properties + Then Connect Source as "CloudSQL-PostgreSQL" and sink as "BigQuery" to establish connection + Then Add pipeline name + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Click on PreviewData for cloudSQLPostgreSQL + Then Verify Preview output schema is not null + Then Close the Preview and deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Open the Logs and capture raw logs + Then Get Count of no of records transferred to BigQuery in "cloudPsqlBigQuery" + Then Validate records out from cloudSQLPostgreSQL is equal to records transferred in BigQuery "cloudPsqlBigQuery" output records + + + @cloudSQLPostgreSQL-e2e + Scenario Outline: Verify all the records transfer from cloudSQLPostgreSQL to Bigquery for different where clause + Given Open DataFusion Project to configure pipeline + When Source is CloudSQLPostGreSQL + When Target is BigQuery + Then Open cloudSQLPostgreSQL Properties + Then Enter the cloudSQLPostgreSQL properties for database "cloudPsqlDbName" using query "" for max and min "" + Then Capture output schema + Then Validate cloudSQLPostgreSQL properties + Then Close the cloudSQLPostgreSQL properties + Then Open BigQuery Target Properties + Then Enter the BigQuery Target Properties for table "cloudPsqlBigQuery" + Then Validate Bigquery properties + Then Close the BigQuery properties + Then Connect Source as "CloudSQL-PostgreSQL" and sink as "BigQuery" to establish connection + Then Add pipeline name + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Click on PreviewData for cloudSQLPostgreSQL + Then Verify Preview output schema is not null + Then Close the Preview and deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Open the Logs and capture raw logs + Then Get Count of no of records transferred to BigQuery in "cloudPsqlBigQuery" + Then Validate records out from cloudSQLPostgreSQL is equal to records transferred in BigQuery "cloudPsqlBigQuery" output records + Examples: + | cloudPostgresSQLDatabaseImportQuery | cloudPostgresSQLSplitColumnValues | + | cloudPSQLDBImportQueryForBetween | cloudPSQLSplitColumnBetweenValue | + | cloudPSQLDBImportQueryForIn | cloudPSQLSplitColumnInValue | + | cloudPSQLDBImportQueryNotIn | cloudPSQLSplitColumnNotInValue | + | cloudPSQLDBImportQueryOrderBy | cloudPSQLSplitColumnOrderByValue | + + + @cloudSQLPostgreSQL-e2e + Scenario:Verify records are transferred from cloudSQLPostgreSQL to BigQuery using Bounding Query + Given Open DataFusion Project to configure pipeline + When Source is CloudSQLPostGreSQL + When Target is BigQuery + Then Open cloudSQLPostgreSQL Properties + Then Enter the cloudSQLPostgreSQL properties for database "cloudPsqlDbName" using query "cloudPSQLQuery" for max values "cloudPSQLSplitColumnMaxValue" with bounding query "cloudPSQLDBBoundingQuery" and "cloudPsqlNoOfSplits" + Then Capture output schema + Then Validate cloudSQLPostgreSQL properties + Then Close the cloudSQLPostgreSQL properties + Then Open BigQuery Target Properties + Then Enter the BigQuery Target Properties for table "cloudPsqlBigQuery" + Then Validate Bigquery properties + Then Close the BigQuery properties + Then Connect Source as "CloudSQL-PostgreSQL" and sink as "BigQuery" to establish connection + Then Add pipeline name + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Click on PreviewData for cloudSQLPostgreSQL + Then Verify Preview output schema is not null + Then Close the Preview and deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Open the Logs and capture raw logs + Then Get Count of no of records transferred to BigQuery in "cloudPsqlBigQuery" + Then Validate records out from cloudSQLPostgreSQL is equal to records transferred in BigQuery "cloudPsqlBigQuery" output records + + @cloudSQLPostgreSQL-e2e + Scenario:Verify all the records transfer from cloudSQLPostgreSQL to GCS supporting different data types + Given Open DataFusion Project to configure pipeline + When Source is CloudSQLPostGreSQL + When Sink is GCS + Then Open cloudSQLPostgreSQL Properties + Then Enter the cloudSQLPostgreSQL properties for database "cloudPsqlDbName" using query "cloudPSQLDBImportQueryForAll" + Then Capture output schema + Then Validate cloudSQLPostgreSQL properties + Then Close the cloudSQLPostgreSQL properties + Then Enter the GCS Properties + Then Close the GCS Properties + Then Connect Source as "CloudSQL-PostgreSQL" and sink as "GCS" to establish connection + Then Add pipeline name + Then Preview and run the pipeline + Then Verify the preview of pipeline is "success" + Then Click on PreviewData for cloudSQLPostgreSQL + Then Verify Preview output schema is not null + Then Close the Preview and deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Open the Logs and capture raw logs + Then Validate the output record count diff --git a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/actions/CdfCloudSqlPostGreSqlActions.java b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/actions/CdfCloudSqlPostGreSqlActions.java index 29b770d819..8ba5f2c4dd 100644 --- a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/actions/CdfCloudSqlPostGreSqlActions.java +++ b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/actions/CdfCloudSqlPostGreSqlActions.java @@ -16,10 +16,18 @@ package io.cdap.plugin.cloudsqlpostgresql.actions; import io.cdap.e2e.pages.locators.CdfBigQueryPropertiesLocators; +import io.cdap.e2e.pages.locators.CdfStudioLocators; +import io.cdap.e2e.utils.SeleniumDriver; import io.cdap.e2e.utils.SeleniumHelper; import io.cdap.plugin.cloudsqlpostgresql.locators.CdfCloudSqlPostGreSqlLocators; +import io.cdap.plugin.utils.CdapUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WindowType; import java.io.IOException; +import java.util.Iterator; +import java.util.Set; /** * cloudSqlPostGreSql connector related Step Actions. @@ -113,4 +121,18 @@ public static void enterConnectionTimeout(String connectionTimeout) { public static void clickPrivateInstance() { CdfCloudSqlPostGreSqlLocators.instanceType.click(); } -} + + public static void getSchema() { + CdfCloudSqlPostGreSqlLocators.getSchemaButton.click(); + } + + public static void clickPreviewData() { + SeleniumHelper.waitElementIsVisible(CdfCloudSqlPostGreSqlLocators.previewData); + CdfCloudSqlPostGreSqlLocators.previewData.click(); + } + + public static void replaceSplitValue(String numberOfSplits) throws IOException { + SeleniumHelper.replaceElementValue(CdfCloudSqlPostGreSqlLocators.numberOfSplits, numberOfSplits); + } + } + diff --git a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/actions/package-info.java b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/actions/package-info.java index d771e8cc74..08719371db 100755 --- a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/actions/package-info.java +++ b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/actions/package-info.java @@ -2,5 +2,3 @@ * Package contains the runner for the GCP features. */ package io.cdap.plugin.cloudsqlpostgresql.actions; - - diff --git a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/locators/CdfCloudSqlPostGreSqlLocators.java b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/locators/CdfCloudSqlPostGreSqlLocators.java index 1a29008f52..088a7ea644 100644 --- a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/locators/CdfCloudSqlPostGreSqlLocators.java +++ b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/locators/CdfCloudSqlPostGreSqlLocators.java @@ -33,15 +33,6 @@ public class CdfCloudSqlPostGreSqlLocators { @FindBy(how = How.XPATH, using = "//*[text()='Sink ']") public static WebElement sink; - @FindBy(how = How.XPATH, using = "//*[contains(@class,'plugin-endpoint_CloudSQL-PostgreSQL')]") - public static WebElement fromCloudSqlPsqlSource; - - @FindBy(how = How.XPATH, using = "//*[contains(@class,'plugin-endpoint_BigQuery')]") - public static WebElement fromBigQuerySource; - - @FindBy(how = How.XPATH, using = "//*[@title=\"CloudSQL MySQL\"]//following-sibling::div") - public static WebElement toCloudSqlMysqlSink; - @FindBy(how = How.XPATH, using = "//*[@data-cy='referenceName' and @class='MuiInputBase-input']") public static WebElement referenceName; @@ -93,83 +84,19 @@ public class CdfCloudSqlPostGreSqlLocators { @FindBy(how = How.XPATH, using = "//*[@data-cy='connectionTimeout' and @class='MuiInputBase-input']") public static WebElement connectionTimeout; - @FindBy(how = How.XPATH, using = "//*[@class='plugin-comments-wrapper ng-scope']") - public static WebElement clickComment; - - @FindBy(how = How.XPATH, using = "(//div[contains(@class,'MuiPaper-rounded')])[4]/div/textarea[1]") - public static WebElement addComment; - - @FindBy(how = How.XPATH, using = "(//div[contains(@class,'MuiPaper-rounded')])[4]/div[2]/div/p") - public static WebElement validateComment; - - @FindBy(how = How.XPATH, using = "(//div[contains(@class,'MuiPaper-rounded')])[3]/div[2]/div/p") - public static WebElement validateSinkComment; - - @FindBy(how = How.XPATH, using = "(//*[contains(text(), 'Comment')])[2]") - public static WebElement saveComment; - - @FindBy(how = How.XPATH, using = "(//*[contains(@class,'MuiIconButton-sizeSmall') and @tabindex='0'])") - public static WebElement editComment; - - @FindBy(how = How.XPATH, using = "(//*[@id='menu-list-grow']//child::li)[1]") - public static WebElement clickEdit; - - @FindBy(how = How.XPATH, using = "(//*[@id='menu-list-grow']//child::li)[2]") - public static WebElement clickDelete; - @FindBy(how = How.XPATH, using = "//*[@class='fa fa-remove']") public static WebElement closeButton; @FindBy(how = How.XPATH, using = "//*[@data-cy='plugin-properties-validate-btn']") public static WebElement validateBtn; - @FindBy(how = How.XPATH, using = "//*[@data-cy='property-row-error' and contains(text(),'referenceName')]") - public static WebElement cldMysqlReferenceNameValidation; - - @FindBy(how = How.XPATH, using = "//*[@data-cy='property-row-error' and contains(text(),'database')]") - public static WebElement cldMysqlDatabaseNameValidation; - - @FindBy(how = How.XPATH, using = "//*[@data-cy='property-row-error' and contains(text(),'connectionName')]") - public static WebElement cldMysqlConnectionNameValidation; - - @FindBy(how = How.XPATH, using = "//*[@data-cy='property-row-error' and contains(text(),'importQuery')]") - public static WebElement cldMysqlImportQueryValidation; - - @FindBy(how = How.XPATH, using = "//*[@data-cy='property-row-error' and contains(text(),'tableName')]") - public static WebElement cldMysqlTableNameValidation; - - @FindBy(how = How.XPATH, using = "//*[@data-cy='property-row-error' and contains(text(),'jdbcPluginName')]") - public static WebElement cldMysqlDriverNameValidation; - @FindBy(how = How.XPATH, using = "//*[@title=\"CloudSQL PostgreSQL\"]//following-sibling::div") public static WebElement cloudSqlPSqlProperties; @FindBy(how = How.XPATH, using = "//*[contains(text(),'Get Schema')]") public static WebElement getSchemaButton; - @FindBy(how = How.XPATH, using = "//*[@class=\"btn pipeline-action-btn pipeline-actions-btn\"]") - public static WebElement actionButton; - - @FindBy(how = How.XPATH, using = "//*[@class=\"btn btn-primary save-button\"]") - public static WebElement pipelineSave; - - @FindBy(how = How.XPATH, using = "//*[contains(text(),'Duplicate')]") - public static WebElement actionDuplicateButton; - - // Later below two locator should be deled when code will re-factor - @FindBy(how = How.XPATH, using = "//*[@data-cy='serviceAccountJSON' and @class='MuiInputBase-input']") - public static WebElement bigQueryServiceAccountJSON; - - @FindBy(how = How.XPATH, using = "//input [@type='radio' and @value='JSON']") - public static WebElement bigQueryJson; - - @FindBy(how = How.XPATH, using = "(//*[@data-cy='plugin-properties-errors-found']") - public static WebElement getSchemaStatus; - - @FindBy(how = How.XPATH, using = "//*[@data-cy='plugin-BigQueryTable-batchsource']") - public static WebElement selectBigQuerySource; - - @FindBy(how = How.XPATH, using = "//*[@placeholder='Add a comment']") - public static WebElement addCommentSink; - + @FindBy(how = How.XPATH, using = "//*[@data-cy='CloudSQLPostgreSQL-preview-data-btn' and " + + "@class='node-preview-data-btn ng-scope']") + public static WebElement previewData; } diff --git a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/locators/package-info.java b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/locators/package-info.java index 0aa9fa7006..76f3f27cd7 100755 --- a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/locators/package-info.java +++ b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/locators/package-info.java @@ -2,5 +2,3 @@ * Package contains the runner for the GCP features. */ package io.cdap.plugin.cloudsqlpostgresql.locators; - - diff --git a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/stepsdesign/CloudSqlPostGreSql.java b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/stepsdesign/CloudSqlPostGreSql.java index 38bfa2cfb8..c0a04fc7cc 100644 --- a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/stepsdesign/CloudSqlPostGreSql.java +++ b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/stepsdesign/CloudSqlPostGreSql.java @@ -15,10 +15,14 @@ */ package io.cdap.plugin.cloudsqlpostgresql.stepsdesign; +import io.cdap.e2e.pages.actions.CdfBigQueryPropertiesActions; +import io.cdap.e2e.pages.actions.CdfGcsActions; +import io.cdap.e2e.pages.actions.CdfPipelineRunAction; import io.cdap.e2e.pages.actions.CdfStudioActions; import io.cdap.e2e.pages.locators.CdfStudioLocators; import io.cdap.e2e.utils.CdfHelper; import io.cdap.e2e.utils.GcpClient; +import io.cdap.e2e.utils.SeleniumDriver; import io.cdap.e2e.utils.SeleniumHelper; import io.cdap.plugin.cloudsqlpostgresql.actions.CdfCloudSqlPostGreSqlActions; import io.cdap.plugin.cloudsqlpostgresql.locators.CdfCloudSqlPostGreSqlLocators; @@ -27,19 +31,38 @@ import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import org.junit.Assert; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import stepsdesign.BeforeActions; +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; +import java.util.UUID; + +import static io.cdap.plugin.utils.GCConstants.ERROR_MSG_VALIDATION; /** * CloudSqlPostGreSql. */ public class CloudSqlPostGreSql implements CdfHelper { List propertiesOutputSchema = new ArrayList(); - static int i = 0; GcpClient gcpClient = new GcpClient(); + static PrintWriter out; + + static { + try { + out = new PrintWriter(BeforeActions.myObj); + } catch (FileNotFoundException e) { + BeforeActions.scenario.write(e.toString()); + } + } + @Given("Open DataFusion Project to configure pipeline") public void openDataFusionProjectToConfigurePipeline() throws IOException, InterruptedException { openCdf(); @@ -55,10 +78,9 @@ public void targetIsCloudSQLPostGreSQL() throws InterruptedException { CdfCloudSqlPostGreSqlActions.selectCloudSQLPostGreSQLSink(); } - @Then("Open CloudSQLPostGreSQL Properties") - public void openCloudSQLPostGreSQLProperties() throws InterruptedException { - CdfCloudSqlPostGreSqlActions.clickCloudSqlPostGreSqlProperties(); - SeleniumHelper.waitElementIsVisible(CdfCloudSqlPostGreSqlLocators.validateBtn, 10); + @When("Target is BigQuery") + public void targetIsBigQuery() { + CdfStudioActions.sinkBigQuery(); } @Then("Validate Connector properties") @@ -70,10 +92,10 @@ public void validatePipeline() throws InterruptedException { @Then("Enter Reference Name & Connection Name with Invalid Test Data in Sink") public void enterTheSinkInvalidData() throws InterruptedException, IOException { CdfCloudSqlPostGreSqlActions.clickCloudSqlPostGreSqlProperties(); - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameInvalid")); - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameInvalid")); - CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("pSqlTableNameCS")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameInvalid")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("cloudPsqlConnectionNameInvalid")); + CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("cloudPsqlTableName")); } @Then("Verify Reference Name Connection Name Fields with Invalid Test Data") @@ -95,57 +117,57 @@ public void verifyTheCldMySqlInvalidPrivate() throws InterruptedException { @Then("Enter the CloudSQLPostGreSQL Source Properties with blank property {string}") public void enterTheCloudSQLPostGreSQLSourcePropertiesWithBlankProperty(String property) throws IOException, - InterruptedException { + InterruptedException { if (property.equalsIgnoreCase("referenceName")) { - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameValid")); - CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp("pSqlImportQuery")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp("cloudPsqlImportQuery")); } else if (property.equalsIgnoreCase("database")) { - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameValid")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameValid")); - CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp("pSqlImportQuery")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameValid")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp("cloudPsqlImportQuery")); } else if (property.equalsIgnoreCase("connectionName")) { - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameValid")); - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp("pSqlImportQuery")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameValid")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp("cloudPsqlImportQuery")); } else if (property.equalsIgnoreCase("importQuery")) { - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameValid")); - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameValid")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameValid")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); } else if (property.equalsIgnoreCase("jdbcPluginName")) { - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameValid")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameValid")); SeleniumHelper.replaceElementValue(CdfCloudSqlPostGreSqlLocators.driverName, ""); - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameValid")); - CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp("pSqlImportQuery")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp("cloudPsqlImportQuery")); } } @Then("Enter the CloudSQLPostGreSQL Sink Properties with blank property {string}") public void enterTheCloudSQLPostGreSQLSinkPropertiesWithBlankProperty(String property) throws IOException, - InterruptedException { + InterruptedException { if (property.equalsIgnoreCase("referenceName")) { - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameValid")); - CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("pSqlTableNameCS")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); + CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("cloudPsqlTableName")); } else if (property.equalsIgnoreCase("database")) { - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameValid")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameValid")); - CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("pSqlTableNameCS")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameValid")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); + CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("cloudPsqlTableName")); } else if (property.equalsIgnoreCase("connectionName")) { - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameValid")); - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("pSqlTableNameCS")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameValid")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("cloudPsqlTableName")); } else if (property.equalsIgnoreCase("tableName")) { - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameValid")); - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameValid")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameValid")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); } else if (property.equalsIgnoreCase("jdbcPluginName")) { - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameValid")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameValid")); SeleniumHelper.replaceElementValue(CdfCloudSqlPostGreSqlLocators.driverName, ""); - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameValid")); - CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("pSqlTableNameCS")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); + CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp("cloudPsqlTableName")); } } @@ -158,20 +180,20 @@ public void validateMandatoryPropertyErrorFor(String property) { @Then("Enter Reference Name & Database Name with Test Data") public void enterTheValidTestData() throws InterruptedException, IOException { - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameValid")); - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameValid")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); } - @Then("Enter Table Name {string} and Connection Name {string}") - public void enterTableNameInTableField(String tableName, String connectionName) throws IOException { + @Then("Enter Table Name {string} and Connection Name") + public void enterTableNameInTableField(String tableName) throws IOException { CdfCloudSqlPostGreSqlActions.enterTableName(CdapUtils.pluginProp(tableName)); CdfCloudSqlPostGreSqlActions.clickPrivateInstance(); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp(connectionName)); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); } @Then("Enter Driver Name with Invalid value") public void enterDriverNameDefaultValue() throws IOException { - CdfCloudSqlPostGreSqlActions.enterDriverName(CdapUtils.pluginProp("pSqlDriverNameInvalid")); + CdfCloudSqlPostGreSqlActions.enterDriverName(CdapUtils.pluginProp("cloudPsqlDriverNameInvalid")); CdfCloudSqlPostGreSqlActions.clickValidateButton(); } @@ -188,18 +210,301 @@ public void closeTheCloudSQLPostGreSQLProperties() { @Then("Enter Connection Name and Import Query {string}") public void enterConnectionImportField(String query) throws IOException, InterruptedException { CdfCloudSqlPostGreSqlActions.clickPrivateInstance(); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameValid")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(query)); } @Then("Enter Reference Name & Connection Name with Invalid Test Data and import query {string}") public void enterReferenceNameConnectionNameWithInvalidTestDataAndImportQuery(String query) throws - InterruptedException, IOException { + InterruptedException, IOException { CdfCloudSqlPostGreSqlActions.clickCloudSqlPostGreSqlProperties(); - CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("pSqlReferenceNameInvalid")); - CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("pSqlDatabaseName")); - CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("pSqlConnectionNameInvalid")); + CdfCloudSqlPostGreSqlActions.enterReferenceName(CdapUtils.pluginProp("cloudPsqlReferenceNameInvalid")); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp("cloudPsqlDbName")); + CdfCloudSqlPostGreSqlActions.enterConnectionName(CdapUtils.pluginProp("cloudPsqlConnectionNameInvalid")); CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(query)); SeleniumHelper.waitAndClick(CdfCloudSqlPostGreSqlLocators.validateBtn, 50); } + + @Then("Open cloudSQLPostgreSQL Properties") + public void openCloudSQLPostgreSQLProperties() { + CdfCloudSqlPostGreSqlActions.clickCloudSqlPostGreSqlProperties(); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} using query {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingQueryToGetAllValues + (String database, String importQuery) throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + } + + public void enterTheCloudSQLPostgreSQLPropertiesForDatabase(String database) throws IOException { + CdfCloudSqlPostGreSqlActions.enterReferenceName("cloudSQLPostgreSQL" + UUID.randomUUID().toString()); + CdfCloudSqlPostGreSqlActions.enterDatabaseName(CdapUtils.pluginProp(database)); + CdfCloudSqlPostGreSqlActions.enterUserName(System.getenv("Cloud_Psql_User_Name")); + CdfCloudSqlPostGreSqlActions.enterPassword(System.getenv("Cloud_Psql_Password")); + CdfCloudSqlPostGreSqlActions.clickPrivateInstance(); + CdfCloudSqlPostGreSqlActions.enterConnectionName(System.getenv("Cloud_Psql_ConnectionName")); + } + + @Then("Capture output schema") + public void captureOutputSchema() { + CdfCloudSqlPostGreSqlActions.getSchema(); + WebDriverWait wait = new WebDriverWait(SeleniumDriver.getDriver(), 10); + wait.until(ExpectedConditions.numberOfElementsToBeMoreThan + (By.xpath("//*[@placeholder=\"Field name\"]"), 0)); + SeleniumHelper.waitElementIsVisible(SeleniumDriver.getDriver().findElement( + By.xpath("//div[@data-cy='schema-fields-list']//*[@placeholder='Field name']")), 10L); + List propertiesOutputSchemaElements = SeleniumDriver.getDriver().findElements( + By.xpath("//div[@data-cy='schema-fields-list']//*[@placeholder='Field name']")); + for (WebElement element : propertiesOutputSchemaElements) { + propertiesOutputSchema.add(element.getAttribute("value")); + } + Assert.assertTrue(propertiesOutputSchema.size() >= 1); + } + + @Then("Validate cloudSQLPostgreSQL properties") + public void validateCloudSQLPostgreSQLProperties() { + CdfCloudSqlPostGreSqlActions.clickValidateButton(); + SeleniumHelper.waitElementIsVisible(CdfCloudSqlPostGreSqlLocators.validateBtn); + String expectedErrorMessage = CdapUtils.errorProp(ERROR_MSG_VALIDATION); + String actualErrorMessage = CdfStudioLocators.pluginValidationSuccessMsg.getText(); + Assert.assertEquals(expectedErrorMessage, actualErrorMessage); + } + + @Then("Close the cloudSQLPostgreSQL properties") + public void closeTheCloudSQLPostgreSQLProperties() { + CdfCloudSqlPostGreSqlActions.closeButton(); + } + + @Then("Open BigQuery Target Properties") + public void openBigQueryTargetProperties() { + CdfStudioActions.clickProperties("BigQuery"); + } + + @Then("Enter the BigQuery Target Properties for table {string}") + public void enterTheBigQueryTargetPropertiesForTable(String tableName) throws IOException { + CdfBigQueryPropertiesActions.enterProjectId(CdapUtils.pluginProp("Project-ID")); + CdfBigQueryPropertiesActions.enterDatasetProjectId(CdapUtils.pluginProp("Project-ID")); + CdfBigQueryPropertiesActions.enterBigQueryReferenceName("BQ_Ref_" + UUID.randomUUID().toString()); + CdfBigQueryPropertiesActions.enterBigQueryDataset(CdapUtils.pluginProp("CloudPsqlBqDataSet")); + CdfBigQueryPropertiesActions.enterBigQueryTable(CdapUtils.pluginProp(tableName)); + CdfBigQueryPropertiesActions.clickUpdateTable(); + CdfBigQueryPropertiesActions.clickTruncatableSwitch(); + } + + @Then("Validate Bigquery properties") + public void validateBigqueryProperties() { + CdfGcsActions.clickValidateButton(); + String expectedErrorMessage = CdapUtils.errorProp(ERROR_MSG_VALIDATION); + String actualErrorMessage = CdfStudioLocators.pluginValidationSuccessMsg.getText(); + Assert.assertEquals(expectedErrorMessage, actualErrorMessage); + } + + @Then("Close the BigQuery properties") + public void closeTheBigQueryProperties() { + CdfStudioActions.clickCloseButton(); + } + + @Then("Connect Source as {string} and sink as {string} to establish connection") + public void connectSourceAsAndSinkAsToEstablishConnection(String source, String sink) { + CdfStudioActions.connectSourceAndSink(source, sink); + } + + @Then("Add pipeline name") + public void addPipelineName() { + CdfStudioActions.pipelineName(); + CdfStudioActions.pipelineNameIp("cloudSQLPostgreSQL_BQ" + UUID.randomUUID().toString()); + CdfStudioActions.pipelineSave(); + SeleniumHelper.waitElementIsVisible(CdfStudioLocators.statusBanner); + WebDriverWait wait = new WebDriverWait(SeleniumDriver.getDriver(), 5); + wait.until(ExpectedConditions.invisibilityOf(CdfStudioLocators.statusBanner)); + } + + @Then("Preview and run the pipeline") + public void previewAndRunThePipeline() { + SeleniumHelper.waitAndClick(CdfStudioLocators.preview, 5L); + CdfStudioLocators.runButton.click(); + } + + @Then("Verify the preview of pipeline is {string}") + public void verifyThePreviewOfPipelineIs(String previewStatus) { + WebDriverWait wait = new WebDriverWait(SeleniumDriver.getDriver(), 180); + wait.until(ExpectedConditions.visibilityOf(CdfStudioLocators.statusBanner)); + Assert.assertTrue(CdfStudioLocators.statusBannerText.getText().contains(previewStatus)); + if (!previewStatus.equalsIgnoreCase("failed")) { + wait.until(ExpectedConditions.invisibilityOf(CdfStudioLocators.statusBanner)); + } + } + + @Then("Click on PreviewData for cloudSQLPostgreSQL") + public void clickOnPreviewDataForCloudSQLPostgreSQL() { + CdfCloudSqlPostGreSqlActions.clickPreviewData(); + } + + @Then("Close the Preview and deploy the pipeline") + public void closeThePreviewAndDeployThePipeline() { + SeleniumHelper.waitAndClick(CdfStudioLocators.closeButton, 5L); + CdfStudioActions.previewSelect(); + SeleniumHelper.waitElementIsVisible(CdfStudioLocators.pipelineDeploy, 2); + CdfStudioActions.pipelineDeploy(); + } + + @Then("Open the Logs and capture raw logs") + public void openTheLogsAndCaptureRawLogs() { + CdfPipelineRunAction.logsClick(); + } + + @Then("Validate records out from cloudSQLPostgreSQL is equal to records transferred in " + + "BigQuery {string} output records") + public void validateRecordsOutFromCloudSQLPostgreSQLIsEqualToRecordsTransferredInBigQueryOutputRecords + (String tableName) throws IOException, InterruptedException { + int countRecords; + countRecords = gcpClient.countBqQuery(CdapUtils.pluginProp(tableName)); + Assert.assertEquals(countRecords, recordOut()); + } + + @Then("Run the Pipeline in Runtime") + public void runThePipelineInRuntime() throws InterruptedException { + CdfPipelineRunAction.runClick(); + } + + @Then("Wait till pipeline is in running state") + public void waitTillPipelineIsInRunningState() throws InterruptedException { + Boolean bool = true; + WebDriverWait wait = new WebDriverWait(SeleniumDriver.getDriver(), 1000000); + wait.until(ExpectedConditions.or + (ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@data-cy='Succeeded']")), + ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@data-cy='Failed']")))); + } + + @Then("Verify the pipeline status is {string}") + public void verifyThePipelineStatusIs(String status) { + boolean webelement = false; + webelement = SeleniumHelper.verifyElementPresent("//*[@data-cy='" + status + "']"); + Assert.assertTrue(webelement); + } + + @Then("Get Count of no of records transferred to BigQuery in {string}") + public void getCountOfNoOfRecordsTransferredToBigQueryIn(String table) throws IOException, InterruptedException { + int countRecords; + countRecords = gcpClient.countBqQuery(CdapUtils.pluginProp(table)); + BeforeActions.scenario.write("**********No of Records Transferred******************:" + countRecords); + Assert.assertTrue(countRecords > 0); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} using query {string} for {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingQueryForNull + (String database, String importQuery, String splitColumnValue) throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + CdfCloudSqlPostGreSqlActions.enterSplitColumn(CdapUtils.pluginProp(splitColumnValue)); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} using " + + "query {string} for between values {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingQueryForBetweenValues + (String database, String importQuery, String cloudPostgresSQLSplitColumnBetweenValue) + throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + CdfCloudSqlPostGreSqlActions.enterSplitColumn(CdapUtils.pluginProp(cloudPostgresSQLSplitColumnBetweenValue)); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} using query {string} for max and min {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingQueryForMaxAndMin + (String database, String importQuery, String splitColumnField) throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + CdfCloudSqlPostGreSqlActions.enterSplitColumn(CdapUtils.pluginProp(splitColumnField)); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} using query {string} " + + "for duplicate values {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingQueryForDuplicateValues + (String database, String importQuery, String splitColumnField) throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + CdfCloudSqlPostGreSqlActions.enterSplitColumn(CdapUtils.pluginProp(splitColumnField)); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} using query {string} for max values {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingQueryForMaxValues + (String database, String importQuery, String splitColumnField) throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + CdfCloudSqlPostGreSqlActions.enterSplitColumn(CdapUtils.pluginProp(splitColumnField)); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} using query {string} for min values {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingQueryForMinValues + (String database, String importQuery, String splitColumnField) throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + CdfCloudSqlPostGreSqlActions.enterSplitColumn(CdapUtils.pluginProp(splitColumnField)); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} " + + "using query {string} for distinct values {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingQueryForDistinctValues + (String database, String importQuery, String splitColumnField) throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + CdfCloudSqlPostGreSqlActions.enterSplitColumn(CdapUtils.pluginProp(splitColumnField)); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} using different join queries {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingDifferentJoinQueries + (String database, String importQuery) throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + } + + @When("Sink is GCS") + public void sinkIsGCS() { + CdfStudioActions.sinkGcs(); + } + + @Then("Validate the output record count") + public void validateTheOutputRecordCount() { + Assert.assertTrue(recordOut() > 0); + } + + @Then("Enter the GCS Properties") + public void enterTheGCSProperties() throws IOException, InterruptedException { + CdfGcsActions.gcsProperties(); + CdfGcsActions.enterReferenceName(); + CdfGcsActions.enterProjectId(); + CdfGcsActions.getGcsBucket(CdapUtils.pluginProp("cloudPSQLGcsBucketName")); + CdfGcsActions.selectFormat("json"); + CdfGcsActions.clickValidateButton(); + } + + @Then("Close the GCS Properties") + public void closeTheGCSProperties() { + CdfGcsActions.closeButton(); + } + + @Then("Verify Preview output schema is not null") + public void verifyPreviewOutputSchemaIsNotNull() { + List previewOutputSchema = new ArrayList(); + List previewOutputSchemaElements = SeleniumDriver.getDriver().findElements( + By.xpath("(//h2[text()='Output Records']/parent::div/div/div/div/div)[1]//div[text()!='']")); + for (WebElement element : previewOutputSchemaElements) { + previewOutputSchema.add(element.getAttribute("title")); + } + Assert.assertTrue(propertiesOutputSchema.size() >= 1); + } + + @Then("Enter the cloudSQLPostgreSQL properties for database {string} using query " + + "{string} for max values {string} with bounding query {string} and {string}") + public void enterTheCloudSQLPostgreSQLPropertiesForDatabaseUsingQueryForMaxValuesWithBoundingQueryAnd + (String database, String importQuery, String splitColumnField, String boundingQuery, String splitValue) + throws IOException, InterruptedException { + enterTheCloudSQLPostgreSQLPropertiesForDatabase(database); + CdfCloudSqlPostGreSqlActions.enterImportQuery(CdapUtils.pluginProp(importQuery)); + CdfCloudSqlPostGreSqlActions.enterSplitColumn(CdapUtils.pluginProp(splitColumnField)); + CdfCloudSqlPostGreSqlActions.enterBoundingQuery(CdapUtils.pluginProp(boundingQuery)); + CdfCloudSqlPostGreSqlActions.replaceSplitValue(CdapUtils.pluginProp(splitValue)); + } } + diff --git a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/stepsdesign/package-info.java b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/stepsdesign/package-info.java index 9e01e3cbce..d772f26a48 100755 --- a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/stepsdesign/package-info.java +++ b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/stepsdesign/package-info.java @@ -2,5 +2,3 @@ * Package contains the stepDesign for the GCP features. */ package io.cdap.plugin.cloudsqlpostgresql.stepsdesign; - - diff --git a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/tests/runner/TestRunner.java b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/tests/runner/TestRunner.java index a1ef259d25..e45b240923 100755 --- a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/tests/runner/TestRunner.java +++ b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/tests/runner/TestRunner.java @@ -25,8 +25,8 @@ @RunWith(Cucumber.class) @CucumberOptions( features = {"src/e2e-test/features"}, - glue = {"io.cdap.plugin.cloudsqlmysql.stepsdesign", "stepsdesign"}, - tags = {"@CLDPGSQL"}, + glue = {"io.cdap.plugin.cloudsqlpostgresql.stepsdesign", "stepsdesign"}, + tags = {"@cloudSQLPostgreSQL"}, monochrome = true, plugin = {"pretty", "html:target/cucumber-html-report", "json:target/cucumber-reports/cucumber.json", "junit:target/cucumber-reports/cucumber.xml"} diff --git a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/tests/runner/package-info.java b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/tests/runner/package-info.java index fac81f79f1..bbc072c786 100755 --- a/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/tests/runner/package-info.java +++ b/src/e2e-test/java/io/cdap/plugin/cloudsqlpostgresql/tests/runner/package-info.java @@ -17,4 +17,3 @@ * Package contains the runner for the GCP features. */ package io.cdap.plugin.cloudsqlpostgresql.tests.runner; - diff --git a/src/e2e-test/resources/errorMessage.properties b/src/e2e-test/resources/errorMessage.properties index a3c0afe062..5221d0c26e 100755 --- a/src/e2e-test/resources/errorMessage.properties +++ b/src/e2e-test/resources/errorMessage.properties @@ -2,4 +2,5 @@ errorMessageColor=#a40403 errorMessageMandatory=Required property 'PROPERTY' has no value. ERROR_MESSAGE_SPLIT_COLUMN_NAME=Split-By Field Name must be specified if Number of Splits is not set to 1. ERROR_MESSAGE_NUMBER_OF_SPLITS_NAME=Invalid value for numSplits '0'. Must be at least 1. -ERROR_MESSAGE_NUMBER_OF_BOUNDING_QUERY=Bounding Query must be specified if Number of Splits is not set to 1. \ No newline at end of file +ERROR_MESSAGE_NUMBER_OF_BOUNDING_QUERY=Bounding Query must be specified if Number of Splits is not set to 1. +errorMessageValidation=No errors found. diff --git a/src/e2e-test/resources/pluginParameters.properties b/src/e2e-test/resources/pluginParameters.properties index 4493900938..197bf77aff 100755 --- a/src/e2e-test/resources/pluginParameters.properties +++ b/src/e2e-test/resources/pluginParameters.properties @@ -1,22 +1,36 @@ Project-ID=cdf-athena windowSize=1920x1040 -Data-Set=test_automation -pSqlErrorMessageColor=#a40403 -pSqlReferenceNameInvalid=#@#@#@#@#@ -pSqlReferenceNameValid=TestReference -pSqlDriverNameInvalid=$#$#$#$#$# -pSqlDriverNameValid=cloudsql-postgresql -pSqlDatabaseName=postgres -pSqlUserName=postgres -pSqlPassword=india1234 -pSqlConnectionNameValid=10.232.15.232 -pSqlConnectionNameInvalid=10 -pSqlImportQuery=select * from psql; -pSqlBoundingQuery=select MIN(s_no),MAX(s_no) from cdftest4; -pSqlTableNameCS=psql -pSqlConnectionTimeout=20 -pSqlSplitColumn=s_no -pSqlIncorrectSplit=@#*() -pSqlNumberOfSplits=3 -pSqlInvalidNumberOfSplits=0 -pSqlTableNameBQCS=booleantbl \ No newline at end of file +CloudPsqlBqDataSet=test_automation +cloudPsqlImportQuery=select * from psql; +cloudPsqlDbName=postgres +cloudPsqlTableName=psql +cloudPsqlReferenceNameValid=TestReference +cloudPsqlDriverNameInvalid=$#$#$#$#$# +cloudPsqlReferenceNameInvalid=#@#@#@#@#@ +cloudPsqlConnectionNameInvalid=10 +cloudPSQLDBImportQueryForAll=select* from postgre_datatype +cloudPSQLDBBoundingQuery= Select MIN(dayofjoining),MAX(dayofjoining) from EmployeeDetails +cloudPSQLDBImportQueryForBetween=select* from EmployeeDetails where empid between 621375 and 850279 +cloudPSQLSplitColumnBetweenValue=empid +cloudPSQLDBImportQueryForIn=select* from EmployeeDetails where firstname in ('Reid','Madge') +cloudPSQLSplitColumnInValue=firstname +cloudPSQLDBImportQueryNotIn=select* from EmployeeDetails where firstname not in ('Reid','Madge') +cloudPSQLSplitColumnNotInValue=firstname +cloudPSQLDBImportQueryOrderBy=select* from EmployeeDetails order By lastname +cloudPSQLSplitColumnOrderByValue=lastname +cloudPSQLDBImportQueryDuplicate=select firstname,email,count(*) from EmployeeDetails Group By firstname,email Having count(*)>1; +cloudPSQLSplitColumnDuplicateValue=firstname,email +cloudPSQLDBImportQueryForMax=select max(dayofjoining) from EmployeeDetails +cloudPSQLSplitColumnMaxValue=dayofjoining +cloudPSQLDBImportQueryForMin=select min(dayofjoining) from EmployeeDetails +cloudPSQLSplitColumnMinValue=dayofjoining +cloudPSQLDBImportQueryDistinct=select distinct firstname,lastname from EmployeeDetails +cloudPSQLSplitColumnDistinctValue=firstname +cloudPSQLDBImportQueryInnerJoin=select first_name,last_name from customers inner join orders on customers.customer_id=orders.customer_id +cloudPSQLDBImportQueryLeftJoin=select first_name,last_name from customers left join orders on customers.customer_id=orders.customer_id +cloudPSQLDBImportQueryRightJoin=select first_name,last_name from customers right join orders on customers.customer_id=orders.customer_id +cloudPSQLDBImportQueryOuterJoin=select first_name,last_name from customers full outer join orders on customers.customer_id=orders.customer_id +cloudPSQLQuery=select *from EmployeeDetails where $CONDITIONS; +cloudPsqlNoOfSplits=3 +cloudPsqlBigQuery=psql +cloudPSQLGcsBucketName=cdf-athena/Employee_work/2021-09-03-21-00