Skip to content

Commit 20dc7aa

Browse files
Merge f6f0f25 into bd48c99
2 parents bd48c99 + f6f0f25 commit 20dc7aa

File tree

7 files changed

+264
-2
lines changed

7 files changed

+264
-2
lines changed

.github/workflows/e2e.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ jobs:
108108
class: org.apache.dolphinscheduler.e2e.cases.WorkflowE2ETest
109109
- name: WorkflowHttp
110110
class: org.apache.dolphinscheduler.e2e.cases.WorkflowHttpTaskE2ETest
111+
- name: WorkflowJava
112+
class: org.apache.dolphinscheduler.e2e.cases.WorkflowJavaTaskE2ETest
111113
# - name: WorkflowForSwitch
112114
# class: org.apache.dolphinscheduler.e2e.cases.WorkflowSwitchE2ETest
113115
- name: FileManage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
/*
2+
* Licensed to Apache Software Foundation (ASF) under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Apache Software Foundation (ASF) licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.dolphinscheduler.e2e.cases;
21+
22+
import org.apache.dolphinscheduler.e2e.core.DolphinScheduler;
23+
import org.apache.dolphinscheduler.e2e.pages.LoginPage;
24+
import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage;
25+
import org.apache.dolphinscheduler.e2e.pages.project.ProjectDetailPage;
26+
import org.apache.dolphinscheduler.e2e.pages.project.ProjectPage;
27+
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowDefinitionTab;
28+
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
29+
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowInstanceTab;
30+
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.JavaTaskForm;
31+
import org.apache.dolphinscheduler.e2e.pages.security.EnvironmentPage;
32+
import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage;
33+
import org.apache.dolphinscheduler.e2e.pages.security.TenantPage;
34+
import org.apache.dolphinscheduler.e2e.pages.security.UserPage;
35+
import org.junit.jupiter.api.AfterAll;
36+
import org.junit.jupiter.api.BeforeAll;
37+
import org.junit.jupiter.api.Order;
38+
import org.junit.jupiter.api.Test;
39+
import org.openqa.selenium.By;
40+
import org.openqa.selenium.WebElement;
41+
import org.openqa.selenium.remote.RemoteWebDriver;
42+
import org.openqa.selenium.support.ui.ExpectedConditions;
43+
import org.openqa.selenium.support.ui.WebDriverWait;
44+
import org.testcontainers.shaded.org.awaitility.Awaitility;
45+
46+
import java.time.Duration;
47+
48+
import static org.assertj.core.api.Assertions.assertThat;
49+
50+
@DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml")
51+
public class WorkflowJavaTaskE2ETest {
52+
private static final String project = "test-workflow-1";
53+
54+
private static final String workflow = "test-workflow-1";
55+
56+
private static final String user = "admin";
57+
58+
private static final String password = "dolphinscheduler123";
59+
60+
private static final String email = "[email protected]";
61+
62+
private static final String phone = "15800000000";
63+
64+
private static final String tenant = System.getProperty("user.name");
65+
66+
private static final String environmentName = "JAVA_HOME";
67+
68+
private static final String environmentConfig = "export JAVA_HOME=${JAVA_HOME:-/opt/java/openjdk}";
69+
70+
private static final String environmentDesc = "JAVA_HOME_DESC";
71+
72+
private static final String environmentWorkerGroup = "default";
73+
74+
private static final String javaContent = "public class Test {" +
75+
" public static void main(String[] args) {" +
76+
" System.out.println(\"hello world\");" +
77+
" }" +
78+
"}";
79+
80+
private static RemoteWebDriver browser;
81+
82+
@BeforeAll
83+
public static void setup() {
84+
UserPage userPage = new LoginPage(browser)
85+
.login(user, password)
86+
.goToNav(SecurityPage.class)
87+
.goToTab(TenantPage.class)
88+
.create(tenant)
89+
.goToNav(SecurityPage.class)
90+
.goToTab(EnvironmentPage.class)
91+
.create(environmentName, environmentConfig, environmentDesc, environmentWorkerGroup)
92+
.goToNav(SecurityPage.class)
93+
.goToTab(UserPage.class);
94+
95+
new WebDriverWait(userPage.driver(), Duration.ofSeconds(20)).until(ExpectedConditions.visibilityOfElementLocated(
96+
new By.ByClassName("name")));
97+
98+
userPage.update(user, user, email, phone, tenant)
99+
.goToNav(ProjectPage.class)
100+
.create(project)
101+
;
102+
}
103+
104+
@AfterAll
105+
public static void cleanup() {
106+
new NavBarPage(browser)
107+
.goToNav(ProjectPage.class)
108+
.goTo(project)
109+
.goToTab(WorkflowDefinitionTab.class)
110+
.delete(workflow);
111+
112+
new NavBarPage(browser)
113+
.goToNav(ProjectPage.class)
114+
.delete(project);
115+
116+
browser.navigate().refresh();
117+
118+
new NavBarPage(browser)
119+
.goToNav(SecurityPage.class)
120+
.goToTab(TenantPage.class)
121+
.delete(tenant);
122+
}
123+
124+
125+
126+
@Test
127+
@Order(1)
128+
void testCreateWorkflow() {
129+
WorkflowDefinitionTab workflowDefinitionPage =
130+
new ProjectPage(browser)
131+
.goTo(project)
132+
.goToTab(WorkflowDefinitionTab.class);
133+
134+
workflowDefinitionPage
135+
.createWorkflow()
136+
.<JavaTaskForm> addTask(WorkflowForm.TaskType.JAVA)
137+
.script(javaContent)
138+
.name("test-1")
139+
.addParam("today", "${system.datetime}")
140+
.selectEnv(environmentName)
141+
.submit()
142+
.submit()
143+
.name(workflow)
144+
.addGlobalParam("global_param", "hello world")
145+
.submit()
146+
;
147+
148+
Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList())
149+
.as("Workflow list should contain newly-created workflow")
150+
.anyMatch(
151+
it -> it.getText().contains(workflow)
152+
));
153+
workflowDefinitionPage.publish(workflow);
154+
}
155+
156+
157+
@Test
158+
@Order(30)
159+
void testRunWorkflow() {
160+
final ProjectDetailPage projectPage =
161+
new ProjectPage(browser)
162+
.goToNav(ProjectPage.class)
163+
.goTo(project);
164+
165+
projectPage
166+
.goToTab(WorkflowInstanceTab.class)
167+
.deleteAll();
168+
projectPage
169+
.goToTab(WorkflowDefinitionTab.class)
170+
.run(workflow)
171+
.submit();
172+
173+
Awaitility.await().untilAsserted(() -> {
174+
browser.navigate().refresh();
175+
176+
final WorkflowInstanceTab.Row row = projectPage
177+
.goToTab(WorkflowInstanceTab.class)
178+
.instances()
179+
.iterator()
180+
.next();
181+
182+
assertThat(row.isSuccess()).isTrue();
183+
assertThat(row.executionTime()).isEqualTo(1);
184+
});
185+
}
186+
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.HttpTaskForm;
2323
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.ShellTaskForm;
2424
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.SubWorkflowTaskForm;
25+
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.SwitchTaskForm;
26+
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.JavaTaskForm;
2527

2628
import java.nio.charset.StandardCharsets;
2729
import java.time.Duration;
2830
import java.util.List;
2931
import java.util.concurrent.TimeUnit;
3032

31-
import org.apache.dolphinscheduler.e2e.pages.project.workflow.task.SwitchTaskForm;
3233
import org.openqa.selenium.By;
3334
import org.openqa.selenium.JavascriptExecutor;
3435
import org.openqa.selenium.WebDriver;
@@ -85,6 +86,8 @@ public <T> T addTask(TaskType type) {
8586
return (T) new SwitchTaskForm(this);
8687
case HTTP:
8788
return (T) new HttpTaskForm(this);
89+
case JAVA:
90+
return (T) new JavaTaskForm(this);
8891
}
8992
throw new UnsupportedOperationException("Unknown task type");
9093
}
@@ -121,5 +124,6 @@ public enum TaskType {
121124
SUB_PROCESS,
122125
SWITCH,
123126
HTTP,
127+
JAVA,
124128
}
125129
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
*/
20+
21+
package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
22+
23+
import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
24+
import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
25+
import org.openqa.selenium.WebDriver;
26+
27+
public class JavaTaskForm extends TaskNodeForm{
28+
private CodeEditor codeEditor;
29+
30+
private WebDriver driver;
31+
32+
public JavaTaskForm(WorkflowForm parent) {
33+
super(parent);
34+
35+
this.codeEditor = new CodeEditor(parent.driver());
36+
37+
this.driver = parent.driver();
38+
}
39+
40+
public JavaTaskForm script(String script) {
41+
codeEditor.content(script);
42+
return this;
43+
}
44+
}

dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/TaskNodeForm.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public abstract class TaskNodeForm {
6565
})
6666
private WebElement selectPreTasks;
6767

68+
@FindBys({
69+
@FindBy(className = "env-select"),
70+
@FindBy(className = "n-base-selection"),
71+
})
72+
private WebElement selectEnv;
73+
6874
@FindBys({
6975
@FindBy(className = "btn-custom-parameters"),
7076
@FindBy(tagName = "button"),
@@ -112,6 +118,25 @@ public TaskNodeForm addParam(String key, String value) {
112118
return this;
113119
}
114120

121+
public TaskNodeForm selectEnv(String envName){
122+
((JavascriptExecutor)parent().driver()).executeScript("arguments[0].click();", selectEnv);
123+
124+
final By optionsLocator = By.className("n-base-selection-input__content");
125+
126+
new WebDriverWait(parent.driver(), Duration.ofSeconds(20))
127+
.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
128+
129+
List<WebElement> webElements = parent.driver().findElements(optionsLocator);
130+
131+
webElements.stream()
132+
.filter(it -> it.getText().contains(envName))
133+
.findFirst()
134+
.orElseThrow(() -> new RuntimeException("No such envName: " + envName))
135+
.click();
136+
137+
return this;
138+
}
139+
115140
public TaskNodeForm preTask(String preTaskName) {
116141
((JavascriptExecutor)parent().driver()).executeScript("arguments[0].click();", selectPreTasks);
117142

dolphinscheduler-standalone-server/src/main/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18-
FROM eclipse-temurin:8-jre
18+
FROM eclipse-temurin:8-jdk
1919

2020
ENV DOCKER true
2121
ENV TZ Asia/Shanghai

dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-environment-name.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export function useEnvironmentName(
9393
return {
9494
type: 'select',
9595
field: 'environmentCode',
96+
class: 'env-select',
9697
span: 12,
9798
name: t('project.node.environment_name'),
9899
props: {

0 commit comments

Comments
 (0)