Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e send-email test scenarios #1637

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's expected that we would log a message when email is sent successfully.
A RuntimeException is thrown in the failure case - does this show up in the pipeline logs when there is an error in sending email? https://github.com/cdapio/hydrator-plugins/blob/develop/core-plugins/src/main/java/io/cdap/plugin/batch/action/EmailAction.java#L154

Then Close the pipeline logs
Then Validate OUT record count is equal to IN record count
Original file line number Diff line number Diff line change
@@ -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: "<filepath>"
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: "<RunCondition>"
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 "<status>"
#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 |
Original file line number Diff line number Diff line change
@@ -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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we using file source plugin in these tests? If not, please remove irrelevant code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we are using file source plugin.

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());
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading