Skip to content

Commit

Permalink
fix flaky e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
SbloodyS committed Jun 27, 2024
1 parent d9485e7 commit 8fb382f
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data.basedir.path=/tmp/dolphinscheduler
# use shared file mount point
resource.storage.type=LOCAL
# resource store on HDFS/S3 path, resource file will store to this base path, self configuration, please make sure the directory exists on hdfs and have read write permissions. "/dolphinscheduler" is recommended
resource.storage.upload.base.path=/dolphinscheduler
resource.storage.upload.base.path=/tmp/dolphinscheduler

# The Azure client ID (Azure Application (client) ID)
resource.azure.client.id=minioadmin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
@Slf4j
public abstract class BaseWorkflowE2ETest {

protected static String projectName = UUID.randomUUID().toString();
protected static final String projectName = UUID.randomUUID().toString();

protected static final AdminUser adminUser = new AdminUser();

Expand Down Expand Up @@ -112,7 +112,7 @@ protected WorkflowInstanceTab.Row untilWorkflowInstanceExist(String workflowName
.stream()
.filter(it -> it.workflowInstanceName().startsWith(workflowName))
.findFirst()
.orElse(null);
.orElseThrow(null);
}, Objects::nonNull);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@
public class NavBarPage {
protected final RemoteWebDriver driver;

@FindBy(css = ".tab-horizontal .n-menu-item:nth-child(2) > .n-menu-item-content")
@FindBy(xpath = "//div[contains(@class, 'tab-horizontal')]//div[contains(@role,'menubar')]//span[contains(text(), 'Project')]")
private WebElement projectTab;

@FindBy(css = ".tab-horizontal .n-menu-item:nth-child(3) > .n-menu-item-content")
@FindBy(xpath = "//div[contains(@class, 'tab-horizontal')]//div[contains(@role,'menubar')]//span[contains(text(), 'Resources')]")
private WebElement resourceTab;

@FindBy(css = ".tab-horizontal .n-menu-item:nth-child(4) > .n-menu-item-content")
@FindBy(xpath = "//div[contains(@class, 'tab-horizontal')]//div[contains(@role,'menubar')]//span[contains(text(), 'Data Quality')]")
private WebElement dataQualityTab;

@FindBy(css = ".tab-horizontal .n-menu-item:nth-child(5) > .n-menu-item-content")
@FindBy(xpath = "//div[contains(@class, 'tab-horizontal')]//div[contains(@role,'menubar')]//span[contains(text(), 'Datasource')]")
private WebElement dataSourceTab;

@FindBy(css = ".tab-horizontal .n-menu-item:nth-child(7) > .n-menu-item-content")
@FindBy(xpath = "//div[contains(@class, 'tab-horizontal')]//div[contains(@role,'menubar')]//span[contains(text(), 'Security')]")
private WebElement securityTab;

public NavBarPage(RemoteWebDriver driver) {
Expand All @@ -66,14 +66,14 @@ public NavBarPage(RemoteWebDriver driver) {
public <T extends NavBarItem> T goToNav(Class<T> nav) {
if (nav == ProjectPage.class) {
WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(projectTab));
projectTab.click();
((JavascriptExecutor) driver).executeScript("arguments[0].click();", projectTab());
WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/projects/list"));
return nav.cast(new ProjectPage(driver));
}

if (nav == SecurityPage.class) {
WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(securityTab));
securityTab.click();
((JavascriptExecutor) driver).executeScript("arguments[0].click();", securityTab());
WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/tenant-manage"));
return nav.cast(new SecurityPage(driver));
}
Expand All @@ -87,7 +87,7 @@ public <T extends NavBarItem> T goToNav(Class<T> nav) {

if (nav == DataSourcePage.class) {
WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(dataSourceTab));
dataSourceTab.click();
((JavascriptExecutor) driver).executeScript("arguments[0].click();", dataSourceTab());
WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/datasource"));
return nav.cast(new DataSourcePage(driver));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@
*/
package org.apache.dolphinscheduler.e2e.pages.project;

import java.time.Duration;
import lombok.SneakyThrows;
import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory;
import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage;
import org.apache.dolphinscheduler.e2e.pages.project.workflow.TaskInstanceTab;
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowDefinitionTab;
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowInstanceTab;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.FindBy;

import lombok.Getter;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

@Getter
public final class ProjectDetailPage extends NavBarPage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public WebElement getTask(String taskName) {

public WorkflowSaveDialog submit() {
buttonSave().click();

WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(.,'Basic Information')]")));
return new WorkflowSaveDialog(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
package org.apache.dolphinscheduler.e2e.pages.project.workflow;

import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
Expand All @@ -45,6 +47,8 @@ public WorkflowRunDialog(WorkflowDefinitionTab parent) {
}

public WorkflowDefinitionTab submit() {
By runDialogTitleXpath = By.xpath(String.format("//*[contains(text(), '%s')]", "Please set the parameters before starting"));
WebDriverWaitFactory.createWebDriverWait(parent.driver()).until(ExpectedConditions.visibilityOfElementLocated(runDialogTitleXpath));
WebDriverWaitFactory.createWebDriverWait(parent.driver()).until(ExpectedConditions.elementToBeClickable(buttonSubmit()));

buttonSubmit().click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
package org.apache.dolphinscheduler.e2e.pages.project.workflow;

import lombok.Getter;

import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
Expand All @@ -44,7 +48,7 @@ public final class WorkflowSaveDialog {
})
private WebElement inputName;

@FindBy(className = "btn-submit")
@FindBy(xpath = "//div[contains(text(), 'Basic Information')]/../following-sibling::div[contains(@class, 'n-card__footer')]//button[contains(@class, 'btn-submit')]")
private WebElement buttonSubmit;

@FindBys({
Expand Down Expand Up @@ -72,8 +76,6 @@ public WorkflowSaveDialog name(String name) {
public WorkflowSaveDialog addGlobalParam(String key, String value) {
final int len = globalParamsItems().findElements(By.tagName("input")).size();

final WebDriver driver = parent().driver();

if (len == 0) {
buttonGlobalCustomParameters().click();

Expand All @@ -90,8 +92,9 @@ public WorkflowSaveDialog addGlobalParam(String key, String value) {
}

public WorkflowForm submit() {
buttonSubmit().click();

WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(buttonSubmit));
buttonSubmit.click();
WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("workflow-definition"));
return parent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public class FileManagePage extends NavBarPage implements ResourcePage.Tab {

private final RenameBox renameBox;

private final CreateFileBox createFileBox;

private final UploadFileBox uploadFileBox;

private final EditFileBox editFileBox;
Expand All @@ -90,8 +88,6 @@ public FileManagePage(RemoteWebDriver driver) {

renameBox = new RenameBox();

createFileBox = new CreateFileBox();

uploadFileBox = new UploadFileBox();

editFileBox = new EditFileBox();
Expand Down Expand Up @@ -175,10 +171,11 @@ public FileManagePage createFile(String fileName, String scripts) {

WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/resource/file/create"));

createFileBox().inputFileName().sendKeys(fileName);
createFileBox().codeEditor().content(scripts);
createFileBox().buttonSubmit().click();
// todo: check if the operation is successful
CreateFileBox createFileBox = new CreateFileBox();
createFileBox.inputFileName().sendKeys(fileName);
createFileBox.codeEditor().content(scripts);
createFileBox.buttonSubmit().click();
WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/resource/file-manage"));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Preconditions;
import com.google.common.io.Files;

public abstract class AbstractStorageOperator implements StorageOperator {

private static final Logger log = LoggerFactory.getLogger(AbstractStorageOperator.class);
protected final String resourceBaseAbsolutePath;

public AbstractStorageOperator(String resourceBaseAbsolutePath) {
Expand Down Expand Up @@ -60,7 +64,7 @@ public ResourceMetadata getResourceMetaData(String resourceAbsolutePath) {
@Override
public String getStorageBaseDirectory() {
// All directory should end with File.separator
return PropertyUtils.getString(Constants.RESOURCE_UPLOAD_PATH, "/dolphinscheduler");
return PropertyUtils.getString(Constants.RESOURCE_UPLOAD_PATH, "/tmp/dolphinscheduler");
}

@Override
Expand Down

0 comments on commit 8fb382f

Please sign in to comment.