From 953521d15daefb5f8cb2aa2c28fb01fa03593663 Mon Sep 17 00:00:00 2001 From: muminmmd Date: Wed, 18 May 2022 17:13:01 +0530 Subject: [PATCH 1/3] e2e send-email test scenarios --- .../ErrorScenariosSendEmailAlert.feature | 46 ++++++ .../source/MacrosSendEmailAlert.feature | 67 +++++++++ .../RunTimeScenariosSendEmailAlert.feature | 58 ++++++++ .../common/stepsdesign/TestSetupHooks.java | 134 ++++++++++++++++++ .../sendemail/actions/SendEmailActions.java | 55 +++++++ .../sendemail/locators/SendEmailLocators.java | 39 +++++ .../sendemail/locators/package-info.java | 19 +++ .../plugin/sendemail/runners/TestRunner.java | 38 +++++ .../sendemail/runners/package-info.java | 19 +++ .../sendemail/stepsdesign/SendEmail.java | 53 +++++++ .../test/resources/errorMessage.properties | 6 + .../pluginDataCyAttributes.properties | 45 ++++++ .../resources/pluginParameters.properties | 68 +++++++++ .../testdata/file/CSV_DATATYPE_TEST_1.csv | 5 + .../testdata/file/CSV_INVALID_FORMAT_FILE.csv | 5 + 15 files changed, 657 insertions(+) create mode 100644 e2e-test/src/test/features/sendemail/source/ErrorScenariosSendEmailAlert.feature create mode 100644 e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature create mode 100644 e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature create mode 100644 e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java create mode 100644 e2e-test/src/test/java/io/cdap/plugin/sendemail/actions/SendEmailActions.java create mode 100644 e2e-test/src/test/java/io/cdap/plugin/sendemail/locators/SendEmailLocators.java create mode 100644 e2e-test/src/test/java/io/cdap/plugin/sendemail/locators/package-info.java create mode 100644 e2e-test/src/test/java/io/cdap/plugin/sendemail/runners/TestRunner.java create mode 100644 e2e-test/src/test/java/io/cdap/plugin/sendemail/runners/package-info.java create mode 100644 e2e-test/src/test/java/io/cdap/plugin/sendemail/stepsdesign/SendEmail.java create mode 100644 e2e-test/src/test/resources/errorMessage.properties create mode 100644 e2e-test/src/test/resources/pluginDataCyAttributes.properties create mode 100644 e2e-test/src/test/resources/pluginParameters.properties create mode 100644 e2e-test/src/test/resources/testdata/file/CSV_DATATYPE_TEST_1.csv create mode 100644 e2e-test/src/test/resources/testdata/file/CSV_INVALID_FORMAT_FILE.csv diff --git a/e2e-test/src/test/features/sendemail/source/ErrorScenariosSendEmailAlert.feature b/e2e-test/src/test/features/sendemail/source/ErrorScenariosSendEmailAlert.feature new file mode 100644 index 000000000..30767b3ea --- /dev/null +++ b/e2e-test/src/test/features/sendemail/source/ErrorScenariosSendEmailAlert.feature @@ -0,0 +1,46 @@ +@Send_Email +Feature: Send Email Alert - Verify error scenarios + + @SEND_EMAIL-01 + Scenario: Verify send email alert validation errors for mandatory fields + Given Open Datafusion Project to configure pipeline + And Click plugin property: "configureTab" + And Click plugin property: "pipelineAlertTab" + And Click plugin property: "createAlertButton" + And Select send email alert plugin + And Click on the Validate button + And Verify mandatory property error for below listed properties: + | sender | + | recipients | + | subject | + | message | + + @SEND_EMAIL @PLUGIN-1253 + Scenario: Validate proper format for sender field in send email plugin + Given Open Datafusion Project to configure pipeline + And Click plugin property: "configureTab" + And Click plugin property: "pipelineAlertTab" + And Click plugin property: "createAlertButton" + And Select send email alert plugin + And Select dropdown plugin property: "emailRunCondition" with option value: "sendEmailCompletion" + And Enter input plugin property: "emailSender" with value: "sendEmailInvalidSender" + And Enter send email plugin property email recipient with value: "sendEmailRecipients" + And Enter input plugin property: "emailSubject" with value: "sendEmailSubject" + And Enter textarea plugin property: "emailMessage" with value: "sendEmailMessage" + And Click on the Validate button + And Verify that the Plugin Property: "sender" is displaying an in-line error message: "errorMessageInvalidSenderField" + + @SEND_EMAIL @PLUGIN-1253 + Scenario: Verify proper format for recipient field in send email plugin + Given Open Datafusion Project to configure pipeline + And Click plugin property: "configureTab" + And Click plugin property: "pipelineAlertTab" + And Click plugin property: "createAlertButton" + And Select send email alert plugin + And Select dropdown plugin property: "emailRunCondition" with option value: "sendEmailCompletion" + And Enter input plugin property: "emailSender" with value: "sendEmailSender" + And Enter send email plugin property email recipient with value: "sendEmailInvalidRecipients" + And Enter input plugin property: "emailSubject" with value: "sendEmailSubject" + And Enter textarea plugin property: "emailMessage" with value: "sendEmailMessage" + And Click on the Validate button + And Verify that the Plugin Property: "sender" is displaying an in-line error message: "errorMessageInvalidRecipientField" diff --git a/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature b/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature new file mode 100644 index 000000000..69478b2d6 --- /dev/null +++ b/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature @@ -0,0 +1,67 @@ +@Send_Email +Feature: Send Email Alert - Verify macro scenarios + + @SEND_EMAIL @FILE_SOURCE_TEST @BQ_SINK_TEST + Scenario: Verify send email functionality with macro arguments using File to BigQuery pipeline + Given Open Datafusion Project to configure pipeline + And Select plugin: "File" from the plugins list as: "Source" + And Expand Plugin group in the LHS plugins list: "Sink" + And Select plugin: "BigQuery" from the plugins list as: "Sink" + And Connect plugins: "File" and "BigQuery" to establish connection + And Navigate to the properties page of plugin: "File" + And Enter input plugin property: "referenceName" with value: "FileReferenceName" + And Enter input plugin property: "path" with value: "csvAllDataTypeFile" + And Select dropdown plugin property: "format" with option value: "csv" + And Click plugin property: "skipHeader" + And Click on the Get Schema button + And Verify the Output Schema matches the Expected Schema: "csvAllDataTypeFileSchema" + And Validate "File" plugin properties + And Close the Plugin Properties page + And Navigate to the properties page of plugin: "BigQuery" + And Replace input plugin property: "projectId" with value: "projectId" + And Enter input plugin property: "datasetProjectId" with value: "projectId" + And Enter input plugin property: "referenceName" with value: "BQReferenceName" + And Enter input plugin property: "dataset" with value: "dataset" + And Enter input plugin property: "table" with value: "bqTargetTable" + And Click plugin property: "truncateTable" + And Click plugin property: "updateTableSchema" + And Validate "BigQuery" plugin properties + And Close the Plugin Properties page + And Click plugin property: "configureTab" + And Click plugin property: "pipelineAlertTab" + And Click plugin property: "createAlertButton" + And Select send email alert plugin + And Select dropdown plugin property: "emailRunCondition" with option value: "sendEmailCompletion" + And Click on the Macro button of Property: "emailSender" and set the value to: "sender" + And Click on the Macro button of Property: "emailRecipient" and set the value to: "recipients" + And Click on the Macro button of Property: "emailSubject" and set the value to: "subject" + And Click on the Macro button of Property: "emailMessage" and set the value in textarea: "message" + And Click on the Macro button of Property: "emailUsername" and set the value to: "username" + And Click on the Macro button of Property: "emailPassword" and set the value to: "password" + And Click on the Macro button of Property: "emailProtocol" and set the value to: "protocol" + And Click on the Macro button of Property: "emailHost" and set the value to: "host" + And Click on the Macro button of Property: "emailPort" and set the value to: "port" + And Click on the Macro button of Property: "emailIncludeWorkflowToken" and set the value to: "token" + And Validate send email plugin properties + And Click plugin property: "emailNextButton" + And Click plugin property: "emailConfirmButton" + And Click Pipeline Alert Save Button + And Save and Deploy Pipeline + And Run the Pipeline in Runtime + And Enter runtime argument value "sendEmailSender" for key "sender" + And Enter runtime argument value "sendEmailRecipients" for key "recipients" + And Enter runtime argument value "sendEmailSubject" for key "subject" + And Enter runtime argument value "sendEmailMessage" for key "message" + And Enter runtime argument value "sendEmailUsername" for key "username" + And Enter runtime argument value "sendEmailPassword" for key "password" + And Enter runtime argument value "sendEmailProtocol" for key "protocol" + And Enter runtime argument value "sendEmailHost" for key "host" + And Enter runtime argument value "sendEmailPort" for key "port" + And Enter runtime argument value "sendEmailIncludeWorkflowToken" for key "token" + And Run the Pipeline in Runtime with runtime arguments + And Wait till pipeline is in running state + And Open and capture logs + And Verify the pipeline status is "Succeeded" + #And Verify email sent message in logs (Implement this step once PLUGIN-1255 is fixed.) + Then Close the pipeline logs + Then Validate OUT record count is equal to IN record count diff --git a/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature b/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature new file mode 100644 index 000000000..6f33d333d --- /dev/null +++ b/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature @@ -0,0 +1,58 @@ +@Send_Email +Feature: Send Email Alert - Run time scenarios + + @SEND_EMAIL @BQ_SINK_TEST @FILE_SOURCE_TEST + Scenario Outline: Verify send email alert functionality using File to BigQuery pipeline for different run conditions + Given Open Datafusion Project to configure pipeline + And Select plugin: "File" from the plugins list as: "Source" + And Expand Plugin group in the LHS plugins list: "Sink" + And Select plugin: "BigQuery" from the plugins list as: "Sink" + And Connect plugins: "File" and "BigQuery" to establish connection + And Navigate to the properties page of plugin: "File" + And Enter input plugin property: "referenceName" with value: "FileReferenceName" + And Enter input plugin property: "path" with value: "" + And Select dropdown plugin property: "format" with option value: "csv" + And Click plugin property: "skipHeader" + And Click on the Get Schema button + And Validate "File" plugin properties + And Close the Plugin Properties page + And Navigate to the properties page of plugin: "BigQuery" + And Replace input plugin property: "projectId" with value: "projectId" + And Enter input plugin property: "datasetProjectId" with value: "projectId" + And Enter input plugin property: "referenceName" with value: "BQReferenceName" + And Enter input plugin property: "dataset" with value: "dataset" + And Enter input plugin property: "table" with value: "bqTargetTable" + And Click plugin property: "truncateTable" + And Click plugin property: "updateTableSchema" + And Validate "BigQuery" plugin properties + And Close the Plugin Properties page + And Click plugin property: "configureTab" + And Click plugin property: "pipelineAlertTab" + And Click plugin property: "createAlertButton" + And Select send email alert plugin + And Select dropdown plugin property: "emailRunCondition" with option value: "" + And Enter input plugin property: "emailSender" with value: "sendEmailSender" + And Enter send email plugin property email recipient with value: "sendEmailRecipients" + And Enter input plugin property: "emailSubject" with value: "sendEmailSubject" + And Enter textarea plugin property: "emailMessage" with value: "sendEmailMessage" + And Enter input plugin property: "emailUsername" with value: "sendEmailUsername" + And Enter input plugin property: "emailPassword" with value: "sendEmailPassword" + And Enter input plugin property: "emailProtocol" with value: "sendEmailProtocol" + And Enter input plugin property: "emailHost" with value: "sendEmailHost" + And Enter input plugin property: "emailPort" with value: "sendEmailPort" + And Validate send email plugin properties + And Click plugin property: "emailNextButton" + And Click plugin property: "emailConfirmButton" + And Click Pipeline Alert Save Button + And Save and Deploy Pipeline + And Run the Pipeline in Runtime + And Wait till pipeline is in running state + And Open and capture logs + And Verify the pipeline status is "" + #And Verify email sent message in logs (Implement this step once PLUGIN-1255 is fixed.) + Examples: + | RunCondition | filepath | status | + | sendEmailCompletion | csvAllDataTypeFile | Succeeded | + | sendEmailSuccess | csvAllDataTypeFile | Succeeded | + | sendEmailFailure | sendEmailCsvInvalidFormatFile | Failed | + | sendEmailCompletion | sendEmailCsvInvalidFormatFile | Failed | diff --git a/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java b/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java new file mode 100644 index 000000000..8ec8498f3 --- /dev/null +++ b/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java @@ -0,0 +1,134 @@ +/* + * Copyright © 2022 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.common.stepsdesign; + +import com.google.cloud.bigquery.BigQueryException; +import io.cdap.e2e.utils.BigQueryClient; +import io.cdap.e2e.utils.PluginPropertyUtils; +import io.cucumber.java.After; +import io.cucumber.java.Before; +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import stepsdesign.BeforeActions; + +import java.io.IOException; +import java.nio.file.Paths; +import java.util.UUID; + +/** + * GCP test hooks. + */ +public class TestSetupHooks { + private static boolean firstFileSourceTestFlag = true; + private static boolean firstFileSinkTestFlag = true; + + @Before(order = 1, value = "@FILE_SOURCE_TEST") + public static void setFileSourceAbsolutePath() { + if (firstFileSourceTestFlag) { + PluginPropertyUtils.addPluginProp("csvFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("csvFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("csvAllDataTypeFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("csvAllDataTypeFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("tsvFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("tsvFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("blobFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("blobFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("delimitedFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("delimitedFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("textFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("textFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("outputFieldTestFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("outputFieldTestFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("readRecursivePath", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("readRecursivePath")).getPath()) + "/"); + PluginPropertyUtils.addPluginProp("sendEmailCsvInvalidFormatFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("sendEmailCsvInvalidFormatFile")).getPath()) + "/"); + firstFileSourceTestFlag = false; + } + } + + @Before(order = 1, value = "@FILE_SINK_TEST") + public static void setFileSinkAbsolutePath() { + if (firstFileSinkTestFlag) { + PluginPropertyUtils.addPluginProp("filePluginOutputFolder" + , Paths.get("target/" + PluginPropertyUtils.pluginProp("filePluginOutputFolder")) + .toAbsolutePath().toString()); + firstFileSinkTestFlag = false; + } + } + + @Before(order = 1, value = "@BQ_SINK_TEST") + public static void setTempTargetBQTableName() { + String bqTargetTableName = "E2E_TARGET_" + UUID.randomUUID().toString().replaceAll("-", "_"); + PluginPropertyUtils.addPluginProp("bqTargetTable", bqTargetTableName); + BeforeActions.scenario.write("BQ Target table name - " + bqTargetTableName); + } + + @After(order = 1, value = "@BQ_SINK_TEST") + public static void deleteTempTargetBQTable() throws IOException, InterruptedException { + String bqTargetTableName = PluginPropertyUtils.pluginProp("bqTargetTable"); + try { + BigQueryClient.dropBqQuery(bqTargetTableName); + BeforeActions.scenario.write("BQ Target table - " + bqTargetTableName + " deleted successfully"); + PluginPropertyUtils.removePluginProp("bqTargetTable"); + } catch (BigQueryException e) { + if (e.getMessage().contains("Not found: Table")) { + BeforeActions.scenario.write("BQ Target Table " + bqTargetTableName + " does not exist"); + } else { + Assert.fail(e.getMessage()); + } + } + } + + /** + * Create BigQuery table with 3 columns (Id - Int, Value - Int, UID - string) containing random testdata. + * Sample row: + * Id | Value | UID + * 22 | 968 | 245308db-6088-4db2-a933-f0eea650846a + */ + @Before(order = 1, value = "@BQ_SOURCE_TEST") + public static void createTempSourceBQTable() throws IOException, InterruptedException { + String bqSourceTable = "E2E_SOURCE_" + UUID.randomUUID().toString().replaceAll("-", "_"); + StringBuilder records = new StringBuilder(StringUtils.EMPTY); + for (int index = 2; index <= 25; index++) { + records.append(" (").append(index).append(", ").append((int) (Math.random() * 1000 + 1)).append(", '") + .append(UUID.randomUUID()).append("'), "); + } + BigQueryClient.getSoleQueryResult("create table `test_automation." + bqSourceTable + "` as " + + "SELECT * FROM UNNEST([ " + + " STRUCT(1 AS Id, " + ((int) (Math.random() * 1000 + 1)) + " as Value, " + + "'" + UUID.randomUUID() + "' as UID), " + + records + + " (26, " + ((int) (Math.random() * 1000 + 1)) + ", " + + "'" + UUID.randomUUID() + "') " + + "])"); + PluginPropertyUtils.addPluginProp("bqSourceTable", bqSourceTable); + BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " created successfully"); + } + + @After(order = 1, value = "@BQ_SOURCE_TEST") + public static void deleteTempSourceBQTable() throws IOException, InterruptedException { + String bqSourceTable = PluginPropertyUtils.pluginProp("bqSourceTable"); + BigQueryClient.dropBqQuery(bqSourceTable); + BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " deleted successfully"); + PluginPropertyUtils.removePluginProp("bqSourceTable"); + } + + @Before(order = 1, value = "@SEND_EMAIL") + public static void setGCSConnectionName() { + PluginPropertyUtils.addPluginProp("sendEmailSubject", "send-email-" + UUID.randomUUID()); + } +} diff --git a/e2e-test/src/test/java/io/cdap/plugin/sendemail/actions/SendEmailActions.java b/e2e-test/src/test/java/io/cdap/plugin/sendemail/actions/SendEmailActions.java new file mode 100644 index 000000000..ab7c0e879 --- /dev/null +++ b/e2e-test/src/test/java/io/cdap/plugin/sendemail/actions/SendEmailActions.java @@ -0,0 +1,55 @@ +/* + * Copyright © 2022 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.sendemail.actions; + +import io.cdap.e2e.utils.ElementHelper; +import io.cdap.e2e.utils.PluginPropertyUtils; +import io.cdap.e2e.utils.SeleniumHelper; +import io.cdap.e2e.utils.WaitHelper; +import io.cdap.plugin.sendemail.locators.SendEmailLocators; + + +/** + * Send-email alert related actions. + */ + +public class SendEmailActions { + + static { + SeleniumHelper.getPropertiesLocators(SendEmailLocators.class); + } + + public static void clickOnSendEmail() { + ElementHelper.clickOnElement(SendEmailLocators.sendEmailAlert); + } + + public static void enterRecipientDetails(String value) { + String valueFromPluginPropertiesFile = PluginPropertyUtils.pluginProp(value); + if (valueFromPluginPropertiesFile == null) { + ElementHelper.sendKeys(SendEmailLocators.recipientInput, value); + } else { + ElementHelper.sendKeys(SendEmailLocators.recipientInput, valueFromPluginPropertiesFile); + } + } + + public static void clickPipelineAlertSaveButton() { + ElementHelper.clickOnElement(SendEmailLocators.pipelineAlertSaveButton); + } + + public static void verifyIfSendEmailPluginIsValidatedSuccessfully() { + WaitHelper.waitForElementToBeDisplayed(SendEmailLocators.sendEmailPluginValidationSuccessMsg); + } +} diff --git a/e2e-test/src/test/java/io/cdap/plugin/sendemail/locators/SendEmailLocators.java b/e2e-test/src/test/java/io/cdap/plugin/sendemail/locators/SendEmailLocators.java new file mode 100644 index 000000000..1ed86245e --- /dev/null +++ b/e2e-test/src/test/java/io/cdap/plugin/sendemail/locators/SendEmailLocators.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2022 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.sendemail.locators; + +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.How; + +/** + * Send-email alert plugin Locators. + */ + +public class SendEmailLocators { + + @FindBy(how = How.XPATH, using = "//div[@content-data='action' and normalize-space(text())='Send Email']") + public static WebElement sendEmailAlert; + + @FindBy(how = How.XPATH, using = "//*[text()='No errors found.']") + public static WebElement sendEmailPluginValidationSuccessMsg; + + @FindBy(how = How.XPATH, using = "//*[@data-cy='recipients']//input") + public static WebElement recipientInput; + + @FindBy(how = How.XPATH, using = "//button[@data-testid='config-apply-close']") + public static WebElement pipelineAlertSaveButton; +} diff --git a/e2e-test/src/test/java/io/cdap/plugin/sendemail/locators/package-info.java b/e2e-test/src/test/java/io/cdap/plugin/sendemail/locators/package-info.java new file mode 100644 index 000000000..27fc8c81f --- /dev/null +++ b/e2e-test/src/test/java/io/cdap/plugin/sendemail/locators/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright © 2022 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 locators for Send-email alert + */ +package io.cdap.plugin.sendemail.locators; diff --git a/e2e-test/src/test/java/io/cdap/plugin/sendemail/runners/TestRunner.java b/e2e-test/src/test/java/io/cdap/plugin/sendemail/runners/TestRunner.java new file mode 100644 index 000000000..863c505da --- /dev/null +++ b/e2e-test/src/test/java/io/cdap/plugin/sendemail/runners/TestRunner.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2022 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.sendemail.runners; + +import io.cucumber.junit.Cucumber; +import io.cucumber.junit.CucumberOptions; +import org.junit.runner.RunWith; + +/** + * Test Runner to execute send-email alert testcases. + */ +@RunWith(Cucumber.class) +@CucumberOptions( + features = {"src/test/features"}, + glue = {"io.cdap.plugin.sendemail.stepsdesign", "stepsdesign", "io.cdap.plugin.file.stepsdesign", + "io.cdap.plugin.common.stepsdesign"}, + tags = {"@Send_Email and not @PLUGIN-1253"}, + // TODO: Enable test once issue is fixed https://cdap.atlassian.net/browse/PLUGIN-1253 + monochrome = true, + plugin = {"pretty", "html:target/cucumber-html-report/send-email", + "json:target/cucumber-reports/cucumber-send-email.json", + "junit:target/cucumber-reports/cucumber-send-email.xml"} +) +public class TestRunner { +} diff --git a/e2e-test/src/test/java/io/cdap/plugin/sendemail/runners/package-info.java b/e2e-test/src/test/java/io/cdap/plugin/sendemail/runners/package-info.java new file mode 100644 index 000000000..76b348fe0 --- /dev/null +++ b/e2e-test/src/test/java/io/cdap/plugin/sendemail/runners/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright © 2022 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 runner for the send-email alert plugin. + */ +package io.cdap.plugin.sendemail.runners; diff --git a/e2e-test/src/test/java/io/cdap/plugin/sendemail/stepsdesign/SendEmail.java b/e2e-test/src/test/java/io/cdap/plugin/sendemail/stepsdesign/SendEmail.java new file mode 100644 index 000000000..fa14a5bf3 --- /dev/null +++ b/e2e-test/src/test/java/io/cdap/plugin/sendemail/stepsdesign/SendEmail.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2022 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.sendemail.stepsdesign; + +import io.cdap.e2e.pages.actions.CdfPluginPropertiesActions; +import io.cdap.plugin.sendemail.actions.SendEmailActions; +import io.cucumber.java.en.And; + +/** + * Send-email alert plugin related step design. + */ + +public class SendEmail { + + @And("Select send email alert plugin") + public void selectSendEmailAlert() { + SendEmailActions.clickOnSendEmail(); + } + + @And("Enter send email plugin property email recipient with value: {string}") + public void enterSendEmailPluginPropertyEmailRecipientWithValue(String value) { + SendEmailActions.enterRecipientDetails(value); + } + + @And("Click Pipeline Alert Save Button") + public void clickPipelineAlertSaveButton() { + SendEmailActions.clickPipelineAlertSaveButton(); + } + + @And("Validate send email plugin properties") + public void validateSendEmailPluginProperties() { + CdfPluginPropertiesActions.clickValidateButton(); + SendEmailActions.verifyIfSendEmailPluginIsValidatedSuccessfully(); + } + + @And("Verify email sent message in logs") + public void verifyEmailSentMessageInLogs() { + // (Implement this step once PLUGIN-1255 is fixed.) + } +} diff --git a/e2e-test/src/test/resources/errorMessage.properties b/e2e-test/src/test/resources/errorMessage.properties new file mode 100644 index 000000000..0d013a6fb --- /dev/null +++ b/e2e-test/src/test/resources/errorMessage.properties @@ -0,0 +1,6 @@ +validationSuccessMessage=No errors found. +validationErrorMessage=COUNT ERROR found +errorMessageInputPath=Invalid schema: Input path not found +errorMessageFileInvalidOutputField=Path field 'PATH_FIELD' must exist in input schema. +errorMessageInvalidSenderField= +errorMessageInvalidRecipientField= diff --git a/e2e-test/src/test/resources/pluginDataCyAttributes.properties b/e2e-test/src/test/resources/pluginDataCyAttributes.properties new file mode 100644 index 000000000..e402ad4e0 --- /dev/null +++ b/e2e-test/src/test/resources/pluginDataCyAttributes.properties @@ -0,0 +1,45 @@ +referenceName=referenceName +projectId=project +datasetProjectId=datasetProject +dataset=dataset +table=table +truncateTable=switch-truncateTable +truncateTableMacroInput=truncateTable +updateTableSchema=switch-allowSchemaRelaxation +updateTableSchemaMacroInput=allowSchemaRelaxation +outputSchemaMacroInput=Output Schema-macro-input +path=path +pathSuffix=suffix +format=select-format +formatMacroInput=format +sampleSize=sampleSize +delimiter=delimiter +skipHeader=switch-skipHeader +skipHeaderMacroInput=skipHeader +maximumSplitSize=maxSplitSize +regexPathFilter=fileRegex +pathField=pathField +pathFileNameOnly=filenameOnly +readFilesRecursively=recursive +allowEmptyInput=ignoreNonExistingFolders +fileSystemProperties=fileSystemProperties +fileEncoding=fileEncoding + +## SEND-EMAIL-ALERT-DATA-CY-PROPERTIES-START +emailRunCondition=select-runCondition +emailSender=sender +emailRecipient=recipients +emailSubject=subject +emailMessage=message +emailUsername=username +emailPassword=password +emailProtocol=protocol +emailHost=host +emailPort=port +emailIncludeWorkflowToken=includeWorkflowToken +emailNextButton=next-btn +emailConfirmButton=confirm-btn +configureTab=pipeline-configure-modeless-btn +pipelineAlertTab=pipeline-configure-alerts-tab +createAlertButton=post-run-alerts-create +## SEND-EMAIL-ALERT-DATA-CY-PROPERTIES-END diff --git a/e2e-test/src/test/resources/pluginParameters.properties b/e2e-test/src/test/resources/pluginParameters.properties new file mode 100644 index 000000000..2dc347b84 --- /dev/null +++ b/e2e-test/src/test/resources/pluginParameters.properties @@ -0,0 +1,68 @@ +projectId=cdf-athena +dataset=test_automation +csvFormat=csv + +## FILE-PLUGIN-PROPERTIES-START +incorrectFilePath=invalidPath +csvFile=testdata/file/CSV_TEST.csv +csvFileSchema=[{"key":"EmployeeDepartment","value":"string"},{"key":"Employeename","value":"string"},\ + {"key":"Salary","value":"int"},{"key":"workhours","value":"int"}] +csvFileOutputSchema={ "type": "record", "name": "text", "fields": [ \ + { "name": "EmployeeDepartment", "type": "string" }, { "name": "Employeename", "type": "string" }, \ + { "name": "Salary", "type": "int" }, { "name": "workhours", "type": "int" } ] } +csvAllDataTypeFile=testdata/file/CSV_DATATYPE_TEST_1.csv +csvAllDataTypeFileSchema=[{"key":"id","value":"int"},{"key":"name","value":"string"},\ + {"key":"yearofbirth","value":"int"},{"key":"isdeleted","value":"boolean"},{"key":"email","value":"string"},\ + {"key":"createddate","value":"string"},{"key":"revenue","value":"string"},{"key":"points","value":"string"},\ + {"key":"longdatatype","value":"string"},{"key":"doubledatatype","value":"double"},\ + {"key":"date","value":"string"},{"key":"null","value":"string"},{"key":"BytesData","value":"string"}] +tsvFile=testdata/file/TSV_TEST.tsv +tsvFileSchema=[{"key":"testscenarioid","value":"string"},{"key":"testdescription","value":"string"},\ + {"key":"testconditionid","value":"string"},{"key":"testtype","value":"string"}] +blobFile=testdata/file/BLOB_TEST.zip +blobFileSchema=[{"key":"body","value":"bytes"}] +delimitedFile=testdata/file/DELIMITED_TEST.txt +delimiter=@ +incorrectDelimiter=# +delimitedFileSchema=[{"key":"id","value":"int"},{"key":"name","value":"string"},\ + {"key":"yearofbirth","value":"int"},{"key":"datatype","value":"long"},{"key":"tablename","value":"string"}] +textFile=testdata/file/TEXT_TEST.txt +textFileSchema=[{"key":"offset","value":"long"},{"key":"body","value":"string"}] +outputFieldTestFile=testdata/file/OUTPUTFIELD_TEST.csv +outputPathField=outputfield +invalidOutputPathField=invalid +outputFieldTestFileSchema=[{"key":"id","value":"int"},{"key":"firstname","value":"string"},\ + {"key":"lastname","value":"string"},{"key":"photo","value":"string"},{"key":"outputfield","value":"string"}] +overrideSchema=[{"key":"id","value":"float"},{"key":"firstname","value":"string"},\ + {"key":"lastname","value":"string"},{"key":"photo","value":"string"},{"key":"outputfield","value":"string"}] +overrideField=id +invalidOverrideField=invalid +overrideDataType=float +readRecursivePath=testdata/file/RECURSIVE_TEST +readRecursivePathSchema=[{"key":"id","value":"int"},{"key":"name","value":"string"},\ + {"key":"yearofbirth","value":"int"},{"key":"tablename","value":"string"},{"key":"offset","value":"string"}] +fileMaxSplitSize=120 +regexPathFilter=.+TEST.csv +incorrectRegexPathFilter=/tZY +filePluginOutputFolder=file-plugin-output +skipHeaderTrue=true +fileSinkPathSuffix=yyyy-MM-dd-HH-mm-ss +## FILE-PLUGIN-PROPERTIES-END + +## SEND-EMAIL-PROPERTIES-START +sendEmailCompletion=completion +sendEmailSuccess=success +sendEmailFailure=failure +sendEmailSender=testsendemailalert@gmail.com +sendEmailInvalidSender=ymlsing +sendEmailRecipients=testsendemailalert@gmail.com +sendEmailInvalidRecipients=incorrectrecp +sendEmailMessage=test case +sendEmailUsername=testsendemailalert@gmail.com +sendEmailPassword=dummyPassword +sendEmailProtocol=smtps +sendEmailHost=smtp.gmail.com +sendEmailPort=465 +sendEmailIncludeWorkflowToken=true +sendEmailCsvInvalidFormatFile=testdata/file/CSV_INVALID_FORMAT_FILE.csv +## SEND-EMAIL-PROPERTIES-END diff --git a/e2e-test/src/test/resources/testdata/file/CSV_DATATYPE_TEST_1.csv b/e2e-test/src/test/resources/testdata/file/CSV_DATATYPE_TEST_1.csv new file mode 100644 index 000000000..94b35afaa --- /dev/null +++ b/e2e-test/src/test/resources/testdata/file/CSV_DATATYPE_TEST_1.csv @@ -0,0 +1,5 @@ +id,name,yearofbirth,isdeleted,email,createddate,revenue,points,longdatatype,doubledatatype,date,null,BytesData +1,albert einstein,1879,true,sumitsri@gmail.com,2021-09-20 11:27:50 UTC,900750000.01,3.14235678,-9223372036854770000,22.8,1996-07-21,,10111011101110111011 +2,isaac newton,1643,false,sumitsri@gmail.com,2021-09-20 11:27:50 UTC,900750000.01,3.14235678906787648,-9223372036854770000,123.08,1996-07-21,str,10111011101110111011 +3,marie curie,1867,true,sumitsri@gmail.com,2021-09-20 11:27:50 UTC,900750000.01,3.14235678,-9223372036854770000,124.97,1996-07-21,,10111011101110111011 +4,galilée,1564,false,sumitsri@gmail.com,2021-09-20 11:27:50 UTC,900750000.01,3.14235678,-2^63,234.89,1996-07-21,,10111011101110111011 \ No newline at end of file diff --git a/e2e-test/src/test/resources/testdata/file/CSV_INVALID_FORMAT_FILE.csv b/e2e-test/src/test/resources/testdata/file/CSV_INVALID_FORMAT_FILE.csv new file mode 100644 index 000000000..681d28cc1 --- /dev/null +++ b/e2e-test/src/test/resources/testdata/file/CSV_INVALID_FORMAT_FILE.csv @@ -0,0 +1,5 @@ +id,name,yearofbirth,isdeleted,email,createddate,revenue,points,longdatatype,doubledatatype,date,null,BytesData +1,albert einstein,1879,true,sumitsri@gmail.com,2021-09-20 11:27:50 UTC,900750000.01,3.14235678,-9223372036854770000,22.8,1996-07-21,,10111011101110111011 +2,isaac newton,1643,false,sumitsri@gmail.com,2021-09-20 11:27:50 UTC,900750000.01,3.14235678906787648,-9223372036854770000,123.08,1996-07-21,str,10111011101110111011 +3,marie curie,1867,true,sumitsri@gmail.com,2021-09-20 11:27:50 UTC,900750000.01,3.14235678,-9223372036854770000,124.97,1996-07-21,,10111011101110111011 +4,galilée,1564,false,sumitsri@gmail.com,2021-09-20 11:27:50, {format.fit.ni}ke, just-fin=[dataple]x.{] UTC,900750000.01,3.14235678,-2^63,234.89,1996-07-21,,10111011101110111011 \ No newline at end of file From b058e2a14aba231c49bf608cac89805b51c5c9f2 Mon Sep 17 00:00:00 2001 From: muminmmd Date: Tue, 24 May 2022 19:23:20 +0530 Subject: [PATCH 2/3] e2e send-email test scenarios 2 --- .../source/MacrosSendEmailAlert.feature | 3 +- .../RunTimeScenariosSendEmailAlert.feature | 53 +++++++++++++++++++ .../common/stepsdesign/TestSetupHooks.java | 37 ++++++------- .../test/resources/errorMessage.properties | 1 + .../resources/pluginParameters.properties | 2 +- 5 files changed, 76 insertions(+), 20 deletions(-) diff --git a/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature b/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature index 69478b2d6..24f41f2c7 100644 --- a/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature +++ b/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature @@ -50,7 +50,8 @@ Feature: Send Email Alert - Verify macro scenarios And Run the Pipeline in Runtime And Enter runtime argument value "sendEmailSender" for key "sender" And Enter runtime argument value "sendEmailRecipients" for key "recipients" - And Enter runtime argument value "sendEmailSubject" for key "subject" + #And Enter runtime argument value "sendEmailSubject" for key "subject" + And Enter runtime argument value "emailSubject" for key "subject" And Enter runtime argument value "sendEmailMessage" for key "message" And Enter runtime argument value "sendEmailUsername" for key "username" And Enter runtime argument value "sendEmailPassword" for key "password" diff --git a/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature b/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature index 6f33d333d..400a1de38 100644 --- a/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature +++ b/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature @@ -56,3 +56,56 @@ Feature: Send Email Alert - Run time scenarios | sendEmailSuccess | csvAllDataTypeFile | Succeeded | | sendEmailFailure | sendEmailCsvInvalidFormatFile | Failed | | sendEmailCompletion | sendEmailCsvInvalidFormatFile | Failed | + + @SEND_EMAIL @BQ_SINK_TEST @FILE_SOURCE_TEST + Scenario: Verify email sent failure text in logs when the pipeline is successful + Given Open Datafusion Project to configure pipeline + And Select plugin: "File" from the plugins list as: "Source" + And Expand Plugin group in the LHS plugins list: "Sink" + And Select plugin: "BigQuery" from the plugins list as: "Sink" + And Connect plugins: "File" and "BigQuery" to establish connection + And Navigate to the properties page of plugin: "File" + And Enter input plugin property: "referenceName" with value: "FileReferenceName" + And Enter input plugin property: "path" with value: "csvAllDataTypeFile" + And Select dropdown plugin property: "format" with option value: "csv" + And Click plugin property: "skipHeader" + And Click on the Get Schema button + And Validate "File" plugin properties + And Close the Plugin Properties page + And Navigate to the properties page of plugin: "BigQuery" + And Replace input plugin property: "projectId" with value: "projectId" + And Enter input plugin property: "datasetProjectId" with value: "projectId" + And Enter input plugin property: "referenceName" with value: "BQReferenceName" + And Enter input plugin property: "dataset" with value: "dataset" + And Enter input plugin property: "table" with value: "bqTargetTable" + And Click plugin property: "truncateTable" + And Click plugin property: "updateTableSchema" + And Validate "BigQuery" plugin properties + And Close the Plugin Properties page + And Click plugin property: "configureTab" + And Click plugin property: "pipelineAlertTab" + And Click plugin property: "createAlertButton" + And Select send email alert plugin + And Select dropdown plugin property: "emailRunCondition" with option value: "sendEmailCompletion" + And Enter input plugin property: "emailSender" with value: "sendEmailSender" + And Enter send email plugin property email recipient with value: "sendEmailRecipients" + And Enter input plugin property: "emailSubject" with value: "sendEmailSubject" + And Enter textarea plugin property: "emailMessage" with value: "sendEmailMessage" + And Enter input plugin property: "emailUsername" with value: "sendEmailUsername" + And Enter input plugin property: "emailPassword" with value: "sendInvalidEmailPassword" + And Enter input plugin property: "emailProtocol" with value: "sendEmailProtocol" + And Enter input plugin property: "emailHost" with value: "sendEmailHost" + And Enter input plugin property: "emailPort" with value: "sendEmailPort" + And Validate send email plugin properties + And Click plugin property: "emailNextButton" + And Click plugin property: "emailConfirmButton" + And Click Pipeline Alert Save Button + And Save and Deploy Pipeline + And Run the Pipeline in Runtime + And Wait till pipeline is in running state + And Open and capture logs + And Verify the pipeline status is "Succeeded" + And Close the pipeline logs + And Open Pipeline logs and verify Log entries having below listed Level and Message: + | Level | Message | + | ERROR | errorMessageSentEmailFailure | diff --git a/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java b/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java index 8ec8498f3..36f5ecc36 100644 --- a/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java +++ b/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java @@ -38,24 +38,24 @@ public class TestSetupHooks { @Before(order = 1, value = "@FILE_SOURCE_TEST") public static void setFileSourceAbsolutePath() { if (firstFileSourceTestFlag) { - PluginPropertyUtils.addPluginProp("csvFile", Paths.get(TestSetupHooks.class.getResource - ("/" + PluginPropertyUtils.pluginProp("csvFile")).getPath()).toString()); +// PluginPropertyUtils.addPluginProp("csvFile", Paths.get(TestSetupHooks.class.getResource +// ("/" + PluginPropertyUtils.pluginProp("csvFile")).getPath()).toString()); PluginPropertyUtils.addPluginProp("csvAllDataTypeFile", Paths.get(TestSetupHooks.class.getResource ("/" + PluginPropertyUtils.pluginProp("csvAllDataTypeFile")).getPath()).toString()); - PluginPropertyUtils.addPluginProp("tsvFile", Paths.get(TestSetupHooks.class.getResource - ("/" + PluginPropertyUtils.pluginProp("tsvFile")).getPath()).toString()); - PluginPropertyUtils.addPluginProp("blobFile", Paths.get(TestSetupHooks.class.getResource - ("/" + PluginPropertyUtils.pluginProp("blobFile")).getPath()).toString()); - PluginPropertyUtils.addPluginProp("delimitedFile", Paths.get(TestSetupHooks.class.getResource - ("/" + PluginPropertyUtils.pluginProp("delimitedFile")).getPath()).toString()); - PluginPropertyUtils.addPluginProp("textFile", Paths.get(TestSetupHooks.class.getResource - ("/" + PluginPropertyUtils.pluginProp("textFile")).getPath()).toString()); - PluginPropertyUtils.addPluginProp("outputFieldTestFile", Paths.get(TestSetupHooks.class.getResource - ("/" + PluginPropertyUtils.pluginProp("outputFieldTestFile")).getPath()).toString()); - PluginPropertyUtils.addPluginProp("readRecursivePath", Paths.get(TestSetupHooks.class.getResource - ("/" + PluginPropertyUtils.pluginProp("readRecursivePath")).getPath()) + "/"); - PluginPropertyUtils.addPluginProp("sendEmailCsvInvalidFormatFile", Paths.get(TestSetupHooks.class.getResource - ("/" + PluginPropertyUtils.pluginProp("sendEmailCsvInvalidFormatFile")).getPath()) + "/"); +// PluginPropertyUtils.addPluginProp("tsvFile", Paths.get(TestSetupHooks.class.getResource +// ("/" + PluginPropertyUtils.pluginProp("tsvFile")).getPath()).toString()); +// PluginPropertyUtils.addPluginProp("blobFile", Paths.get(TestSetupHooks.class.getResource +// ("/" + PluginPropertyUtils.pluginProp("blobFile")).getPath()).toString()); +// PluginPropertyUtils.addPluginProp("delimitedFile", Paths.get(TestSetupHooks.class.getResource +// ("/" + PluginPropertyUtils.pluginProp("delimitedFile")).getPath()).toString()); +// PluginPropertyUtils.addPluginProp("textFile", Paths.get(TestSetupHooks.class.getResource +// ("/" + PluginPropertyUtils.pluginProp("textFile")).getPath()).toString()); +// PluginPropertyUtils.addPluginProp("outputFieldTestFile", Paths.get(TestSetupHooks.class.getResource +// ("/" + PluginPropertyUtils.pluginProp("outputFieldTestFile")).getPath()).toString()); +// PluginPropertyUtils.addPluginProp("readRecursivePath", Paths.get(TestSetupHooks.class.getResource +// ("/" + PluginPropertyUtils.pluginProp("readRecursivePath")).getPath()) + "/"); +// PluginPropertyUtils.addPluginProp("sendEmailCsvInvalidFormatFile", Paths.get(TestSetupHooks.class.getResource +// ("/" + PluginPropertyUtils.pluginProp("sendEmailCsvInvalidFormatFile")).getPath()) + "/"); firstFileSourceTestFlag = false; } } @@ -128,7 +128,8 @@ public static void deleteTempSourceBQTable() throws IOException, InterruptedExce } @Before(order = 1, value = "@SEND_EMAIL") - public static void setGCSConnectionName() { - PluginPropertyUtils.addPluginProp("sendEmailSubject", "send-email-" + UUID.randomUUID()); + public static void setSendEmailPrerequisite() { + PluginPropertyUtils.addPluginProp("emailSubject", "send-email-" + UUID.randomUUID()); + PluginPropertyUtils.addPluginProp("sendEmailPassword", System.getenv("SEND_EMAIL_PASSWORD")); } } diff --git a/e2e-test/src/test/resources/errorMessage.properties b/e2e-test/src/test/resources/errorMessage.properties index 0d013a6fb..f1a090b84 100644 --- a/e2e-test/src/test/resources/errorMessage.properties +++ b/e2e-test/src/test/resources/errorMessage.properties @@ -4,3 +4,4 @@ errorMessageInputPath=Invalid schema: Input path not found errorMessageFileInvalidOutputField=Path field 'PATH_FIELD' must exist in input schema. errorMessageInvalidSenderField= errorMessageInvalidRecipientField= +errorMessageSentEmailFailure=Error while running post action Email-1. diff --git a/e2e-test/src/test/resources/pluginParameters.properties b/e2e-test/src/test/resources/pluginParameters.properties index 2dc347b84..09ce57806 100644 --- a/e2e-test/src/test/resources/pluginParameters.properties +++ b/e2e-test/src/test/resources/pluginParameters.properties @@ -59,7 +59,7 @@ sendEmailRecipients=testsendemailalert@gmail.com sendEmailInvalidRecipients=incorrectrecp sendEmailMessage=test case sendEmailUsername=testsendemailalert@gmail.com -sendEmailPassword=dummyPassword +sendInvalidEmailPassword=123 sendEmailProtocol=smtps sendEmailHost=smtp.gmail.com sendEmailPort=465 From a57bbe28885c5da9023af84478b4ca86ab46401a Mon Sep 17 00:00:00 2001 From: muminmmd Date: Tue, 24 May 2022 19:34:47 +0530 Subject: [PATCH 3/3] e2e send-email test scenarios 3 --- .../source/MacrosSendEmailAlert.feature | 1 - .../RunTimeScenariosSendEmailAlert.feature | 2 +- .../common/stepsdesign/TestSetupHooks.java | 32 +++++++++---------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature b/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature index 24f41f2c7..91826ab98 100644 --- a/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature +++ b/e2e-test/src/test/features/sendemail/source/MacrosSendEmailAlert.feature @@ -50,7 +50,6 @@ Feature: Send Email Alert - Verify macro scenarios And Run the Pipeline in Runtime And Enter runtime argument value "sendEmailSender" for key "sender" And Enter runtime argument value "sendEmailRecipients" for key "recipients" - #And Enter runtime argument value "sendEmailSubject" for key "subject" And Enter runtime argument value "emailSubject" for key "subject" And Enter runtime argument value "sendEmailMessage" for key "message" And Enter runtime argument value "sendEmailUsername" for key "username" diff --git a/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature b/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature index 400a1de38..d8518260b 100644 --- a/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature +++ b/e2e-test/src/test/features/sendemail/source/RunTimeScenariosSendEmailAlert.feature @@ -58,7 +58,7 @@ Feature: Send Email Alert - Run time scenarios | sendEmailCompletion | sendEmailCsvInvalidFormatFile | Failed | @SEND_EMAIL @BQ_SINK_TEST @FILE_SOURCE_TEST - Scenario: Verify email sent failure text in logs when the pipeline is successful + Scenario: Verify email sent failure text message in logs when the pipeline is successful Given Open Datafusion Project to configure pipeline And Select plugin: "File" from the plugins list as: "Source" And Expand Plugin group in the LHS plugins list: "Sink" diff --git a/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java b/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java index 36f5ecc36..ccca2d904 100644 --- a/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java +++ b/e2e-test/src/test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.java @@ -38,24 +38,24 @@ public class TestSetupHooks { @Before(order = 1, value = "@FILE_SOURCE_TEST") public static void setFileSourceAbsolutePath() { if (firstFileSourceTestFlag) { -// PluginPropertyUtils.addPluginProp("csvFile", Paths.get(TestSetupHooks.class.getResource -// ("/" + PluginPropertyUtils.pluginProp("csvFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("csvFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("csvFile")).getPath()).toString()); PluginPropertyUtils.addPluginProp("csvAllDataTypeFile", Paths.get(TestSetupHooks.class.getResource ("/" + PluginPropertyUtils.pluginProp("csvAllDataTypeFile")).getPath()).toString()); -// PluginPropertyUtils.addPluginProp("tsvFile", Paths.get(TestSetupHooks.class.getResource -// ("/" + PluginPropertyUtils.pluginProp("tsvFile")).getPath()).toString()); -// PluginPropertyUtils.addPluginProp("blobFile", Paths.get(TestSetupHooks.class.getResource -// ("/" + PluginPropertyUtils.pluginProp("blobFile")).getPath()).toString()); -// PluginPropertyUtils.addPluginProp("delimitedFile", Paths.get(TestSetupHooks.class.getResource -// ("/" + PluginPropertyUtils.pluginProp("delimitedFile")).getPath()).toString()); -// PluginPropertyUtils.addPluginProp("textFile", Paths.get(TestSetupHooks.class.getResource -// ("/" + PluginPropertyUtils.pluginProp("textFile")).getPath()).toString()); -// PluginPropertyUtils.addPluginProp("outputFieldTestFile", Paths.get(TestSetupHooks.class.getResource -// ("/" + PluginPropertyUtils.pluginProp("outputFieldTestFile")).getPath()).toString()); -// PluginPropertyUtils.addPluginProp("readRecursivePath", Paths.get(TestSetupHooks.class.getResource -// ("/" + PluginPropertyUtils.pluginProp("readRecursivePath")).getPath()) + "/"); -// PluginPropertyUtils.addPluginProp("sendEmailCsvInvalidFormatFile", Paths.get(TestSetupHooks.class.getResource -// ("/" + PluginPropertyUtils.pluginProp("sendEmailCsvInvalidFormatFile")).getPath()) + "/"); + PluginPropertyUtils.addPluginProp("tsvFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("tsvFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("blobFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("blobFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("delimitedFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("delimitedFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("textFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("textFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("outputFieldTestFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("outputFieldTestFile")).getPath()).toString()); + PluginPropertyUtils.addPluginProp("readRecursivePath", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("readRecursivePath")).getPath()) + "/"); + PluginPropertyUtils.addPluginProp("sendEmailCsvInvalidFormatFile", Paths.get(TestSetupHooks.class.getResource + ("/" + PluginPropertyUtils.pluginProp("sendEmailCsvInvalidFormatFile")).getPath()) + "/"); firstFileSourceTestFlag = false; } }