You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ke...@apache.org on 2022/01/26 04:24:25 UTC

[dolphinscheduler] branch cleanup/e2e updated (2fe34a2 -> 1981ba3)

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a change to branch cleanup/e2e
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git.


 discard 2fe34a2  Clean up the E2E with Java API to avoid platform sensitive
     new 1981ba3  Clean up the E2E with Java API to avoid platform sensitive

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (2fe34a2)
            \
             N -- N -- N   refs/heads/cleanup/e2e (1981ba3)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/e2e.yml | 1 -
 1 file changed, 1 deletion(-)

[dolphinscheduler] 01/01: Clean up the E2E with Java API to avoid platform sensitive

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch cleanup/e2e
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git

commit 1981ba3c0c2daf82d6ba2f80d9c42d16cb0b18ac
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Wed Jan 26 10:14:39 2022 +0800

    Clean up the E2E with Java API to avoid platform sensitive
---
 .../e2e/cases/FileManageE2ETest.java               | 51 +++++++++++-----------
 .../e2e/cases/WorkerGroupE2ETest.java              | 14 +++---
 .../docker/file-manage/docker-compose.yaml         | 20 +++------
 .../dolphinscheduler/e2e/core/Constants.java       | 22 +++-------
 .../e2e/core/DolphinSchedulerExtension.java        | 28 ++----------
 dolphinscheduler-e2e/pom.xml                       |  2 +-
 6 files changed, 47 insertions(+), 90 deletions(-)

diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/FileManageE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/FileManageE2ETest.java
index 1a32b5e..8531099 100644
--- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/FileManageE2ETest.java
+++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/FileManageE2ETest.java
@@ -20,6 +20,9 @@
 package org.apache.dolphinscheduler.e2e.cases;
 
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
 import org.apache.dolphinscheduler.e2e.core.Constants;
 import org.apache.dolphinscheduler.e2e.core.DolphinScheduler;
 import org.apache.dolphinscheduler.e2e.pages.LoginPage;
@@ -29,6 +32,13 @@ import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage;
 import org.apache.dolphinscheduler.e2e.pages.security.TenantPage;
 import org.apache.dolphinscheduler.e2e.pages.security.UserPage;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Comparator;
+
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Order;
@@ -37,14 +47,7 @@ import org.openqa.selenium.By;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.remote.RemoteWebDriver;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.awaitility.Awaitility.await;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.file.Paths;
-import java.util.Arrays;
+import lombok.SneakyThrows;
 
 @DolphinScheduler(composeFiles = "docker/file-manage/docker-compose.yaml")
 public class FileManageE2ETest {
@@ -72,9 +75,9 @@ public class FileManageE2ETest {
 
     private static final String testUnder1GBFileName = "test_file_0.01G";
 
-    private static final String testOver1GBFilePath = Constants.HOST_TMP_PATH + "/test_file_1.5G";
+    private static final Path testOver1GBFilePath = Constants.HOST_TMP_PATH.resolve("test_file_1.5G");
 
-    private static final String testUnder1GBFilePath = Constants.HOST_TMP_PATH + "/" + testUnder1GBFileName;
+    private static final Path testUnder1GBFilePath = Constants.HOST_TMP_PATH.resolve(testUnder1GBFileName);
 
     @BeforeAll
     public static void setup() {
@@ -95,18 +98,14 @@ public class FileManageE2ETest {
     }
 
     @AfterAll
+    @SneakyThrows
     public static void cleanup() {
-        String[] command = {"/bin/bash", "-c", String.format("sudo rm -f %s && sudo rm -f %s && sudo rm -rf %s", testUnder1GBFilePath, testOver1GBFilePath, Constants.HOST_CHROME_DOWNLOAD_PATH)};
-
-        try {
-            Process pro = Runtime.getRuntime().exec(command);
-            int status = pro.waitFor();
-            if (status != 0) {
-                throw new RuntimeException(String.format("Failed to call shell's command: %s", Arrays.toString(command)));
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
+        Files.deleteIfExists(testUnder1GBFilePath);
+        Files.deleteIfExists(testOver1GBFilePath);
+        Files.walk(Constants.HOST_CHROME_DOWNLOAD_PATH)
+             .sorted(Comparator.reverseOrder())
+             .map(Path::toFile)
+             .forEach(File::delete);
     }
 
     @Test
@@ -267,10 +266,10 @@ public class FileManageE2ETest {
     void testUploadOver1GBFile() throws IOException {
         final FileManagePage page = new FileManagePage(browser);
 
-        RandomAccessFile file = new RandomAccessFile(testOver1GBFilePath, "rw");
+        RandomAccessFile file = new RandomAccessFile(testOver1GBFilePath.toFile(), "rw");
         file.setLength((long) (1.5 * 1024 * 1024 * 1024));
 
-        page.uploadFile(testOver1GBFilePath);
+        page.uploadFile(testOver1GBFilePath.toFile().getAbsolutePath());
 
         await().untilAsserted(() ->
             assertThat(browser.findElement(By.tagName("body")).getText())
@@ -285,10 +284,10 @@ public class FileManageE2ETest {
 
         browser.navigate().refresh();
 
-        RandomAccessFile file = new RandomAccessFile(testUnder1GBFilePath, "rw");
+        RandomAccessFile file = new RandomAccessFile(testUnder1GBFilePath.toFile(), "rw");
         file.setLength((long) (0.01 * 1024 * 1024 * 1024));
 
-        page.uploadFile(testUnder1GBFilePath);
+        page.uploadFile(testUnder1GBFilePath.toFile().getAbsolutePath());
 
         await().untilAsserted(() -> {
             assertThat(page.fileList())
@@ -305,7 +304,7 @@ public class FileManageE2ETest {
 
         page.downloadFile(testUnder1GBFileName);
 
-        File file = new File(Paths.get(Constants.HOST_CHROME_DOWNLOAD_PATH, testUnder1GBFileName).toFile().getAbsolutePath());
+        File file = Constants.HOST_CHROME_DOWNLOAD_PATH.resolve(testUnder1GBFileName).toFile();
 
         await().untilAsserted(() -> {
             assert file.exists();
diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkerGroupE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkerGroupE2ETest.java
index a0bc082..7e58a59 100644
--- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkerGroupE2ETest.java
+++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkerGroupE2ETest.java
@@ -20,12 +20,14 @@
 package org.apache.dolphinscheduler.e2e.cases;
 
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
 import org.apache.dolphinscheduler.e2e.core.DolphinScheduler;
 import org.apache.dolphinscheduler.e2e.pages.LoginPage;
 import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage;
-import org.apache.dolphinscheduler.e2e.pages.security.TenantPage;
 import org.apache.dolphinscheduler.e2e.pages.security.WorkerGroupPage;
-import org.junit.jupiter.api.AfterAll;
+
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
@@ -33,12 +35,8 @@ import org.openqa.selenium.By;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.remote.RemoteWebDriver;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.awaitility.Awaitility.await;
-
 @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml")
 class WorkerGroupE2ETest {
-    private static final String tenant = System.getProperty("user.name");
     private static final String workerGroupName = "test_worker_group";
     private static final String editWorkerGroupName = "edit_worker_group";
 
@@ -54,7 +52,7 @@ class WorkerGroupE2ETest {
 
     @Test
     @Order(1)
-    void testCreateWorkerGroup() throws InterruptedException {
+    void testCreateWorkerGroup() {
         final WorkerGroupPage page = new WorkerGroupPage(browser);
 
         page.create(workerGroupName);
@@ -71,7 +69,7 @@ class WorkerGroupE2ETest {
 
     @Test
     @Order(20)
-    void testCreateDuplicateWorkerGroup() throws InterruptedException {
+    void testCreateDuplicateWorkerGroup() {
         final WorkerGroupPage page = new WorkerGroupPage(browser);
 
         page.create(workerGroupName);
diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/file-manage/docker-compose.yaml b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/file-manage/docker-compose.yaml
index 4b5e254..4aed71e 100644
--- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/file-manage/docker-compose.yaml
+++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/file-manage/docker-compose.yaml
@@ -15,7 +15,7 @@
 # limitations under the License.
 #
 
-version: "2.1"
+version: "3.8"
 
 services:
   dolphinscheduler:
@@ -38,7 +38,7 @@ services:
       s3:
         condition: service_healthy
       mc:
-        condition: service_healthy
+        condition: service_completed_successfully
   s3:
     image: minio/minio:latest
     hostname: s3
@@ -59,20 +59,12 @@ services:
       retries: 120
   mc:
     image: minio/mc:latest
-    entrypoint: ""
-    hostname: mc
-    tty: true
-    stdin_open: true
+    entrypoint: bash
     networks:
       - e2e
-    command: bash -c '
-      mc alias set s3 http://s3:9000 accessKey123 secretKey123
-      && mc mb s3/dolphinscheduler && tail -f /dev/null'
-    healthcheck:
-      test: [ "CMD", "echo", "1" ]
-      interval: 5s
-      timeout: 120s
-      retries: 120
+    command:
+      - -c
+      - mc alias set s3 http://s3:9000 accessKey123 secretKey123 && mc mb s3/dolphinscheduler
     depends_on:
       s3:
         condition: service_healthy
diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/Constants.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/Constants.java
index 1852fa8..caa3a2b 100644
--- a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/Constants.java
+++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/Constants.java
@@ -17,35 +17,25 @@
 
 package org.apache.dolphinscheduler.e2e.core;
 
+import lombok.experimental.UtilityClass;
+
+import java.nio.file.Path;
 import java.nio.file.Paths;
 
-/**
- * Constants
- */
+@UtilityClass
 public final class Constants {
-
-    private Constants() {
-        throw new UnsupportedOperationException("Construct Constants");
-    }
-
     /**
      * tmp directory path
      */
-    public static final String HOST_TMP_PATH = System.getProperty("java.io.tmpdir");
+    public static final Path HOST_TMP_PATH = Paths.get(System.getProperty("java.io.tmpdir"));
 
     /**
      * chrome download path in host
      */
-    public static final String HOST_CHROME_DOWNLOAD_PATH = Paths.get(System.getProperty("java.io.tmpdir"), "download").toFile().getAbsolutePath();
+    public static final Path HOST_CHROME_DOWNLOAD_PATH = HOST_TMP_PATH.resolve("download");
 
     /**
      * chrome download path in selenium/standalone-chrome-debug container
      */
     public static final String SELENIUM_CONTAINER_CHROME_DOWNLOAD_PATH = "/home/seluser/Downloads";
-
-    /**
-     * host os name
-     */
-    public static final String OS_NAME = System.getProperties().getProperty("os.name");
-
 }
diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinSchedulerExtension.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinSchedulerExtension.java
index 0273df2..76c5be3 100644
--- a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinSchedulerExtension.java
+++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinSchedulerExtension.java
@@ -31,7 +31,6 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.Duration;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
@@ -118,32 +117,11 @@ final class DolphinSchedulerExtension
             record = Files.createTempDirectory("record-");
         }
 
-        // According to https://github.com/SeleniumHQ/docker-selenium#mounting-volumes-to-retrieve-downloaded-files
-        if ("linux".equalsIgnoreCase(Constants.OS_NAME)) {
-            File file = new File(Constants.HOST_CHROME_DOWNLOAD_PATH);
-            boolean result = file.mkdir();
-
-            if (!result) {
-                throw new IOException(String.format("mkdir %s error", Constants.HOST_CHROME_DOWNLOAD_PATH));
-            }
-
-            String[] command = {"/bin/bash", "-c", String.format("sudo chown 1200:1201 %s", Constants.HOST_CHROME_DOWNLOAD_PATH)};
-
-            try {
-                Process pro = Runtime.getRuntime().exec(command);
-                int status = pro.waitFor();
-                if (status != 0) {
-                    throw new IOException(String.format("Failed to call shell's command: %s", Arrays.toString(command)));
-                }
-            } catch (Exception e) {
-                throw new IOException(e);
-            }
-            
-        }
-
         browser = new BrowserWebDriverContainer<>()
             .withCapabilities(new ChromeOptions())
-            .withFileSystemBind(Constants.HOST_CHROME_DOWNLOAD_PATH, Constants.SELENIUM_CONTAINER_CHROME_DOWNLOAD_PATH)
+            .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) {
             browser.withNetwork(network);
diff --git a/dolphinscheduler-e2e/pom.xml b/dolphinscheduler-e2e/pom.xml
index 7be8131..23d99c2 100644
--- a/dolphinscheduler-e2e/pom.xml
+++ b/dolphinscheduler-e2e/pom.xml
@@ -127,7 +127,7 @@
             <dependency>
                 <groupId>org.testcontainers</groupId>
                 <artifactId>testcontainers-bom</artifactId>
-                <version>1.16.1</version>
+                <version>1.16.3</version>
                 <scope>import</scope>
                 <type>pom</type>
             </dependency>