Skip to content

Commit

Permalink
chanage
Browse files Browse the repository at this point in the history
  • Loading branch information
xdu-chenrj committed Oct 18, 2024
1 parent 7a0e835 commit 3bc797e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
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.ShellTaskForm;
import org.apache.dolphinscheduler.e2e.pages.resource.FileManagePage;
import org.apache.dolphinscheduler.e2e.pages.resource.ResourcePage;
import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage;
import org.apache.dolphinscheduler.e2e.pages.security.TenantPage;
import org.apache.dolphinscheduler.e2e.pages.security.UserPage;
Expand Down Expand Up @@ -77,8 +75,8 @@ void testRunShellTasks_SuccessCase() {
.goToTab(WorkflowDefinitionTab.class);

// todo: use yaml to define the workflow
String workflowName = "SuccessCase";
String taskName = "ShellSuccess";
String workflowName = "SslSuccessCase";
String taskName = "SslShellSuccess";
workflowDefinitionPage
.createWorkflow()
.<ShellTaskForm>addTask(WorkflowForm.TaskType.SHELL)
Expand All @@ -103,186 +101,4 @@ void testRunShellTasks_SuccessCase() {
assertThat(taskInstance.retryTimes()).isEqualTo(0);
}

@Test
void testRunShellTasks_WorkflowParamsCase() {
WorkflowDefinitionTab workflowDefinitionPage =
new ProjectPage(browser)
.goToNav(ProjectPage.class)
.goTo(projectName)
.goToTab(WorkflowDefinitionTab.class);

// todo: use yaml to define the workflow
String workflowName = "WorkflowParamsCase";
String taskName = "ShellSuccess";
workflowDefinitionPage
.createWorkflow()
.<ShellTaskForm>addTask(WorkflowForm.TaskType.SHELL)
.script("[ \"${name}\" = \"tom\" ] && echo \"success\" || { echo \"failed\"; exit 1; }")
.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
void testRunShellTasks_LocalParamsCase() {
WorkflowDefinitionTab workflowDefinitionPage =
new ProjectPage(browser)
.goToNav(ProjectPage.class)
.goTo(projectName)
.goToTab(WorkflowDefinitionTab.class);

String workflowName = "LocalParamsCase";
String taskName = "ShellSuccess";
workflowDefinitionPage
.createWorkflow()
.<ShellTaskForm>addTask(WorkflowForm.TaskType.SHELL)
.script("[ \"${name}\" = \"tom\" ] && echo \"success\" || { echo \"failed\"; exit 1; }")
.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
void testRunShellTasks_GlobalParamsOverrideLocalParamsCase() {
WorkflowDefinitionTab workflowDefinitionPage =
new ProjectPage(browser)
.goToNav(ProjectPage.class)
.goTo(projectName)
.goToTab(WorkflowDefinitionTab.class);

String workflowName = "LocalParamsOverrideWorkflowParamsCase";
String taskName = "ShellSuccess";
workflowDefinitionPage
.createWorkflow()
.<ShellTaskForm>addTask(WorkflowForm.TaskType.SHELL)
.script("[ \"${name}\" = \"jerry\" ] && echo \"success\" || { echo \"failed\"; exit 1; }")
.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
void testRunShellTasks_UsingResourceFile() {
String testFileName = "echo";
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 = "UsingResourceFile";
String taskName = "ShellSuccess";
workflowDefinitionPage
.createWorkflow()
.<ShellTaskForm>addTask(WorkflowForm.TaskType.SHELL)
.script("cat " + testFileName + ".sh")
.name(taskName)
.selectResource(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
void testRunShellTasks_FailedCase() {
WorkflowDefinitionTab workflowDefinitionPage =
new ProjectPage(browser)
.goToNav(ProjectPage.class)
.goTo(projectName)
.goToTab(WorkflowDefinitionTab.class);

String workflowName = "FailedCase";
String taskName = "ShellFailed";
workflowDefinitionPage
.createWorkflow()
.<ShellTaskForm>addTask(WorkflowForm.TaskType.SHELL)
.script("echo 'I am failed'\n exit1\n")
.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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ api:
read-timeout: 0
rpc:
ssl:
enabled: false
enabled: true
cert-file-path: /path/cert.crt
key-file-path: /path/private.pem

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ master:
task-thread-pool-usage-weight: 40
rpc:
ssl:
enabled: false
enabled: true
cert-file-path: /path/cert.crt
key-file-path: /path/private.pem

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ worker:
default-tenant-enabled: false
rpc:
ssl:
enabled: false
enabled: true
cert-file-path: /path/cert.crt
key-file-path: /path/private.pem

Expand Down

0 comments on commit 3bc797e

Please sign in to comment.