diff --git a/.github/actions/workflow-telemetry-action b/.github/actions/workflow-telemetry-action new file mode 160000 index 000000000000..f974e0c5942f --- /dev/null +++ b/.github/actions/workflow-telemetry-action @@ -0,0 +1 @@ +Subproject commit f974e0c5942f8f37973c4cc395704165fbe629ba diff --git a/.github/workflows/api-test.yml b/.github/workflows/api-test.yml index b7a1aa4303f6..c635b1bc8b43 100644 --- a/.github/workflows/api-test.yml +++ b/.github/workflows/api-test.yml @@ -20,6 +20,8 @@ on: push: branches: - dev + - '[0-9]+.[0-9]+.[0-9]+-prepare' + - '[0-9]+.[0-9]+.[0-9]+-release' name: API-Test @@ -125,7 +127,7 @@ jobs: run: | ./mvnw -B -f dolphinscheduler-api-test/pom.xml -am \ -DfailIfNoTests=false \ - -Dspotless.skip=false \ + -Dspotless.skip=true \ -Dtest=${{ matrix.case.class }} test - uses: actions/upload-artifact@v4 if: always() diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 8810a33c96f4..79859e3df613 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -23,6 +23,8 @@ on: pull_request: branches: - 'dev' + - '[0-9]+.[0-9]+.[0-9]+-prepare' + - '[0-9]+.[0-9]+.[0-9]+-release' concurrency: group: codeql-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/e2e-k8s.yml b/.github/workflows/e2e-k8s.yml index 351aea8802cc..9074d97a8c30 100644 --- a/.github/workflows/e2e-k8s.yml +++ b/.github/workflows/e2e-k8s.yml @@ -20,6 +20,8 @@ on: push: branches: - dev + - '[0-9]+.[0-9]+.[0-9]+-prepare' + - '[0-9]+.[0-9]+.[0-9]+-release' name: E2E-K8S diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index d9a3cd795e09..6246416c36a8 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -20,6 +20,8 @@ on: push: branches: - dev + - '[0-9]+.[0-9]+.[0-9]+-prepare' + - '[0-9]+.[0-9]+.[0-9]+-release' name: E2E @@ -27,6 +29,8 @@ concurrency: group: e2e-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +permissions: + pull-requests: write jobs: paths-filter: @@ -122,46 +126,8 @@ jobs: class: org.apache.dolphinscheduler.e2e.cases.PostgresDataSourceE2ETest - name: ShellTaskE2ETest class: org.apache.dolphinscheduler.e2e.cases.tasks.ShellTaskE2ETest - env: - RECORDING_PATH: /tmp/recording-${{ matrix.case.name }} - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-e2e - restore-keys: ${{ runner.os }}-maven- - - uses: actions/download-artifact@v4 - name: Download Docker Images - with: - name: standalone-image - path: /tmp - - name: Load Docker Images - run: | - docker load -i /tmp/standalone-image.tar - - name: Run Test - run: | - ./mvnw -B -f dolphinscheduler-e2e/pom.xml -am \ - -DfailIfNoTests=false \ - -Dtest=${{ matrix.case.class }} test - - uses: actions/upload-artifact@v4 - if: always() - name: Upload Recording - with: - name: recording-${{ matrix.case.name }} - path: ${{ env.RECORDING_PATH }} - retention-days: 1 - e2e-optional: - name: ${{ matrix.case.name }} - needs: build - runs-on: ubuntu-latest - timeout-minutes: 30 - strategy: - matrix: - case: + - name: PythonTaskE2ETest + class: org.apache.dolphinscheduler.e2e.cases.tasks.PythonTaskE2ETest - name: SqlServerDataSource class: org.apache.dolphinscheduler.e2e.cases.SqlServerDataSourceE2ETest - name: HiveDataSource @@ -172,6 +138,15 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: 'adopt' + - name: Collect Workflow Telemetry + uses: ./.github/actions/workflow-telemetry-action + with: + comment_on_pr: false - name: Cache local Maven repository uses: actions/cache@v3 with: diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 87d178185add..1cb5f5a84b4a 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -20,7 +20,8 @@ name: Frontend on: push: branches: - - dev + - '[0-9]+.[0-9]+.[0-9]+-prepare' + - '[0-9]+.[0-9]+.[0-9]+-release' paths: - '.github/workflows/frontend.yml' - 'dolphinscheduler-ui/**' diff --git a/.github/workflows/owasp-dependency-check.yaml b/.github/workflows/owasp-dependency-check.yaml index b99486f29840..b4ee52c57d8d 100644 --- a/.github/workflows/owasp-dependency-check.yaml +++ b/.github/workflows/owasp-dependency-check.yaml @@ -20,7 +20,8 @@ name: OWASP Dependency Check on: push: branches: - - dev + - '[0-9]+.[0-9]+.[0-9]+-prepare' + - '[0-9]+.[0-9]+.[0-9]+-release' pull_request: paths: - '**/pom.xml' @@ -30,6 +31,7 @@ env: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 120 steps: - uses: actions/checkout@v4 with: @@ -47,4 +49,4 @@ jobs: continue-on-error: true with: name: dependency report - path: target/dependency-check-report.html + path: target/dependency-check-report.html diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index d0c88b9ca602..ad42ee57df5f 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -24,7 +24,8 @@ on: - '**/*.md' - 'dolphinscheduler-ui' branches: - - dev + - '[0-9]+.[0-9]+.[0-9]+-prepare' + - '[0-9]+.[0-9]+.[0-9]+-release' env: LOG_DIR: /tmp/dolphinscheduler diff --git a/.gitmodules b/.gitmodules index bb2ed9794603..0467f266493d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ path = .github/actions/auto-assign-action url = https://github.com/kentaro-m/auto-assign-action.git branch = 288f36f +[submodule ".github/actions/workflow-telemetry-action"] + path = .github/actions/workflow-telemetry-action + url = https://github.com/catchpoint/workflow-telemetry-action diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ExecutorAPITest.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ExecutorAPITest.java index 3b90131af9b6..6a563efb481b 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ExecutorAPITest.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ExecutorAPITest.java @@ -31,17 +31,8 @@ import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.WarningType; -import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.User; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - -import lombok.extern.slf4j.Slf4j; - import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.util.EntityUtils; @@ -51,6 +42,14 @@ import java.util.LinkedHashMap; import java.util.List; +import lombok.extern.slf4j.Slf4j; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + //TODO: Some test cases rely on ProcessInstance APIs. Should complete remaining cases after ProcessInstance related API tests done. @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") @Slf4j @@ -80,7 +79,8 @@ public class ExecutorAPITest { public static void setup() { LoginPage loginPage = new LoginPage(); HttpResponse loginHttpResponse = loginPage.login(username, password); - sessionId = JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); + sessionId = + JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); executorPage = new ExecutorPage(sessionId); processDefinitionPage = new ProcessDefinitionPage(sessionId); projectPage = new ProjectPage(sessionId); @@ -103,24 +103,30 @@ public void testStartProcessInstance() { HttpResponse createProjectResponse = projectPage.createProject(loginUser, "project-test"); HttpResponse queryAllProjectListResponse = projectPage.queryAllProjectList(loginUser); Assertions.assertTrue(queryAllProjectListResponse.getBody().getSuccess()); - projectCode = (long) ((LinkedHashMap) ((List) queryAllProjectListResponse.getBody().getData()).get(0)).get("code"); + projectCode = (long) ((LinkedHashMap) ((List) queryAllProjectListResponse + .getBody().getData()).get(0)).get("code"); // upload test workflow definition json ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource("workflow-json/test.json").getFile()); CloseableHttpResponse importProcessDefinitionResponse = processDefinitionPage - .importProcessDefinition(loginUser, projectCode, file); + .importProcessDefinition(loginUser, projectCode, file); String data = EntityUtils.toString(importProcessDefinitionResponse.getEntity()); Assertions.assertTrue(data.contains("\"success\":true")); // get workflow definition code - HttpResponse queryAllProcessDefinitionByProjectCodeResponse = processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); + HttpResponse queryAllProcessDefinitionByProjectCodeResponse = + processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); Assertions.assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getSuccess()); - Assertions.assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getData().toString().contains("hello world")); - processDefinitionCode = (long) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse.getBody().getData()).get(0)).get("processDefinition")).get("code"); + Assertions.assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getData().toString() + .contains("hello world")); + processDefinitionCode = + (long) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse + .getBody().getData()).get(0)).get("processDefinition")).get("code"); // release test workflow - HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, projectCode, processDefinitionCode, ReleaseState.ONLINE); + HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, + projectCode, processDefinitionCode, ReleaseState.ONLINE); Assertions.assertTrue(releaseProcessDefinitionResponse.getBody().getSuccess()); // trigger workflow instance @@ -128,11 +134,12 @@ public void testStartProcessInstance() { Date date = new Date(); String scheduleTime = String.format("%s,%s", formatter.format(date), formatter.format(date)); log.info("use current time {} as scheduleTime", scheduleTime); - HttpResponse startProcessInstanceResponse = executorPage.startProcessInstance(loginUser, projectCode, processDefinitionCode, scheduleTime, FailureStrategy.END, WarningType.NONE); + HttpResponse startProcessInstanceResponse = executorPage.startProcessInstance(loginUser, projectCode, + processDefinitionCode, scheduleTime, FailureStrategy.END, WarningType.NONE); Assertions.assertTrue(startProcessInstanceResponse.getBody().getSuccess()); triggerCode = (long) startProcessInstanceResponse.getBody().getData(); - } catch (Exception e) { + } catch (Exception e) { log.error("failed", e); Assertions.fail(); } @@ -141,7 +148,8 @@ public void testStartProcessInstance() { @Test @Order(2) public void testStartCheckProcessDefinition() { - HttpResponse testStartCheckProcessDefinitionResponse = executorPage.startCheckProcessDefinition(loginUser, projectCode, processDefinitionCode); + HttpResponse testStartCheckProcessDefinitionResponse = + executorPage.startCheckProcessDefinition(loginUser, projectCode, processDefinitionCode); Assertions.assertTrue(testStartCheckProcessDefinitionResponse.getBody().getSuccess()); } diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProcessDefinitionAPITest.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProcessDefinitionAPITest.java index 4c4507e78591..a5870ceca29d 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProcessDefinitionAPITest.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProcessDefinitionAPITest.java @@ -30,21 +30,21 @@ import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.User; -import java.io.File;; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.util.EntityUtils; + +import java.io.File; import java.util.LinkedHashMap; import java.util.List; +import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import lombok.extern.slf4j.Slf4j; - -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.util.EntityUtils; - @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") @Slf4j public class ProcessDefinitionAPITest { @@ -67,12 +67,12 @@ public class ProcessDefinitionAPITest { private static String processDefinitionName; - @BeforeAll public static void setup() { LoginPage loginPage = new LoginPage(); HttpResponse loginHttpResponse = loginPage.login(username, password); - sessionId = JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); + sessionId = + JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); processDefinitionPage = new ProcessDefinitionPage(sessionId); projectPage = new ProjectPage(sessionId); loginUser = new User(); @@ -93,14 +93,15 @@ public void testImportProcessDefinition() { HttpResponse queryAllProjectListResponse = projectPage.queryAllProjectList(loginUser); Assertions.assertTrue(queryAllProjectListResponse.getBody().getSuccess()); - projectCode = (long) ((LinkedHashMap) ((List) queryAllProjectListResponse.getBody().getData()).get(0)).get("code"); + projectCode = (long) ((LinkedHashMap) ((List) queryAllProjectListResponse + .getBody().getData()).get(0)).get("code"); ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource("workflow-json/test.json").getFile()); CloseableHttpResponse importProcessDefinitionResponse = processDefinitionPage - .importProcessDefinition(loginUser, projectCode, file); + .importProcessDefinition(loginUser, projectCode, file); String data = EntityUtils.toString(importProcessDefinitionResponse.getEntity()); Assertions.assertTrue(data.contains("\"success\":true")); - } catch (Exception e) { + } catch (Exception e) { log.error("failed", e); Assertions.fail(); } @@ -109,72 +110,92 @@ public void testImportProcessDefinition() { @Test @Order(2) public void testQueryAllProcessDefinitionByProjectCode() { - HttpResponse queryAllProcessDefinitionByProjectCodeResponse = processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); + HttpResponse queryAllProcessDefinitionByProjectCodeResponse = + processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); Assertions.assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getSuccess()); - Assertions.assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getData().toString().contains("hello world")); - processDefinitionCode = (long) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse.getBody().getData()).get(0)).get("processDefinition")).get("code"); - processDefinitionName = (String) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse.getBody().getData()).get(0)).get("processDefinition")).get("name"); + Assertions.assertTrue( + queryAllProcessDefinitionByProjectCodeResponse.getBody().getData().toString().contains("hello world")); + processDefinitionCode = + (long) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse + .getBody().getData()).get(0)).get("processDefinition")).get("code"); + processDefinitionName = + (String) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse + .getBody().getData()).get(0)).get("processDefinition")).get("name"); } @Test @Order(3) public void testQueryProcessDefinitionByCode() { - HttpResponse queryProcessDefinitionByCodeResponse = processDefinitionPage.queryProcessDefinitionByCode(loginUser, projectCode, processDefinitionCode); + HttpResponse queryProcessDefinitionByCodeResponse = + processDefinitionPage.queryProcessDefinitionByCode(loginUser, projectCode, processDefinitionCode); Assertions.assertTrue(queryProcessDefinitionByCodeResponse.getBody().getSuccess()); - Assertions.assertTrue(queryProcessDefinitionByCodeResponse.getBody().getData().toString().contains("hello world")); + Assertions.assertTrue( + queryProcessDefinitionByCodeResponse.getBody().getData().toString().contains("hello world")); } @Test @Order(4) public void testgetProcessListByProjectCode() { - HttpResponse getProcessListByProjectCodeResponse = processDefinitionPage.getProcessListByProjectCode(loginUser, projectCode); + HttpResponse getProcessListByProjectCodeResponse = + processDefinitionPage.getProcessListByProjectCode(loginUser, projectCode); Assertions.assertTrue(getProcessListByProjectCodeResponse.getBody().getSuccess()); - Assertions.assertTrue(getProcessListByProjectCodeResponse.getBody().getData().toString().contains("test_import")); + Assertions + .assertTrue(getProcessListByProjectCodeResponse.getBody().getData().toString().contains("test_import")); } @Test @Order(5) public void testQueryProcessDefinitionByName() { - HttpResponse queryProcessDefinitionByNameResponse = processDefinitionPage.queryProcessDefinitionByName(loginUser, projectCode, processDefinitionName); + HttpResponse queryProcessDefinitionByNameResponse = + processDefinitionPage.queryProcessDefinitionByName(loginUser, projectCode, processDefinitionName); Assertions.assertTrue(queryProcessDefinitionByNameResponse.getBody().getSuccess()); - Assertions.assertTrue(queryProcessDefinitionByNameResponse.getBody().getData().toString().contains("hello world")); + Assertions.assertTrue( + queryProcessDefinitionByNameResponse.getBody().getData().toString().contains("hello world")); } @Test @Order(6) public void testQueryProcessDefinitionList() { - HttpResponse queryProcessDefinitionListResponse = processDefinitionPage.queryProcessDefinitionList(loginUser, projectCode); + HttpResponse queryProcessDefinitionListResponse = + processDefinitionPage.queryProcessDefinitionList(loginUser, projectCode); Assertions.assertTrue(queryProcessDefinitionListResponse.getBody().getSuccess()); - Assertions.assertTrue(queryProcessDefinitionListResponse.getBody().getData().toString().contains("hello world")); + Assertions + .assertTrue(queryProcessDefinitionListResponse.getBody().getData().toString().contains("hello world")); } @Test @Order(7) public void testReleaseProcessDefinition() { - HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, projectCode, processDefinitionCode, ReleaseState.ONLINE); + HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, + projectCode, processDefinitionCode, ReleaseState.ONLINE); Assertions.assertTrue(releaseProcessDefinitionResponse.getBody().getSuccess()); - HttpResponse queryProcessDefinitionByCodeResponse = processDefinitionPage.queryProcessDefinitionByCode(loginUser, projectCode, processDefinitionCode); + HttpResponse queryProcessDefinitionByCodeResponse = + processDefinitionPage.queryProcessDefinitionByCode(loginUser, projectCode, processDefinitionCode); Assertions.assertTrue(queryProcessDefinitionByCodeResponse.getBody().getSuccess()); - Assertions.assertTrue(queryProcessDefinitionByCodeResponse.getBody().getData().toString().contains("releaseState=ONLINE")); + Assertions.assertTrue( + queryProcessDefinitionByCodeResponse.getBody().getData().toString().contains("releaseState=ONLINE")); } @Test @Order(8) public void testDeleteProcessDefinitionByCode() { - HttpResponse deleteProcessDefinitionByCodeResponse = processDefinitionPage.deleteProcessDefinitionByCode(loginUser, projectCode, processDefinitionCode); + HttpResponse deleteProcessDefinitionByCodeResponse = + processDefinitionPage.deleteProcessDefinitionByCode(loginUser, projectCode, processDefinitionCode); Assertions.assertFalse(deleteProcessDefinitionByCodeResponse.getBody().getSuccess()); - HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, projectCode, processDefinitionCode, ReleaseState.OFFLINE); + HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, + projectCode, processDefinitionCode, ReleaseState.OFFLINE); Assertions.assertTrue(releaseProcessDefinitionResponse.getBody().getSuccess()); - deleteProcessDefinitionByCodeResponse = processDefinitionPage.deleteProcessDefinitionByCode(loginUser, projectCode, processDefinitionCode); + deleteProcessDefinitionByCodeResponse = + processDefinitionPage.deleteProcessDefinitionByCode(loginUser, projectCode, processDefinitionCode); Assertions.assertTrue(deleteProcessDefinitionByCodeResponse.getBody().getSuccess()); - HttpResponse queryProcessDefinitionListResponse = processDefinitionPage.queryProcessDefinitionList(loginUser, projectCode); + HttpResponse queryProcessDefinitionListResponse = + processDefinitionPage.queryProcessDefinitionList(loginUser, projectCode); Assertions.assertTrue(queryProcessDefinitionListResponse.getBody().getSuccess()); - Assertions.assertFalse(queryProcessDefinitionListResponse.getBody().getData().toString().contains("hello world")); + Assertions + .assertFalse(queryProcessDefinitionListResponse.getBody().getData().toString().contains("hello world")); } } - - diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProcessInstanceAPITest.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProcessInstanceAPITest.java index 0c939bb0fb28..1ddc2f8275b9 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProcessInstanceAPITest.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProcessInstanceAPITest.java @@ -48,6 +48,8 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -55,8 +57,6 @@ import org.junit.jupiter.api.Test; import org.testcontainers.shaded.org.awaitility.Awaitility; -import lombok.extern.slf4j.Slf4j; - @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") @Slf4j public class ProcessInstanceAPITest { @@ -89,7 +89,8 @@ public class ProcessInstanceAPITest { public static void setup() { LoginPage loginPage = new LoginPage(); HttpResponse loginHttpResponse = loginPage.login(username, password); - sessionId = JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); + sessionId = + JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); processInstancePage = new ProcessInstancePage(sessionId); executorPage = new ExecutorPage(sessionId); processDefinitionPage = new ProcessDefinitionPage(sessionId); @@ -113,24 +114,30 @@ public void testQueryProcessInstancesByTriggerCode() { HttpResponse createProjectResponse = projectPage.createProject(loginUser, "project-test"); HttpResponse queryAllProjectListResponse = projectPage.queryAllProjectList(loginUser); assertTrue(queryAllProjectListResponse.getBody().getSuccess()); - projectCode = (long) ((LinkedHashMap) ((List) queryAllProjectListResponse.getBody().getData()).get(0)).get("code"); + projectCode = (long) ((LinkedHashMap) ((List) queryAllProjectListResponse + .getBody().getData()).get(0)).get("code"); // upload test workflow definition json ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource("workflow-json/test.json").getFile()); CloseableHttpResponse importProcessDefinitionResponse = processDefinitionPage - .importProcessDefinition(loginUser, projectCode, file); + .importProcessDefinition(loginUser, projectCode, file); String data = EntityUtils.toString(importProcessDefinitionResponse.getEntity()); assertTrue(data.contains("\"success\":true")); // get workflow definition code - HttpResponse queryAllProcessDefinitionByProjectCodeResponse = processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); + HttpResponse queryAllProcessDefinitionByProjectCodeResponse = + processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getSuccess()); - assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getData().toString().contains("hello world")); - processDefinitionCode = (long) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse.getBody().getData()).get(0)).get("processDefinition")).get("code"); + assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getData().toString() + .contains("hello world")); + processDefinitionCode = + (long) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse + .getBody().getData()).get(0)).get("processDefinition")).get("code"); // release test workflow - HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, projectCode, processDefinitionCode, ReleaseState.ONLINE); + HttpResponse releaseProcessDefinitionResponse = processDefinitionPage.releaseProcessDefinition(loginUser, + projectCode, processDefinitionCode, ReleaseState.ONLINE); assertTrue(releaseProcessDefinitionResponse.getBody().getSuccess()); // trigger workflow instance @@ -138,23 +145,27 @@ public void testQueryProcessInstancesByTriggerCode() { Date date = new Date(); String scheduleTime = String.format("%s,%s", formatter.format(date), formatter.format(date)); log.info("use current time {} as scheduleTime", scheduleTime); - HttpResponse startProcessInstanceResponse = executorPage.startProcessInstance(loginUser, projectCode, processDefinitionCode, scheduleTime, FailureStrategy.END, WarningType.NONE); + HttpResponse startProcessInstanceResponse = executorPage.startProcessInstance(loginUser, projectCode, + processDefinitionCode, scheduleTime, FailureStrategy.END, WarningType.NONE); assertTrue(startProcessInstanceResponse.getBody().getSuccess()); // make sure process instance has completed and successfully persisted into db Awaitility.await() - .atMost(30, TimeUnit.SECONDS) - .untilAsserted(() -> { - // query workflow instance by trigger code - triggerCode = (long) startProcessInstanceResponse.getBody().getData(); - HttpResponse queryProcessInstancesByTriggerCodeResponse = processInstancePage.queryProcessInstancesByTriggerCode(loginUser, projectCode, triggerCode); - assertTrue(queryProcessInstancesByTriggerCodeResponse.getBody().getSuccess()); - List> body = (List>) queryProcessInstancesByTriggerCodeResponse.getBody().getData(); - assertTrue(CollectionUtils.isNotEmpty(body)); - assertEquals("SUCCESS", body.get(0).get("state")); - processInstanceId = (int) body.get(0).get("id"); - }); - } catch (Exception e) { + .atMost(30, TimeUnit.SECONDS) + .untilAsserted(() -> { + // query workflow instance by trigger code + triggerCode = (long) startProcessInstanceResponse.getBody().getData(); + HttpResponse queryProcessInstancesByTriggerCodeResponse = processInstancePage + .queryProcessInstancesByTriggerCode(loginUser, projectCode, triggerCode); + assertTrue(queryProcessInstancesByTriggerCodeResponse.getBody().getSuccess()); + List> body = + (List>) queryProcessInstancesByTriggerCodeResponse + .getBody().getData(); + assertTrue(CollectionUtils.isNotEmpty(body)); + assertEquals("SUCCESS", body.get(0).get("state")); + processInstanceId = (int) body.get(0).get("id"); + }); + } catch (Exception e) { log.error("failed", e); Assertions.fail(); } @@ -163,7 +174,8 @@ public void testQueryProcessInstancesByTriggerCode() { @Test @Order(2) public void testQueryProcessInstanceList() { - HttpResponse queryProcessInstanceListResponse = processInstancePage.queryProcessInstanceList(loginUser, projectCode, 1, 10); + HttpResponse queryProcessInstanceListResponse = + processInstancePage.queryProcessInstanceList(loginUser, projectCode, 1, 10); assertTrue(queryProcessInstanceListResponse.getBody().getSuccess()); assertTrue(queryProcessInstanceListResponse.getBody().getData().toString().contains("test_import")); } @@ -171,7 +183,8 @@ public void testQueryProcessInstanceList() { @Test @Order(3) public void testQueryTaskListByProcessId() { - HttpResponse queryTaskListByProcessIdResponse = processInstancePage.queryTaskListByProcessId(loginUser, projectCode, processInstanceId); + HttpResponse queryTaskListByProcessIdResponse = + processInstancePage.queryTaskListByProcessId(loginUser, projectCode, processInstanceId); assertTrue(queryTaskListByProcessIdResponse.getBody().getSuccess()); assertTrue(queryTaskListByProcessIdResponse.getBody().getData().toString().contains("test_import")); } @@ -179,7 +192,8 @@ public void testQueryTaskListByProcessId() { @Test @Order(4) public void testQueryProcessInstanceById() { - HttpResponse queryProcessInstanceByIdResponse = processInstancePage.queryProcessInstanceById(loginUser, projectCode, processInstanceId); + HttpResponse queryProcessInstanceByIdResponse = + processInstancePage.queryProcessInstanceById(loginUser, projectCode, processInstanceId); assertTrue(queryProcessInstanceByIdResponse.getBody().getSuccess()); assertTrue(queryProcessInstanceByIdResponse.getBody().getData().toString().contains("test_import")); } @@ -187,10 +201,12 @@ public void testQueryProcessInstanceById() { @Test @Order(5) public void testDeleteProcessInstanceById() { - HttpResponse deleteProcessInstanceByIdResponse = processInstancePage.deleteProcessInstanceById(loginUser, projectCode, processInstanceId); + HttpResponse deleteProcessInstanceByIdResponse = + processInstancePage.deleteProcessInstanceById(loginUser, projectCode, processInstanceId); assertTrue(deleteProcessInstanceByIdResponse.getBody().getSuccess()); - HttpResponse queryProcessInstanceListResponse = processInstancePage.queryProcessInstanceList(loginUser, projectCode, 1, 10); + HttpResponse queryProcessInstanceListResponse = + processInstancePage.queryProcessInstanceList(loginUser, projectCode, 1, 10); assertTrue(queryProcessInstanceListResponse.getBody().getSuccess()); Assertions.assertFalse(queryProcessInstanceListResponse.getBody().getData().toString().contains("test_import")); } diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProjectAPITest.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProjectAPITest.java index 40caa45a3182..cf5621f06c37 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProjectAPITest.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/ProjectAPITest.java @@ -29,17 +29,17 @@ import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.User; +import java.util.LinkedHashMap; +import java.util.List; + +import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import lombok.extern.slf4j.Slf4j; - -import java.util.LinkedHashMap; -import java.util.List; - @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") @Slf4j // TODO: Add more detailed permission control related cases after userPage test cases completed @@ -59,7 +59,8 @@ public class ProjectAPITest { public static void setup() { LoginPage loginPage = new LoginPage(); HttpResponse loginHttpResponse = loginPage.login(username, password); - sessionId = JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); + sessionId = + JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); projectPage = new ProjectPage(sessionId); loginUser = new User(); loginUser.setUserName("admin"); @@ -98,7 +99,8 @@ public void testUpdateProject() { List projects = (List) queryAllProjectListResponse.getBody().getData(); Long code = (Long) projects.get(0).get("code"); - HttpResponse updateProjectResponse = projectPage.updateProject(loginUser, code,"project-new", loginUser.getUserName()); + HttpResponse updateProjectResponse = + projectPage.updateProject(loginUser, code, "project-new", loginUser.getUserName()); Assertions.assertTrue(updateProjectResponse.getBody().getSuccess()); queryAllProjectListResponse = projectPage.queryAllProjectList(loginUser); @@ -133,17 +135,21 @@ public void testQueryProjectListPaging() { @Test @Order(6) public void testQueryProjectWithAuthorizedLevelListPaging() { - HttpResponse queryProjectWithAuthorizedLevelListPagingResponse = projectPage.queryProjectWithAuthorizedLevelListPaging(loginUser, loginUser.getId(),1, 1); + HttpResponse queryProjectWithAuthorizedLevelListPagingResponse = + projectPage.queryProjectWithAuthorizedLevelListPaging(loginUser, loginUser.getId(), 1, 1); Assertions.assertTrue(queryProjectWithAuthorizedLevelListPagingResponse.getBody().getSuccess()); - Assertions.assertTrue(queryProjectWithAuthorizedLevelListPagingResponse.getBody().getData().toString().contains("project-new")); + Assertions.assertTrue(queryProjectWithAuthorizedLevelListPagingResponse.getBody().getData().toString() + .contains("project-new")); } @Test @Order(7) public void testQueryUnauthorizedProject() { - HttpResponse queryUnauthorizedProjectResponse = projectPage.queryUnauthorizedProject(loginUser, loginUser.getId()); + HttpResponse queryUnauthorizedProjectResponse = + projectPage.queryUnauthorizedProject(loginUser, loginUser.getId()); Assertions.assertTrue(queryUnauthorizedProjectResponse.getBody().getSuccess()); - // project-new was created by instead of authorized to this user, therefore, it should be in the unauthorized list + // project-new was created by instead of authorized to this user, therefore, it should be in the unauthorized + // list Assertions.assertTrue(queryUnauthorizedProjectResponse.getBody().getData().toString().contains("project-new")); } @@ -152,17 +158,21 @@ public void testQueryUnauthorizedProject() { public void testQueryAuthorizedProject() { HttpResponse queryAuthorizedProjectResponse = projectPage.queryAuthorizedProject(loginUser, loginUser.getId()); Assertions.assertTrue(queryAuthorizedProjectResponse.getBody().getSuccess()); - // project-new was created by instead of authorized to this user, therefore, it should not be in the authorized list + // project-new was created by instead of authorized to this user, therefore, it should not be in the authorized + // list Assertions.assertFalse(queryAuthorizedProjectResponse.getBody().getData().toString().contains("project-new")); } @Test @Order(9) public void testQueryProjectWithAuthorizedLevel() { - HttpResponse queryProjectWithAuthorizedLevelResponse = projectPage.queryProjectWithAuthorizedLevel(loginUser, loginUser.getId()); + HttpResponse queryProjectWithAuthorizedLevelResponse = + projectPage.queryProjectWithAuthorizedLevel(loginUser, loginUser.getId()); Assertions.assertTrue(queryProjectWithAuthorizedLevelResponse.getBody().getSuccess()); - // queryProjectWithAuthorizedLevel api returns a joint-set of projects both created by and authorized to the user - Assertions.assertTrue(queryProjectWithAuthorizedLevelResponse.getBody().getData().toString().contains("project-new")); + // queryProjectWithAuthorizedLevel api returns a joint-set of projects both created by and authorized to the + // user + Assertions.assertTrue( + queryProjectWithAuthorizedLevelResponse.getBody().getData().toString().contains("project-new")); } @Test @@ -181,10 +191,13 @@ public void testQueryAuthorizedUser() { @Test @Order(11) public void testQueryProjectCreatedAndAuthorizedByUser() { - HttpResponse queryProjectCreatedAndAuthorizedByUserResponse = projectPage.queryProjectCreatedAndAuthorizedByUser(loginUser); + HttpResponse queryProjectCreatedAndAuthorizedByUserResponse = + projectPage.queryProjectCreatedAndAuthorizedByUser(loginUser); Assertions.assertTrue(queryProjectCreatedAndAuthorizedByUserResponse.getBody().getSuccess()); - // queryProjectCreatedAndAuthorizedByUser api returns a joint-set of projects both created by and authorized to the user - Assertions.assertTrue(queryProjectCreatedAndAuthorizedByUserResponse.getBody().getData().toString().contains("project-new")); + // queryProjectCreatedAndAuthorizedByUser api returns a joint-set of projects both created by and authorized to + // the user + Assertions.assertTrue( + queryProjectCreatedAndAuthorizedByUserResponse.getBody().getData().toString().contains("project-new")); } @Test @@ -192,7 +205,8 @@ public void testQueryProjectCreatedAndAuthorizedByUser() { public void testQueryAllProjectListForDependent() { HttpResponse queryAllProjectListForDependentResponse = projectPage.queryAllProjectListForDependent(loginUser); Assertions.assertTrue(queryAllProjectListForDependentResponse.getBody().getSuccess()); - Assertions.assertTrue(queryAllProjectListForDependentResponse.getBody().getData().toString().contains("project-new")); + Assertions.assertTrue( + queryAllProjectListForDependentResponse.getBody().getData().toString().contains("project-new")); } @Test @@ -203,8 +217,7 @@ public void testDeleteProject() { Long code = (Long) projects.get(0).get("code"); HttpResponse queryAllProjectListForDependentResponse = projectPage.deleteProject(loginUser, code); Assertions.assertTrue(queryAllProjectListForDependentResponse.getBody().getSuccess()); - Assertions.assertFalse(queryAllProjectListForDependentResponse.getBody().getData().toString().contains("project-new")); + Assertions.assertFalse( + queryAllProjectListForDependentResponse.getBody().getData().toString().contains("project-new")); } } - - diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/SchedulerAPITest.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/SchedulerAPITest.java index ac06afefc6f4..9d02acfd28bd 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/SchedulerAPITest.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/SchedulerAPITest.java @@ -35,14 +35,14 @@ import java.util.LinkedHashMap; import java.util.List; +import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import lombok.extern.slf4j.Slf4j; - @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") @Slf4j public class SchedulerAPITest { @@ -67,12 +67,12 @@ public class SchedulerAPITest { private static int scheduleId; - @BeforeAll public static void setup() { LoginPage loginPage = new LoginPage(); HttpResponse loginHttpResponse = loginPage.login(username, password); - sessionId = JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); + sessionId = + JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); projectPage = new ProjectPage(sessionId); schedulerPage = new SchedulerPage(sessionId); processDefinitionPage = new ProcessDefinitionPage(sessionId); @@ -94,17 +94,24 @@ public void testCreateSchedule() { HttpResponse queryAllProjectListResponse = projectPage.queryAllProjectList(loginUser); Assertions.assertTrue(queryAllProjectListResponse.getBody().getSuccess()); - projectCode = (long) ((LinkedHashMap) ((List) queryAllProjectListResponse.getBody().getData()).get(0)).get("code"); + projectCode = (long) ((LinkedHashMap) ((List) queryAllProjectListResponse + .getBody().getData()).get(0)).get("code"); ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource("workflow-json/test.json").getFile()); processDefinitionPage.importProcessDefinition(loginUser, projectCode, file); - HttpResponse queryAllProcessDefinitionByProjectCodeResponse = processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); + HttpResponse queryAllProcessDefinitionByProjectCodeResponse = + processDefinitionPage.queryAllProcessDefinitionByProjectCode(loginUser, projectCode); Assertions.assertTrue(queryAllProcessDefinitionByProjectCodeResponse.getBody().getSuccess()); - processDefinitionCode = (long) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse.getBody().getData()).get(0)).get("processDefinition")).get("code"); - - processDefinitionPage.releaseProcessDefinition(loginUser, projectCode, processDefinitionCode, ReleaseState.ONLINE); - final String schedule = "{\"startTime\":\"2019-08-08 00:00:00\",\"endTime\":\"2100-08-08 00:00:00\",\"timezoneId\":\"America/Phoenix\",\"crontab\":\"0 0 3/6 * * ? *\"}" ; - HttpResponse createScheduleResponse = schedulerPage.createSchedule(loginUser, projectCode, processDefinitionCode, schedule); + processDefinitionCode = + (long) ((LinkedHashMap) ((LinkedHashMap) ((List) queryAllProcessDefinitionByProjectCodeResponse + .getBody().getData()).get(0)).get("processDefinition")).get("code"); + + processDefinitionPage.releaseProcessDefinition(loginUser, projectCode, processDefinitionCode, + ReleaseState.ONLINE); + final String schedule = + "{\"startTime\":\"2019-08-08 00:00:00\",\"endTime\":\"2100-08-08 00:00:00\",\"timezoneId\":\"America/Phoenix\",\"crontab\":\"0 0 3/6 * * ? *\"}"; + HttpResponse createScheduleResponse = + schedulerPage.createSchedule(loginUser, projectCode, processDefinitionCode, schedule); Assertions.assertTrue(createScheduleResponse.getBody().getSuccess()); Assertions.assertTrue(createScheduleResponse.getBody().getData().toString().contains("2019-08-08")); } @@ -115,13 +122,15 @@ public void testQueryScheduleList() { HttpResponse queryScheduleListResponse = schedulerPage.queryScheduleList(loginUser, projectCode); Assertions.assertTrue(queryScheduleListResponse.getBody().getSuccess()); Assertions.assertTrue(queryScheduleListResponse.getBody().getData().toString().contains("2019-08-08")); - scheduleId = (int) ((LinkedHashMap) ((List) queryScheduleListResponse.getBody().getData()).get(0)).get("id"); + scheduleId = (int) ((LinkedHashMap) ((List) queryScheduleListResponse.getBody() + .getData()).get(0)).get("id"); } @Test @Order(3) public void testPublishScheduleOnline() { - HttpResponse publishScheduleOnlineResponse = schedulerPage.publishScheduleOnline(loginUser, projectCode, scheduleId); + HttpResponse publishScheduleOnlineResponse = + schedulerPage.publishScheduleOnline(loginUser, projectCode, scheduleId); Assertions.assertTrue(publishScheduleOnlineResponse.getBody().getSuccess()); HttpResponse queryScheduleListResponse = schedulerPage.queryScheduleList(loginUser, projectCode); @@ -137,14 +146,17 @@ public void testOfflineSchedule() { HttpResponse queryScheduleListResponse = schedulerPage.queryScheduleList(loginUser, projectCode); Assertions.assertTrue(queryScheduleListResponse.getBody().getSuccess()); - Assertions.assertTrue(queryScheduleListResponse.getBody().getData().toString().contains("releaseState=OFFLINE")); + Assertions + .assertTrue(queryScheduleListResponse.getBody().getData().toString().contains("releaseState=OFFLINE")); } @Test @Order(5) public void testUpdateSchedule() { - final String schedule = "{\"startTime\":\"1996-08-08 00:00:00\",\"endTime\":\"2200-08-08 00:00:00\",\"timezoneId\":\"America/Phoenix\",\"crontab\":\"0 0 3/6 * * ? *\"}"; - HttpResponse updateScheduleResponse = schedulerPage.updateSchedule(loginUser, projectCode, scheduleId, schedule); + final String schedule = + "{\"startTime\":\"1996-08-08 00:00:00\",\"endTime\":\"2200-08-08 00:00:00\",\"timezoneId\":\"America/Phoenix\",\"crontab\":\"0 0 3/6 * * ? *\"}"; + HttpResponse updateScheduleResponse = + schedulerPage.updateSchedule(loginUser, projectCode, scheduleId, schedule); Assertions.assertTrue(updateScheduleResponse.getBody().getSuccess()); HttpResponse queryScheduleListResponse = schedulerPage.queryScheduleList(loginUser, projectCode); @@ -163,5 +175,3 @@ public void testDeleteScheduleById() { Assertions.assertFalse(queryScheduleListResponse.getBody().getData().toString().contains("1996-08-08")); } } - - diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/TenantAPITest.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/TenantAPITest.java index 76dbd21cdc9f..2f8e6aa056a5 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/TenantAPITest.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/TenantAPITest.java @@ -28,17 +28,18 @@ import org.apache.dolphinscheduler.api.test.pages.security.TenantPage; import org.apache.dolphinscheduler.api.test.utils.JSONUtils; +import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import lombok.extern.slf4j.Slf4j; - @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") @Slf4j public class TenantAPITest { + private static final String tenant = System.getProperty("user.name"); private static final String user = "admin"; @@ -54,7 +55,8 @@ public static void setup() { LoginPage loginPage = new LoginPage(); HttpResponse loginHttpResponse = loginPage.login(user, password); - sessionId = JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); + sessionId = + JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); } @AfterAll @@ -90,7 +92,9 @@ public void testGetTenantListPaging() { HttpResponse createTenantHttpResponse = tenantPage.getTenantListPaging(sessionId, 1, 10, ""); boolean result = false; - for (TenantListPagingResponseTotalList tenantListPagingResponseTotalList : JSONUtils.convertValue(createTenantHttpResponse.getBody().getData(), TenantListPagingResponseData.class).getTotalList()) { + for (TenantListPagingResponseTotalList tenantListPagingResponseTotalList : JSONUtils + .convertValue(createTenantHttpResponse.getBody().getData(), TenantListPagingResponseData.class) + .getTotalList()) { if (tenantListPagingResponseTotalList.getTenantCode().equals(tenant)) { result = true; existTenantId = tenantListPagingResponseTotalList.getId(); diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/WorkerGroupAPITest.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/WorkerGroupAPITest.java index a83dea06e1a3..d34f6bad2d3a 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/WorkerGroupAPITest.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/cases/WorkerGroupAPITest.java @@ -33,14 +33,14 @@ import java.util.List; import java.util.Set; +import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import lombok.extern.slf4j.Slf4j; - @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") @Slf4j public class WorkerGroupAPITest { @@ -59,7 +59,8 @@ public class WorkerGroupAPITest { public static void setup() { LoginPage loginPage = new LoginPage(); HttpResponse loginHttpResponse = loginPage.login(username, password); - sessionId = JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); + sessionId = + JSONUtils.convertValue(loginHttpResponse.getBody().getData(), LoginResponseData.class).getSessionId(); workerGroupPage = new WorkerGroupPage(sessionId); loginUser = new User(); loginUser.setId(123); @@ -75,7 +76,7 @@ public static void cleanup() { @Order(1) public void testSaveWorkerGroup() { HttpResponse saveWorkerGroupHttpResponse = workerGroupPage - .saveWorkerGroup(loginUser, 1, "test_worker_group", "10.5.0.5:1234", "test", null); + .saveWorkerGroup(loginUser, 1, "test_worker_group", "10.5.0.5:1234", "test", null); Assertions.assertTrue(saveWorkerGroupHttpResponse.getBody().getSuccess()); HttpResponse queryAllWorkerGroupsResponse = workerGroupPage.queryAllWorkerGroups(loginUser); @@ -88,9 +89,10 @@ public void testSaveWorkerGroup() { @Test @Order(2) public void testQueryAllWorkerGroupsPaging() { - HttpResponse queryAllWorkerGroupsPagingResponse = workerGroupPage.queryAllWorkerGroupsPaging(loginUser, 1, 2, null); + HttpResponse queryAllWorkerGroupsPagingResponse = + workerGroupPage.queryAllWorkerGroupsPaging(loginUser, 1, 2, null); Assertions.assertTrue(queryAllWorkerGroupsPagingResponse.getBody().getSuccess()); - String workerGroupPageInfoData = queryAllWorkerGroupsPagingResponse.getBody().getData().toString(); + String workerGroupPageInfoData = queryAllWorkerGroupsPagingResponse.getBody().getData().toString(); Assertions.assertTrue(workerGroupPageInfoData.contains("test_worker_group")); } @@ -100,7 +102,7 @@ public void testQueryAllWorkerGroups() { HttpResponse queryAllWorkerGroupsResponse = workerGroupPage.queryAllWorkerGroups(loginUser); Assertions.assertTrue(queryAllWorkerGroupsResponse.getBody().getSuccess()); - String workerGroupPageInfoData = queryAllWorkerGroupsResponse.getBody().getData().toString(); + String workerGroupPageInfoData = queryAllWorkerGroupsResponse.getBody().getData().toString(); Assertions.assertTrue(workerGroupPageInfoData.contains("test_worker_group")); } diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/entity/TenantListPagingResponseData.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/entity/TenantListPagingResponseData.java index 415d711ebc3c..5577f58b3f56 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/entity/TenantListPagingResponseData.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/entity/TenantListPagingResponseData.java @@ -29,6 +29,7 @@ @NoArgsConstructor @Data public class TenantListPagingResponseData { + private Integer currentPage; private Integer pageSize; diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/entity/TenantListPagingResponseTotalList.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/entity/TenantListPagingResponseTotalList.java index e75196af8eed..25abbeb05610 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/entity/TenantListPagingResponseTotalList.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/entity/TenantListPagingResponseTotalList.java @@ -29,6 +29,7 @@ @NoArgsConstructor @Data public class TenantListPagingResponseTotalList { + private Date createTime; private Date updateTime; diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/LoginPage.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/LoginPage.java index a94231329831..8b40b080c6e5 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/LoginPage.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/LoginPage.java @@ -26,6 +26,7 @@ import java.util.Map; public final class LoginPage { + public HttpResponse login(String username, String password) { Map params = new HashMap<>(); diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/project/ProjectPage.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/project/ProjectPage.java index b5f0a31bfc4f..efd84c2ada94 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/project/ProjectPage.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/project/ProjectPage.java @@ -19,8 +19,6 @@ package org.apache.dolphinscheduler.api.test.pages.project; -import lombok.AllArgsConstructor; - import org.apache.dolphinscheduler.api.test.core.Constants; import org.apache.dolphinscheduler.api.test.entity.HttpResponse; import org.apache.dolphinscheduler.api.test.utils.RequestClient; @@ -29,8 +27,11 @@ import java.util.HashMap; import java.util.Map; +import lombok.AllArgsConstructor; + @AllArgsConstructor public final class ProjectPage { + private String sessionId; public HttpResponse createProject(User loginUser, String projectName) { @@ -90,7 +91,8 @@ public HttpResponse queryProjectListPaging(User loginUser, Integer pageSize, Int return requestClient.get("/projects", headers, params); } - public HttpResponse queryProjectWithAuthorizedLevelListPaging(User loginUser, Integer userId, Integer pageSize, Integer pageNo) { + public HttpResponse queryProjectWithAuthorizedLevelListPaging(User loginUser, Integer userId, Integer pageSize, + Integer pageNo) { Map params = new HashMap<>(); params.put("loginUser", loginUser); params.put("userId", userId); diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/security/TenantPage.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/security/TenantPage.java index 1d1d74de4990..6c4b4733629c 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/security/TenantPage.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/security/TenantPage.java @@ -27,6 +27,7 @@ import java.util.Map; public final class TenantPage { + public HttpResponse createTenant(String sessionId, String tenant, Integer queueId, String description) { Map params = new HashMap<>(); params.put("tenantCode", tenant); diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/security/WorkerGroupPage.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/security/WorkerGroupPage.java index 9d6185fd9a02..1d34d7e76332 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/security/WorkerGroupPage.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/security/WorkerGroupPage.java @@ -19,8 +19,6 @@ package org.apache.dolphinscheduler.api.test.pages.security; -import lombok.AllArgsConstructor; - import org.apache.dolphinscheduler.api.test.core.Constants; import org.apache.dolphinscheduler.api.test.entity.HttpResponse; import org.apache.dolphinscheduler.api.test.utils.RequestClient; @@ -29,13 +27,15 @@ import java.util.HashMap; import java.util.Map; +import lombok.AllArgsConstructor; @AllArgsConstructor public class WorkerGroupPage { private String sessionId; - public HttpResponse saveWorkerGroup(User loginUser, int id, String name, String addrList, String description, String otherParamsJson) { + public HttpResponse saveWorkerGroup(User loginUser, int id, String name, String addrList, String description, + String otherParamsJson) { Map params = new HashMap<>(); params.put("loginUser", loginUser); params.put("id", id); @@ -96,5 +96,4 @@ public HttpResponse queryWorkerAddressList(User loginUser) { return requestClient.get("/worker-groups/worker-address-list", headers, params); } - } diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ExecutorPage.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ExecutorPage.java index 7ae09cafeaa4..1318aa6f3e21 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ExecutorPage.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ExecutorPage.java @@ -34,14 +34,15 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; - @Slf4j @AllArgsConstructor public class ExecutorPage { private String sessionId; - public HttpResponse startProcessInstance(User loginUser, long projectCode, long processDefinitionCode, String scheduleTime, FailureStrategy failureStrategy, WarningType warningType) { + public HttpResponse startProcessInstance(User loginUser, long projectCode, long processDefinitionCode, + String scheduleTime, FailureStrategy failureStrategy, + WarningType warningType) { Map params = new HashMap<>(); params.put("loginUser", loginUser); params.put("processDefinitionCode", processDefinitionCode); @@ -93,7 +94,8 @@ public HttpResponse startCheckProcessDefinition(User loginUser, long projectCode return requestClient.post(url, headers, params); } - public HttpResponse executeTask(User loginUser, long projectCode, int processInstanceId, String startNodeList, TaskDependType taskDependType) { + public HttpResponse executeTask(User loginUser, long projectCode, int processInstanceId, String startNodeList, + TaskDependType taskDependType) { Map params = new HashMap<>(); params.put("loginUser", loginUser); params.put("processInstanceId", processInstanceId); @@ -107,4 +109,4 @@ public HttpResponse executeTask(User loginUser, long projectCode, int processIns return requestClient.post(url, headers, params); } -} \ No newline at end of file +} diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ProcessDefinitionPage.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ProcessDefinitionPage.java index ef72e997ae59..3f3b715c39b2 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ProcessDefinitionPage.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ProcessDefinitionPage.java @@ -25,6 +25,8 @@ import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.dao.entity.User; +import org.apache.http.client.methods.CloseableHttpResponse; + import java.io.File; import java.util.HashMap; import java.util.Map; @@ -32,9 +34,6 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.http.client.methods.CloseableHttpResponse; - - @Slf4j @AllArgsConstructor public class ProcessDefinitionPage { @@ -107,7 +106,8 @@ public HttpResponse queryProcessDefinitionList(User loginUser, long projectCode) return requestClient.get(url, headers, params); } - public HttpResponse releaseProcessDefinition(User loginUser, long projectCode, long code, ReleaseState releaseState) { + public HttpResponse releaseProcessDefinition(User loginUser, long projectCode, long code, + ReleaseState releaseState) { Map params = new HashMap<>(); params.put("loginUser", loginUser); params.put("code", code); diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ProcessInstancePage.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ProcessInstancePage.java index e07e1166b1c0..eba4e6303650 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ProcessInstancePage.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/ProcessInstancePage.java @@ -19,13 +19,9 @@ package org.apache.dolphinscheduler.api.test.pages.workflow; -import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.test.core.Constants; import org.apache.dolphinscheduler.api.test.entity.HttpResponse; import org.apache.dolphinscheduler.api.test.utils.RequestClient; -import org.apache.dolphinscheduler.common.enums.FailureStrategy; -import org.apache.dolphinscheduler.common.enums.TaskDependType; -import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.dao.entity.User; import java.util.HashMap; @@ -34,7 +30,6 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; - @Slf4j @AllArgsConstructor public class ProcessInstancePage { diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/SchedulerPage.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/SchedulerPage.java index cfe23fd1bbc9..d6b3b9a74382 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/SchedulerPage.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/pages/workflow/SchedulerPage.java @@ -30,7 +30,6 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; - @Slf4j @AllArgsConstructor public class SchedulerPage { @@ -63,7 +62,6 @@ public HttpResponse queryScheduleList(User loginUser, long projectCode) { return requestClient.post(url, headers, params); } - public HttpResponse publishScheduleOnline(User loginUser, long projectCode, int scheduleId) { Map params = new HashMap<>(); params.put("loginUser", loginUser); diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/utils/JSONUtils.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/utils/JSONUtils.java index 0d9a9b97429d..3a25c927ffb5 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/utils/JSONUtils.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/utils/JSONUtils.java @@ -17,12 +17,11 @@ package org.apache.dolphinscheduler.api.test.utils; -import static java.nio.charset.StandardCharsets.UTF_8; - import static com.fasterxml.jackson.databind.DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT; import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; import static com.fasterxml.jackson.databind.DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL; import static com.fasterxml.jackson.databind.MapperFeature.REQUIRE_SETTERS_FOR_GETTERS; +import static java.nio.charset.StandardCharsets.UTF_8; import org.apache.dolphinscheduler.api.test.core.Constants; @@ -72,8 +71,11 @@ public class JSONUtils { * can use static singleton, inject: just make sure to reuse! */ private static final ObjectMapper objectMapper = - new ObjectMapper().configure(FAIL_ON_UNKNOWN_PROPERTIES, false).configure(ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true).configure(READ_UNKNOWN_ENUM_VALUES_AS_NULL, true) - .configure(REQUIRE_SETTERS_FOR_GETTERS, true).setTimeZone(TimeZone.getDefault()).setDateFormat(new SimpleDateFormat(Constants.YYYY_MM_DD_HH_MM_SS)); + new ObjectMapper().configure(FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true) + .configure(READ_UNKNOWN_ENUM_VALUES_AS_NULL, true) + .configure(REQUIRE_SETTERS_FOR_GETTERS, true).setTimeZone(TimeZone.getDefault()) + .setDateFormat(new SimpleDateFormat(Constants.YYYY_MM_DD_HH_MM_SS)); private JSONUtils() { throw new UnsupportedOperationException("Construct JSONUtils"); diff --git a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/utils/RequestClient.java b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/utils/RequestClient.java index 2993ea8de3f4..b04511f250d8 100644 --- a/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/utils/RequestClient.java +++ b/dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api/test/utils/RequestClient.java @@ -23,6 +23,15 @@ import org.apache.dolphinscheduler.api.test.entity.HttpResponse; import org.apache.dolphinscheduler.api.test.entity.HttpResponseBody; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicHeader; + import java.io.File; import java.io.FileInputStream; import java.util.HashMap; @@ -39,17 +48,6 @@ import okhttp3.RequestBody; import okhttp3.Response; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.message.BasicHeader; -import org.apache.http.util.EntityUtils; - - @Slf4j public class RequestClient { @@ -70,10 +68,10 @@ public HttpResponse get(String url, Map headers, Map headers, Map headers, Map headers, Map headers, Map params, File file) { + public CloseableHttpResponse postWithFile(String url, Map headers, Map params, + File file) { try { Headers headersBuilder = Headers.of(headers); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addTextBody("json", getParams(params), ContentType.MULTIPART_FORM_DATA); builder.addBinaryBody( - "file", - new FileInputStream(file), - ContentType.APPLICATION_OCTET_STREAM, - file.getName() - ); + "file", + new FileInputStream(file), + ContentType.APPLICATION_OCTET_STREAM, + file.getName()); HttpEntity multipart = builder.build(); String requestUrl = String.format("%s%s", Constants.DOLPHINSCHEDULER_API_URL, url); log.info("POST request to {}, Headers: {}, Params: {}", requestUrl, headersBuilder, params); @@ -199,7 +197,6 @@ public CloseableHttpResponse postWithFile(String url, Map header return null; } - @SneakyThrows public HttpResponse delete(String url, Map headers, Map params) { if (headers == null) { @@ -214,10 +211,10 @@ public HttpResponse delete(String url, Map headers, Map createDockerCompose(ExtensionContext context) .withPull(true) .withTailChildContainers(true) .withLogConsumer(serviceName, outputFrame -> log.info(outputFrame.getUtf8String())) - .waitingFor(serviceName, Wait.forHealthcheck().withStartupTimeout(Duration.ofSeconds(Constants.DOCKER_COMPOSE_DEFAULT_TIMEOUT))); + .waitingFor(serviceName, Wait.forHealthcheck() + .withStartupTimeout(Duration.ofSeconds(Constants.DOCKER_COMPOSE_DEFAULT_TIMEOUT))); return compose; } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java index 7bf49e001664..4df7a69da57d 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java @@ -25,7 +25,6 @@ import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.User; -import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; import java.io.IOException; import java.util.List; @@ -122,8 +121,6 @@ Map queryTaskListByProcessId(User loginUser, long projectCode, Integer processId) throws IOException; - Map parseLogForDependentResult(String log) throws IOException; - /** * query sub process instance detail info by task id * diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java index 5e5d703017c1..11ff034bb64e 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java @@ -21,7 +21,6 @@ import static org.apache.dolphinscheduler.api.enums.Status.PROCESS_INSTANCE_NOT_EXIST; import static org.apache.dolphinscheduler.api.enums.Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR; import static org.apache.dolphinscheduler.common.constants.Constants.DATA_LIST; -import static org.apache.dolphinscheduler.common.constants.Constants.DEPENDENT_SPLIT; import static org.apache.dolphinscheduler.common.constants.Constants.GLOBAL_PARAMS; import static org.apache.dolphinscheduler.common.constants.Constants.LOCAL_PARAMS; import static org.apache.dolphinscheduler.common.constants.Constants.PROCESS_INSTANCE_STATE; @@ -59,7 +58,6 @@ import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.RelationSubWorkflow; -import org.apache.dolphinscheduler.dao.entity.ResponseTaskLog; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; import org.apache.dolphinscheduler.dao.entity.TaskInstance; @@ -76,7 +74,6 @@ import org.apache.dolphinscheduler.dao.repository.ProcessInstanceMapDao; import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao; import org.apache.dolphinscheduler.dao.utils.WorkflowUtils; -import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.TaskTypeUtils; @@ -86,11 +83,6 @@ import org.apache.commons.lang3.StringUtils; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -446,11 +438,10 @@ public Result queryProcessInstanceList(User loginUser, WorkflowInstanceQueryRequ * @param projectCode project code * @param processId process instance id * @return task list for the process instance - * @throws IOException io exception */ @Override public Map queryTaskListByProcessId(User loginUser, long projectCode, - Integer processId) throws IOException { + Integer processId) { Project project = projectMapper.queryByCode(projectCode); // check user access for project Map result = @@ -471,7 +462,6 @@ public Map queryTaskListByProcessId(User loginUser, long project } List taskInstanceList = taskInstanceDao.queryValidTaskListByWorkflowInstanceId(processId, processInstance.getTestFlag()); - addDependResultForTaskList(loginUser, taskInstanceList); Map resultMap = new HashMap<>(); resultMap.put(PROCESS_INSTANCE_STATE, processInstance.getState().toString()); resultMap.put(TASK_LIST, taskInstanceList); @@ -541,57 +531,6 @@ public List queryDynamicSubWorkflowInstances(User loginUs return allDynamicSubWorkflowDtos; } - /** - * add dependent result for dependent task - */ - private void addDependResultForTaskList(User loginUser, List taskInstanceList) throws IOException { - for (TaskInstance taskInstance : taskInstanceList) { - if (TaskTypeUtils.isDependentTask(taskInstance.getTaskType())) { - log.info("DEPENDENT type task instance need to set dependent result, taskCode:{}, taskInstanceId:{}", - taskInstance.getTaskCode(), taskInstance.getId()); - // TODO The result of dependent item should not be obtained from the log, waiting for optimization. - Result logResult = loggerService.queryLog(loginUser, - taskInstance.getId(), Constants.LOG_QUERY_SKIP_LINE_NUMBER, Constants.LOG_QUERY_LIMIT); - if (logResult.getCode() == Status.SUCCESS.ordinal()) { - String log = logResult.getData().getMessage(); - Map resultMap = parseLogForDependentResult(log); - taskInstance.setDependentResult(JSONUtils.toJsonString(resultMap)); - } - } - } - } - - @Override - public Map parseLogForDependentResult(String content) throws IOException { - Map resultMap = new HashMap<>(); - if (StringUtils.isEmpty(content)) { - log.warn("Log content is empty."); - return resultMap; - } - - BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(content.getBytes( - StandardCharsets.UTF_8)), StandardCharsets.UTF_8)); - String line; - while ((line = br.readLine()) != null) { - if (line.contains(DEPENDENT_SPLIT)) { - String[] tmpStringArray = line.split(":\\|\\|"); - if (tmpStringArray.length != 2) { - continue; - } - String dependResultString = tmpStringArray[1]; - String[] dependStringArray = dependResultString.split(","); - if (dependStringArray.length != 3) { - continue; - } - String key = dependStringArray[0].trim().split(":")[1].trim(); - String result = dependStringArray[1].trim().split(":")[1].trim(); - DependResult dependResult = DependResult.valueOf(result); - resultMap.put(key, dependResult); - } - } - return resultMap; - } - /** * query sub process instance detail info by task id * diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java index 208d880fc143..26bbc9541202 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java @@ -64,7 +64,6 @@ import org.apache.dolphinscheduler.dao.repository.ProcessInstanceMapDao; import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao; import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager; -import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.service.expand.CuringParamsService; import org.apache.dolphinscheduler.service.model.TaskNode; @@ -481,23 +480,6 @@ public void testQueryTaskListByProcessId() throws IOException { Assertions.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); } - @Test - public void testParseLogForDependentResult() throws IOException { - String logString = - "[INFO] 2019-03-19 17:11:08.475 org.apache.dolphinscheduler.server.worker.log.TaskLogger:[172]" - + " - [taskAppId=TASK_223_10739_452334] dependent item complete, :|| dependentKey: 223-ALL-day-last1Day, result: SUCCESS, dependentDate: Wed Mar 19 17:10:36 CST 2019\n" - + "[INFO] 2019-03-19 17:11:08.476 org.apache.dolphinscheduler.server.worker.runner.TaskScheduleThread:[172]" - + " - task : 223_10739_452334 exit status code : 0\n" - + "[root@node2 current]# "; - Map resultMap = - processInstanceService.parseLogForDependentResult(logString); - Assertions.assertEquals(1, resultMap.size()); - - resultMap.clear(); - resultMap = processInstanceService.parseLogForDependentResult(""); - Assertions.assertEquals(0, resultMap.size()); - } - @Test public void testQuerySubProcessInstanceByTaskId() { long projectCode = 1L; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java index 629cfe9aea16..81b99c15889b 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java @@ -201,12 +201,6 @@ public class TaskInstance implements Serializable { @TableField(exist = false) private Priority processInstancePriority; - /** - * dependent state - */ - @TableField(exist = false) - private String dependentResult; - /** * workerGroup */ diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java index e23fcb97b586..6c1c7f03a3c5 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java @@ -62,7 +62,6 @@ public static void copyTaskInstance(TaskInstance source, TaskInstance target) { target.setMaxRetryTimes(source.getMaxRetryTimes()); target.setRetryInterval(source.getRetryInterval()); target.setTaskInstancePriority(source.getTaskInstancePriority()); - target.setDependentResult(source.getDependentResult()); target.setWorkerGroup(source.getWorkerGroup()); target.setEnvironmentCode(source.getEnvironmentCode()); target.setEnvironmentConfig(source.getEnvironmentConfig()); diff --git a/dolphinscheduler-dist/release-docs/LICENSE b/dolphinscheduler-dist/release-docs/LICENSE index 290d0ab3f37e..1fbd3e6e521b 100644 --- a/dolphinscheduler-dist/release-docs/LICENSE +++ b/dolphinscheduler-dist/release-docs/LICENSE @@ -746,7 +746,7 @@ MIT licenses axios 0.27.2: https://github.com/axios/axios MIT date-fns 2.29.3: https://github.com/date-fns/date-fns MIT lodash 4.17.21: https://github.com/lodash/lodash MIT - monaco-editor 0.34.0: https://github.com/microsoft/monaco-editor MIT + monaco-editor 0.50.0: https://github.com/microsoft/monaco-editor MIT naive-ui 2.30.7: https://github.com/TuSimple/naive-ui MIT nprogress 0.2.0: https://github.com/rstacruz/nprogress MIT pinia 2.0.22: https://github.com/vuejs/pinia MIT diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ClickhouseDataSourceE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ClickhouseDataSourceE2ETest.java index 412b5f6a8a2d..09d8fa4ea824 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ClickhouseDataSourceE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ClickhouseDataSourceE2ETest.java @@ -1,112 +1,107 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.dolphinscheduler.e2e.cases; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; -import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; -import org.apache.dolphinscheduler.e2e.pages.LoginPage; -import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; - -import java.time.Duration; - -import org.testcontainers.shaded.org.awaitility.Awaitility; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - - -@DolphinScheduler(composeFiles = "docker/datasource-clickhouse/docker-compose.yaml") -public class ClickhouseDataSourceE2ETest { - private static RemoteWebDriver browser; - - private static final String tenant = System.getProperty("user.name"); - - private static final String user = "admin"; - - private static final String password = "dolphinscheduler123"; - - private static final String dataSourceType = "CLICKHOUSE"; - - private static final String dataSourceName = "clickhouse_test"; - - private static final String dataSourceDescription = "clickhouse_test"; - - private static final String ip = "clickhouse"; - - private static final String port = "8123"; - - private static final String userName = "ch_test"; - - private static final String pgPassword = "ch_test"; - - private static final String database = "ch_test"; - - private static final String jdbcParams = ""; - - - @BeforeAll - public static void setup() { - new LoginPage(browser) - .login(user, password) - .goToNav(DataSourcePage.class); - } - - @Test - @Order(10) - void testCreateClickhouseDataSource() { - final DataSourcePage page = new DataSourcePage(browser); - - page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, pgPassword, database, jdbcParams); - - WebDriverWaitFactory.createWebDriverWait(page.driver()).until(ExpectedConditions.invisibilityOfElementLocated( - new By.ByClassName("dialog-create-data-source"))); - - Awaitility.await().untilAsserted(() -> assertThat(page.dataSourceItemsList()) - .as("DataSource list should contain newly-created database") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(dataSourceName))); - } - - @Test - @Order(20) - void testDeleteClickhouseDataSource() { - final DataSourcePage page = new DataSourcePage(browser); - - page.delete(dataSourceName); - - Awaitility.await().untilAsserted(() -> { - browser.navigate().refresh(); - - assertThat( - page.dataSourceItemsList() - ).noneMatch( - it -> it.getText().contains(dataSourceName) - ); - }); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.dolphinscheduler.e2e.cases; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; +import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; +import org.apache.dolphinscheduler.e2e.pages.LoginPage; +import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.testcontainers.shaded.org.awaitility.Awaitility; + +@DolphinScheduler(composeFiles = "docker/datasource-clickhouse/docker-compose.yaml") +public class ClickhouseDataSourceE2ETest { + + private static RemoteWebDriver browser; + + private static final String tenant = System.getProperty("user.name"); + + private static final String user = "admin"; + + private static final String password = "dolphinscheduler123"; + + private static final String dataSourceType = "CLICKHOUSE"; + + private static final String dataSourceName = "clickhouse_test"; + + private static final String dataSourceDescription = "clickhouse_test"; + + private static final String ip = "clickhouse"; + + private static final String port = "8123"; + + private static final String userName = "ch_test"; + + private static final String pgPassword = "ch_test"; + + private static final String database = "ch_test"; + + private static final String jdbcParams = ""; + + @BeforeAll + public static void setup() { + new LoginPage(browser) + .login(user, password) + .goToNav(DataSourcePage.class); + } + + @Test + @Order(10) + void testCreateClickhouseDataSource() { + final DataSourcePage page = new DataSourcePage(browser); + + page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, pgPassword, + database, jdbcParams); + + WebDriverWaitFactory.createWebDriverWait(page.driver()).until(ExpectedConditions.invisibilityOfElementLocated( + new By.ByClassName("dialog-create-data-source"))); + + Awaitility.await().untilAsserted(() -> assertThat(page.dataSourceItemsList()) + .as("DataSource list should contain newly-created database") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(dataSourceName))); + } + + @Test + @Order(20) + void testDeleteClickhouseDataSource() { + final DataSourcePage page = new DataSourcePage(browser); + + page.delete(dataSourceName); + + Awaitility.await().untilAsserted(() -> { + browser.navigate().refresh(); + + assertThat( + page.dataSourceItemsList()).noneMatch( + it -> it.getText().contains(dataSourceName)); + }); + } +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ClusterE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ClusterE2ETest.java index a7e526540bec..b75b496b5e17 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ClusterE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ClusterE2ETest.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.e2e.cases; - import static org.assertj.core.api.Assertions.assertThat; import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; @@ -27,13 +26,13 @@ import org.apache.dolphinscheduler.e2e.pages.security.ClusterPage; import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; -import org.testcontainers.shaded.org.awaitility.Awaitility; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") class ClusterE2ETest { @@ -53,8 +52,7 @@ public static void setup() { new LoginPage(browser) .login("admin", "dolphinscheduler123") .goToNav(SecurityPage.class) - .goToTab(ClusterPage.class) - ; + .goToTab(ClusterPage.class); } @Test @@ -78,10 +76,8 @@ void testCreateDuplicateCluster() { final ClusterPage page = new ClusterPage(browser); page.create(clusterName, clusterConfig, clusterDesc); - Awaitility.await().untilAsserted(() -> - assertThat(browser.findElement(By.tagName("body")).getText()) - .contains("already exists") - ); + Awaitility.await().untilAsserted(() -> assertThat(browser.findElement(By.tagName("body")).getText()) + .contains("already exists")); page.createClusterForm().buttonCancel().click(); } @@ -112,12 +108,10 @@ void testDeleteCluster() { browser.navigate().refresh(); assertThat( - page.clusterList() - ) - .as("Cluster list should not contain deleted cluster") - .noneMatch( - it -> it.getText().contains(clusterName) || it.getText().contains(editClusterName) - ); + page.clusterList()) + .as("Cluster list should not contain deleted cluster") + .noneMatch( + it -> it.getText().contains(clusterName) || it.getText().contains(editClusterName)); }); } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/EnvironmentE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/EnvironmentE2ETest.java index 1e3d84864534..626f2cc44b4a 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/EnvironmentE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/EnvironmentE2ETest.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.e2e.cases; - import static org.assertj.core.api.Assertions.assertThat; import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; @@ -27,13 +26,13 @@ import org.apache.dolphinscheduler.e2e.pages.security.EnvironmentPage; import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; -import org.testcontainers.shaded.org.awaitility.Awaitility; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") class EnvironmentE2ETest { @@ -55,8 +54,7 @@ public static void setup() { new LoginPage(browser) .login("admin", "dolphinscheduler123") .goToNav(SecurityPage.class) - .goToTab(EnvironmentPage.class) - ; + .goToTab(EnvironmentPage.class); } @Test @@ -80,10 +78,8 @@ void testCreateDuplicateEnvironment() { final EnvironmentPage page = new EnvironmentPage(browser); page.create(environmentName, environmentConfig, environmentDesc, environmentWorkerGroup); - Awaitility.await().untilAsserted(() -> - assertThat(browser.findElement(By.tagName("body")).getText()) - .contains("already exists") - ); + Awaitility.await().untilAsserted(() -> assertThat(browser.findElement(By.tagName("body")).getText()) + .contains("already exists")); page.createEnvironmentForm().buttonCancel().click(); } @@ -92,7 +88,8 @@ void testCreateDuplicateEnvironment() { @Order(30) void testEditEnvironment() { final EnvironmentPage page = new EnvironmentPage(browser); - page.update(environmentName, editEnvironmentName, editEnvironmentConfig, editEnvironmentDesc, editEnvironmentWorkerGroup); + page.update(environmentName, editEnvironmentName, editEnvironmentConfig, editEnvironmentDesc, + editEnvironmentWorkerGroup); Awaitility.await().untilAsserted(() -> { browser.navigate().refresh(); @@ -114,12 +111,11 @@ void testDeleteEnvironment() { browser.navigate().refresh(); assertThat( - page.environmentList() - ) - .as("Environment list should not contain deleted environment") - .noneMatch( - it -> it.getText().contains(environmentName) || it.getText().contains(editEnvironmentName) - ); + page.environmentList()) + .as("Environment list should not contain deleted environment") + .noneMatch( + it -> it.getText().contains(environmentName) + || it.getText().contains(editEnvironmentName)); }); } } 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 ad041b9ac449..83d45f4531a1 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 @@ -19,7 +19,6 @@ */ package org.apache.dolphinscheduler.e2e.cases; - import static org.assertj.core.api.Assertions.assertThat; import org.apache.dolphinscheduler.e2e.core.Constants; @@ -37,10 +36,10 @@ import java.io.RandomAccessFile; import java.nio.file.Files; import java.nio.file.Path; -import java.time.Duration; import java.util.Comparator; -import org.testcontainers.shaded.org.awaitility.Awaitility; +import lombok.SneakyThrows; + import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; @@ -49,12 +48,11 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import lombok.SneakyThrows; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/file-manage/docker-compose.yaml") public class FileManageE2ETest { + private static RemoteWebDriver browser; private static final String tenant = System.getProperty("user.name"); @@ -92,19 +90,19 @@ public static void setup() { .create(tenant); Awaitility.await().untilAsserted(() -> assertThat(tenantPage.tenantList()) - .as("Tenant list should contain newly-created tenant") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(tenant))); + .as("Tenant list should contain newly-created tenant") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(tenant))); UserPage userPage = tenantPage.goToNav(SecurityPage.class) - .goToTab(UserPage.class); + .goToTab(UserPage.class); WebDriverWaitFactory.createWebDriverWait(userPage.driver()).until(ExpectedConditions.visibilityOfElementLocated( new By.ByClassName("name"))); userPage.update(user, user, email, phone, tenant) - .goToNav(ResourcePage.class) - .goToTab(FileManagePage.class); + .goToNav(ResourcePage.class) + .goToTab(FileManagePage.class); } @AfterAll @@ -113,9 +111,9 @@ public static void cleanup() { Files.deleteIfExists(testUnder1GBFilePath); Files.deleteIfExists(testOver1GBFilePath); Files.walk(Constants.HOST_CHROME_DOWNLOAD_PATH) - .sorted(Comparator.reverseOrder()) - .map(Path::toFile) - .forEach(File::delete); + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); } @Test @@ -139,57 +137,57 @@ void testCancelCreateDirectory() { page.cancelCreateDirectory(testDirectoryName); Awaitility.await().untilAsserted(() -> assertThat(page.fileList()) - .as("File list should contain newly-created file") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(testDirectoryName))); + .as("File list should contain newly-created file") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(testDirectoryName))); } -// @Test -// @Order(20) -// void testCreateDuplicateDirectory() { -// final FileManagePage page = new FileManagePage(browser); -// -// page.createDirectory(testDirectoryName, "test_desc"); -// -// await().untilAsserted(() -> assertThat(browser.findElement(By.tagName("body")).getText()) -// .contains("resource already exists") -// ); -// -// page.createDirectoryBox().buttonCancel().click(); -// } - -// @Test -// @Order(21) -// void testCreateSubDirectory() { -// final FileManagePage page = new FileManagePage(browser); -// -// page.createSubDirectory(testDirectoryName, testSubDirectoryName, "test_desc"); -// -// await().untilAsserted(() -> assertThat(page.fileList()) -// .as("File list should contain newly-created file") -// .extracting(WebElement::getText) -// .anyMatch(it -> it.contains(testSubDirectoryName))); -// } - -/* -* when the storage is s3,the directory cannot be renamed -* */ -// @Test -// @Order(22) -// void testRenameDirectory() { -// final FileManagePage page = new FileManagePage(browser); -// -// page.rename(testDirectoryName, 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(20) + // void testCreateDuplicateDirectory() { + // final FileManagePage page = new FileManagePage(browser); + // + // page.createDirectory(testDirectoryName, "test_desc"); + // + // await().untilAsserted(() -> assertThat(browser.findElement(By.tagName("body")).getText()) + // .contains("resource already exists") + // ); + // + // page.createDirectoryBox().buttonCancel().click(); + // } + + // @Test + // @Order(21) + // void testCreateSubDirectory() { + // final FileManagePage page = new FileManagePage(browser); + // + // page.createSubDirectory(testDirectoryName, testSubDirectoryName, "test_desc"); + // + // await().untilAsserted(() -> assertThat(page.fileList()) + // .as("File list should contain newly-created file") + // .extracting(WebElement::getText) + // .anyMatch(it -> it.contains(testSubDirectoryName))); + // } + + /* + * when the storage is s3,the directory cannot be renamed + */ + // @Test + // @Order(22) + // void testRenameDirectory() { + // final FileManagePage page = new FileManagePage(browser); + // + // page.rename(testDirectoryName, 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) @@ -197,17 +195,15 @@ void testDeleteDirectory() { final FileManagePage page = new FileManagePage(browser); page.goToNav(ResourcePage.class) - .goToTab(FileManagePage.class) - .delete(testDirectoryName); + .goToTab(FileManagePage.class) + .delete(testDirectoryName); Awaitility.await().untilAsserted(() -> { browser.navigate().refresh(); assertThat( - page.fileList() - ).noneMatch( - it -> it.getText().contains(testDirectoryName) - ); + page.fileList()).noneMatch( + it -> it.getText().contains(testDirectoryName)); }); } @@ -220,9 +216,9 @@ void testCreateFile() { page.createFile(testFileName, scripts); Awaitility.await().untilAsserted(() -> assertThat(page.fileList()) - .as("File list should contain newly-created file") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(testFileName))); + .as("File list should contain newly-created file") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(testFileName))); } @Test @@ -236,9 +232,9 @@ void testRenameFile() { browser.navigate().refresh(); assertThat(page.fileList()) - .as("File list should contain newly-created file") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(testRenameFileName)); + .as("File list should contain newly-created file") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(testRenameFileName)); }); } @@ -251,9 +247,9 @@ void testEditFile() { page.editFile(testRenameFileName, scripts); Awaitility.await().untilAsserted(() -> assertThat(page.fileList()) - .as("File list should contain newly-created file") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(testRenameFileName))); + .as("File list should contain newly-created file") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(testRenameFileName))); } @Test @@ -267,10 +263,8 @@ void testDeleteFile() { browser.navigate().refresh(); assertThat( - page.fileList() - ).noneMatch( - it -> it.getText().contains(testRenameFileName) - ); + page.fileList()).noneMatch( + it -> it.getText().contains(testRenameFileName)); }); } @@ -286,13 +280,14 @@ void testUploadUnder1GBFile() throws IOException { page.uploadFile(testUnder1GBFilePath.toFile().getAbsolutePath()); - WebDriverWaitFactory.createWebDriverWait(browser).until(ExpectedConditions.invisibilityOfElementLocated(By.id("fileUpdateDialog"))); + WebDriverWaitFactory.createWebDriverWait(browser) + .until(ExpectedConditions.invisibilityOfElementLocated(By.id("fileUpdateDialog"))); Awaitility.await().untilAsserted(() -> { assertThat(page.fileList()) - .as("File list should contain newly-created file") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(testUnder1GBFileName)); + .as("File list should contain newly-created file") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(testUnder1GBFileName)); }); } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/HiveDataSourceE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/HiveDataSourceE2ETest.java index 3726ec1acdeb..fa9fb809139f 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/HiveDataSourceE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/HiveDataSourceE2ETest.java @@ -27,8 +27,6 @@ import org.apache.dolphinscheduler.e2e.pages.LoginPage; import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; -import java.time.Duration; - import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -36,11 +34,11 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/datasource-hive/docker-compose.yaml") public class HiveDataSourceE2ETest { + private static RemoteWebDriver browser; private static final String tenant = System.getProperty("user.name"); @@ -70,9 +68,8 @@ public class HiveDataSourceE2ETest { @BeforeAll public static void setup() { new LoginPage(browser) - .login(user, password) - .goToNav(DataSourcePage.class); - + .login(user, password) + .goToNav(DataSourcePage.class); } @@ -81,15 +78,16 @@ public static void setup() { void testCreateHiveDataSource() { final DataSourcePage page = new DataSourcePage(browser); - page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, hivePassword, database, jdbcParams); + page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, hivePassword, + database, jdbcParams); WebDriverWaitFactory.createWebDriverWait(page.driver()).until(ExpectedConditions.invisibilityOfElementLocated( new By.ByClassName("dialog-create-data-source"))); Awaitility.await().untilAsserted(() -> assertThat(page.dataSourceItemsList()) - .as("DataSource list should contain newly-created database") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(dataSourceName))); + .as("DataSource list should contain newly-created database") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(dataSourceName))); } @Test @@ -103,10 +101,8 @@ void testDeleteHiveDataSource() { browser.navigate().refresh(); assertThat( - page.dataSourceItemsList() - ).noneMatch( - it -> it.getText().contains(dataSourceName) - ); + page.dataSourceItemsList()).noneMatch( + it -> it.getText().contains(dataSourceName)); }); } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/MysqlDataSourceE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/MysqlDataSourceE2ETest.java index 5c0746a5b547..faf033f0d0d8 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/MysqlDataSourceE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/MysqlDataSourceE2ETest.java @@ -1,113 +1,108 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.dolphinscheduler.e2e.cases; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; -import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; -import org.apache.dolphinscheduler.e2e.pages.LoginPage; -import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; - -import java.time.Duration; - -import org.testcontainers.shaded.org.awaitility.Awaitility; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - - -@DolphinScheduler(composeFiles = "docker/datasource-mysql/docker-compose.yaml") -public class MysqlDataSourceE2ETest { - private static RemoteWebDriver browser; - - private static final String tenant = System.getProperty("user.name"); - - private static final String user = "admin"; - - private static final String password = "dolphinscheduler123"; - - private static final String dataSourceType = "MYSQL"; - - private static final String dataSourceName = "mysql_test"; - - private static final String dataSourceDescription = "mysql_test"; - - private static final String ip = "mysql"; - - private static final String port = "3306"; - - private static final String userName = "root"; - - private static final String mysqlPassword = "123456"; - - private static final String database = "mysql"; - - private static final String jdbcParams = "{\"useSSL\": false}"; - - - @BeforeAll - public static void setup() { - new LoginPage(browser) - .login(user, password) - .goToNav(DataSourcePage.class); - } - - @Test - @Order(10) - void testCreateMysqlDataSource() { - final DataSourcePage page = new DataSourcePage(browser); - - page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, mysqlPassword, database, jdbcParams); - - WebDriverWaitFactory.createWebDriverWait(page.driver()).until(ExpectedConditions.invisibilityOfElementLocated( - new By.ByClassName("dialog-create-data-source"))); - - Awaitility.await().untilAsserted(() -> assertThat(page.dataSourceItemsList()) - .as("DataSource list should contain newly-created database") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(dataSourceName))); - } - - @Test - @Order(20) - void testDeleteMysqlDataSource() { - final DataSourcePage page = new DataSourcePage(browser); - - page.delete(dataSourceName); - - Awaitility.await().untilAsserted(() -> { - browser.navigate().refresh(); - - assertThat( - page.dataSourceItemsList() - ).noneMatch( - it -> it.getText().contains(dataSourceName) - ); - }); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.dolphinscheduler.e2e.cases; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; +import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; +import org.apache.dolphinscheduler.e2e.pages.LoginPage; +import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.testcontainers.shaded.org.awaitility.Awaitility; + +@DolphinScheduler(composeFiles = "docker/datasource-mysql/docker-compose.yaml") +public class MysqlDataSourceE2ETest { + + private static RemoteWebDriver browser; + + private static final String tenant = System.getProperty("user.name"); + + private static final String user = "admin"; + + private static final String password = "dolphinscheduler123"; + + private static final String dataSourceType = "MYSQL"; + + private static final String dataSourceName = "mysql_test"; + + private static final String dataSourceDescription = "mysql_test"; + + private static final String ip = "mysql"; + + private static final String port = "3306"; + + private static final String userName = "root"; + + private static final String mysqlPassword = "123456"; + + private static final String database = "mysql"; + + private static final String jdbcParams = "{\"useSSL\": false}"; + + @BeforeAll + public static void setup() { + new LoginPage(browser) + .login(user, password) + .goToNav(DataSourcePage.class); + } + + @Test + @Order(10) + void testCreateMysqlDataSource() { + final DataSourcePage page = new DataSourcePage(browser); + + page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, mysqlPassword, + database, jdbcParams); + + WebDriverWaitFactory.createWebDriverWait(page.driver()).until(ExpectedConditions.invisibilityOfElementLocated( + new By.ByClassName("dialog-create-data-source"))); + + Awaitility.await().untilAsserted(() -> assertThat(page.dataSourceItemsList()) + .as("DataSource list should contain newly-created database") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(dataSourceName))); + } + + @Test + @Order(20) + void testDeleteMysqlDataSource() { + final DataSourcePage page = new DataSourcePage(browser); + + page.delete(dataSourceName); + + Awaitility.await().untilAsserted(() -> { + browser.navigate().refresh(); + + assertThat( + page.dataSourceItemsList()).noneMatch( + it -> it.getText().contains(dataSourceName)); + }); + } + +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/PostgresDataSourceE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/PostgresDataSourceE2ETest.java index cbed2b3b8ba3..a8a1db9e3d11 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/PostgresDataSourceE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/PostgresDataSourceE2ETest.java @@ -1,112 +1,107 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.dolphinscheduler.e2e.cases; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; -import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; -import org.apache.dolphinscheduler.e2e.pages.LoginPage; -import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; - -import java.time.Duration; - -import org.testcontainers.shaded.org.awaitility.Awaitility; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - - -@DolphinScheduler(composeFiles = "docker/datasource-postgresql/docker-compose.yaml") -public class PostgresDataSourceE2ETest { - private static RemoteWebDriver browser; - - private static final String tenant = System.getProperty("user.name"); - - private static final String user = "admin"; - - private static final String password = "dolphinscheduler123"; - - private static final String dataSourceType = "POSTGRESQL"; - - private static final String dataSourceName = "postgres_test"; - - private static final String dataSourceDescription = "postgres_test"; - - private static final String ip = "postgres"; - - private static final String port = "5432"; - - private static final String userName = "postgres"; - - private static final String pgPassword = "postgres"; - - private static final String database = "postgres"; - - private static final String jdbcParams = ""; - - - @BeforeAll - public static void setup() { - new LoginPage(browser) - .login(user, password) - .goToNav(DataSourcePage.class); - } - - @Test - @Order(10) - void testCreatePostgresDataSource() { - final DataSourcePage page = new DataSourcePage(browser); - - page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, pgPassword, database, jdbcParams); - - WebDriverWaitFactory.createWebDriverWait(page.driver()).until(ExpectedConditions.invisibilityOfElementLocated( - new By.ByClassName("dialog-create-data-source"))); - - Awaitility.await().untilAsserted(() -> assertThat(page.dataSourceItemsList()) - .as("DataSource list should contain newly-created database") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(dataSourceName))); - } - - @Test - @Order(20) - void testDeletePostgresDataSource() { - final DataSourcePage page = new DataSourcePage(browser); - - page.delete(dataSourceName); - - Awaitility.await().untilAsserted(() -> { - browser.navigate().refresh(); - - assertThat( - page.dataSourceItemsList() - ).noneMatch( - it -> it.getText().contains(dataSourceName) - ); - }); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.dolphinscheduler.e2e.cases; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; +import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; +import org.apache.dolphinscheduler.e2e.pages.LoginPage; +import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.testcontainers.shaded.org.awaitility.Awaitility; + +@DolphinScheduler(composeFiles = "docker/datasource-postgresql/docker-compose.yaml") +public class PostgresDataSourceE2ETest { + + private static RemoteWebDriver browser; + + private static final String tenant = System.getProperty("user.name"); + + private static final String user = "admin"; + + private static final String password = "dolphinscheduler123"; + + private static final String dataSourceType = "POSTGRESQL"; + + private static final String dataSourceName = "postgres_test"; + + private static final String dataSourceDescription = "postgres_test"; + + private static final String ip = "postgres"; + + private static final String port = "5432"; + + private static final String userName = "postgres"; + + private static final String pgPassword = "postgres"; + + private static final String database = "postgres"; + + private static final String jdbcParams = ""; + + @BeforeAll + public static void setup() { + new LoginPage(browser) + .login(user, password) + .goToNav(DataSourcePage.class); + } + + @Test + @Order(10) + void testCreatePostgresDataSource() { + final DataSourcePage page = new DataSourcePage(browser); + + page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, pgPassword, + database, jdbcParams); + + WebDriverWaitFactory.createWebDriverWait(page.driver()).until(ExpectedConditions.invisibilityOfElementLocated( + new By.ByClassName("dialog-create-data-source"))); + + Awaitility.await().untilAsserted(() -> assertThat(page.dataSourceItemsList()) + .as("DataSource list should contain newly-created database") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(dataSourceName))); + } + + @Test + @Order(20) + void testDeletePostgresDataSource() { + final DataSourcePage page = new DataSourcePage(browser); + + page.delete(dataSourceName); + + Awaitility.await().untilAsserted(() -> { + browser.navigate().refresh(); + + assertThat( + page.dataSourceItemsList()).noneMatch( + it -> it.getText().contains(dataSourceName)); + }); + } +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ProjectE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ProjectE2ETest.java index f9f54299e8d4..e23a1000b1c2 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ProjectE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ProjectE2ETest.java @@ -25,14 +25,15 @@ import org.apache.dolphinscheduler.e2e.pages.LoginPage; import org.apache.dolphinscheduler.e2e.pages.project.ProjectPage; -import org.testcontainers.shaded.org.awaitility.Awaitility; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.openqa.selenium.remote.RemoteWebDriver; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") class ProjectE2ETest { + private static final String project = "test-project-1"; private static RemoteWebDriver browser; @@ -59,10 +60,8 @@ void testDeleteProject() { Awaitility.await().untilAsserted(() -> { browser.navigate().refresh(); assertThat( - page.projectList() - ).noneMatch( - it -> it.getText().contains(project) - ); + page.projectList()).noneMatch( + it -> it.getText().contains(project)); }); } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/QueueE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/QueueE2ETest.java index 0ad3ee3a357f..c9c73d87149c 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/QueueE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/QueueE2ETest.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.e2e.cases; - import static org.assertj.core.api.Assertions.assertThat; import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; @@ -27,13 +26,13 @@ import org.apache.dolphinscheduler.e2e.pages.security.QueuePage; import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; -import org.testcontainers.shaded.org.awaitility.Awaitility; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") class QueueE2ETest { @@ -50,8 +49,7 @@ public static void setup() { new LoginPage(browser) .login("admin", "dolphinscheduler123") .goToNav(SecurityPage.class) - .goToTab(QueuePage.class) - ; + .goToTab(QueuePage.class); } @Test @@ -75,10 +73,8 @@ void testCreateDuplicateQueue() { final QueuePage page = new QueuePage(browser); page.create(queueName, queueValue); - Awaitility.await().untilAsserted(() -> - assertThat(browser.findElement(By.tagName("body")).getText()) - .contains("already exists") - ); + Awaitility.await().untilAsserted(() -> assertThat(browser.findElement(By.tagName("body")).getText()) + .contains("already exists")); page.createQueueForm().buttonCancel().click(); } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/SqlServerDataSourceE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/SqlServerDataSourceE2ETest.java index 7f6ee662dd3f..c01452eaecd6 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/SqlServerDataSourceE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/SqlServerDataSourceE2ETest.java @@ -1,112 +1,107 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.dolphinscheduler.e2e.cases; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; -import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; -import org.apache.dolphinscheduler.e2e.pages.LoginPage; -import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; - -import java.time.Duration; - -import org.testcontainers.shaded.org.awaitility.Awaitility; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - - -@DolphinScheduler(composeFiles = "docker/datasource-sqlserver/docker-compose.yaml") -public class SqlServerDataSourceE2ETest { - private static RemoteWebDriver browser; - - private static final String tenant = System.getProperty("user.name"); - - private static final String user = "admin"; - - private static final String password = "dolphinscheduler123"; - - private static final String dataSourceType = "SQLSERVER"; - - private static final String dataSourceName = "sqlserver_test"; - - private static final String dataSourceDescription = "sqlserver_test"; - - private static final String ip = "sqlserver"; - - private static final String port = "1433"; - - private static final String userName = "sa"; - - private static final String pgPassword = "OcP2020123"; - - private static final String database = "master"; - - private static final String jdbcParams = ""; - - - @BeforeAll - public static void setup() { - new LoginPage(browser) - .login(user, password) - .goToNav(DataSourcePage.class); - } - - @Test - @Order(10) - void testCreateSqlServerDataSource() { - final DataSourcePage page = new DataSourcePage(browser); - - page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, pgPassword, database, jdbcParams); - - WebDriverWaitFactory.createWebDriverWait(page.driver()).until(ExpectedConditions.invisibilityOfElementLocated( - new By.ByClassName("dialog-create-data-source"))); - - Awaitility.await().untilAsserted(() -> assertThat(page.dataSourceItemsList()) - .as("DataSource list should contain newly-created database") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(dataSourceName))); - } - - @Test - @Order(20) - void testDeleteSqlServerDataSource() { - final DataSourcePage page = new DataSourcePage(browser); - - page.delete(dataSourceName); - - Awaitility.await().untilAsserted(() -> { - browser.navigate().refresh(); - - assertThat( - page.dataSourceItemsList() - ).noneMatch( - it -> it.getText().contains(dataSourceName) - ); - }); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.dolphinscheduler.e2e.cases; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; +import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; +import org.apache.dolphinscheduler.e2e.pages.LoginPage; +import org.apache.dolphinscheduler.e2e.pages.datasource.DataSourcePage; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.testcontainers.shaded.org.awaitility.Awaitility; + +@DolphinScheduler(composeFiles = "docker/datasource-sqlserver/docker-compose.yaml") +public class SqlServerDataSourceE2ETest { + + private static RemoteWebDriver browser; + + private static final String tenant = System.getProperty("user.name"); + + private static final String user = "admin"; + + private static final String password = "dolphinscheduler123"; + + private static final String dataSourceType = "SQLSERVER"; + + private static final String dataSourceName = "sqlserver_test"; + + private static final String dataSourceDescription = "sqlserver_test"; + + private static final String ip = "sqlserver"; + + private static final String port = "1433"; + + private static final String userName = "sa"; + + private static final String pgPassword = "OcP2020123"; + + private static final String database = "master"; + + private static final String jdbcParams = ""; + + @BeforeAll + public static void setup() { + new LoginPage(browser) + .login(user, password) + .goToNav(DataSourcePage.class); + } + + @Test + @Order(10) + void testCreateSqlServerDataSource() { + final DataSourcePage page = new DataSourcePage(browser); + + page.createDataSource(dataSourceType, dataSourceName, dataSourceDescription, ip, port, userName, pgPassword, + database, jdbcParams); + + WebDriverWaitFactory.createWebDriverWait(page.driver()).until(ExpectedConditions.invisibilityOfElementLocated( + new By.ByClassName("dialog-create-data-source"))); + + Awaitility.await().untilAsserted(() -> assertThat(page.dataSourceItemsList()) + .as("DataSource list should contain newly-created database") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(dataSourceName))); + } + + @Test + @Order(20) + void testDeleteSqlServerDataSource() { + final DataSourcePage page = new DataSourcePage(browser); + + page.delete(dataSourceName); + + Awaitility.await().untilAsserted(() -> { + browser.navigate().refresh(); + + assertThat( + page.dataSourceItemsList()).noneMatch( + it -> it.getText().contains(dataSourceName)); + }); + } +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TenantE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TenantE2ETest.java index d80eae7b89d9..696c8f172f6f 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TenantE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TenantE2ETest.java @@ -26,16 +26,17 @@ import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; import org.apache.dolphinscheduler.e2e.pages.security.TenantPage; -import org.testcontainers.shaded.org.awaitility.Awaitility; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") class TenantE2ETest { + private static final String tenant = System.getProperty("user.name"); private static final String editDescription = "This is a test"; @@ -44,10 +45,9 @@ class TenantE2ETest { @BeforeAll public static void setup() { new LoginPage(browser) - .login("admin", "dolphinscheduler123") - .goToNav(SecurityPage.class) - .goToTab(TenantPage.class) - ; + .login("admin", "dolphinscheduler123") + .goToNav(SecurityPage.class) + .goToTab(TenantPage.class); } @Test @@ -57,9 +57,9 @@ void testCreateTenant() { page.create(tenant); Awaitility.await().untilAsserted(() -> assertThat(page.tenantList()) - .as("Tenant list should contain newly-created tenant") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(tenant))); + .as("Tenant list should contain newly-created tenant") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(tenant))); } @Test @@ -69,10 +69,8 @@ void testCreateDuplicateTenant() { page.create(tenant); - Awaitility.await().untilAsserted(() -> - assertThat(browser.findElement(By.tagName("body")).getText()) - .contains("already exists") - ); + Awaitility.await().untilAsserted(() -> assertThat(browser.findElement(By.tagName("body")).getText()) + .contains("already exists")); page.tenantForm().buttonCancel().click(); } @@ -87,9 +85,9 @@ void testUpdateTenant() { Awaitility.await().untilAsserted(() -> { browser.navigate().refresh(); assertThat(page.tenantList()) - .as("Tenant list should contain newly-modified tenant") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(tenant)); + .as("Tenant list should contain newly-modified tenant") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(tenant)); }); } @@ -103,10 +101,8 @@ void testDeleteTenant() { browser.navigate().refresh(); assertThat( - page.tenantList() - ).noneMatch( - it -> it.getText().contains(tenant) - ); + page.tenantList()).noneMatch( + it -> it.getText().contains(tenant)); }); } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TokenE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TokenE2ETest.java index 8d287637b0de..7a23f7625c2e 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TokenE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/TokenE2ETest.java @@ -26,12 +26,12 @@ import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; import org.apache.dolphinscheduler.e2e.pages.security.TokenPage; -import org.testcontainers.shaded.org.awaitility.Awaitility; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") public class TokenE2ETest { @@ -43,10 +43,9 @@ public class TokenE2ETest { @BeforeAll public static void setup() { new LoginPage(browser) - .login("admin", "dolphinscheduler123") - .goToNav(SecurityPage.class) - .goToTab(TokenPage.class) - ; + .login("admin", "dolphinscheduler123") + .goToNav(SecurityPage.class) + .goToTab(TokenPage.class); } @Test @@ -59,9 +58,9 @@ void testCreateToken() { browser.navigate().refresh(); assertThat(page.tokenList()) - .as("Token list should contain newly-created token") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(userName)); + .as("Token list should contain newly-created token") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(userName)); }); } @@ -76,9 +75,9 @@ void testEditToken() { browser.navigate().refresh(); assertThat(page.tokenList()) - .as("Token list should contain newly-modified token") - .extracting(WebElement::getText) - .isNotEqualTo(oldToken); + .as("Token list should contain newly-modified token") + .extracting(WebElement::getText) + .isNotEqualTo(oldToken); }); } @@ -92,7 +91,7 @@ void testDeleteToken() { browser.navigate().refresh(); assertThat(page.tokenList()) - .noneMatch(it -> it.getText().contains(userName)); + .noneMatch(it -> it.getText().contains(userName)); }); } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/UserE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/UserE2ETest.java index 150e84b61829..59afb550ae73 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/UserE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/UserE2ETest.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.e2e.cases; - import static org.assertj.core.api.Assertions.assertThat; import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; @@ -30,9 +29,6 @@ import org.apache.dolphinscheduler.e2e.pages.security.TenantPage; import org.apache.dolphinscheduler.e2e.pages.security.UserPage; -import java.time.Duration; - -import org.testcontainers.shaded.org.awaitility.Awaitility; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; @@ -41,10 +37,11 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") class UserE2ETest { + private static final String tenant = System.getProperty("user.name"); private static final String user = "test_user"; private static final String password = "testUser123"; @@ -78,9 +75,9 @@ public static void setup() { @AfterAll public static void cleanup() { new NavBarPage(browser) - .goToNav(SecurityPage.class) - .goToTab(TenantPage.class) - .delete(tenant); + .goToNav(SecurityPage.class) + .goToTab(TenantPage.class) + .delete(tenant); } @Test @@ -94,9 +91,9 @@ void testCreateUser() { browser.navigate().refresh(); assertThat(page.userList()) - .as("User list should contain newly-created user") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(user)); + .as("User list should contain newly-created user") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(user)); }); } @@ -107,10 +104,8 @@ void testCreateDuplicateUser() { page.create(user, password, email, phone, tenant); - Awaitility.await().untilAsserted(() -> - assertThat(browser.findElement(By.tagName("body")).getText()) - .contains("already exists") - ); + Awaitility.await().untilAsserted(() -> assertThat(browser.findElement(By.tagName("body")).getText()) + .contains("already exists")); page.createUserForm().buttonCancel().click(); } @@ -130,12 +125,12 @@ void testEditUser() { Awaitility.await().untilAsserted(() -> { browser.navigate().refresh(); assertThat(page.userList()) - .as("User list should contain newly-modified User") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(editUser)); + .as("User list should contain newly-modified User") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(editUser)); }); } - + @Test @Order(40) void testDeleteUser() { @@ -147,10 +142,8 @@ void testDeleteUser() { browser.navigate().refresh(); assertThat( - page.userList() - ).noneMatch( - it -> it.getText().contains(user) || it.getText().contains(editUser) - ); + page.userList()).noneMatch( + it -> it.getText().contains(user) || it.getText().contains(editUser)); }); } } 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 be8caf09136b..5b6aae81050d 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 @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.e2e.cases; - import static org.assertj.core.api.Assertions.assertThat; import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; @@ -28,9 +27,6 @@ import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; import org.apache.dolphinscheduler.e2e.pages.security.WorkerGroupPage; -import java.time.Duration; - -import org.testcontainers.shaded.org.awaitility.Awaitility; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -38,10 +34,11 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") class WorkerGroupE2ETest { + private static final String workerGroupName = "test_worker_group"; private static final String editWorkerGroupName = "edit_worker_group"; @@ -50,9 +47,9 @@ class WorkerGroupE2ETest { @BeforeAll public static void setup() { new LoginPage(browser) - .login("admin", "dolphinscheduler123") - .goToNav(SecurityPage.class) - .goToTab(WorkerGroupPage.class); + .login("admin", "dolphinscheduler123") + .goToNav(SecurityPage.class) + .goToTab(WorkerGroupPage.class); } @Test @@ -61,7 +58,7 @@ void testCreateWorkerGroup() { final WorkerGroupPage page = new WorkerGroupPage(browser); WebDriverWaitFactory.createWebDriverWait(page.driver()) - .until(ExpectedConditions.urlContains("/security/worker-group-manage")); + .until(ExpectedConditions.urlContains("/security/worker-group-manage")); page.create(workerGroupName); @@ -69,9 +66,9 @@ void testCreateWorkerGroup() { browser.navigate().refresh(); assertThat(page.workerGroupList()) - .as("workerGroup list should contain newly-created workerGroup") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(workerGroupName)); + .as("workerGroup list should contain newly-created workerGroup") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(workerGroupName)); }); } @@ -82,10 +79,8 @@ void testCreateDuplicateWorkerGroup() { page.create(workerGroupName); - Awaitility.await().untilAsserted(() -> - assertThat(browser.findElement(By.tagName("body")).getText()) - .contains("already exists") - ); + Awaitility.await().untilAsserted(() -> assertThat(browser.findElement(By.tagName("body")).getText()) + .contains("already exists")); page.createWorkerForm().buttonCancel().click(); } @@ -99,13 +94,12 @@ void testEditWorkerGroup() { Awaitility.await().untilAsserted(() -> { browser.navigate().refresh(); assertThat(page.workerGroupList()) - .as("workerGroup list should contain newly-modified workerGroup") - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(editWorkerGroupName)); + .as("workerGroup list should contain newly-modified workerGroup") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(editWorkerGroupName)); }); } - @Test @Order(40) void testDeleteWorkerGroup() { @@ -117,10 +111,8 @@ void testDeleteWorkerGroup() { browser.navigate().refresh(); assertThat( - page.workerGroupList() - ).noneMatch( - it -> it.getText().contains(workerGroupName) || it.getText().contains(editWorkerGroupName) - ); + page.workerGroupList()).noneMatch( + it -> it.getText().contains(workerGroupName) || it.getText().contains(editWorkerGroupName)); }); } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowE2ETest.java index bbfcacbcebaa..11543d709ce6 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowE2ETest.java @@ -19,6 +19,8 @@ package org.apache.dolphinscheduler.e2e.cases; +import static org.assertj.core.api.Assertions.assertThat; + import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; import org.apache.dolphinscheduler.e2e.pages.LoginPage; @@ -35,7 +37,6 @@ import org.apache.dolphinscheduler.e2e.pages.security.TenantPage; import org.apache.dolphinscheduler.e2e.pages.security.UserPage; -import org.testcontainers.shaded.org.awaitility.Awaitility; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; @@ -43,14 +44,11 @@ import org.openqa.selenium.By; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.time.Duration; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") class WorkflowE2ETest { + private static final String project = "test-workflow-1"; private static final String workflow = "test-workflow-1"; @@ -82,58 +80,55 @@ public static void setup() { userPage.update(user, user, email, phone, tenant) .goToNav(ProjectPage.class) - .create(project) - ; + .create(project); } @AfterAll public static void cleanup() { new NavBarPage(browser) - .goToNav(ProjectPage.class) - .goTo(project) - .goToTab(WorkflowDefinitionTab.class) - .delete(workflow); + .goToNav(ProjectPage.class) + .goTo(project) + .goToTab(WorkflowDefinitionTab.class) + .delete(workflow); new NavBarPage(browser) - .goToNav(ProjectPage.class) - .delete(project); + .goToNav(ProjectPage.class) + .delete(project); browser.navigate().refresh(); new NavBarPage(browser) - .goToNav(SecurityPage.class) - .goToTab(TenantPage.class) - .delete(tenant); + .goToNav(SecurityPage.class) + .goToTab(TenantPage.class) + .delete(tenant); } @Test @Order(1) void testCreateWorkflow() { WorkflowDefinitionTab workflowDefinitionPage = - new ProjectPage(browser) - .goTo(project) - .goToTab(WorkflowDefinitionTab.class); + new ProjectPage(browser) + .goTo(project) + .goToTab(WorkflowDefinitionTab.class); workflowDefinitionPage - .createWorkflow() + .createWorkflow() - . addTask(TaskType.SHELL) - .script("echo ${today}\necho ${global_param}\n") - .name("test-1") - .addParam("today", "${system.datetime}") - .submit() + .addTask(TaskType.SHELL) + .script("echo ${today}\necho ${global_param}\n") + .name("test-1") + .addParam("today", "${system.datetime}") + .submit() - .submit() - .name(workflow) - .addGlobalParam("global_param", "hello world") - .submit() - ; + .submit() + .name(workflow) + .addGlobalParam("global_param", "hello world") + .submit(); Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList()) .as("Workflow list should contain newly-created workflow") .anyMatch( - it -> it.getText().contains(workflow) - )); + it -> it.getText().contains(workflow))); workflowDefinitionPage.publish(workflow); } @@ -142,28 +137,26 @@ void testCreateWorkflow() { void testCreateSubWorkflow() { final String workflow = "test-sub-workflow-1"; WorkflowDefinitionTab workflowDefinitionPage = - new ProjectPage(browser) - .goToNav(ProjectPage.class) - .goTo(project) - .goToTab(WorkflowDefinitionTab.class); + new ProjectPage(browser) + .goToNav(ProjectPage.class) + .goTo(project) + .goToTab(WorkflowDefinitionTab.class); workflowDefinitionPage - .createSubProcessWorkflow() + .createSubProcessWorkflow() - . addTask(TaskType.SUB_PROCESS) - .childNode("test-workflow-1") - .name("test-sub-1") - .submit() + .addTask(TaskType.SUB_PROCESS) + .childNode("test-workflow-1") + .name("test-sub-1") + .submit() - .submit() - .name(workflow) - .addGlobalParam("global_param", "hello world") - .submit() - ; + .submit() + .name(workflow) + .addGlobalParam("global_param", "hello world") + .submit(); Awaitility.await().untilAsserted(() -> assertThat( - workflowDefinitionPage.workflowList() - ).anyMatch(it -> it.getText().contains(workflow))); + workflowDefinitionPage.workflowList()).anyMatch(it -> it.getText().contains(workflow))); workflowDefinitionPage.publish(workflow); } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowHttpTaskE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowHttpTaskE2ETest.java index 3f78fd25f79e..e29c0f1f87b7 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowHttpTaskE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowHttpTaskE2ETest.java @@ -19,6 +19,8 @@ package org.apache.dolphinscheduler.e2e.cases; +import static org.assertj.core.api.Assertions.assertThat; + import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; import org.apache.dolphinscheduler.e2e.pages.LoginPage; @@ -32,6 +34,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; @@ -39,16 +42,10 @@ import org.openqa.selenium.By; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; import org.testcontainers.shaded.org.awaitility.Awaitility; - -import java.time.Duration; - -import static org.assertj.core.api.Assertions.assertThat; @DolphinScheduler(composeFiles = "docker/workflow-http/docker-compose.yaml") public class WorkflowHttpTaskE2ETest { - private static final String project = "test-workflow-1"; private static final String workflow = "test-workflow-1"; @@ -82,8 +79,7 @@ public static void setup() { userPage.update(user, user, email, phone, tenant) .goToNav(ProjectPage.class) - .create(project) - ; + .create(project); } @AfterAll @@ -116,7 +112,7 @@ void testCreateWorkflow() { workflowDefinitionPage .createWorkflow() - . addTask(WorkflowForm.TaskType.HTTP) + .addTask(WorkflowForm.TaskType.HTTP) .url(mockServerUrl) .name("test-1") .addParam("today", "${system.datetime}") @@ -125,18 +121,15 @@ void testCreateWorkflow() { .submit() .name(workflow) .addGlobalParam("global_param", "hello world") - .submit() - ; + .submit(); Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList()) .as("Workflow list should contain newly-created workflow") .anyMatch( - it -> it.getText().contains(workflow) - )); + it -> it.getText().contains(workflow))); workflowDefinitionPage.publish(workflow); } - @Test @Order(30) void testRunWorkflow() { diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java index 700ec03f43ce..332bb4ff6fb6 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java @@ -19,6 +19,8 @@ package org.apache.dolphinscheduler.e2e.cases; +import static org.assertj.core.api.Assertions.assertThat; + import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; import org.apache.dolphinscheduler.e2e.pages.LoginPage; @@ -33,23 +35,19 @@ 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; import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; import org.testcontainers.shaded.org.awaitility.Awaitility; -import java.time.Duration; - -import static org.assertj.core.api.Assertions.assertThat; - @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") public class WorkflowJavaTaskE2ETest { + private static final String project = "test-workflow-1"; private static final String workflow = "test-workflow-1"; @@ -98,8 +96,7 @@ public static void setup() { userPage.update(user, user, email, phone, tenant) .goToNav(ProjectPage.class) - .create(project) - ; + .create(project); } @AfterAll @@ -122,8 +119,6 @@ public static void cleanup() { .delete(tenant); } - - @Test @Order(1) void testCreateWorkflow() { @@ -134,7 +129,7 @@ void testCreateWorkflow() { workflowDefinitionPage .createWorkflow() - . addTask(WorkflowForm.TaskType.JAVA) + .addTask(WorkflowForm.TaskType.JAVA) .script(javaContent) .name("test-1") .addParam("today", "${system.datetime}") @@ -143,18 +138,15 @@ void testCreateWorkflow() { .submit() .name(workflow) .addGlobalParam("global_param", "hello world") - .submit() - ; + .submit(); Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList()) .as("Workflow list should contain newly-created workflow") .anyMatch( - it -> it.getText().contains(workflow) - )); + it -> it.getText().contains(workflow))); workflowDefinitionPage.publish(workflow); } - @Test @Order(30) void testRunWorkflow() { diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowSwitchE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowSwitchE2ETest.java index cee9b52b47db..685d5fdc523b 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowSwitchE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowSwitchE2ETest.java @@ -19,6 +19,8 @@ package org.apache.dolphinscheduler.e2e.cases; +import static org.assertj.core.api.Assertions.assertThat; + import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; import org.apache.dolphinscheduler.e2e.pages.LoginPage; import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; @@ -35,19 +37,18 @@ import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; import org.apache.dolphinscheduler.e2e.pages.security.TenantPage; -import org.testcontainers.shaded.org.awaitility.Awaitility; +import java.util.List; + import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.openqa.selenium.remote.RemoteWebDriver; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; +import org.testcontainers.shaded.org.awaitility.Awaitility; @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") class WorkflowSwitchE2ETest { + private static final String project = "test-workflow-1"; private static final String workflow = "test-workflow-1"; private static final String ifBranchName = "key==1"; @@ -60,31 +61,28 @@ class WorkflowSwitchE2ETest { @BeforeAll public static void setup() { new LoginPage(browser) - .login("admin", "dolphinscheduler123") - .goToNav(SecurityPage.class) - .goToTab(TenantPage.class) - .create(tenant) - .goToNav(ProjectPage.class) - .create(project) - ; + .login("admin", "dolphinscheduler123") + .goToNav(SecurityPage.class) + .goToTab(TenantPage.class) + .create(tenant) + .goToNav(ProjectPage.class) + .create(project); } @AfterAll public static void cleanup() { new NavBarPage(browser) - .goToNav(ProjectPage.class) - .goTo(project) - .goToTab(WorkflowDefinitionTab.class) - .cancelPublishAll() - .deleteAll() - ; + .goToNav(ProjectPage.class) + .goTo(project) + .goToTab(WorkflowDefinitionTab.class) + .cancelPublishAll() + .deleteAll(); new NavBarPage(browser) - .goToNav(ProjectPage.class) - .delete(project) - .goToNav(SecurityPage.class) - .goToTab(TenantPage.class) - .delete(tenant) - ; + .goToNav(ProjectPage.class) + .delete(project) + .goToNav(SecurityPage.class) + .goToTab(TenantPage.class) + .delete(tenant); } @Test @@ -92,33 +90,33 @@ public static void cleanup() { void testCreateSwitchWorkflow() { final WorkflowDefinitionTab workflowDefinitionPage = - new ProjectPage(browser) - .goTo(project) - .goToTab(WorkflowDefinitionTab.class); + new ProjectPage(browser) + .goTo(project) + .goToTab(WorkflowDefinitionTab.class); WorkflowForm workflowForm = workflowDefinitionPage.createWorkflow(); - workflowForm. addTask(TaskType.SHELL) - .script("echo ${today}\necho ${global_param}\n") - .name("pre-task") - .submit(); + workflowForm.addTask(TaskType.SHELL) + .script("echo ${today}\necho ${global_param}\n") + .name("pre-task") + .submit(); SwitchTaskForm switchTaskForm = workflowForm.addTask(TaskType.SWITCH); switchTaskForm.preTask("pre-task") - .name("switch") - .submit(); + .name("switch") + .submit(); workflowForm.addTask(TaskType.SHELL) - .script("echo ${key}") - .preTask("switch") - .name(ifBranchName) - .submit(); + .script("echo ${key}") + .preTask("switch") + .name(ifBranchName) + .submit(); workflowForm.addTask(TaskType.SHELL) - .script("echo ${key}") - .preTask("switch") - .name(elseBranchName) - .submit(); + .script("echo ${key}") + .preTask("switch") + .name(elseBranchName) + .submit(); // format dag workflowForm.formatDAG().confirm(); @@ -130,13 +128,12 @@ workflowForm. addTask(TaskType.SHELL) switchTaskForm.submit(); workflowForm.submit() - .name(workflow) - .addGlobalParam("key", "1") - .submit(); + .name(workflow) + .addGlobalParam("key", "1") + .submit(); Awaitility.await().untilAsserted(() -> assertThat( - workflowDefinitionPage.workflowList() - ).anyMatch(it -> it.getText().contains(workflow))); + workflowDefinitionPage.workflowList()).anyMatch(it -> it.getText().contains(workflow))); workflowDefinitionPage.publish(workflow); } @@ -178,8 +175,10 @@ void testRunWorkflow() { Awaitility.await().untilAsserted(() -> { assertThat(taskInstances.size()).isEqualTo(3); - assertThat(taskInstances.stream().filter(row -> row.taskInstanceName().contains(ifBranchName)).count()).isEqualTo(1); - assertThat(taskInstances.stream().noneMatch(row -> row.taskInstanceName().contains(elseBranchName))).isTrue(); + assertThat(taskInstances.stream().filter(row -> row.taskInstanceName().contains(ifBranchName)).count()) + .isEqualTo(1); + assertThat(taskInstances.stream().noneMatch(row -> row.taskInstanceName().contains(elseBranchName))) + .isTrue(); }); } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/tasks/PythonTaskE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/tasks/PythonTaskE2ETest.java new file mode 100644 index 000000000000..239da7dfeb0e --- /dev/null +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/tasks/PythonTaskE2ETest.java @@ -0,0 +1,338 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.e2e.cases.tasks; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.dolphinscheduler.e2e.cases.workflow.BaseWorkflowE2ETest; +import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; +import org.apache.dolphinscheduler.e2e.core.WebDriverHolder; +import org.apache.dolphinscheduler.e2e.models.environment.PythonEnvironment; +import org.apache.dolphinscheduler.e2e.pages.LoginPage; +import org.apache.dolphinscheduler.e2e.pages.project.ProjectPage; +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.WorkflowForm; +import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowInstanceTab; +import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.PythonTaskForm; +import org.apache.dolphinscheduler.e2e.pages.resource.FileManagePage; +import org.apache.dolphinscheduler.e2e.pages.resource.ResourcePage; +import org.apache.dolphinscheduler.e2e.pages.security.EnvironmentPage; +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.util.Date; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +@DolphinScheduler(composeFiles = "docker/python-task/docker-compose.yaml") +public class PythonTaskE2ETest extends BaseWorkflowE2ETest { + + private static final PythonEnvironment pythonEnvironment = new PythonEnvironment(); + + @BeforeAll + public static void setup() { + browser = WebDriverHolder.getWebDriver(); + + TenantPage tenantPage = new LoginPage(browser) + .login(adminUser) + .goToNav(SecurityPage.class) + .goToTab(TenantPage.class); + + if (tenantPage.tenants().stream().noneMatch(tenant -> tenant.tenantCode().equals(adminUser.getTenant()))) { + tenantPage + .create(adminUser.getTenant()) + .goToNav(SecurityPage.class) + .goToTab(UserPage.class) + .update(adminUser); + } + tenantPage + .goToNav(SecurityPage.class) + .goToTab(EnvironmentPage.class) + .createEnvironmentUntilSuccess(pythonEnvironment.getEnvironmentName(), + pythonEnvironment.getEnvironmentConfig(), + pythonEnvironment.getEnvironmentDesc(), + pythonEnvironment.getEnvironmentWorkerGroup()); + + tenantPage + .goToNav(ProjectPage.class) + .createProjectUntilSuccess(projectName); + } + + @Test + @Order(10) + void testRunPythonTasks_SuccessCase() { + WorkflowDefinitionTab workflowDefinitionPage = + new ProjectPage(browser) + .goToNav(ProjectPage.class) + .goTo(projectName) + .goToTab(WorkflowDefinitionTab.class); + + // todo: use yaml to define the workflow + String workflowName = "PythonSuccessCase"; + String taskName = "PythonSuccessTask"; + String pythonScripts = "print(\"success\")"; + workflowDefinitionPage + .createWorkflow() + .addTask(WorkflowForm.TaskType.PYTHON) + .script(pythonScripts) + .name(taskName) + .submit() + + .submit() + .name(workflowName) + .submit(); + + untilWorkflowDefinitionExist(workflowName); + + workflowDefinitionPage.publish(workflowName); + + runWorkflow(workflowName); + untilWorkflowInstanceExist(workflowName); + WorkflowInstanceTab.Row workflowInstance = untilWorkflowInstanceSuccess(workflowName); + assertThat(workflowInstance.executionTime()).isEqualTo(1); + + TaskInstanceTab.Row taskInstance = untilTaskInstanceSuccess(workflowName, taskName); + assertThat(taskInstance.retryTimes()).isEqualTo(0); + } + + @Test + @Order(20) + void testRunPythonTasks_WorkflowParamsCase() { + WorkflowDefinitionTab workflowDefinitionPage = + new ProjectPage(browser) + .goToNav(ProjectPage.class) + .goTo(projectName) + .goToTab(WorkflowDefinitionTab.class); + + // todo: use yaml to define the workflow + String workflowName = "PythonWorkflowParamsCase"; + String taskName = "PythonWorkflowParamsTask"; + String pythonScripts = "import sys\n" + + "\n" + + "if '${name}' == 'tom':\n" + + " print('success')\n" + + "else:\n" + + " sys.exit(2)"; + workflowDefinitionPage + .createWorkflow() + .addTask(WorkflowForm.TaskType.PYTHON) + .script(pythonScripts) + .name(taskName) + .submit() + + .submit() + .name(workflowName) + .addGlobalParam("name", "tom") + .submit(); + + untilWorkflowDefinitionExist(workflowName); + + workflowDefinitionPage.publish(workflowName); + + runWorkflow(workflowName); + untilWorkflowInstanceExist(workflowName); + WorkflowInstanceTab.Row workflowInstance = untilWorkflowInstanceSuccess(workflowName); + assertThat(workflowInstance.executionTime()).isEqualTo(1); + + TaskInstanceTab.Row taskInstance = untilTaskInstanceSuccess(workflowName, taskName); + assertThat(taskInstance.retryTimes()).isEqualTo(0); + } + + @Test + @Order(30) + void testRunPythonTasks_LocalParamsCase() { + WorkflowDefinitionTab workflowDefinitionPage = + new ProjectPage(browser) + .goToNav(ProjectPage.class) + .goTo(projectName) + .goToTab(WorkflowDefinitionTab.class); + + String workflowName = "PythonLocalParamsCase"; + String taskName = "PythonLocalParamsSuccess"; + String pythonScripts = "import sys\n" + + "\n" + + "if '${name}' == 'tom':\n" + + " print('success')\n" + + "else:\n" + + " sys.exit(2)"; + workflowDefinitionPage + .createWorkflow() + .addTask(WorkflowForm.TaskType.PYTHON) + .script(pythonScripts) + .name(taskName) + .addParam("name", "tom") + .submit() + + .submit() + .name(workflowName) + .submit(); + + untilWorkflowDefinitionExist(workflowName); + + workflowDefinitionPage.publish(workflowName); + + runWorkflow(workflowName); + untilWorkflowInstanceExist(workflowName); + WorkflowInstanceTab.Row workflowInstance = untilWorkflowInstanceSuccess(workflowName); + assertThat(workflowInstance.executionTime()).isEqualTo(1); + + TaskInstanceTab.Row taskInstance = untilTaskInstanceSuccess(workflowName, taskName); + assertThat(taskInstance.retryTimes()).isEqualTo(0); + } + + @Test + @Order(40) + void testRunPythonTasks_GlobalParamsOverrideLocalParamsCase() { + WorkflowDefinitionTab workflowDefinitionPage = + new ProjectPage(browser) + .goToNav(ProjectPage.class) + .goTo(projectName) + .goToTab(WorkflowDefinitionTab.class); + + String workflowName = "PythonLocalParamsOverrideWorkflowParamsCase"; + String taskName = "PythonLocalParamsOverrideWorkflowParamsSuccess"; + String pythonScripts = "import sys\n" + + "\n" + + "if '${name}' == 'jerry':\n" + + " print('success')\n" + + "else:\n" + + " sys.exit(2)"; + workflowDefinitionPage + .createWorkflow() + .addTask(WorkflowForm.TaskType.PYTHON) + .script(pythonScripts) + .name(taskName) + .addParam("name", "tom") + .submit() + + .submit() + .name(workflowName) + .addGlobalParam("name", "jerry") + .submit(); + + untilWorkflowDefinitionExist(workflowName); + + workflowDefinitionPage.publish(workflowName); + + runWorkflow(workflowName); + untilWorkflowInstanceExist(workflowName); + WorkflowInstanceTab.Row workflowInstance = untilWorkflowInstanceSuccess(workflowName); + assertThat(workflowInstance.executionTime()).isEqualTo(1); + + TaskInstanceTab.Row taskInstance = untilTaskInstanceSuccess(workflowName, taskName); + assertThat(taskInstance.retryTimes()).isEqualTo(0); + } + + @Test + @Order(50) + void testRunPythonTasks_UsingResourceFile() { + long current_timestamp = new Date().getTime(); + String testFileName = String.format("echo_%s", current_timestamp); + new ResourcePage(browser) + .goToNav(ResourcePage.class) + .goToTab(FileManagePage.class) + .createFileUntilSuccess(testFileName, "echo 123"); + + final WorkflowDefinitionTab workflowDefinitionPage = + new ProjectPage(browser) + .goToNav(ProjectPage.class) + .goTo(projectName) + .goToTab(WorkflowDefinitionTab.class); + + String workflowName = "PythonUsingResourceFileWorkflowCase"; + String taskName = "PythonUsingResourceFileSuccessTask"; + String pythonScripts = "import sys\n" + + "\n" + + "file_content = \"\"\n" + + "\n" + + "with open('${file_name}', 'r', encoding='UTF8') as f:\n" + + " file_content = f.read()\n" + + "\n" + + "if len(file_content) != 0:\n" + + " print(f'file_content: {file_content}')\n" + + "else:\n" + + " sys.exit(2)\n" + + " "; + workflowDefinitionPage + .createWorkflow() + .addTask(WorkflowForm.TaskType.PYTHON) + .script(pythonScripts) + .name(taskName) + .selectResource(testFileName) + .addParam("file_name", String.format("%s.sh", testFileName)) + .submit() + + .submit() + .name(workflowName) + .submit(); + + untilWorkflowDefinitionExist(workflowName); + + workflowDefinitionPage.publish(workflowName); + + runWorkflow(workflowName); + untilWorkflowInstanceExist(workflowName); + WorkflowInstanceTab.Row workflowInstance = untilWorkflowInstanceSuccess(workflowName); + assertThat(workflowInstance.executionTime()).isEqualTo(1); + + TaskInstanceTab.Row taskInstance = untilTaskInstanceSuccess(workflowName, taskName); + assertThat(taskInstance.retryTimes()).isEqualTo(0); + } + + @Test + @Order(60) + void testRunPythonTasks_FailedCase() { + WorkflowDefinitionTab workflowDefinitionPage = + new ProjectPage(browser) + .goToNav(ProjectPage.class) + .goTo(projectName) + .goToTab(WorkflowDefinitionTab.class); + + String workflowName = "PythonFailedWorkflowCase"; + String taskName = "PythonFailedTask"; + String pythonScripts = "import sys\n" + + "sys.exit(1)"; + workflowDefinitionPage + .createWorkflow() + .addTask(WorkflowForm.TaskType.PYTHON) + .script(pythonScripts) + .name(taskName) + .submit() + + .submit() + .name(workflowName) + .submit(); + + untilWorkflowDefinitionExist(workflowName); + + workflowDefinitionPage.publish(workflowName); + + runWorkflow(workflowName); + untilWorkflowInstanceExist(workflowName); + WorkflowInstanceTab.Row workflowInstance = untilWorkflowInstanceFailed(workflowName); + assertThat(workflowInstance.executionTime()).isEqualTo(1); + + TaskInstanceTab.Row taskInstance = untilTaskInstanceFailed(workflowName, taskName); + assertThat(taskInstance.retryTimes()).isEqualTo(0); + } + +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/tasks/ShellTaskE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/tasks/ShellTaskE2ETest.java index fb44bc843ad9..12f8a4b14ef4 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/tasks/ShellTaskE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/tasks/ShellTaskE2ETest.java @@ -17,8 +17,12 @@ package org.apache.dolphinscheduler.e2e.cases.tasks; +import static org.assertj.core.api.Assertions.assertThat; + import org.apache.dolphinscheduler.e2e.cases.workflow.BaseWorkflowE2ETest; import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; +import org.apache.dolphinscheduler.e2e.core.WebDriverHolder; +import org.apache.dolphinscheduler.e2e.pages.LoginPage; import org.apache.dolphinscheduler.e2e.pages.project.ProjectPage; import org.apache.dolphinscheduler.e2e.pages.project.workflow.TaskInstanceTab; import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowDefinitionTab; @@ -27,19 +31,41 @@ import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.ShellTaskForm; import org.apache.dolphinscheduler.e2e.pages.resource.FileManagePage; import org.apache.dolphinscheduler.e2e.pages.resource.ResourcePage; -import org.junit.FixMethodOrder; -import org.junit.jupiter.api.Order; +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.BeforeAll; +import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; -import org.junit.runners.MethodSorters; -import org.openqa.selenium.WebElement; -import org.testcontainers.shaded.org.awaitility.Awaitility; -import static org.assertj.core.api.Assertions.assertThat; -import static org.testcontainers.shaded.org.awaitility.Awaitility.await; +import org.junit.jupiter.api.TestMethodOrder; -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@TestMethodOrder(MethodOrderer.MethodName.class) @DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") public class ShellTaskE2ETest extends BaseWorkflowE2ETest { + @BeforeAll + public static void setup() { + browser = WebDriverHolder.getWebDriver(); + + TenantPage tenantPage = new LoginPage(browser) + .login(adminUser) + .goToNav(SecurityPage.class) + .goToTab(TenantPage.class); + + if (tenantPage.tenants().stream().noneMatch(tenant -> tenant.tenantCode().equals(adminUser.getTenant()))) { + tenantPage + .create(adminUser.getTenant()) + .goToNav(SecurityPage.class) + .goToTab(UserPage.class) + .update(adminUser); + } + + tenantPage + .goToNav(ProjectPage.class) + .createProjectUntilSuccess(projectName); + } + @Test void testRunShellTasks_SuccessCase() { WorkflowDefinitionTab workflowDefinitionPage = diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/workflow/BaseWorkflowE2ETest.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/workflow/BaseWorkflowE2ETest.java index c2ee2ee44716..550f83d7191c 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/workflow/BaseWorkflowE2ETest.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/workflow/BaseWorkflowE2ETest.java @@ -17,32 +17,24 @@ package org.apache.dolphinscheduler.e2e.cases.workflow; -import java.time.Duration; -import java.util.List; -import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.stream.Collectors; -import lombok.extern.slf4j.Slf4j; -import org.apache.dolphinscheduler.e2e.core.WebDriverHolder; -import org.apache.dolphinscheduler.e2e.models.tenant.DefaultTenant; +import static org.assertj.core.api.Assertions.assertThat; +import static org.testcontainers.shaded.org.awaitility.Awaitility.await; + import org.apache.dolphinscheduler.e2e.models.users.AdminUser; -import org.apache.dolphinscheduler.e2e.models.users.IUser; -import org.apache.dolphinscheduler.e2e.pages.LoginPage; -import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; import org.apache.dolphinscheduler.e2e.pages.project.ProjectDetailPage; import org.apache.dolphinscheduler.e2e.pages.project.ProjectPage; 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.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 java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; + +import lombok.extern.slf4j.Slf4j; + import org.openqa.selenium.remote.RemoteWebDriver; -import static org.assertj.core.api.Assertions.assertThat; -import static org.testcontainers.shaded.org.awaitility.Awaitility.await; @Slf4j public abstract class BaseWorkflowE2ETest { @@ -53,27 +45,6 @@ public abstract class BaseWorkflowE2ETest { protected static RemoteWebDriver browser; - @BeforeAll - public static void setup() { - browser = WebDriverHolder.getWebDriver(); - - TenantPage tenantPage = new LoginPage(browser) - .login(adminUser) - .goToNav(SecurityPage.class) - .goToTab(TenantPage.class); - - if (tenantPage.tenants().stream().noneMatch(tenant -> tenant.tenantCode().equals(adminUser.getTenant()))) { - tenantPage - .create(adminUser.getTenant()) - .goToNav(SecurityPage.class) - .goToTab(UserPage.class) - .update(adminUser); - } - tenantPage - .goToNav(ProjectPage.class) - .createProjectUntilSuccess(projectName); - } - protected void untilWorkflowDefinitionExist(String workflowName) { WorkflowDefinitionTab workflowDefinitionPage = new ProjectPage(browser) .goToNav(ProjectPage.class) @@ -83,8 +54,7 @@ protected void untilWorkflowDefinitionExist(String workflowName) { await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList()) .as("Workflow list should contain newly-created workflow: %s", workflowName) .anyMatch( - it -> it.getText().contains(workflowName) - )); + it -> it.getText().contains(workflowName))); } protected void runWorkflow(String workflowName) { @@ -155,7 +125,8 @@ protected WorkflowInstanceTab.Row untilWorkflowInstanceFailed(String workflowNam if (workflowInstances.size() > 1) { throw new RuntimeException("More than one failed workflow instance found: " + workflowInstances.stream() - .map(WorkflowInstanceTab.Row::workflowInstanceName).collect(Collectors.joining(", "))); + .map(WorkflowInstanceTab.Row::workflowInstanceName) + .collect(Collectors.joining(", "))); } return workflowInstances.get(0); }, Objects::nonNull); diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/environment/IEnvironment.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/environment/IEnvironment.java new file mode 100644 index 000000000000..7469dfa271e0 --- /dev/null +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/environment/IEnvironment.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.e2e.models.environment; + +public interface IEnvironment { + + String getEnvironmentName(); + + String getEnvironmentConfig(); + + String getEnvironmentDesc(); + + String getEnvironmentWorkerGroup(); + +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/environment/PythonEnvironment.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/environment/PythonEnvironment.java new file mode 100644 index 000000000000..63bf7e3cbba3 --- /dev/null +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/environment/PythonEnvironment.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.e2e.models.environment; + +import lombok.Data; + +@Data +public class PythonEnvironment implements IEnvironment { + + private String environmentName; + + private String environmentConfig; + + private String environmentDesc; + + private String environmentWorkerGroup; + + @Override + public String getEnvironmentName() { + return "python-e2e"; + } + + @Override + public String getEnvironmentConfig() { + return "export PYTHON_LAUNCHER=/usr/bin/python3"; + } + + @Override + public String getEnvironmentDesc() { + return "pythonEnvDesc"; + } + + @Override + public String getEnvironmentWorkerGroup() { + return "default"; + } +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/tenant/DefaultTenant.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/tenant/DefaultTenant.java index 598265fa96a4..afd046e4b4e6 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/tenant/DefaultTenant.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/tenant/DefaultTenant.java @@ -18,6 +18,7 @@ package org.apache.dolphinscheduler.e2e.models.tenant; public class DefaultTenant implements ITenant { + @Override public String getTenantCode() { return "default"; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/users/AdminUser.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/users/AdminUser.java index da23bc26bf33..50189759e15e 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/users/AdminUser.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/users/AdminUser.java @@ -17,10 +17,11 @@ package org.apache.dolphinscheduler.e2e.models.users; -import lombok.Data; import org.apache.dolphinscheduler.e2e.models.tenant.BootstrapTenant; import org.apache.dolphinscheduler.e2e.models.tenant.ITenant; +import lombok.Data; + @Data public class AdminUser implements IUser { diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/users/IUser.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/users/IUser.java index 740a4b431e95..1782478a62e4 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/users/IUser.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/models/users/IUser.java @@ -17,8 +17,6 @@ package org.apache.dolphinscheduler.e2e.models.users; -import org.apache.dolphinscheduler.e2e.models.tenant.ITenant; - public interface IUser { String getUserName(); @@ -31,5 +29,4 @@ public interface IUser { String getTenant(); - } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/LoginPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/LoginPage.java index a77149fac353..65f0706e1945 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/LoginPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/LoginPage.java @@ -22,31 +22,28 @@ import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; import org.apache.dolphinscheduler.e2e.models.users.IUser; import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; -import org.apache.dolphinscheduler.e2e.pages.security.TenantPage; + +import lombok.Getter; +import lombok.SneakyThrows; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import lombok.Getter; -import lombok.SneakyThrows; - -import java.time.Duration; @Getter public final class LoginPage extends NavBarPage { + @FindBys({ - @FindBy(className = "input-user-name"), - @FindBy(tagName = "input"), + @FindBy(className = "input-user-name"), + @FindBy(tagName = "input"), }) private WebElement inputUsername; - @FindBys( { - @FindBy(className = "input-password"), - @FindBy(tagName = "input"), + @FindBys({ + @FindBy(className = "input-password"), + @FindBy(tagName = "input"), }) private WebElement inputPassword; @@ -67,7 +64,8 @@ public NavBarPage login(IUser user) { @SneakyThrows public NavBarPage login(String username, String password) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(buttonSwitchLanguage)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(buttonSwitchLanguage)); buttonSwitchLanguage().click(); inputUsername().sendKeys(username); diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/CodeEditor.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/CodeEditor.java index 53ed30b362f7..19954bc8a19f 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/CodeEditor.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/CodeEditor.java @@ -19,28 +19,38 @@ */ package org.apache.dolphinscheduler.e2e.pages.common; +import org.apache.dolphinscheduler.e2e.core.Constants; import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; + +import java.util.List; + +import lombok.Getter; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; + +import org.junit.platform.commons.util.StringUtils; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; - -import lombok.Getter; - -import java.time.Duration; - import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; @Getter +@Slf4j public final class CodeEditor { + @FindBys({ - @FindBy(className = "monaco-editor"), - @FindBy(className = "view-line"), + @FindBy(className = "monaco-editor"), + @FindBy(className = "view-line"), }) - private WebElement editor; + private List editor; + + @FindBy(className = "pre-tasks-model") + private WebElement scrollBar; private WebDriver driver; @@ -49,14 +59,72 @@ public CodeEditor(WebDriver driver) { this.driver = driver; } + @SneakyThrows public CodeEditor content(String content) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(editor)); - - editor.click(); + WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(editor.get(0))); Actions actions = new Actions(this.driver); - actions.moveToElement(editor).sendKeys(content).perform(); + + List contentList = List.of(content.split(Constants.LINE_SEPARATOR)); + + try { + ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", scrollBar); + } catch (org.openqa.selenium.NoSuchElementException ignored) { + log.warn("scroll bar not found, skipping..."); + } + + for (int i = 0; i < contentList.size(); i++) { + String editorLineText; + String inputContent = contentList.get(i); + if (i == 0) { + actions.moveToElement(editor.get(i)) + .click() + .sendKeys(inputContent) + .sendKeys(Constants.LINE_SEPARATOR) + .perform(); + continue; + } else { + editorLineText = editor.get(i).getText(); + } + + if (StringUtils.isNotBlank(inputContent)) { + if (editorLineText.isEmpty()) { + actions.moveToElement(editor.get(i)) + .click() + .sendKeys(inputContent) + .sendKeys(Constants.LINE_SEPARATOR) + .perform(); + Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); + } else { + for (int p = 0; p < editorLineText.strip().length(); p++) { + clearLine(actions, editor.get(i)); + } + if (!editorLineText.isEmpty()) { + clearLine(actions, editor.get(i)); + } + actions.moveToElement(editor.get(i)) + .click() + .sendKeys(inputContent) + .sendKeys(Constants.LINE_SEPARATOR) + .perform(); + Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); + } + } else { + actions.moveToElement(editor.get(i)) + .click() + .sendKeys(Constants.LINE_SEPARATOR) + .perform(); + Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS); + } + } return this; } + + private void clearLine(Actions actions, WebElement element) { + actions.moveToElement(element) + .click() + .sendKeys(Keys.BACK_SPACE) + .perform(); + } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/HttpInput.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/HttpInput.java index 770de59009c1..2a200a4cdae8 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/HttpInput.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/HttpInput.java @@ -18,23 +18,22 @@ * */ - package org.apache.dolphinscheduler.e2e.pages.common; -import lombok.Getter; import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; + +import lombok.Getter; + import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.time.Duration; @Getter public class HttpInput { + @FindBys({ @FindBy(className = "input-url-name"), @FindBy(tagName = "input") @@ -43,8 +42,6 @@ public class HttpInput { private WebDriver driver; - - public HttpInput(WebDriver driver) { PageFactory.initElements(driver, this); this.driver = driver; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/NavBarPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/NavBarPage.java index 7b00a9bd2973..86ebb54d174b 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/NavBarPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/common/NavBarPage.java @@ -26,20 +26,18 @@ import org.apache.dolphinscheduler.e2e.pages.resource.ResourcePage; import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; +import lombok.Getter; + import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import lombok.Getter; - -import java.time.Duration; @Getter public class NavBarPage { + protected final RemoteWebDriver driver; @FindBy(xpath = "//div[contains(@class, 'tab-horizontal')]//div[contains(@role,'menubar')]//span[contains(text(), 'Project')]") @@ -72,21 +70,26 @@ public T goToNav(Class nav) { } if (nav == SecurityPage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(securityTab)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(securityTab)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", securityTab()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/tenant-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/security/tenant-manage")); return nav.cast(new SecurityPage(driver)); } if (nav == ResourcePage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(resourceTab)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(resourceTab)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", resourceTab()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/resource/file-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/resource/file-manage")); return nav.cast(new ResourcePage(driver)); } if (nav == DataSourcePage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(dataSourceTab)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(dataSourceTab)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", dataSourceTab()); WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/datasource")); return nav.cast(new DataSourcePage(driver)); diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/datasource/DataSourcePage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/datasource/DataSourcePage.java index 7f84ac29de7f..16613e25b367 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/datasource/DataSourcePage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/datasource/DataSourcePage.java @@ -1,204 +1,200 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.dolphinscheduler.e2e.pages.datasource; - -import lombok.Getter; - -import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; -import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; - -import java.security.Key; -import java.time.Duration; -import java.util.List; - -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.Keys; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.FindBy; -import org.openqa.selenium.support.FindBys; -import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.ui.ExpectedCondition; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - - -@Getter -public class DataSourcePage extends NavBarPage implements NavBarPage.NavBarItem { - - @FindBy(className = "btn-create-data-source") - private WebElement buttonCreateDataSource; - - @FindBy(className = "data-source-items") - private List dataSourceItemsList; - - @FindBys({ - @FindBy(className = "n-popconfirm__action"), - @FindBy(className = "n-button--primary-type"), - }) - private WebElement buttonConfirm; - - @FindBys({ - @FindBy(className = "dialog-source-modal"), - }) - private WebElement dataSourceModal; - - private final CreateDataSourceForm createDataSourceForm; - - public DataSourcePage(RemoteWebDriver driver) { - super(driver); - - createDataSourceForm = new CreateDataSourceForm(); - } - - public DataSourcePage createDataSource(String dataSourceType, String dataSourceName, String dataSourceDescription, String ip, String port, String userName, String password, String database, - String jdbcParams) { - buttonCreateDataSource().click(); - - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOfElementLocated( - new By.ByClassName("dialog-source-modal"))); - - dataSourceModal().findElement(By.className(dataSourceType.toUpperCase()+"-box")).click(); - - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.className("dialog-create-data-source")), dataSourceType.toUpperCase())); - - createDataSourceForm().inputDataSourceName().sendKeys(dataSourceName); - createDataSourceForm().inputDataSourceDescription().sendKeys(dataSourceDescription); - createDataSourceForm().inputIP().sendKeys(ip); - createDataSourceForm().inputPort().sendKeys(Keys.CONTROL + "a"); - createDataSourceForm().inputPort().sendKeys(Keys.BACK_SPACE); - createDataSourceForm().inputPort().sendKeys(port); - createDataSourceForm().inputUserName().sendKeys(userName); - createDataSourceForm().inputPassword().sendKeys(password); - createDataSourceForm().inputDataBase().sendKeys(database); - - if (!"".equals(jdbcParams)) { - createDataSourceForm().inputJdbcParams().sendKeys(jdbcParams); - } - - createDataSourceForm().buttonSubmit().click(); - - return this; - } - - public DataSourcePage delete(String name) { - dataSourceItemsList() - .stream() - .filter(it -> it.getText().contains(name)) - .flatMap(it -> it.findElements(By.className("btn-delete")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No delete button in data source list")) - .click(); - - ((JavascriptExecutor) driver).executeScript("arguments[0].click();", buttonConfirm()); - - return this; - } - - @Getter - public class CreateDataSourceForm { - CreateDataSourceForm() { - PageFactory.initElements(driver, this); - } - - @FindBy(className = "n-base-select-option__content") - private List selectDataSourceType; - - @FindBys({ - @FindBy(className = "btn-data-source-type-drop-down"), - @FindBy(className = "n-base-selection"), - }) - private WebElement btnDataSourceTypeDropdown; - - @FindBys({ - @FindBy(className = "input-data-source-name"), - @FindBy(tagName = "input"), - }) - private WebElement inputDataSourceName; - - @FindBys({ - @FindBy(className = "input-data-source-description"), - @FindBy(tagName = "textarea"), - }) - private WebElement inputDataSourceDescription; - - @FindBys({ - @FindBy(className = "input-ip"), - @FindBy(tagName = "input"), - }) - private WebElement inputIP; - - @FindBys({ - @FindBy(className = "input-port"), - @FindBy(tagName = "input"), - }) - private WebElement inputPort; - - @FindBys({ - @FindBy(className = "input-username"), - @FindBy(tagName = "input"), - }) - private WebElement inputUserName; - - @FindBys({ - @FindBy(className = "input-password"), - @FindBy(tagName = "input"), - }) - private WebElement inputPassword; - - @FindBys({ - @FindBy(className = "input-data-base"), - @FindBy(tagName = "input"), - }) - private WebElement inputDataBase; - - @FindBys({ - @FindBy(className = "input-jdbc-params"), - @FindBy(tagName = "textarea"), - }) - private WebElement inputJdbcParams; - - @FindBy(className = "btn-submit") - private WebElement buttonSubmit; - - @FindBy(className = "btn-cancel") - private WebElement buttonCancel; - - @FindBy(className = "btn-test-connection") - private WebElement btnTestConnection; - - @FindBys({ - @FindBy(className = "input-zeppelin_rest_endpoint"), - @FindBy(tagName = "input"), - }) - private WebElement inputZeppelinRestEndpoint; - - @FindBys({ - @FindBy(className = "input-kubeConfig"), - @FindBy(tagName = "textarea"), - }) - private WebElement inputKubeConfig; - - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.dolphinscheduler.e2e.pages.datasource; + +import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; +import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; + +import java.util.List; + +import lombok.Getter; + +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.FindBys; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; + +@Getter +public class DataSourcePage extends NavBarPage implements NavBarPage.NavBarItem { + + @FindBy(className = "btn-create-data-source") + private WebElement buttonCreateDataSource; + + @FindBy(className = "data-source-items") + private List dataSourceItemsList; + + @FindBys({ + @FindBy(className = "n-popconfirm__action"), + @FindBy(className = "n-button--primary-type"), + }) + private WebElement buttonConfirm; + + @FindBy(className = "dialog-source-modal") + private WebElement dataSourceModal; + + private final CreateDataSourceForm createDataSourceForm; + + public DataSourcePage(RemoteWebDriver driver) { + super(driver); + + createDataSourceForm = new CreateDataSourceForm(); + } + + public DataSourcePage createDataSource(String dataSourceType, String dataSourceName, String dataSourceDescription, + String ip, String port, String userName, String password, String database, + String jdbcParams) { + buttonCreateDataSource().click(); + + WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOf(dataSourceModal)); + WebElement dataSourceTypeButton = By.className(dataSourceType.toUpperCase() + "-box").findElement(driver); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(dataSourceTypeButton)); + dataSourceTypeButton.click(); + + WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.textToBePresentInElement( + driver.findElement(By.className("dialog-create-data-source")), dataSourceType.toUpperCase())); + + createDataSourceForm().inputDataSourceName().sendKeys(dataSourceName); + createDataSourceForm().inputDataSourceDescription().sendKeys(dataSourceDescription); + createDataSourceForm().inputIP().sendKeys(ip); + createDataSourceForm().inputPort().sendKeys(Keys.CONTROL + "a"); + createDataSourceForm().inputPort().sendKeys(Keys.BACK_SPACE); + createDataSourceForm().inputPort().sendKeys(port); + createDataSourceForm().inputUserName().sendKeys(userName); + createDataSourceForm().inputPassword().sendKeys(password); + createDataSourceForm().inputDataBase().sendKeys(database); + + if (!"".equals(jdbcParams)) { + createDataSourceForm().inputJdbcParams().sendKeys(jdbcParams); + } + + createDataSourceForm().buttonSubmit().click(); + + return this; + } + + public DataSourcePage delete(String name) { + dataSourceItemsList() + .stream() + .filter(it -> it.getText().contains(name)) + .flatMap(it -> it.findElements(By.className("btn-delete")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No delete button in data source list")) + .click(); + + ((JavascriptExecutor) driver).executeScript("arguments[0].click();", buttonConfirm()); + + return this; + } + + @Getter + public class CreateDataSourceForm { + + CreateDataSourceForm() { + PageFactory.initElements(driver, this); + } + + @FindBy(className = "n-base-select-option__content") + private List selectDataSourceType; + + @FindBys({ + @FindBy(className = "btn-data-source-type-drop-down"), + @FindBy(className = "n-base-selection"), + }) + private WebElement btnDataSourceTypeDropdown; + + @FindBys({ + @FindBy(className = "input-data-source-name"), + @FindBy(tagName = "input"), + }) + private WebElement inputDataSourceName; + + @FindBys({ + @FindBy(className = "input-data-source-description"), + @FindBy(tagName = "textarea"), + }) + private WebElement inputDataSourceDescription; + + @FindBys({ + @FindBy(className = "input-ip"), + @FindBy(tagName = "input"), + }) + private WebElement inputIP; + + @FindBys({ + @FindBy(className = "input-port"), + @FindBy(tagName = "input"), + }) + private WebElement inputPort; + + @FindBys({ + @FindBy(className = "input-username"), + @FindBy(tagName = "input"), + }) + private WebElement inputUserName; + + @FindBys({ + @FindBy(className = "input-password"), + @FindBy(tagName = "input"), + }) + private WebElement inputPassword; + + @FindBys({ + @FindBy(className = "input-data-base"), + @FindBy(tagName = "input"), + }) + private WebElement inputDataBase; + + @FindBys({ + @FindBy(className = "input-jdbc-params"), + @FindBy(tagName = "textarea"), + }) + private WebElement inputJdbcParams; + + @FindBy(className = "btn-submit") + private WebElement buttonSubmit; + + @FindBy(className = "btn-cancel") + private WebElement buttonCancel; + + @FindBy(className = "btn-test-connection") + private WebElement btnTestConnection; + + @FindBys({ + @FindBy(className = "input-zeppelin_rest_endpoint"), + @FindBy(tagName = "input"), + }) + private WebElement inputZeppelinRestEndpoint; + + @FindBys({ + @FindBy(className = "input-kubeConfig"), + @FindBy(tagName = "textarea"), + }) + private WebElement inputKubeConfig; + + } +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/ProjectDetailPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/ProjectDetailPage.java index c2fedeccfbb4..79c46ba1f4e3 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/ProjectDetailPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/ProjectDetailPage.java @@ -19,22 +19,23 @@ */ package org.apache.dolphinscheduler.e2e.pages.project; -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 lombok.Getter; +import lombok.SneakyThrows; + 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; @Getter public final class ProjectDetailPage extends NavBarPage { + @FindBy(css = ".tab-vertical .n-submenu:nth-of-type(2) .n-menu-item:nth-of-type(2) > .n-menu-item-content") private WebElement menuProcessDefinition; @@ -52,12 +53,14 @@ public ProjectDetailPage(RemoteWebDriver driver) { public T goToTab(Class tab) { if (tab == WorkflowDefinitionTab.class) { menuProcessDefinition().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/workflow-definition")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/workflow-definition")); return tab.cast(new WorkflowDefinitionTab(driver)); } if (tab == WorkflowInstanceTab.class) { menuProcessInstances().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/workflow/instances")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/workflow/instances")); return tab.cast(new WorkflowInstanceTab(driver)); } if (tab == TaskInstanceTab.class) { diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/ProjectPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/ProjectPage.java index 8be97f5db908..94ca6ea5f8eb 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/ProjectPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/ProjectPage.java @@ -19,11 +19,16 @@ */ package org.apache.dolphinscheduler.e2e.pages.project; +import static org.assertj.core.api.Assertions.assertThat; +import static org.testcontainers.shaded.org.awaitility.Awaitility.await; + import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage.NavBarItem; import java.util.List; +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; @@ -31,15 +36,10 @@ import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import lombok.Getter; -import static org.assertj.core.api.Assertions.assertThat; -import static org.testcontainers.shaded.org.awaitility.Awaitility.await; @Getter public final class ProjectPage extends NavBarPage implements NavBarItem { + @FindBy(className = "btn-create-project") private WebElement buttonCreateProject; @@ -77,7 +77,6 @@ public ProjectPage createProjectUntilSuccess(String project) { return this; } - public ProjectPage delete(String project) { projectList() .stream() @@ -104,6 +103,7 @@ public ProjectDetailPage goTo(String project) { @Getter public class CreateProjectForm { + CreateProjectForm() { PageFactory.initElements(driver, this); } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/TaskInstanceTab.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/TaskInstanceTab.java index d1d81b70e42f..592fd0e0b2cd 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/TaskInstanceTab.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/TaskInstanceTab.java @@ -20,18 +20,19 @@ package org.apache.dolphinscheduler.e2e.pages.project.workflow; -import lombok.Getter; -import lombok.RequiredArgsConstructor; import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; import org.apache.dolphinscheduler.e2e.pages.project.ProjectDetailPage; + +import java.util.List; +import java.util.stream.Collectors; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.FindBy; -import org.openqa.selenium.support.FindBys; - -import java.util.List; -import java.util.stream.Collectors; @Getter public final class TaskInstanceTab extends NavBarPage implements ProjectDetailPage.Tab { @@ -45,14 +46,15 @@ public TaskInstanceTab(RemoteWebDriver driver) { public List instances() { return instanceList() - .stream() - .filter(WebElement::isDisplayed) - .map(Row::new) - .collect(Collectors.toList()); + .stream() + .filter(WebElement::isDisplayed) + .map(Row::new) + .collect(Collectors.toList()); } @RequiredArgsConstructor public static class Row { + private final WebElement row; public String taskInstanceName() { diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowDefinitionTab.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowDefinitionTab.java index d5a7b386c55b..ee38a0ff7dc5 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowDefinitionTab.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowDefinitionTab.java @@ -27,6 +27,8 @@ import java.util.List; import java.util.stream.Collectors; +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; @@ -35,10 +37,9 @@ import org.openqa.selenium.support.FindBys; import org.testcontainers.shaded.org.awaitility.Awaitility; -import lombok.Getter; - @Getter public final class WorkflowDefinitionTab extends NavBarPage implements ProjectDetailPage.Tab { + @FindBy(className = "btn-create-process") private WebElement buttonCreateProcess; @@ -61,8 +62,8 @@ public final class WorkflowDefinitionTab extends NavBarPage implements ProjectDe private WebElement buttonConfirm; @FindBys({ - @FindBy(className = "n-dialog__action"), - @FindBy(className = "n-button--default-type"), + @FindBy(className = "n-dialog__action"), + @FindBy(className = "n-button--default-type"), }) private WebElement publishSuccessButtonCancel; @@ -91,13 +92,13 @@ public WorkflowForm createSubProcessWorkflow() { public WorkflowDefinitionTab publish(String workflow) { workflowList() - .stream() - .filter(it -> it.findElement(By.className("workflow-name")).getAttribute("innerText").equals(workflow)) - .flatMap(it -> it.findElements(By.className("btn-publish")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("Can not find publish button in workflow definition")) - .click(); + .stream() + .filter(it -> it.findElement(By.className("workflow-name")).getAttribute("innerText").equals(workflow)) + .flatMap(it -> it.findElements(By.className("btn-publish")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("Can not find publish button in workflow definition")) + .click(); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", buttonConfirm()); @@ -108,13 +109,13 @@ public WorkflowDefinitionTab publish(String workflow) { public WorkflowRunDialog run(String workflow) { workflowList() - .stream() - .filter(it -> it.findElement(By.className("workflow-name")).getAttribute("innerText").equals(workflow)) - .flatMap(it -> it.findElements(By.className("btn-run")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("Can not find run button in workflow definition")) - .click(); + .stream() + .filter(it -> it.findElement(By.className("workflow-name")).getAttribute("innerText").equals(workflow)) + .flatMap(it -> it.findElements(By.className("btn-run")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("Can not find run button in workflow definition")) + .click(); return new WorkflowRunDialog(this); } @@ -136,19 +137,18 @@ public WorkflowDefinitionTab cancelPublishAll() { public WorkflowDefinitionTab delete(String workflow) { Awaitility.await().untilAsserted(() -> assertThat(workflowList()) - .as("Workflow list should contain newly-created workflow") - .anyMatch( - it -> it.getText().contains(workflow) - )); + .as("Workflow list should contain newly-created workflow") + .anyMatch( + it -> it.getText().contains(workflow))); workflowList() - .stream() - .filter(it -> it.findElement(By.className("workflow-name")).getAttribute("innerText").equals(workflow)) - .flatMap(it -> it.findElements(By.className("btn-delete")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("Can not find delete button in workflow definition")) - .click(); + .stream() + .filter(it -> it.findElement(By.className("workflow-name")).getAttribute("innerText").equals(workflow)) + .flatMap(it -> it.findElements(By.className("btn-delete")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("Can not find delete button in workflow definition")) + .click(); return this; } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowForm.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowForm.java index ce622b03978b..319a59d37dac 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowForm.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowForm.java @@ -21,15 +21,17 @@ import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.HttpTaskForm; +import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.JavaTaskForm; +import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.PythonTaskForm; import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.ShellTaskForm; import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.SubWorkflowTaskForm; import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.SwitchTaskForm; -import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.JavaTaskForm; import java.nio.charset.StandardCharsets; -import java.time.Duration; import java.util.List; -import java.util.concurrent.TimeUnit; + +import lombok.Getter; +import lombok.SneakyThrows; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -38,17 +40,14 @@ import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; import com.google.common.io.Resources; -import lombok.Getter; -import lombok.SneakyThrows; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - @SuppressWarnings("UnstableApiUsage") @Getter public final class WorkflowForm { + private WebDriver driver; private final WorkflowSaveDialog saveForm; private final WorkflowFormatDialog formatDialog; @@ -77,6 +76,8 @@ public T addTask(TaskType type) { final String dragAndDrop = String.join("\n", Resources.readLines(Resources.getResource("dragAndDrop.js"), StandardCharsets.UTF_8)); js.executeScript(dragAndDrop, task, canvas); + WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions + .visibilityOfElementLocated(By.xpath("//*[contains(text(), 'Current node settings')]"))); switch (type) { case SHELL: @@ -89,13 +90,16 @@ public T addTask(TaskType type) { return (T) new HttpTaskForm(this); case JAVA: return (T) new JavaTaskForm(this); + case PYTHON: + return (T) new PythonTaskForm(this); } throw new UnsupportedOperationException("Unknown task type"); } public WebElement getTask(String taskName) { List tasks = WebDriverWaitFactory.createWebDriverWait(driver) - .until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("svg > g > g[class^='x6-graph-svg-stage'] > g[data-shape^='dag-task']"))); + .until(ExpectedConditions.visibilityOfAllElementsLocatedBy( + By.cssSelector("svg > g > g[class^='x6-graph-svg-stage'] > g[data-shape^='dag-task']"))); WebElement task = tasks.stream() .filter(t -> t.getText().contains(taskName)) @@ -110,7 +114,8 @@ public WebElement getTask(String taskName) { public WorkflowSaveDialog submit() { buttonSave().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(.,'Basic Information')]"))); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(.,'Basic Information')]"))); return new WorkflowSaveDialog(this); } @@ -126,5 +131,6 @@ public enum TaskType { SWITCH, HTTP, JAVA, + PYTHON } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowFormatDialog.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowFormatDialog.java index f0ecf53b4655..19778fe61648 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowFormatDialog.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowFormatDialog.java @@ -19,22 +19,19 @@ */ package org.apache.dolphinscheduler.e2e.pages.project.workflow; +import java.util.List; + import lombok.Getter; -import org.openqa.selenium.By; + import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.pagefactory.ByChained; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.util.List; -import java.util.stream.Stream; @Getter public final class WorkflowFormatDialog { + private final WebDriver driver; private final WorkflowForm parent; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowInstanceTab.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowInstanceTab.java index 2b7fa28274f9..e853311f33b8 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowInstanceTab.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowInstanceTab.java @@ -25,25 +25,26 @@ import java.util.List; import java.util.stream.Collectors; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; import org.openqa.selenium.support.pagefactory.ByChained; @Getter public final class WorkflowInstanceTab extends NavBarPage implements ProjectDetailPage.Tab { + @FindBy(className = "items-workflow-instances") private List instanceList; @FindBys({ - @FindBy(className = "btn-selected"), - @FindBy(className = "n-checkbox-box"), + @FindBy(className = "btn-selected"), + @FindBy(className = "n-checkbox-box"), }) private WebElement checkBoxSelectAll; @@ -62,10 +63,10 @@ public WorkflowInstanceTab(RemoteWebDriver driver) { public List instances() { return instanceList() - .stream() - .filter(WebElement::isDisplayed) - .map(Row::new) - .collect(Collectors.toList()); + .stream() + .filter(WebElement::isDisplayed) + .map(Row::new) + .collect(Collectors.toList()); } public WorkflowInstanceTab deleteAll() { @@ -84,6 +85,7 @@ public WorkflowInstanceTab deleteAll() { @RequiredArgsConstructor public static class Row { + private final WebElement row; public String workflowInstanceName() { @@ -108,11 +110,11 @@ public int executionTime() { public Row rerun() { row.findElements(new ByChained(By.className("btn-rerun"), By.className("n-button__content"))) - .stream() - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("Cannot find rerun button")) - .click(); + .stream() + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("Cannot find rerun button")) + .click(); return this; } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowRunDialog.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowRunDialog.java index ac8c22e5da01..4d5ea9329646 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowRunDialog.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowRunDialog.java @@ -21,23 +21,24 @@ import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; - -import lombok.Getter; - -import java.time.Duration; - import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; @Getter public final class WorkflowRunDialog { + private final WorkflowDefinitionTab parent; - @FindBy(className = "btn-submit") + @FindBys({ + @FindBy(xpath = "//div[contains(text(), 'Please set the parameters before starting')]/../.."), + @FindBy(className = "btn-submit") + }) private WebElement buttonSubmit; public WorkflowRunDialog(WorkflowDefinitionTab parent) { @@ -47,12 +48,16 @@ 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())); + 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(); - + WebDriverWaitFactory.createWebDriverWait(parent.driver()) + .until(ExpectedConditions.invisibilityOfElementLocated(runDialogTitleXpath)); return parent(); } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowSaveDialog.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowSaveDialog.java index d61b6a8fb767..f29d71e27ec1 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowSaveDialog.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/WorkflowSaveDialog.java @@ -19,26 +19,21 @@ */ package org.apache.dolphinscheduler.e2e.pages.project.workflow; -import lombok.Getter; - import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; +import lombok.Getter; + 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; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.pagefactory.ByChained; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.util.List; -import java.util.stream.Stream; @Getter public final class WorkflowSaveDialog { + private final WebDriver driver; private final WorkflowForm parent; @@ -82,10 +77,10 @@ public WorkflowSaveDialog addGlobalParam(String key, String value) { globalParamsItems().findElements(By.tagName("input")).get(0).sendKeys(key); globalParamsItems().findElements(By.tagName("input")).get(1).sendKeys(value); } else { - globalParamsItems().findElements(By.tagName("button")).get(len-1).click(); + globalParamsItems().findElements(By.tagName("button")).get(len - 1).click(); globalParamsItems().findElements(By.tagName("input")).get(len).sendKeys(key); - globalParamsItems().findElements(By.tagName("input")).get(len+1).sendKeys(value); + globalParamsItems().findElements(By.tagName("input")).get(len + 1).sendKeys(value); } return this; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/HttpTaskForm.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/HttpTaskForm.java index 5869c6de9cc9..ab77ac3f516e 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/HttpTaskForm.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/HttpTaskForm.java @@ -22,14 +22,15 @@ import org.apache.dolphinscheduler.e2e.pages.common.HttpInput; import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm; + import org.openqa.selenium.WebDriver; -public class HttpTaskForm extends TaskNodeForm{ +public class HttpTaskForm extends TaskNodeForm { + private WebDriver driver; private HttpInput httpInput; - public HttpTaskForm(WorkflowForm parent) { super(parent); this.httpInput = new HttpInput(parent.driver()); diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java index 960f7672fdf2..528c8b80d6d2 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java @@ -22,9 +22,11 @@ import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor; import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm; + import org.openqa.selenium.WebDriver; -public class JavaTaskForm extends TaskNodeForm{ +public class JavaTaskForm extends TaskNodeForm { + private CodeEditor codeEditor; private WebDriver driver; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/PythonTaskForm.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/PythonTaskForm.java new file mode 100644 index 000000000000..0ebabda411aa --- /dev/null +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/PythonTaskForm.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.dolphinscheduler.e2e.pages.project.workflow.task; + +import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor; +import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm; + +import lombok.Getter; + +import org.openqa.selenium.WebDriver; + +@Getter +public final class PythonTaskForm extends TaskNodeForm { + + private CodeEditor codeEditor; + + private WebDriver driver; + + public PythonTaskForm(WorkflowForm parent) { + super(parent); + + this.codeEditor = new CodeEditor(parent.driver()); + + this.driver = parent.driver(); + } + + public PythonTaskForm script(String script) { + codeEditor.content(script); + + return this; + } +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/ShellTaskForm.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/ShellTaskForm.java index fb91bb7e9604..9f11f1f85ceb 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/ShellTaskForm.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/ShellTaskForm.java @@ -23,11 +23,12 @@ import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm; import lombok.Getter; -import org.openqa.selenium.JavascriptExecutor; + import org.openqa.selenium.WebDriver; @Getter public final class ShellTaskForm extends TaskNodeForm { + private CodeEditor codeEditor; private WebDriver driver; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SubWorkflowTaskForm.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SubWorkflowTaskForm.java index 6f328ddf232c..3cf288e1eb0b 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SubWorkflowTaskForm.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SubWorkflowTaskForm.java @@ -22,20 +22,20 @@ import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm; +import java.util.List; + import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.time.Duration; -import java.util.List; @Getter public final class SubWorkflowTaskForm extends TaskNodeForm { + @FindBys({ @FindBy(className = "select-child-node"), @FindBy(className = "n-base-selection"), @@ -47,7 +47,6 @@ public final class SubWorkflowTaskForm extends TaskNodeForm { private WebDriver driver; - public SubWorkflowTaskForm(WorkflowForm parent) { super(parent); @@ -55,12 +54,14 @@ public SubWorkflowTaskForm(WorkflowForm parent) { } public SubWorkflowTaskForm childNode(String node) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(btnSelectChildNodeDropdown)); - + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(btnSelectChildNodeDropdown)); + btnSelectChildNodeDropdown().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOfElementLocated(By.className( - "n-base-select-option__content"))); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.visibilityOfElementLocated(By.className( + "n-base-select-option__content"))); selectChildNode() .stream() diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SwitchTaskForm.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SwitchTaskForm.java index 480f5b410b14..0948be7d9912 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SwitchTaskForm.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SwitchTaskForm.java @@ -19,19 +19,19 @@ */ package org.apache.dolphinscheduler.e2e.pages.project.workflow.task; -import lombok.Getter; import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm; + +import java.util.List; + +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.time.Duration; -import java.util.List; @Getter public final class SwitchTaskForm extends TaskNodeForm { @@ -51,14 +51,14 @@ public SwitchTaskForm(WorkflowForm parent) { } public SwitchTaskForm elseBranch(String elseBranchName) { - ((JavascriptExecutor)parent().driver()).executeScript("arguments[0].click();", inputElseBranch()); + ((JavascriptExecutor) parent().driver()).executeScript("arguments[0].click();", inputElseBranch()); final By optionsLocator = By.className("option-else-branches"); WebDriverWaitFactory.createWebDriverWait(parent().driver()) .until(ExpectedConditions.visibilityOfElementLocated(optionsLocator)); - List webElements = parent().driver().findElements(optionsLocator); + List webElements = parent().driver().findElements(optionsLocator); webElements.stream() .filter(it -> it.getText().contains(elseBranchName)) .findFirst() @@ -71,19 +71,20 @@ public SwitchTaskForm elseBranch(String elseBranchName) { } public SwitchTaskForm addIfBranch(String switchScript, String ifBranchName) { - ((JavascriptExecutor)parent().driver()).executeScript("arguments[0].click();", buttonAddBranch); + ((JavascriptExecutor) parent().driver()).executeScript("arguments[0].click();", buttonAddBranch); SwitchTaskIfBranch switchTaskIfBranch = new SwitchTaskIfBranch(this); switchTaskIfBranch.codeEditor().content(switchScript); - ((JavascriptExecutor)parent().driver()).executeScript("arguments[0].click();", switchTaskIfBranch.inputIfBranch()); + ((JavascriptExecutor) parent().driver()).executeScript("arguments[0].click();", + switchTaskIfBranch.inputIfBranch()); final By optionsLocator = By.className("option-if-branches"); WebDriverWaitFactory.createWebDriverWait(parent().driver()) .until(ExpectedConditions.visibilityOfElementLocated(optionsLocator)); - List webElements = parent().driver().findElements(optionsLocator); + List webElements = parent().driver().findElements(optionsLocator); webElements.stream() .filter(it -> it.getText().contains(ifBranchName)) .findFirst() diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SwitchTaskIfBranch.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SwitchTaskIfBranch.java index 593778f4319c..c3675768c9de 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SwitchTaskIfBranch.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/SwitchTaskIfBranch.java @@ -19,8 +19,10 @@ */ package org.apache.dolphinscheduler.e2e.pages.project.workflow.task; -import lombok.Getter; import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor; + +import lombok.Getter; + import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -29,6 +31,7 @@ @Getter public final class SwitchTaskIfBranch { + private final WebDriver driver; private final SwitchTaskForm parent; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/TaskNodeForm.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/TaskNodeForm.java index 5d0a944b02da..de4bac356758 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/TaskNodeForm.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/TaskNodeForm.java @@ -19,24 +19,26 @@ */ package org.apache.dolphinscheduler.e2e.pages.project.workflow.task; -import lombok.Getter; import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm; + +import java.util.List; + +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.time.Duration; -import java.util.List; @Getter public abstract class TaskNodeForm { + @FindBys({ @FindBy(className = "input-node-name"), @FindBy(tagName = "input") @@ -85,7 +87,6 @@ public abstract class TaskNodeForm { }) private WebElement selectResource; - private final WorkflowForm parent; TaskNodeForm(WorkflowForm parent) { @@ -168,7 +169,8 @@ public TaskNodeForm selectResource(String resourceName) { final By optionsLocator = By.className("n-tree-node-content__text"); - WebDriverWaitFactory.createWebDriverWait(parent().driver()).until(ExpectedConditions.visibilityOfElementLocated(optionsLocator)); + WebDriverWaitFactory.createWebDriverWait(parent().driver()) + .until(ExpectedConditions.visibilityOfElementLocated(optionsLocator)); parent().driver() .findElements(optionsLocator) @@ -177,6 +179,8 @@ public TaskNodeForm selectResource(String resourceName) { .findFirst() .orElseThrow(() -> new RuntimeException("No such resource: " + resourceName)) .click(); + + parent.driver().switchTo().activeElement().sendKeys(Keys.ESCAPE); return this; } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/FileManagePage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/FileManagePage.java index f2d594f155e6..5f373b8190c5 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/FileManagePage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/FileManagePage.java @@ -1,331 +1,333 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.dolphinscheduler.e2e.pages.resource; - -import lombok.Getter; - -import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; -import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor; -import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; - -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.Keys; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.LocalFileDetector; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.FindBy; -import org.openqa.selenium.support.FindBys; -import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.ui.ExpectedCondition; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.io.File; -import java.time.Duration; -import java.util.List; -import static org.assertj.core.api.Assertions.assertThat; -import static org.testcontainers.shaded.org.awaitility.Awaitility.await; - - -@Getter -public class FileManagePage extends NavBarPage implements ResourcePage.Tab { - @FindBy(className = "btn-create-directory") - private WebElement buttonCreateDirectory; - - @FindBy(className = "btn-create-file") - private WebElement buttonCreateFile; - - @FindBy(className = "btn-upload-resource") - private WebElement buttonUploadFile; - - private final CreateDirectoryBox createDirectoryBox; - - private final RenameBox renameBox; - - private final UploadFileBox uploadFileBox; - - private final EditFileBox editFileBox; - - @FindBy(className = "items") - private List fileList; - - @FindBys({ - @FindBy(className = "n-popconfirm__action"), - @FindBy(className = "n-button--primary-type"), - }) - private WebElement buttonConfirm; - - @FindBys({ - @FindBy(className = "monaco-editor"), - @FindBy(className = "view-line"), - }) - private WebElement editor; - - public FileManagePage(RemoteWebDriver driver) { - super(driver); - - createDirectoryBox = new CreateDirectoryBox(); - - renameBox = new RenameBox(); - - uploadFileBox = new UploadFileBox(); - - editFileBox = new EditFileBox(); - - } - - public FileManagePage createDirectory(String name) { - buttonCreateDirectory().click(); - - createDirectoryBox().inputDirectoryName().sendKeys(name); - createDirectoryBox().buttonSubmit().click(); - - return this; - } - - public FileManagePage cancelCreateDirectory(String name) { - buttonCreateDirectory().click(); - - createDirectoryBox().inputDirectoryName().sendKeys(name); - createDirectoryBox().buttonCancel().click(); - - return this; - } - - public FileManagePage rename(String currentName, String AfterName) { - fileList() - .stream() - .filter(it -> it.getText().contains(currentName)) - .flatMap(it -> it.findElements(By.className("btn-rename")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No rename button in file manage list")) - .click(); - - renameBox().inputName().sendKeys(Keys.CONTROL + "a"); - renameBox().inputName().sendKeys(Keys.BACK_SPACE); - renameBox().inputName().sendKeys(AfterName); - renameBox().buttonSubmit().click(); - - return this; - } - - public FileManagePage createSubDirectory(String directoryName, String subDirectoryName) { - fileList() - .stream() - .filter(it -> it.getText().contains(directoryName)) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException(String.format("No %s in file manage list", directoryName))) - .click(); - - buttonCreateDirectory().click(); - - createDirectoryBox().inputDirectoryName().sendKeys(subDirectoryName); - createDirectoryBox().buttonSubmit().click(); - - return this; - } - - public FileManagePage delete(String name) { - fileList() - .stream() - .filter(it -> it.getText().contains(name)) - .flatMap(it -> it.findElements(By.className("btn-delete")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No delete button in file manage list")) - .click(); - - ((JavascriptExecutor) driver).executeScript("arguments[0].click();", buttonConfirm()); - - return this; - } - - // todo: add file type - public FileManagePage createFile(String fileName, String scripts) { - - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(buttonCreateFile())); - - buttonCreateFile().click(); - - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/resource/file/create")); - - 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; - } - - public FileManagePage createFileUntilSuccess(String fileName, String scripts) { - - createFile(fileName, scripts); - - await() - .untilAsserted(() -> - assertThat(fileList()) - .as("File list should contain newly-created file: " + fileName) - .extracting(WebElement::getText) - .anyMatch(it -> it.contains(fileName))); - return this; - } - - public FileManagePage editFile(String fileName, String scripts) { - fileList() - .stream() - .filter(it -> it.getText().contains(fileName)) - .flatMap(it -> it.findElements(By.className("btn-edit")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No edit button in file manage list")) - .click(); - - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/edit")); - - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.tagName("body")), fileName)); - - editFileBox().codeEditor().content(scripts); - editFileBox().buttonSubmit().click(); - - return this; - } - - public FileManagePage uploadFile(String filePath) { - buttonUploadFile().click(); - - driver.setFileDetector(new LocalFileDetector()); - - uploadFileBox().buttonUpload().sendKeys(filePath); - uploadFileBox().buttonSubmit().click(); - - return this; - } - - public FileManagePage downloadFile(String fileName) { - fileList() - .stream() - .filter(it -> it.getText().contains(fileName)) - .flatMap(it -> it.findElements(By.className("btn-download")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No download button in file manage list")) - .click(); - - return this; - } - - @Getter - public class CreateDirectoryBox { - CreateDirectoryBox() { - PageFactory.initElements(driver, this); - } - - @FindBys({ - @FindBy(className = "input-directory-name"), - @FindBy(tagName = "input"), - }) - private WebElement inputDirectoryName; - - @FindBy(className = "btn-submit") - private WebElement buttonSubmit; - - @FindBy(className = "btn-cancel") - private WebElement buttonCancel; - } - - @Getter - public class RenameBox { - RenameBox() { - PageFactory.initElements(driver, this); - } - - @FindBys({ - @FindBy(className = "input-name"), - @FindBy(tagName = "input"), - }) - private WebElement inputName; - - @FindBy(className = "btn-submit") - private WebElement buttonSubmit; - - @FindBy(className = "btn-cancel") - private WebElement buttonCancel; - } - - @Getter - public class CreateFileBox { - CreateFileBox() { - PageFactory.initElements(driver, this); - } - - @FindBys({ - @FindBy(className = "input-file-name"), - @FindBy(tagName = "input"), - }) - private WebElement inputFileName; - - private final CodeEditor codeEditor = new CodeEditor(driver); - - @FindBy(className = "btn-submit") - private WebElement buttonSubmit; - - @FindBy(className = "btn-cancel") - private WebElement buttonCancel; - } - - @Getter - public class EditFileBox { - EditFileBox() { - PageFactory.initElements(driver, this); - } - - CodeEditor codeEditor = new CodeEditor(driver); - - @FindBy(className = "btn-submit") - private WebElement buttonSubmit; - - @FindBy(className = "btn-cancel") - private WebElement buttonCancel; - } - - @Getter - public class UploadFileBox { - UploadFileBox() { - PageFactory.initElements(driver, this); - } - - @FindBys({ - @FindBy(className = "btn-upload"), - @FindBy(tagName = "input"), - }) - private WebElement buttonUpload; - - @FindBy(className = "btn-submit") - private WebElement buttonSubmit; - - @FindBy(className = "btn-cancel") - private WebElement buttonCancel; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.dolphinscheduler.e2e.pages.resource; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.testcontainers.shaded.org.awaitility.Awaitility.await; + +import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; +import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor; +import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; + +import java.util.List; + +import lombok.Getter; + +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.LocalFileDetector; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.FindBys; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; + +@Getter +public class FileManagePage extends NavBarPage implements ResourcePage.Tab { + + @FindBy(className = "btn-create-directory") + private WebElement buttonCreateDirectory; + + @FindBy(className = "btn-create-file") + private WebElement buttonCreateFile; + + @FindBy(className = "btn-upload-resource") + private WebElement buttonUploadFile; + + private final CreateDirectoryBox createDirectoryBox; + + private final RenameBox renameBox; + + private final UploadFileBox uploadFileBox; + + private final EditFileBox editFileBox; + + @FindBy(className = "items") + private List fileList; + + @FindBys({ + @FindBy(className = "n-popconfirm__action"), + @FindBy(className = "n-button--primary-type"), + }) + private WebElement buttonConfirm; + + @FindBys({ + @FindBy(className = "monaco-editor"), + @FindBy(className = "view-line"), + }) + private WebElement editor; + + public FileManagePage(RemoteWebDriver driver) { + super(driver); + + createDirectoryBox = new CreateDirectoryBox(); + + renameBox = new RenameBox(); + + uploadFileBox = new UploadFileBox(); + + editFileBox = new EditFileBox(); + + } + + public FileManagePage createDirectory(String name) { + buttonCreateDirectory().click(); + + createDirectoryBox().inputDirectoryName().sendKeys(name); + createDirectoryBox().buttonSubmit().click(); + + return this; + } + + public FileManagePage cancelCreateDirectory(String name) { + buttonCreateDirectory().click(); + + createDirectoryBox().inputDirectoryName().sendKeys(name); + createDirectoryBox().buttonCancel().click(); + + return this; + } + + public FileManagePage rename(String currentName, String AfterName) { + fileList() + .stream() + .filter(it -> it.getText().contains(currentName)) + .flatMap(it -> it.findElements(By.className("btn-rename")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No rename button in file manage list")) + .click(); + + renameBox().inputName().sendKeys(Keys.CONTROL + "a"); + renameBox().inputName().sendKeys(Keys.BACK_SPACE); + renameBox().inputName().sendKeys(AfterName); + renameBox().buttonSubmit().click(); + + return this; + } + + public FileManagePage createSubDirectory(String directoryName, String subDirectoryName) { + fileList() + .stream() + .filter(it -> it.getText().contains(directoryName)) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException(String.format("No %s in file manage list", directoryName))) + .click(); + + buttonCreateDirectory().click(); + + createDirectoryBox().inputDirectoryName().sendKeys(subDirectoryName); + createDirectoryBox().buttonSubmit().click(); + + return this; + } + + public FileManagePage delete(String name) { + fileList() + .stream() + .filter(it -> it.getText().contains(name)) + .flatMap(it -> it.findElements(By.className("btn-delete")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No delete button in file manage list")) + .click(); + + ((JavascriptExecutor) driver).executeScript("arguments[0].click();", buttonConfirm()); + + return this; + } + + // todo: add file type + public FileManagePage createFile(String fileName, String scripts) { + + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(buttonCreateFile())); + + buttonCreateFile().click(); + + WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/resource/file/create")); + + 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; + } + + public FileManagePage createFileUntilSuccess(String fileName, String scripts) { + + createFile(fileName, scripts); + + await() + .untilAsserted(() -> assertThat(fileList()) + .as("File list should contain newly-created file: " + fileName) + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(fileName))); + return this; + } + + public FileManagePage editFile(String fileName, String scripts) { + fileList() + .stream() + .filter(it -> it.getText().contains(fileName)) + .flatMap(it -> it.findElements(By.className("btn-edit")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No edit button in file manage list")) + .click(); + + WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/edit")); + + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.tagName("body")), fileName)); + + editFileBox().codeEditor().content(scripts); + editFileBox().buttonSubmit().click(); + + return this; + } + + public FileManagePage uploadFile(String filePath) { + buttonUploadFile().click(); + + driver.setFileDetector(new LocalFileDetector()); + + uploadFileBox().buttonUpload().sendKeys(filePath); + uploadFileBox().buttonSubmit().click(); + + return this; + } + + public FileManagePage downloadFile(String fileName) { + fileList() + .stream() + .filter(it -> it.getText().contains(fileName)) + .flatMap(it -> it.findElements(By.className("btn-download")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No download button in file manage list")) + .click(); + + return this; + } + + @Getter + public class CreateDirectoryBox { + + CreateDirectoryBox() { + PageFactory.initElements(driver, this); + } + + @FindBys({ + @FindBy(className = "input-directory-name"), + @FindBy(tagName = "input"), + }) + private WebElement inputDirectoryName; + + @FindBy(className = "btn-submit") + private WebElement buttonSubmit; + + @FindBy(className = "btn-cancel") + private WebElement buttonCancel; + } + + @Getter + public class RenameBox { + + RenameBox() { + PageFactory.initElements(driver, this); + } + + @FindBys({ + @FindBy(className = "input-name"), + @FindBy(tagName = "input"), + }) + private WebElement inputName; + + @FindBy(className = "btn-submit") + private WebElement buttonSubmit; + + @FindBy(className = "btn-cancel") + private WebElement buttonCancel; + } + + @Getter + public class CreateFileBox { + + CreateFileBox() { + PageFactory.initElements(driver, this); + } + + @FindBys({ + @FindBy(className = "input-file-name"), + @FindBy(tagName = "input"), + }) + private WebElement inputFileName; + + private final CodeEditor codeEditor = new CodeEditor(driver); + + @FindBy(className = "btn-submit") + private WebElement buttonSubmit; + + @FindBy(className = "btn-cancel") + private WebElement buttonCancel; + } + + @Getter + public class EditFileBox { + + EditFileBox() { + PageFactory.initElements(driver, this); + } + + CodeEditor codeEditor = new CodeEditor(driver); + + @FindBy(className = "btn-submit") + private WebElement buttonSubmit; + + @FindBy(className = "btn-cancel") + private WebElement buttonCancel; + } + + @Getter + public class UploadFileBox { + + UploadFileBox() { + PageFactory.initElements(driver, this); + } + + @FindBys({ + @FindBy(className = "btn-upload"), + @FindBy(tagName = "input"), + }) + private WebElement buttonUpload; + + @FindBy(className = "btn-submit") + private WebElement buttonSubmit; + + @FindBy(className = "btn-cancel") + private WebElement buttonCancel; + } +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/ResourcePage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/ResourcePage.java index 23264147f8c9..bd79de08297b 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/ResourcePage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/ResourcePage.java @@ -1,63 +1,61 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.dolphinscheduler.e2e.pages.resource; - -import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; -import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; - -import java.time.Duration; - -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.FindBy; -import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import lombok.Getter; - - -@Getter -public class ResourcePage extends NavBarPage implements NavBarPage.NavBarItem { - @FindBy(css = ".tab-vertical > .n-menu-item:nth-child(1) > .n-menu-item-content") - private WebElement fileManageTab; - - public ResourcePage(RemoteWebDriver driver) { - super(driver); - - PageFactory.initElements(driver, this); - } - - public T goToTab(Class tab) { - if (tab == FileManagePage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/resource")); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(fileManageTab)); - ((JavascriptExecutor) driver).executeScript("arguments[0].click();", fileManageTab()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/file-manage")); - return tab.cast(new FileManagePage(driver)); - } - - throw new UnsupportedOperationException("Unknown tab: " + tab.getName()); - } - - public interface Tab { - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.dolphinscheduler.e2e.pages.resource; + +import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; +import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; + +import lombok.Getter; + +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; + +@Getter +public class ResourcePage extends NavBarPage implements NavBarPage.NavBarItem { + + @FindBy(css = ".tab-vertical > .n-menu-item:nth-child(1) > .n-menu-item-content") + private WebElement fileManageTab; + + public ResourcePage(RemoteWebDriver driver) { + super(driver); + + PageFactory.initElements(driver, this); + } + + public T goToTab(Class tab) { + if (tab == FileManagePage.class) { + WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/resource")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(fileManageTab)); + ((JavascriptExecutor) driver).executeScript("arguments[0].click();", fileManageTab()); + WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/file-manage")); + return tab.cast(new FileManagePage(driver)); + } + + throw new UnsupportedOperationException("Unknown tab: " + tab.getName()); + } + + public interface Tab { + } +} diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/ClusterPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/ClusterPage.java index f95439768abe..8cf54969565c 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/ClusterPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/ClusterPage.java @@ -23,6 +23,8 @@ import java.util.List; +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; @@ -31,13 +33,10 @@ import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import lombok.Getter; @Getter public final class ClusterPage extends NavBarPage implements SecurityPage.Tab { + @FindBy(className = "btn-create-cluster") private WebElement buttonCreateCluster; @@ -45,8 +44,8 @@ public final class ClusterPage extends NavBarPage implements SecurityPage.Tab { private List clusterList; @FindBys({ - @FindBy(className = "n-popconfirm__action"), - @FindBy(className = "n-button--primary-type"), + @FindBy(className = "n-popconfirm__action"), + @FindBy(className = "n-button--primary-type"), }) private WebElement buttonConfirm; @@ -79,7 +78,6 @@ public ClusterPage update(String oldName, String name, String config, String des .orElseThrow(() -> new RuntimeException("No edit button in cluster list")) .click(); - editClusterForm().inputClusterName().sendKeys(Keys.CONTROL + "a"); editClusterForm().inputClusterName().sendKeys(Keys.BACK_SPACE); editClusterForm().inputClusterName().sendKeys(name); @@ -114,31 +112,32 @@ public ClusterPage delete(String name) { @Getter public class ClusterForm { + ClusterForm() { PageFactory.initElements(driver, this); } @FindBys({ - @FindBy(className = "input-cluster-name"), - @FindBy(tagName = "input"), + @FindBy(className = "input-cluster-name"), + @FindBy(tagName = "input"), }) private WebElement inputClusterName; @FindBys({ - @FindBy(className = "input-cluster-config"), - @FindBy(tagName = "textarea"), + @FindBy(className = "input-cluster-config"), + @FindBy(tagName = "textarea"), }) private WebElement inputClusterConfig; @FindBys({ - @FindBy(className = "input-cluster-desc"), - @FindBy(tagName = "input"), + @FindBy(className = "input-cluster-desc"), + @FindBy(tagName = "input"), }) private WebElement inputClusterDesc; @FindBys({ - @FindBy(className = "n-base-selection-tags"), - @FindBy(className = "n-tag__content"), + @FindBy(className = "n-base-selection-tags"), + @FindBy(className = "n-tag__content"), }) private WebElement selectedWorkerGroup; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/EnvironmentPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/EnvironmentPage.java index c318c257e3e0..d8fc86eb04d7 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/EnvironmentPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/EnvironmentPage.java @@ -19,12 +19,16 @@ package org.apache.dolphinscheduler.e2e.pages.security; +import static org.assertj.core.api.Assertions.assertThat; +import static org.testcontainers.shaded.org.awaitility.Awaitility.await; + import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory; import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; -import java.time.Duration; import java.util.List; +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; @@ -33,13 +37,11 @@ import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; - -import lombok.Getter; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; @Getter public final class EnvironmentPage extends NavBarPage implements SecurityPage.Tab { + @FindBy(className = "btn-create-environment") private WebElement buttonCreateEnvironment; @@ -47,8 +49,8 @@ public final class EnvironmentPage extends NavBarPage implements SecurityPage.Ta private List environmentList; @FindBys({ - @FindBy(className = "n-popconfirm__action"), - @FindBy(className = "n-button--primary-type"), + @FindBy(className = "n-popconfirm__action"), + @FindBy(className = "n-button--primary-type"), }) private WebElement buttonConfirm; @@ -68,8 +70,9 @@ public EnvironmentPage create(String name, String config, String desc, String wo createEnvironmentForm().inputEnvironmentDesc().sendKeys(desc); editEnvironmentForm().btnSelectWorkerGroupDropdown().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( - "n-base-select-option__content"))); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( + "n-base-select-option__content"))); editEnvironmentForm().selectWorkerGroupList() .stream() .filter(it -> it.getText().contains(workerGroup)) @@ -82,17 +85,25 @@ public EnvironmentPage create(String name, String config, String desc, String wo return this; } + public EnvironmentPage createEnvironmentUntilSuccess(String name, String config, String desc, String workerGroup) { + create(name, config, desc, workerGroup); + await().untilAsserted(() -> assertThat(environmentList()) + .as("environment list should contain newly-created environment") + .anyMatch(it -> it.getText().contains(name))); + return this; + } + public EnvironmentPage update(String oldName, String name, String config, String desc, String workerGroup) { environmentList() .stream() - .filter(it -> it.findElement(By.className("environment-name")).getAttribute("innerHTML").contains(oldName)) + .filter(it -> it.findElement(By.className("environment-name")).getAttribute("innerHTML") + .contains(oldName)) .flatMap(it -> it.findElements(By.className("edit")).stream()) .filter(WebElement::isDisplayed) .findFirst() .orElseThrow(() -> new RuntimeException("No edit button in environment list")) .click(); - editEnvironmentForm().inputEnvironmentName().sendKeys(Keys.CONTROL + "a"); editEnvironmentForm().inputEnvironmentName().sendKeys(Keys.BACK_SPACE); editEnvironmentForm().inputEnvironmentName().sendKeys(name); @@ -107,8 +118,9 @@ public EnvironmentPage update(String oldName, String name, String config, String if (editEnvironmentForm().selectedWorkerGroup().getAttribute("innerHTML").equals(workerGroup)) { editEnvironmentForm().btnSelectWorkerGroupDropdown().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( - "n-base-select-option__content"))); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( + "n-base-select-option__content"))); editEnvironmentForm().selectWorkerGroupList() .stream() .filter(it -> it.getText().contains(workerGroup)) @@ -140,25 +152,26 @@ public EnvironmentPage delete(String name) { @Getter public class EnvironmentForm { + EnvironmentForm() { PageFactory.initElements(driver, this); } @FindBys({ - @FindBy(className = "input-environment-name"), - @FindBy(tagName = "input"), + @FindBy(className = "input-environment-name"), + @FindBy(tagName = "input"), }) private WebElement inputEnvironmentName; @FindBys({ - @FindBy(className = "input-environment-config"), - @FindBy(tagName = "textarea"), + @FindBy(className = "input-environment-config"), + @FindBy(tagName = "textarea"), }) private WebElement inputEnvironmentConfig; @FindBys({ - @FindBy(className = "input-environment-desc"), - @FindBy(tagName = "input"), + @FindBy(className = "input-environment-desc"), + @FindBy(tagName = "input"), }) private WebElement inputEnvironmentDesc; @@ -172,8 +185,8 @@ public class EnvironmentForm { private List selectWorkerGroupList; @FindBys({ - @FindBy(className = "n-base-selection-tags"), - @FindBy(className = "n-tag__content"), + @FindBy(className = "n-base-selection-tags"), + @FindBy(className = "n-tag__content"), }) private WebElement selectedWorkerGroup; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/NamespacePage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/NamespacePage.java index 0d10e345fe46..31b805c125a1 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/NamespacePage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/NamespacePage.java @@ -23,16 +23,17 @@ import java.util.List; +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; -import lombok.Getter; - @Getter public final class NamespacePage extends NavBarPage implements SecurityPage.Tab { + @FindBy(id = "btnCreateNamespace") private WebElement buttonCreateNamespace; @@ -59,7 +60,8 @@ public NamespacePage create(String namespaceName, String namespaceValue) { public NamespacePage update(String namespaceName, String editNamespaceName, String editNamespaceValue) { namespaceList() .stream() - .filter(it -> it.findElement(By.className("namespaceName")).getAttribute("innerHTML").contains(namespaceName)) + .filter(it -> it.findElement(By.className("namespaceName")).getAttribute("innerHTML") + .contains(namespaceName)) .flatMap(it -> it.findElements(By.className("edit")).stream()) .filter(WebElement::isDisplayed) .findFirst() @@ -75,6 +77,7 @@ public NamespacePage update(String namespaceName, String editNamespaceName, Stri @Getter public class NamespaceForm { + NamespaceForm() { PageFactory.initElements(driver, this); } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/QueuePage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/QueuePage.java index 2eb93d351736..bbe9a1719908 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/QueuePage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/QueuePage.java @@ -21,9 +21,10 @@ import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; -import java.security.Key; import java.util.List; +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; @@ -32,10 +33,9 @@ import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; -import lombok.Getter; - @Getter public final class QueuePage extends NavBarPage implements SecurityPage.Tab { + @FindBy(className = "btn-create-queue") private WebElement buttonCreateQueue; @@ -84,13 +84,14 @@ public QueuePage update(String queueName, String editQueueName, String editQueue @Getter public class QueueForm { + QueueForm() { PageFactory.initElements(driver, this); } @FindBys({ - @FindBy(className = "input-queue-name"), - @FindBy(tagName = "input"), + @FindBy(className = "input-queue-name"), + @FindBy(tagName = "input"), }) private WebElement inputQueueName; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/SecurityPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/SecurityPage.java index 11cb748f7bd2..093d2201d311 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/SecurityPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/SecurityPage.java @@ -24,17 +24,13 @@ import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage.NavBarItem; +import lombok.Getter; + import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.FindBy; -import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import lombok.Getter; - -import java.time.Duration; @Getter public class SecurityPage extends NavBarPage implements NavBarItem { @@ -70,58 +66,74 @@ public SecurityPage(RemoteWebDriver driver) { public T goToTab(Class tab) { if (tab == TenantPage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(menuTenantManage)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(menuTenantManage)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", menuTenantManage()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/tenant-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/security/tenant-manage")); return tab.cast(new TenantPage(driver)); } if (tab == UserPage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(menUserManage)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(menUserManage)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", menUserManage()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/user-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/security/user-manage")); return tab.cast(new UserPage(driver)); } if (tab == WorkerGroupPage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(menWorkerGroupManage)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(menWorkerGroupManage)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", menWorkerGroupManage()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/worker-group-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/security/worker-group-manage")); return tab.cast(new WorkerGroupPage(driver)); } if (tab == QueuePage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(menuQueueManage)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(menuQueueManage)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", menuQueueManage()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/yarn-queue-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/security/yarn-queue-manage")); return tab.cast(new QueuePage(driver)); } if (tab == EnvironmentPage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(menuEnvironmentManage)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(menuEnvironmentManage)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", menuEnvironmentManage()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/environment-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/security/environment-manage")); return tab.cast(new EnvironmentPage(driver)); } if (tab == ClusterPage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(menuClusterManage)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(menuClusterManage)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", menuClusterManage()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/cluster-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/security/cluster-manage")); return tab.cast(new ClusterPage(driver)); } if (tab == TokenPage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(menuTokenManage)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(menuTokenManage)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", menuTokenManage()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/token-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/security/token-manage")); return tab.cast(new TokenPage(driver)); } if (tab == NamespacePage.class) { - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(menuNamespaceManage)); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(menuNamespaceManage)); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", menuNamespaceManage()); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.urlContains("/security/k8s-namespace-manage")); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.urlContains("/security/k8s-namespace-manage")); return tab.cast(new NamespacePage(driver)); } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TenantPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TenantPage.java index e6b9f877c15a..d1225bd0bec3 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TenantPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TenantPage.java @@ -19,14 +19,15 @@ package org.apache.dolphinscheduler.e2e.pages.security; -import java.util.stream.Collectors; -import lombok.RequiredArgsConstructor; import org.apache.dolphinscheduler.e2e.models.tenant.ITenant; import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; import java.util.List; +import java.util.stream.Collectors; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; -import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowInstanceTab; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; @@ -36,13 +37,9 @@ import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; -import lombok.Getter; -import org.openqa.selenium.support.pagefactory.ByChained; -import static org.assertj.core.api.Assertions.assertThat; -import static org.testcontainers.shaded.org.awaitility.Awaitility.await; - @Getter public final class TenantPage extends NavBarPage implements SecurityPage.Tab { + @FindBy(className = "btn-create-tenant") private WebElement buttonCreateTenant; @@ -132,6 +129,7 @@ public TenantPage delete(String tenant) { @Getter public class TenantForm { + TenantForm() { PageFactory.initElements(driver, this); } @@ -160,6 +158,7 @@ public class TenantForm { @RequiredArgsConstructor public static class Row { + private final WebElement row; public String tenantCode() { diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TokenPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TokenPage.java index 7be82a840aca..9ba0ceb69da1 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TokenPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/TokenPage.java @@ -23,9 +23,10 @@ import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage.Tab; -import java.time.Duration; import java.util.List; +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; @@ -34,14 +35,12 @@ import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -import lombok.Getter; import com.google.common.base.Strings; @Getter public final class TokenPage extends NavBarPage implements Tab { + @FindBy(className = "btn-create-token") private WebElement buttonCreateToken; @@ -49,8 +48,8 @@ public final class TokenPage extends NavBarPage implements Tab { private List tokenList; @FindBys({ - @FindBy(className = "n-popconfirm__action"), - @FindBy(className = "n-button--primary-type"), + @FindBy(className = "n-popconfirm__action"), + @FindBy(className = "n-button--primary-type"), }) private WebElement buttonConfirm; @@ -70,10 +69,12 @@ public TokenPage(RemoteWebDriver driver) { public TokenPage create(String userName) { buttonCreateToken().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(createTokenForm().selectUserNameDropdown())); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(createTokenForm().selectUserNameDropdown())); createTokenForm().selectUserNameDropdown().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( - "n-base-select-option__content"))); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( + "n-base-select-option__content"))); createTokenForm().selectUserNameList() .stream() .filter(it -> it.getText().contains(userName)) @@ -82,7 +83,8 @@ public TokenPage create(String userName) { userName))) .click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(createTokenForm().buttonGenerateToken())); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(createTokenForm().buttonGenerateToken())); createTokenForm().buttonGenerateToken().click(); createTokenForm().buttonSubmit().click(); @@ -92,16 +94,18 @@ public TokenPage create(String userName) { public TokenPage update(String userName) { tokenList().stream() - .filter(it -> it.findElement(By.className("username")).getAttribute("innerHTML").contains(userName)) - .flatMap(it -> it.findElements(By.className("edit")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No edit button in token list")) - .click(); - - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(editTokenForm().buttonGenerateToken())); + .filter(it -> it.findElement(By.className("username")).getAttribute("innerHTML").contains(userName)) + .flatMap(it -> it.findElements(By.className("edit")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No edit button in token list")) + .click(); + + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(editTokenForm().buttonGenerateToken())); editTokenForm().buttonGenerateToken().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.elementToBeClickable(editTokenForm().buttonGenerateToken())); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.elementToBeClickable(editTokenForm().buttonGenerateToken())); editTokenForm().buttonSubmit().click(); @@ -110,23 +114,23 @@ public TokenPage update(String userName) { public String getToken(String userName) { return tokenList().stream() - .filter(it -> it.findElement(By.className("username")).getAttribute("innerHTML").contains(userName)) - .flatMap(it -> it.findElements(By.className("token")).stream()) - .filter(it -> !Strings.isNullOrEmpty(it.getAttribute("innerHTML"))) - .map(it -> it.getAttribute("innerHTML")) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("No token for such user: " + userName)); + .filter(it -> it.findElement(By.className("username")).getAttribute("innerHTML").contains(userName)) + .flatMap(it -> it.findElements(By.className("token")).stream()) + .filter(it -> !Strings.isNullOrEmpty(it.getAttribute("innerHTML"))) + .map(it -> it.getAttribute("innerHTML")) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("No token for such user: " + userName)); } public TokenPage delete(String userName) { tokenList() - .stream() - .filter(it -> it.getText().contains(userName)) - .flatMap(it -> it.findElements(By.className("delete")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No delete button in token list")) - .click(); + .stream() + .filter(it -> it.getText().contains(userName)) + .flatMap(it -> it.findElements(By.className("delete")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No delete button in token list")) + .click(); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", buttonConfirm()); @@ -135,13 +139,14 @@ public TokenPage delete(String userName) { @Getter public class TokenForm { + TokenForm() { PageFactory.initElements(driver, this); } @FindBys({ - @FindBy(className = "input-username"), - @FindBy(className = "n-base-selection"), + @FindBy(className = "input-username"), + @FindBy(className = "n-base-selection"), }) private WebElement selectUserNameDropdown; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/UserPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/UserPage.java index 1ee52e8a281e..bd6d2d7d4998 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/UserPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/UserPage.java @@ -23,9 +23,10 @@ import org.apache.dolphinscheduler.e2e.models.users.IUser; import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; -import java.time.Duration; import java.util.List; +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; @@ -34,13 +35,11 @@ import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; - -import lombok.Getter; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; @Getter public final class UserPage extends NavBarPage implements SecurityPage.Tab { + @FindBy(className = "btn-create-user") private WebElement buttonCreateUser; @@ -48,15 +47,14 @@ public final class UserPage extends NavBarPage implements SecurityPage.Tab { private List userList; @FindBys({ - @FindBy(className = "n-popconfirm__action"), - @FindBy(className = "n-button--primary-type"), + @FindBy(className = "n-popconfirm__action"), + @FindBy(className = "n-button--primary-type"), }) private WebElement buttonConfirm; private final UserForm createUserForm = new UserForm(); private final UserForm editUserForm = new UserForm(); - public UserPage(RemoteWebDriver driver) { super(driver); } @@ -69,15 +67,16 @@ public UserPage create(String user, String password, String email, String phone, createUserForm().btnSelectTenantDropdown().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( - "n-base-select-option__content"))); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( + "n-base-select-option__content"))); createUserForm().selectTenant() - .stream() - .filter(it -> it.getText().contains(tenant)) - .findFirst() - .orElseThrow(() -> new RuntimeException(String.format("No %s in tenant dropdown list", tenant))) - .click(); + .stream() + .filter(it -> it.getText().contains(tenant)) + .findFirst() + .orElseThrow(() -> new RuntimeException(String.format("No %s in tenant dropdown list", tenant))) + .click(); createUserForm().inputEmail().sendKeys(email); createUserForm().inputPhone().sendKeys(phone); @@ -101,21 +100,22 @@ public UserPage update(String user, String editPhone, String tenant) { userList().stream() - .filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(user)) - .flatMap(it -> it.findElements(By.className("edit")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No edit button in user list")) - .click(); - - editUserForm().inputUserName().sendKeys(Keys.CONTROL+"a"); + .filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(user)) + .flatMap(it -> it.findElements(By.className("edit")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No edit button in user list")) + .click(); + + editUserForm().inputUserName().sendKeys(Keys.CONTROL + "a"); editUserForm().inputUserName().sendKeys(Keys.BACK_SPACE); editUserForm().inputUserName().sendKeys(editUser); createUserForm().btnSelectTenantDropdown().click(); - WebDriverWaitFactory.createWebDriverWait(driver).until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( - "n-base-select-option__content"))); + WebDriverWaitFactory.createWebDriverWait(driver) + .until(ExpectedConditions.visibilityOfElementLocated(new By.ByClassName( + "n-base-select-option__content"))); createUserForm().selectTenant() .stream() @@ -124,11 +124,11 @@ public UserPage update(String user, .orElseThrow(() -> new RuntimeException(String.format("No %s in tenant dropdown list", tenant))) .click(); - editUserForm().inputEmail().sendKeys(Keys.CONTROL+"a"); + editUserForm().inputEmail().sendKeys(Keys.CONTROL + "a"); editUserForm().inputEmail().sendKeys(Keys.BACK_SPACE); editUserForm().inputEmail().sendKeys(editEmail); - editUserForm().inputPhone().sendKeys(Keys.CONTROL+"a"); + editUserForm().inputPhone().sendKeys(Keys.CONTROL + "a"); editUserForm().inputPhone().sendKeys(Keys.BACK_SPACE); editUserForm().inputPhone().sendKeys(editPhone); @@ -139,13 +139,13 @@ public UserPage update(String user, public UserPage delete(String user) { userList() - .stream() - .filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(user)) - .flatMap(it -> it.findElements(By.className("delete")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No delete button in user list")) - .click(); + .stream() + .filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(user)) + .flatMap(it -> it.findElements(By.className("delete")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No delete button in user list")) + .click(); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", buttonConfirm()); @@ -154,25 +154,26 @@ public UserPage delete(String user) { @Getter public class UserForm { + UserForm() { PageFactory.initElements(driver, this); } @FindBys({ - @FindBy(className = "input-username"), - @FindBy(tagName = "input"), + @FindBy(className = "input-username"), + @FindBy(tagName = "input"), }) private WebElement inputUserName; @FindBys({ - @FindBy(className = "input-password"), - @FindBy(tagName = "input"), + @FindBy(className = "input-password"), + @FindBy(tagName = "input"), }) private WebElement inputUserPassword; @FindBys({ - @FindBy(className = "select-tenant"), - @FindBy(className = "n-base-selection"), + @FindBy(className = "select-tenant"), + @FindBy(className = "n-base-selection"), }) private WebElement btnSelectTenantDropdown; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/WorkerGroupPage.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/WorkerGroupPage.java index ced1e5a70948..736db769d9d3 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/WorkerGroupPage.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/security/WorkerGroupPage.java @@ -19,8 +19,12 @@ package org.apache.dolphinscheduler.e2e.pages.security; -import lombok.Getter; import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; + +import java.util.List; + +import lombok.Getter; + import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; @@ -30,11 +34,9 @@ import org.openqa.selenium.support.FindBys; import org.openqa.selenium.support.PageFactory; -import java.util.List; - - @Getter public final class WorkerGroupPage extends NavBarPage implements SecurityPage.Tab { + @FindBy(className = "btn-create-worker-group") private WebElement buttonCreateWorkerGroup; @@ -42,16 +44,14 @@ public final class WorkerGroupPage extends NavBarPage implements SecurityPage.Ta private List workerGroupList; @FindBys({ - @FindBy(className = "n-popconfirm__action"), - @FindBy(className = "n-button--primary-type"), + @FindBy(className = "n-popconfirm__action"), + @FindBy(className = "n-button--primary-type"), }) private WebElement buttonConfirm; private final WorkerGroupForm createWorkerForm = new WorkerGroupForm(); private final WorkerGroupForm editWorkerForm = new WorkerGroupForm(); - - public WorkerGroupPage(RemoteWebDriver driver) { super(driver); } @@ -87,16 +87,15 @@ public WorkerGroupPage update(String workerGroupName, String editWorkerGroupName return this; } - public WorkerGroupPage delete(String Worker) { workerGroupList() - .stream() - .filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(Worker)) - .flatMap(it -> it.findElements(By.className("delete")).stream()) - .filter(WebElement::isDisplayed) - .findFirst() - .orElseThrow(() -> new RuntimeException("No delete button in workerGroup list")) - .click(); + .stream() + .filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(Worker)) + .flatMap(it -> it.findElements(By.className("delete")).stream()) + .filter(WebElement::isDisplayed) + .findFirst() + .orElseThrow(() -> new RuntimeException("No delete button in workerGroup list")) + .click(); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", buttonConfirm()); @@ -105,19 +104,20 @@ public WorkerGroupPage delete(String Worker) { @Getter public class WorkerGroupForm { + WorkerGroupForm() { PageFactory.initElements(driver, this); } @FindBys({ - @FindBy(className = "input-worker-group-name"), - @FindBy(tagName = "input"), + @FindBy(className = "input-worker-group-name"), + @FindBy(tagName = "input"), }) private WebElement inputWorkerGroupName; @FindBys({ - @FindBy(className = "select-worker-address"), - @FindBy(className = "n-base-selection"), + @FindBy(className = "select-worker-address"), + @FindBy(className = "n-base-selection"), }) private WebElement btnSelectWorkerAddress; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/python-task/Dockerfile b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/python-task/Dockerfile new file mode 100644 index 000000000000..92103973f18f --- /dev/null +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/python-task/Dockerfile @@ -0,0 +1,25 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM apache/dolphinscheduler-standalone-server:ci + +RUN apt update \ + && apt install -y software-properties-common \ + && add-apt-repository ppa:deadsnakes/ppa \ + && apt update \ + && apt-get install -y python3.8 libpython3.8-dev python3.8-dev python3.8-distutils \ + && rm -rf /var/lib/apt/lists/* diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/python-task/docker-compose.yaml b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/python-task/docker-compose.yaml new file mode 100644 index 000000000000..3a287cce3dd8 --- /dev/null +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/python-task/docker-compose.yaml @@ -0,0 +1,40 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: "3.8" + +services: + dolphinscheduler: + image: apache/dolphinscheduler-standalone-server:ci-python + build: + context: . + dockerfile: ./Dockerfile + environment: + MASTER_MAX_CPU_LOAD_AVG: 100 + WORKER_TENANT_AUTO_CREATE: 'true' + ports: + - "12345:12345" + networks: + - e2e + healthcheck: + test: [ "CMD", "curl", "http://localhost:12345/dolphinscheduler/actuator/health" ] + interval: 5s + timeout: 5s + retries: 120 + +networks: + e2e: 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 caa3a2b819c4..1eb0fb4bafd6 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,13 +17,14 @@ package org.apache.dolphinscheduler.e2e.core; -import lombok.experimental.UtilityClass; - import java.nio.file.Path; import java.nio.file.Paths; +import lombok.experimental.UtilityClass; + @UtilityClass public final class Constants { + /** * tmp directory path */ @@ -38,4 +39,8 @@ public final class Constants { * chrome download path in selenium/standalone-chrome-debug container */ public static final String SELENIUM_CONTAINER_CHROME_DOWNLOAD_PATH = "/home/seluser/Downloads"; + + public static final String LINE_SEPARATOR = "\n"; + + public static final long DEFAULT_SLEEP_MILLISECONDS = 500; } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinScheduler.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinScheduler.java index 8d49ca3b9112..2feab903d7ee 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinScheduler.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/DolphinScheduler.java @@ -37,5 +37,6 @@ @TestMethodOrder(OrderAnnotation.class) @ExtendWith(DolphinSchedulerExtension.class) public @interface DolphinScheduler { + String[] composeFiles(); } 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 eeadc41e25fd..973af59e12ff 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 @@ -37,6 +37,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; @@ -45,6 +47,7 @@ import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.RemoteWebDriver; import org.testcontainers.Testcontainers; +import org.testcontainers.containers.BindMode; import org.testcontainers.containers.BrowserWebDriverContainer; import org.testcontainers.containers.ComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; @@ -54,10 +57,9 @@ import com.google.common.base.Strings; import com.google.common.net.HostAndPort; -import lombok.extern.slf4j.Slf4j; - @Slf4j final class DolphinSchedulerExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback { + private final boolean LOCAL_MODE = Objects.equals(System.getProperty("local"), "true"); private final boolean M1_CHIP_FLAG = Objects.equals(System.getProperty("m1_chip"), "true"); @@ -97,14 +99,17 @@ public void beforeAll(ExtensionContext context) throws IOException { browser.withAccessToHost(true); } browser.start(); - - driver = new RemoteWebDriver(browser.getSeleniumAddress(), new ChromeOptions()); + ChromeOptions chromeOptions = new ChromeOptions(); + chromeOptions.addArguments("--allow-running-insecure-content"); + chromeOptions.addArguments(String.format("--unsafely-treat-insecure-origin-as-secure=http://%s:%s", + address.getHost(), address.getPort())); + driver = new RemoteWebDriver(browser.getSeleniumAddress(), chromeOptions); driver.manage().timeouts() - .implicitlyWait(Duration.ofSeconds(10)) - .pageLoadTimeout(Duration.ofSeconds(10)); + .implicitlyWait(Duration.ofSeconds(1)) + .pageLoadTimeout(Duration.ofSeconds(5)); driver.manage().window() - .maximize(); + .maximize(); driver.get(new URL("http", address.getHost(), address.getPort(), rootPath).toString()); @@ -112,9 +117,9 @@ public void beforeAll(ExtensionContext context) throws IOException { final Class clazz = context.getRequiredTestClass(); Stream.of(clazz.getDeclaredFields()) - .filter(it -> Modifier.isStatic(it.getModifiers())) - .filter(f -> WebDriver.class.isAssignableFrom(f.getType())) - .forEach(it -> setDriver(clazz, it)); + .filter(it -> Modifier.isStatic(it.getModifiers())) + .filter(f -> WebDriver.class.isAssignableFrom(f.getType())) + .forEach(it -> setDriver(clazz, it)); WebDriverHolder.setWebDriver(driver); } @@ -128,7 +133,8 @@ private void runInDockerContainer(ExtensionContext context) { compose = createDockerCompose(context); compose.start(); - address = HostAndPort.fromParts("host.testcontainers.internal", compose.getServicePort(serviceName, DOCKER_PORT)); + address = + HostAndPort.fromParts("host.testcontainers.internal", compose.getServicePort(serviceName, DOCKER_PORT)); rootPath = "/dolphinscheduler/ui/"; } @@ -139,11 +145,20 @@ private void setBrowserContainerByOsName() { imageName = DockerImageName.parse("seleniarm/standalone-chromium:124.0-chromedriver-124.0") .asCompatibleSubstituteFor("selenium/standalone-chrome"); + if (!Files.exists(Constants.HOST_CHROME_DOWNLOAD_PATH)) { + try { + Files.createDirectories(Constants.HOST_CHROME_DOWNLOAD_PATH); + } catch (IOException e) { + log.error("Failed to create chrome download directory: {}", Constants.HOST_CHROME_DOWNLOAD_PATH); + throw new RuntimeException(e); + } + } + 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) + Constants.SELENIUM_CONTAINER_CHROME_DOWNLOAD_PATH, BindMode.READ_WRITE) .withRecordingMode(RECORD_ALL, record.toFile(), MP4) .withStartupTimeout(Duration.ofSeconds(300)); } else { @@ -151,7 +166,7 @@ private void setBrowserContainerByOsName() { .withCapabilities(new ChromeOptions()) .withCreateContainerCmdModifier(cmd -> cmd.withUser("root")) .withFileSystemBind(Constants.HOST_CHROME_DOWNLOAD_PATH.toFile().getAbsolutePath(), - Constants.SELENIUM_CONTAINER_CHROME_DOWNLOAD_PATH) + Constants.SELENIUM_CONTAINER_CHROME_DOWNLOAD_PATH, BindMode.READ_WRITE) .withRecordingMode(RECORD_ALL, record.toFile(), MP4) .withStartupTimeout(Duration.ofSeconds(300)); } @@ -183,8 +198,8 @@ public void afterAll(ExtensionContext context) { public void beforeEach(ExtensionContext context) { final Object instance = context.getRequiredTestInstance(); Stream.of(instance.getClass().getDeclaredFields()) - .filter(f -> WebDriver.class.isAssignableFrom(f.getType())) - .forEach(it -> setDriver(instance, it)); + .filter(f -> WebDriver.class.isAssignableFrom(f.getType())) + .forEach(it -> setDriver(instance, it)); } private void setDriver(Object object, Field field) { @@ -192,7 +207,7 @@ private void setDriver(Object object, Field field) { field.setAccessible(true); field.set(object, driver); } catch (IllegalAccessException e) { - LOGGER.error("Failed to inject web driver to field: {}", field.getName(), e); + log.error("Failed to inject web driver to field: {}", field.getName(), e); } } @@ -200,23 +215,22 @@ private ComposeContainer createDockerCompose(ExtensionContext context) { final Class clazz = context.getRequiredTestClass(); final DolphinScheduler annotation = clazz.getAnnotation(DolphinScheduler.class); final List files = Stream.of(annotation.composeFiles()) - .map(it -> DolphinScheduler.class.getClassLoader().getResource(it)) - .filter(Objects::nonNull) - .map(URL::getPath) - .map(File::new) - .collect(Collectors.toList()); + .map(it -> DolphinScheduler.class.getClassLoader().getResource(it)) + .filter(Objects::nonNull) + .map(URL::getPath) + .map(File::new) + .collect(Collectors.toList()); - ComposeContainer compose = new ComposeContainer(files) + ComposeContainer compose = new ComposeContainer(files) .withPull(true) .withTailChildContainers(true) .withLocalCompose(true) .withExposedService( serviceName, DOCKER_PORT, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(300))) - .withLogConsumer(serviceName, outputFrame -> LOGGER.info(outputFrame.getUtf8String())) + .withLogConsumer(serviceName, outputFrame -> log.info(outputFrame.getUtf8String())) .waitingFor(serviceName, Wait.forHealthcheck().withStartupTimeout(Duration.ofSeconds(300))); - return compose; } } diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/TestDescription.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/TestDescription.java index 59ef66b7f6ae..fbf277f2a46b 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/TestDescription.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/TestDescription.java @@ -24,12 +24,13 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import org.junit.jupiter.api.extension.ExtensionContext; - import lombok.RequiredArgsConstructor; +import org.junit.jupiter.api.extension.ExtensionContext; + @RequiredArgsConstructor final class TestDescription implements org.testcontainers.lifecycle.TestDescription { + private static final String UNKNOWN_NAME = "unknown"; private final ExtensionContext context; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/WebDriverWaitFactory.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/WebDriverWaitFactory.java index 946fe071abe7..2d9f47eb23a8 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/WebDriverWaitFactory.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-core/src/main/java/org/apache/dolphinscheduler/e2e/core/WebDriverWaitFactory.java @@ -18,6 +18,7 @@ package org.apache.dolphinscheduler.e2e.core; import java.time.Duration; + import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.WebDriverWait; @@ -25,7 +26,7 @@ public class WebDriverWaitFactory { private static final Duration DEFAULT_INTERVAL = Duration.ofMillis(500); - private static final Duration DEFAULT_TIMEOUT = Duration.ofSeconds(60); + private static final Duration DEFAULT_TIMEOUT = Duration.ofSeconds(10); /** * Create a WebDriverWait instance with default timeout 60s and interval 100ms. diff --git a/dolphinscheduler-e2e/lombok.config b/dolphinscheduler-e2e/lombok.config index 0056b8f78b64..cc34fa2311d7 100644 --- a/dolphinscheduler-e2e/lombok.config +++ b/dolphinscheduler-e2e/lombok.config @@ -16,5 +16,5 @@ # lombok.accessors.fluent=true -lombok.log.fieldname=LOGGER +lombok.log.fieldname=log lombok.accessors.fluent=true diff --git a/dolphinscheduler-e2e/pom.xml b/dolphinscheduler-e2e/pom.xml index 67312404869a..3ee8886acb13 100644 --- a/dolphinscheduler-e2e/pom.xml +++ b/dolphinscheduler-e2e/pom.xml @@ -31,18 +31,20 @@ - 8 - 8 + 11 + 11 UTF-8 5.8.1 - 4.13.0 + 4.21.0 1.18.20 3.20.2 1.5.30 1.7.36 2.17.2 31.0.1-jre + 2.22.2 + 1.19.8 @@ -119,7 +121,7 @@ org.testcontainers testcontainers-bom - 1.19.8 + ${testcontainers.version} import pom @@ -131,7 +133,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + ${maven-surefire-plugin.version} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/mapper/JdbcRegistryLockMapper.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/mapper/JdbcRegistryLockMapper.java index 0f529a878670..2d11c90a2414 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/mapper/JdbcRegistryLockMapper.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/mapper/JdbcRegistryLockMapper.java @@ -38,7 +38,7 @@ public interface JdbcRegistryLockMapper extends BaseMapper { @Update({"