Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 29 additions & 6 deletions src/main/java/io/cdap/e2e/pages/actions/CdfPipelineRunAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,38 @@ public static void waitForPipelineToTransitionToStatus(String pipelineStatus, lo
* Timeout: {@link ConstantsUtil#IMPLICIT_TIMEOUT_SECONDS}
*/
public static void waitTillPipelineRunCompletes() throws InterruptedException {
// Adding a page refresh in case tests are running on CDF to update the pipeline status.
RetryUtils.retry(ConstantsUtil.PIPELINE_REFRESH_TIMEOUT_SECONDS, ConstantsUtil.PIPELINE_RUN_TIMEOUT_SECONDS,
10, () -> {
try {
// Wait for the Pipeline run to complete for the default timeout
WaitHelper.waitForElementToBeHidden(CdfPipelineRunLocators.runningStatus);
} catch (Exception e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

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

can we properly log the error?

}

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove empty line


// Loop to refresh the page if the pipeline is still running till max refresh count
int maxRefreshCount = ConstantsUtil.MAX_PAGE_REFRESH_ATTEMPTS;
while (maxRefreshCount > 0) {
boolean isPipelineRunning = isRunning();

if (isPipelineRunning) {
PageHelper.refreshCurrentPage();
return !(isRunning());

try {
Thread.sleep(5000); // Wait for 5 second after the refresh
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to use the static wait as there are multiple threads running in parallel and UI responsiveness can introduce unwanted failures

Copy link
Member

Choose a reason for hiding this comment

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

can we move this to constant class?

} catch (InterruptedException e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

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

same comment here

}
);

waitTillPipelineRunCompletes(ConstantsUtil.IMPLICIT_TIMEOUT_SECONDS);
WaitHelper.waitForPageToLoad();
WaitHelper.waitForElementToBeClickable(CdfPipelineRunLocators.runDropdownButton);
WaitHelper.waitForElementToBeHidden(
CdfPipelineRunLocators.runningStatus, ConstantsUtil.IMPLICIT_TIMEOUT_SECONDS);
} else {
break;
}

--maxRefreshCount;
}
}

/**
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/io/cdap/e2e/pages/actions/CdfSignInActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.cdap.e2e.utils.WaitHelper;

import java.io.IOException;

import java.time.Duration;


/**
Expand All @@ -41,13 +41,16 @@ public static void login() throws IOException, InterruptedException {
ElementHelper.clickOnElement(cdfSignInLocator.nextButton);

ElementHelper.clickIfDisplayed(cdfSignInLocator.selectTestAccount(ConstantsUtil.CDF_TEST_ACCOUNT_NAME),
ConstantsUtil.SMALL_TIMEOUT_SECONDS, cdfSignInLocator.clickOnContinueButton());
ConstantsUtil.CDF_LOGIN_TIMEOUT_SECONDS, cdfSignInLocator.clickOnContinueButton());

ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnContinueButton(), ConstantsUtil.SMALL_TIMEOUT_SECONDS,
cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source"));
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnContinueButton());
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnAllowButton());

ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnAllowButton(), ConstantsUtil.SMALL_TIMEOUT_SECONDS,
cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source"));
// ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnContinueButton(), ConstantsUtil.SMALL_TIMEOUT_SECONDS,
// cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source"));
//
// ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnAllowButton(), ConstantsUtil.SMALL_TIMEOUT_SECONDS,
// cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source"));

}

Expand Down
25 changes: 17 additions & 8 deletions src/main/java/io/cdap/e2e/pages/actions/CdfStudioActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.cdap.e2e.utils.SeleniumDriver;
import io.cdap.e2e.utils.SeleniumHelper;
import io.cdap.e2e.utils.WaitHelper;
import io.cucumber.java8.Th;
import org.openqa.selenium.By;
import org.openqa.selenium.ElementClickInterceptedException;
import org.openqa.selenium.TimeoutException;
Expand All @@ -33,6 +34,7 @@
import org.slf4j.LoggerFactory;

import java.net.URISyntaxException;
import java.time.Duration;

/**
* Represents Cdf Studio Page Actions
Expand Down Expand Up @@ -178,8 +180,9 @@ public static void fillPipelineNameAndSave(String pipelineName) {
pipelineName();
pipelineNameIp(pipelineName);
pipelineSave();
WaitHelper.waitForElementToBeDisplayed(CdfStudioLocators.statusBanner);
WaitHelper.waitForElementToBeHidden(CdfStudioLocators.statusBanner);
WaitHelper.waitForElementToBeOptionallyDisplayed(CdfStudioLocators.statusBannerDisplay(),
ConstantsUtil.SMALL_TIMEOUT_SECONDS);
WaitHelper.waitForElementToBeHidden(CdfStudioLocators.statusBannerDisplay(), ConstantsUtil.SMALL_TIMEOUT_SECONDS);
}

/**
Expand Down Expand Up @@ -217,7 +220,7 @@ public static void closePreviewMenu() {
* @param runtimeArgumentKey macro argument
* @param value actual value to enter
*/
public static void enterRuntimeArgumentValue(String runtimeArgumentKey, String value) {
public static void enterRuntimeArgumentValue(String runtimeArgumentKey, String value) throws InterruptedException {
ElementHelper.sendKeys(CdfStudioLocators.runtimeArgsValue(runtimeArgumentKey), value);
}

Expand Down Expand Up @@ -286,16 +289,18 @@ public static void clickPreviewLogsButton() {
*
* @param status
*/
public static void verifyPipelinePreviewStatusInLogs(String status) {
AssertionHelper.verifyElementDisplayed(CdfLogLocators.getPipelineStatusFromLogs(status));
public static void verifyPipelinePreviewStatusInLogs(String status) throws InterruptedException {
WaitHelper.waitForElementToBeDisplayed(CdfLogLocators.getPipelineStatusFromLogs(status));
// AssertionHelper.verifyElementDisplayed(CdfLogLocators.getPipelineStatusFromLogs(status));
}

/**
* Click on the Deploy button
*/
public static void pipelineDeploy() {
ElementHelper.clickOnElement(CdfStudioLocators.pipelineDeploy);
WaitHelper.waitForElementToBeDisplayed(CdfStudioLocators.deployingPipelineMessage);
WaitHelper.waitForElementToBeOptionallyDisplayed(CdfStudioLocators.locatorOfdeployingPipelineMessage(),
ConstantsUtil.SMALL_TIMEOUT_SECONDS);
WaitHelper.waitForElementToBeHidden(
CdfStudioLocators.locatorOfdeployingPipelineMessage(), ConstantsUtil.PIPELINE_DEPLOY_TIMEOUT_SECONDS);
}
Expand Down Expand Up @@ -529,10 +534,14 @@ public static void clickOnFixAllButtonIfDisplayed() {
* Imports a pipeline from the specified file path.
* @param filePath The path to the file containing the pipeline to be imported.
**/
public static void importPipeline(String filePath) throws URISyntaxException {
public static void importPipeline(String filePath) throws URISyntaxException, InterruptedException {
WaitHelper.waitForElementToBeDisplayed(CdfStudioLocators.importPipelineButton);
FileImportUtil.uploadFile(CdfStudioLocators.importPipelineInputTag(), filePath);
clickOnFixAllButtonIfDisplayed();

// clickOnFixAllButtonIfDisplayed();
ElementHelper.clickOnElement(CdfStudioLocators.fixAllButtonWrangler);
Thread.sleep(20000);
WaitHelper.waitForPageToLoad();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public By clickOnContinueButton() {
}

public static By locatePluginNameInList(String pluginName, String pluginGroupName) {
return By.xpath("//div[@data-cy='plugin-" + pluginGroupName + "-group']" +
return By.xpath("//div[@data-testid='plugin-" + pluginGroupName + "-group']" +
"//div[contains(@class, 'PluginNameContainer')][normalize-space(text()) = '" + pluginName + "' " +
"or translate(normalize-space(text()),' ','') = '" + pluginName + "']");
}
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/io/cdap/e2e/pages/locators/CdfStudioLocators.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ public static By locateDataPipelineTypeSelectedOption(String option) {
}

public static WebElement locatePluginGroupExpanded(String pluginGroupName) {
String xpath = "//div[@data-cy='plugin-" + pluginGroupName + "-group-summary' and @aria-expanded='true']";
String xpath = "//div[@data-testid='plugin-" + pluginGroupName + "-group-summary' and @aria-expanded='true']";
return SeleniumDriver.getDriver().findElement(By.xpath(xpath));
}

public static By locatorOfPluginGroupCollapsed(String pluginGroupName) {
String xpath = "//div[@data-cy='plugin-" + pluginGroupName + "-group-summary' and @aria-expanded='false']";
String xpath = "//div[@data-testid='plugin-" + pluginGroupName + "-group-summary' and @aria-expanded='false']";
return By.xpath(xpath);
}

Expand All @@ -185,19 +185,19 @@ public static WebElement locatePluginGroupCollapsed(String pluginGroupName) {
}

public static WebElement locatePluginNameInList(String pluginName, String pluginGroupName) {
String xpath = "//div[@data-cy='plugin-" + pluginGroupName + "-group']" +
String xpath = "//div[@data-testid='plugin-" + pluginGroupName + "-group']" +
"//div[contains(@class, 'PluginNameContainer')][normalize-space(text()) = '" + pluginName + "' " +
"or translate(normalize-space(text()),' ','') = '" + pluginName + "']";
return SeleniumDriver.getDriver().findElement(By.xpath(xpath));
}

public static WebElement locateSinkPluginNameInList(String pluginName) {
String xpath = "//*[@data-cy='plugin-" + pluginName + "-batchsink']";
String xpath = "//*[@data-testid='plugin-" + pluginName + "-batchsink']";
return SeleniumDriver.getDriver().findElement(By.xpath(xpath));
}

public static WebElement locateRealtimeSourcePluginNameInList(String pluginName) {
String xpath = "//*[@data-cy='plugin-" + pluginName + "-streamingsource']";
String xpath = "//*[@data-testid='plugin-" + pluginName + "-streamingsource']";
return SeleniumDriver.getDriver().findElement(By.xpath(xpath));
}

Expand Down Expand Up @@ -272,8 +272,15 @@ public static By locatorOfLoadingSpinnerOnValidateButton() {
@FindBy(how = How.XPATH, using = "//*[@id='import-pipeline']")
public static WebElement importPipelineButton;

@FindBy(how = How.XPATH, using = "//button[@data-testid='fix-all-btn']")
public static WebElement fixAllButtonWrangler;

public static By fixAllButton() {
return By.xpath("//button[@data-cy='fix-all-btn']");
return By.xpath("//button[@data-testid='fix-all-btn']");
}

public static By statusBannerDisplay() {
return By.xpath("//*[@data-cy='valium-banner-hydrator']");
}

public static WebElement importPipelineInputTag() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/cdap/e2e/utils/CdfHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import stepsdesign.BeforeActions;

import java.io.IOException;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/io/cdap/e2e/utils/ConstantsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,20 @@ public class ConstantsUtil {
/**
* DEFAULT_TIMEOUT_SECONDS: To be used in external wait helpers defined in {@link WaitHelper}
*/
public static final int DEFAULT_TIMEOUT_SECONDS = 180;
public static final int DEFAULT_TIMEOUT_SECONDS = 300;
/**
* PAGE_LOAD_TIMEOUT_SECONDS: To be used as Selenium driver's default page load timeout
*/
public static final int PAGE_LOAD_TIMEOUT_SECONDS = 50;
public static final int PAGE_LOAD_TIMEOUT_SECONDS = 300;
/**
* SMALL_TIMEOUT_SECONDS: To be used as a small static wait (only if needed)
*/
public static final int SMALL_TIMEOUT_SECONDS = 5;
public static final int SMALL_TIMEOUT_SECONDS = 20;
/**
* CDFLOGIN_TIMEOUT_SECONDS: To be used as a small static wait (only if needed) for cdf login page
*/
public static final int CDF_LOGIN_TIMEOUT_SECONDS = 50;

/**
* MEDIUM_TIMEOUT_SECONDS: To be used as a medium static wait (only if needed)
*/
Expand All @@ -111,4 +116,6 @@ public class ConstantsUtil {
public static final int PIPELINE_RUN_TIMEOUT_SECONDS = 900;

public static final int PIPELINE_REFRESH_TIMEOUT_SECONDS = 120;

public static final int MAX_PAGE_REFRESH_ATTEMPTS = 10;
}
Loading