Browse Source

[Feature][e2e] Suggest e2e test adapt M1 chip (#9077)

3.0.0/version-upgrade
xiangzihao 3 years ago committed by GitHub
parent
commit
197accc601
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowRunDialog.java
  2. 68
      dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinSchedulerExtension.java

4
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowRunDialog.java

@ -24,6 +24,8 @@ import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.PageFactory;
import lombok.Getter; import lombok.Getter;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
@Getter @Getter
public final class WorkflowRunDialog { public final class WorkflowRunDialog {
@ -39,6 +41,8 @@ public final class WorkflowRunDialog {
} }
public WorkflowDefinitionTab submit() { public WorkflowDefinitionTab submit() {
new WebDriverWait(parent().driver(), 5).until(ExpectedConditions.elementToBeClickable(buttonSubmit()));
buttonSubmit().click(); buttonSubmit().click();
return parent(); return parent();

68
dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinSchedulerExtension.java

@ -59,13 +59,14 @@ import com.google.common.base.Strings;
import com.google.common.net.HostAndPort; import com.google.common.net.HostAndPort;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.testcontainers.utility.DockerImageName;
@Slf4j @Slf4j
final class DolphinSchedulerExtension final class DolphinSchedulerExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback {
implements BeforeAllCallback, AfterAllCallback,
BeforeEachCallback {
private final boolean LOCAL_MODE = Objects.equals(System.getProperty("local"), "true"); private final boolean LOCAL_MODE = Objects.equals(System.getProperty("local"), "true");
private final boolean M1_CHIP_FLAG = Objects.equals(System.getProperty("m1_chip"), "true");
private RemoteWebDriver driver; private RemoteWebDriver driver;
private DockerComposeContainer<?> compose; private DockerComposeContainer<?> compose;
private BrowserWebDriverContainer<?> browser; private BrowserWebDriverContainer<?> browser;
@ -73,36 +74,24 @@ final class DolphinSchedulerExtension
private HostAndPort address; private HostAndPort address;
private String rootPath; private String rootPath;
private Path record;
@Override @Override
@SuppressWarnings("UnstableApiUsage") @SuppressWarnings("UnstableApiUsage")
public void beforeAll(ExtensionContext context) throws IOException { public void beforeAll(ExtensionContext context) throws IOException {
Awaitility.setDefaultTimeout(Duration.ofSeconds(60)); Awaitility.setDefaultTimeout(Duration.ofSeconds(60));
Awaitility.setDefaultPollInterval(Duration.ofSeconds(10)); Awaitility.setDefaultPollInterval(Duration.ofSeconds(10));
setRecordPath();
if (LOCAL_MODE) { if (LOCAL_MODE) {
runInLocal(); runInLocal();
} else { } else {
runInDockerContainer(context); runInDockerContainer(context);
} }
final Path record; setBrowserContainerByOsName();
if (!Strings.isNullOrEmpty(System.getenv("RECORDING_PATH"))) {
record = Paths.get(System.getenv("RECORDING_PATH"));
if (!record.toFile().exists()) {
if (!record.toFile().mkdir()) {
throw new IOException("Failed to create recording directory: " + record.toAbsolutePath());
}
}
} else {
record = Files.createTempDirectory("record-");
}
browser = new BrowserWebDriverContainer<>()
.withCapabilities(new ChromeOptions())
.withCreateContainerCmdModifier(cmd -> cmd.withUser("root"))
.withFileSystemBind(Constants.HOST_CHROME_DOWNLOAD_PATH.toFile().getAbsolutePath(),
Constants.SELENIUM_CONTAINER_CHROME_DOWNLOAD_PATH)
.withRecordingMode(RECORD_ALL, record.toFile(), MP4);
if (network != null) { if (network != null) {
browser.withNetwork(network); browser.withNetwork(network);
} }
@ -128,8 +117,8 @@ final class DolphinSchedulerExtension
} }
private void runInLocal() { private void runInLocal() {
Testcontainers.exposeHostPorts(8888); Testcontainers.exposeHostPorts(3000);
address = HostAndPort.fromParts("host.testcontainers.internal", 8888); address = HostAndPort.fromParts("host.testcontainers.internal", 3000);
rootPath = "/"; rootPath = "/";
} }
@ -159,6 +148,41 @@ final class DolphinSchedulerExtension
rootPath = "/dolphinscheduler/ui/"; rootPath = "/dolphinscheduler/ui/";
} }
private void setBrowserContainerByOsName() {
DockerImageName imageName;
if (LOCAL_MODE && M1_CHIP_FLAG) {
imageName = DockerImageName.parse("seleniarm/standalone-chromium:4.1.2-20220227")
.asCompatibleSubstituteFor("selenium/standalone-chrome");
browser = new BrowserWebDriverContainer<>(imageName)
.withCapabilities(new ChromeOptions())
.withCreateContainerCmdModifier(cmd -> cmd.withUser("root"))
.withFileSystemBind(Constants.HOST_CHROME_DOWNLOAD_PATH.toFile().getAbsolutePath(),
Constants.SELENIUM_CONTAINER_CHROME_DOWNLOAD_PATH);
} else {
browser = new BrowserWebDriverContainer<>()
.withCapabilities(new ChromeOptions())
.withCreateContainerCmdModifier(cmd -> cmd.withUser("root"))
.withFileSystemBind(Constants.HOST_CHROME_DOWNLOAD_PATH.toFile().getAbsolutePath(),
Constants.SELENIUM_CONTAINER_CHROME_DOWNLOAD_PATH)
.withRecordingMode(RECORD_ALL, record.toFile(), MP4);
}
}
private void setRecordPath() throws IOException {
if (!Strings.isNullOrEmpty(System.getenv("RECORDING_PATH"))) {
record = Paths.get(System.getenv("RECORDING_PATH"));
if (!record.toFile().exists()) {
if (!record.toFile().mkdir()) {
throw new IOException("Failed to create recording directory: " + record.toAbsolutePath());
}
}
} else {
record = Files.createTempDirectory("record-");
}
}
@Override @Override
public void afterAll(ExtensionContext context) { public void afterAll(ExtensionContext context) {
browser.afterTest(new TestDescription(context), Optional.empty()); browser.afterTest(new TestDescription(context), Optional.empty());

Loading…
Cancel
Save