|
|
|
@ -20,6 +20,7 @@
|
|
|
|
|
package org.apache.dolphinscheduler.e2e.cases; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.e2e.core.Constants; |
|
|
|
|
import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; |
|
|
|
|
import org.apache.dolphinscheduler.e2e.pages.LoginPage; |
|
|
|
|
import org.apache.dolphinscheduler.e2e.pages.resource.FileManagePage; |
|
|
|
@ -28,6 +29,7 @@ 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 org.junit.jupiter.api.AfterAll; |
|
|
|
|
import org.junit.jupiter.api.BeforeAll; |
|
|
|
|
import org.junit.jupiter.api.Order; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
@ -38,6 +40,12 @@ 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; |
|
|
|
|
|
|
|
|
|
@DolphinScheduler(composeFiles = "docker/file-manage/docker-compose.yaml") |
|
|
|
|
public class FileManageE2ETest { |
|
|
|
|
private static RemoteWebDriver browser; |
|
|
|
@ -54,6 +62,20 @@ public class FileManageE2ETest {
|
|
|
|
|
|
|
|
|
|
private static final String testDiretoryName = "test_directory"; |
|
|
|
|
|
|
|
|
|
private static final String testSubDirectoryName = "test_sub_directory"; |
|
|
|
|
|
|
|
|
|
private static final String testRenameDirectoryName = "test_rename_directory"; |
|
|
|
|
|
|
|
|
|
private static final String testFileName = "test_file"; |
|
|
|
|
|
|
|
|
|
private static final String testRenameFileName = "test_rename_file.sh"; |
|
|
|
|
|
|
|
|
|
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 String testUnder1GBFilePath = Constants.HOST_TMP_PATH + "/" + testUnder1GBFileName; |
|
|
|
|
|
|
|
|
|
@BeforeAll |
|
|
|
|
public static void setup() { |
|
|
|
|
TenantPage tenantPage = new LoginPage(browser) |
|
|
|
@ -72,6 +94,21 @@ public class FileManageE2ETest {
|
|
|
|
|
.goToTab(FileManagePage.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@AfterAll |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(10) |
|
|
|
|
void testCreateDirectory() { |
|
|
|
@ -85,6 +122,19 @@ public class FileManageE2ETest {
|
|
|
|
|
.anyMatch(it -> it.contains(testDiretoryName))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(11) |
|
|
|
|
void testCancelCreateDirectory() { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
|
|
|
|
|
page.cancelCreateDirectory(testDiretoryName, "test_desc"); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> assertThat(page.fileList()) |
|
|
|
|
.as("File list should contain newly-created file") |
|
|
|
|
.extracting(WebElement::getText) |
|
|
|
|
.anyMatch(it -> it.contains(testDiretoryName))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(20) |
|
|
|
|
void testCreateDuplicateDirectory() { |
|
|
|
@ -99,12 +149,44 @@ public class FileManageE2ETest {
|
|
|
|
|
page.createDirectoryBox().buttonCancel().click(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(21) |
|
|
|
|
void testCreateSubDirectory() { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
|
|
|
|
|
page.createSubDirectory(testDiretoryName, testSubDirectoryName, "test_desc"); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> assertThat(page.fileList()) |
|
|
|
|
.as("File list should contain newly-created file") |
|
|
|
|
.extracting(WebElement::getText) |
|
|
|
|
.anyMatch(it -> it.contains(testSubDirectoryName))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(22) |
|
|
|
|
void testRenameDirectory() { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
|
|
|
|
|
page.rename(testSubDirectoryName, testRenameDirectoryName); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> { |
|
|
|
|
browser.navigate().refresh(); |
|
|
|
|
|
|
|
|
|
assertThat(page.fileList()) |
|
|
|
|
.as("File list should contain newly-created file") |
|
|
|
|
.extracting(WebElement::getText) |
|
|
|
|
.anyMatch(it -> it.contains(testRenameDirectoryName)); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(30) |
|
|
|
|
void testDeleteDirectory() { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
|
|
|
|
|
page.delete(testDiretoryName); |
|
|
|
|
page.goToNav(ResourcePage.class) |
|
|
|
|
.goToTab(FileManagePage.class) |
|
|
|
|
.delete(testDiretoryName); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> { |
|
|
|
|
browser.navigate().refresh(); |
|
|
|
@ -116,4 +198,117 @@ public class FileManageE2ETest {
|
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(40) |
|
|
|
|
void testCreateFile() { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
String scripts = "echo 123"; |
|
|
|
|
|
|
|
|
|
page.createFile(testFileName, scripts); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> assertThat(page.fileList()) |
|
|
|
|
.as("File list should contain newly-created file") |
|
|
|
|
.extracting(WebElement::getText) |
|
|
|
|
.anyMatch(it -> it.contains(testFileName))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(41) |
|
|
|
|
void testRenameFile() { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
|
|
|
|
|
page.rename(testFileName, testRenameFileName); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> { |
|
|
|
|
browser.navigate().refresh(); |
|
|
|
|
|
|
|
|
|
assertThat(page.fileList()) |
|
|
|
|
.as("File list should contain newly-created file") |
|
|
|
|
.extracting(WebElement::getText) |
|
|
|
|
.anyMatch(it -> it.contains(testRenameFileName)); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(42) |
|
|
|
|
void testEditFile() { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
String scripts = "echo 456"; |
|
|
|
|
|
|
|
|
|
page.editFile(testRenameFileName, scripts); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> assertThat(page.fileList()) |
|
|
|
|
.as("File list should contain newly-created file") |
|
|
|
|
.extracting(WebElement::getText) |
|
|
|
|
.anyMatch(it -> it.contains(testRenameFileName))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(45) |
|
|
|
|
void testDeleteFile() { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
|
|
|
|
|
page.delete(testRenameFileName); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> { |
|
|
|
|
browser.navigate().refresh(); |
|
|
|
|
|
|
|
|
|
assertThat( |
|
|
|
|
page.fileList() |
|
|
|
|
).noneMatch( |
|
|
|
|
it -> it.getText().contains(testRenameFileName) |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(60) |
|
|
|
|
void testUploadOver1GBFile() throws IOException { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
|
|
|
|
|
RandomAccessFile file = new RandomAccessFile(testOver1GBFilePath, "rw"); |
|
|
|
|
file.setLength((long) (1.5 * 1024 * 1024 * 1024)); |
|
|
|
|
|
|
|
|
|
page.uploadFile(testOver1GBFilePath); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> |
|
|
|
|
assertThat(browser.findElement(By.tagName("body")).getText()) |
|
|
|
|
.contains("Upload File size cannot exceed 1g") |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(65) |
|
|
|
|
void testUploadUnder1GBFile() throws IOException { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
|
|
|
|
|
browser.navigate().refresh(); |
|
|
|
|
|
|
|
|
|
RandomAccessFile file = new RandomAccessFile(testUnder1GBFilePath, "rw"); |
|
|
|
|
file.setLength((long) (0.01 * 1024 * 1024 * 1024)); |
|
|
|
|
|
|
|
|
|
page.uploadFile(testUnder1GBFilePath); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> { |
|
|
|
|
assertThat(page.fileList()) |
|
|
|
|
.as("File list should contain newly-created file") |
|
|
|
|
.extracting(WebElement::getText) |
|
|
|
|
.anyMatch(it -> it.contains(testUnder1GBFileName)); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@Order(70) |
|
|
|
|
void testDownloadFile() { |
|
|
|
|
final FileManagePage page = new FileManagePage(browser); |
|
|
|
|
|
|
|
|
|
page.downloadFile(testUnder1GBFileName); |
|
|
|
|
|
|
|
|
|
File file = new File(Paths.get(Constants.HOST_CHROME_DOWNLOAD_PATH, testUnder1GBFileName).toFile().getAbsolutePath()); |
|
|
|
|
|
|
|
|
|
await().untilAsserted(() -> { |
|
|
|
|
assert file.exists(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|