[E2E] Clean up the E2E with Java API to avoid platform sensitive (#8197)
parent
aeb7d89c50
commit
db953a229c
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue