Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
DolphinScheduler
提交
c3a98dd9
DolphinScheduler
项目概览
apache
/
DolphinScheduler
上一次同步 1 年多
通知
704
Star
9572
Fork
3514
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
c3a98dd9
编写于
11月 11, 2022
作者:
E
Eric Gao
提交者:
GitHub
11月 11, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[3.0.2-prepare] Fix issues after cherry-pick and run CI (#12808)
上级
206fd003
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
54 addition
and
40 deletion
+54
-40
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
...eduler/api/service/impl/ProcessDefinitionServiceImpl.java
+1
-1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
...cheduler/api/service/impl/ProcessInstanceServiceImpl.java
+9
-1
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
...che/dolphinscheduler/api/service/ExecutorServiceTest.java
+1
-0
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
...inscheduler/api/service/ProcessDefinitionServiceTest.java
+5
-1
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java
...phinscheduler/api/service/ProcessInstanceServiceTest.java
+10
-10
dolphinscheduler-bom/pom.xml
dolphinscheduler-bom/pom.xml
+1
-0
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DateUtilsTest.java
...g/apache/dolphinscheduler/common/utils/DateUtilsTest.java
+21
-21
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java
...apache/dolphinscheduler/dao/entity/ProcessDefinition.java
+2
-2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/WorkflowUtils.java
.../org/apache/dolphinscheduler/dao/utils/WorkflowUtils.java
+1
-1
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/WorkflowUtilsTest.java
.../apache/dolphinscheduler/dao/utils/WorkflowUtilsTest.java
+3
-3
未找到文件。
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
浏览文件 @
c3a98dd9
...
@@ -750,7 +750,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
...
@@ -750,7 +750,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
for
(
ProcessDefinition
process
:
processDefinitionList
)
{
for
(
ProcessDefinition
process
:
processDefinitionList
)
{
try
{
try
{
this
.
deleteProcessDefinitionByCode
(
loginUser
,
process
.
getCode
());
this
.
deleteProcessDefinitionByCode
(
loginUser
,
pro
jectCode
,
pro
cess
.
getCode
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ServiceException
(
Status
.
DELETE_PROCESS_DEFINE_ERROR
,
process
.
getName
(),
e
.
getMessage
());
throw
new
ServiceException
(
Status
.
DELETE_PROCESS_DEFINE_ERROR
,
process
.
getName
(),
e
.
getMessage
());
}
}
...
...
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
浏览文件 @
c3a98dd9
...
@@ -98,12 +98,17 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -98,12 +98,17 @@ import org.springframework.transaction.annotation.Transactional;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
/**
* process instance service impl
* process instance service impl
*/
*/
@Service
@Service
public
class
ProcessInstanceServiceImpl
extends
BaseServiceImpl
implements
ProcessInstanceService
{
public
class
ProcessInstanceServiceImpl
extends
BaseServiceImpl
implements
ProcessInstanceService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ProcessInstanceServiceImpl
.
class
);
public
static
final
String
TASK_TYPE
=
"taskType"
;
public
static
final
String
TASK_TYPE
=
"taskType"
;
public
static
final
String
LOCAL_PARAMS_LIST
=
"localParamsList"
;
public
static
final
String
LOCAL_PARAMS_LIST
=
"localParamsList"
;
...
@@ -679,7 +684,10 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
...
@@ -679,7 +684,10 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
ProcessInstance
processInstance
=
processInstanceMapper
.
queryDetailById
(
processInstanceId
);
ProcessInstance
processInstance
=
processInstanceMapper
.
queryDetailById
(
processInstanceId
);
if
(
processInstance
==
null
)
{
if
(
processInstance
==
null
)
{
throw
new
RuntimeException
(
"workflow instance is null"
);
logger
.
error
(
"Process instance does not exist, projectCode:{}, processInstanceId:{}."
,
projectCode
,
processInstanceId
);
putMsg
(
result
,
Status
.
PROCESS_INSTANCE_NOT_EXIST
,
processInstanceId
);
return
result
;
}
}
ProcessDefinition
processDefinition
=
processDefineMapper
.
queryByCode
(
processInstance
.
getProcessDefinitionCode
());
ProcessDefinition
processDefinition
=
processDefineMapper
.
queryByCode
(
processInstance
.
getProcessDefinitionCode
());
...
...
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
浏览文件 @
c3a98dd9
...
@@ -59,6 +59,7 @@ import java.util.Map;
...
@@ -59,6 +59,7 @@ import java.util.Map;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.InjectMocks
;
...
...
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
浏览文件 @
c3a98dd9
...
@@ -722,12 +722,16 @@ public class ProcessDefinitionServiceTest {
...
@@ -722,12 +722,16 @@ public class ProcessDefinitionServiceTest {
Mockito
.
when
(
dataSourceMapper
.
queryDataSourceByNameAndUserId
(
userId
,
"mysql_1"
)).
thenReturn
(
dataSource
);
Mockito
.
when
(
dataSourceMapper
.
queryDataSourceByNameAndUserId
(
userId
,
"mysql_1"
)).
thenReturn
(
dataSource
);
long
projectCode
=
1001
;
long
projectCode
=
1001
;
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
Constants
.
STATUS
,
Status
.
SUCCESS
);
Mockito
.
when
(
projectMapper
.
queryByCode
(
projectCode
)).
thenReturn
(
getProject
(
projectCode
));
Mockito
.
when
(
projectService
.
checkProjectAndAuth
(
loginUser
,
getProject
(
projectCode
),
projectCode
)).
thenReturn
(
result
);
Mockito
.
when
(
processService
.
saveTaskDefine
(
Mockito
.
same
(
loginUser
),
Mockito
.
eq
(
projectCode
),
Mockito
.
notNull
(),
Mockito
.
anyBoolean
())).
thenReturn
(
2
);
Mockito
.
when
(
processService
.
saveTaskDefine
(
Mockito
.
same
(
loginUser
),
Mockito
.
eq
(
projectCode
),
Mockito
.
notNull
(),
Mockito
.
anyBoolean
())).
thenReturn
(
2
);
Mockito
.
when
(
processService
.
saveProcessDefine
(
Mockito
.
same
(
loginUser
),
Mockito
.
notNull
(),
Mockito
.
notNull
(),
Mockito
.
anyBoolean
())).
thenReturn
(
1
);
Mockito
.
when
(
processService
.
saveProcessDefine
(
Mockito
.
same
(
loginUser
),
Mockito
.
notNull
(),
Mockito
.
notNull
(),
Mockito
.
anyBoolean
())).
thenReturn
(
1
);
Mockito
.
when
(
processService
.
saveTaskRelation
(
Mockito
.
same
(
loginUser
),
Mockito
.
eq
(
projectCode
),
Mockito
.
anyLong
(),
Mockito
.
when
(
processService
.
saveTaskRelation
(
Mockito
.
same
(
loginUser
),
Mockito
.
eq
(
projectCode
),
Mockito
.
anyLong
(),
Mockito
.
eq
(
1
),
Mockito
.
notNull
(),
Mockito
.
notNull
(),
Mockito
.
anyBoolean
())).
thenReturn
(
0
);
Mockito
.
eq
(
1
),
Mockito
.
notNull
(),
Mockito
.
notNull
(),
Mockito
.
anyBoolean
())).
thenReturn
(
0
);
Map
<
String
,
Object
>
result
=
processDefinitionService
.
importSqlProcessDefinition
(
loginUser
,
projectCode
,
mockMultipartFile
);
result
=
processDefinitionService
.
importSqlProcessDefinition
(
loginUser
,
projectCode
,
mockMultipartFile
);
Assert
.
assertEquals
(
result
.
get
(
Constants
.
STATUS
),
Status
.
SUCCESS
);
Assert
.
assertEquals
(
result
.
get
(
Constants
.
STATUS
),
Status
.
SUCCESS
);
}
}
...
...
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java
浏览文件 @
c3a98dd9
...
@@ -201,7 +201,7 @@ public class ProcessInstanceServiceTest {
...
@@ -201,7 +201,7 @@ public class ProcessInstanceServiceTest {
Result
successRes
=
processInstanceService
.
queryProcessInstanceList
(
loginUser
,
projectCode
,
1
,
"2020-01-01 00:00:00"
,
Result
successRes
=
processInstanceService
.
queryProcessInstanceList
(
loginUser
,
projectCode
,
1
,
"2020-01-01 00:00:00"
,
"2020-01-02 00:00:00"
,
""
,
loginUser
.
getUserName
(),
ExecutionStatus
.
SUBMITTED_SUCCESS
,
"2020-01-02 00:00:00"
,
""
,
loginUser
.
getUserName
(),
ExecutionStatus
.
SUBMITTED_SUCCESS
,
"192.168.xx.xx"
,
1
,
10
);
"192.168.xx.xx"
,
1
,
10
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
(
int
)
successRes
.
getCode
());
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
(
int
)
successRes
.
getCode
());
// data parameter empty
// data parameter empty
when
(
processInstanceMapper
.
queryProcessInstanceListPaging
(
Mockito
.
any
(
Page
.
class
),
eq
(
project
.
getCode
()),
eq
(
1L
),
eq
(
""
),
eq
(-
1
),
Mockito
.
any
(),
when
(
processInstanceMapper
.
queryProcessInstanceListPaging
(
Mockito
.
any
(
Page
.
class
),
eq
(
project
.
getCode
()),
eq
(
1L
),
eq
(
""
),
eq
(-
1
),
Mockito
.
any
(),
...
@@ -209,7 +209,7 @@ public class ProcessInstanceServiceTest {
...
@@ -209,7 +209,7 @@ public class ProcessInstanceServiceTest {
successRes
=
processInstanceService
.
queryProcessInstanceList
(
loginUser
,
projectCode
,
1
,
""
,
successRes
=
processInstanceService
.
queryProcessInstanceList
(
loginUser
,
projectCode
,
1
,
""
,
""
,
""
,
loginUser
.
getUserName
(),
ExecutionStatus
.
SUBMITTED_SUCCESS
,
""
,
""
,
loginUser
.
getUserName
(),
ExecutionStatus
.
SUBMITTED_SUCCESS
,
"192.168.xx.xx"
,
1
,
10
);
"192.168.xx.xx"
,
1
,
10
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
(
int
)
successRes
.
getCode
());
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
(
int
)
successRes
.
getCode
());
//executor null
//executor null
when
(
usersService
.
queryUser
(
loginUser
.
getId
())).
thenReturn
(
null
);
when
(
usersService
.
queryUser
(
loginUser
.
getId
())).
thenReturn
(
null
);
...
@@ -218,7 +218,7 @@ public class ProcessInstanceServiceTest {
...
@@ -218,7 +218,7 @@ public class ProcessInstanceServiceTest {
"2020-01-02 00:00:00"
,
""
,
"admin"
,
ExecutionStatus
.
SUBMITTED_SUCCESS
,
"2020-01-02 00:00:00"
,
""
,
"admin"
,
ExecutionStatus
.
SUBMITTED_SUCCESS
,
"192.168.xx.xx"
,
1
,
10
);
"192.168.xx.xx"
,
1
,
10
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
(
int
)
executorExistRes
.
getCode
());
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
(
int
)
executorExistRes
.
getCode
());
//executor name empty
//executor name empty
when
(
processInstanceMapper
.
queryProcessInstanceListPaging
(
Mockito
.
any
(
Page
.
class
),
eq
(
project
.
getCode
()),
eq
(
1L
),
eq
(
""
),
eq
(
0
),
Mockito
.
any
(),
when
(
processInstanceMapper
.
queryProcessInstanceListPaging
(
Mockito
.
any
(
Page
.
class
),
eq
(
project
.
getCode
()),
eq
(
1L
),
eq
(
""
),
eq
(
0
),
Mockito
.
any
(),
...
@@ -226,7 +226,7 @@ public class ProcessInstanceServiceTest {
...
@@ -226,7 +226,7 @@ public class ProcessInstanceServiceTest {
Result
executorEmptyRes
=
processInstanceService
.
queryProcessInstanceList
(
loginUser
,
projectCode
,
1
,
"2020-01-01 00:00:00"
,
Result
executorEmptyRes
=
processInstanceService
.
queryProcessInstanceList
(
loginUser
,
projectCode
,
1
,
"2020-01-01 00:00:00"
,
"2020-01-02 00:00:00"
,
""
,
""
,
ExecutionStatus
.
SUBMITTED_SUCCESS
,
"2020-01-02 00:00:00"
,
""
,
""
,
ExecutionStatus
.
SUBMITTED_SUCCESS
,
"192.168.xx.xx"
,
1
,
10
);
"192.168.xx.xx"
,
1
,
10
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
(
int
)
executorEmptyRes
.
getCode
());
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
(
int
)
executorEmptyRes
.
getCode
());
}
}
...
@@ -299,7 +299,7 @@ public class ProcessInstanceServiceTest {
...
@@ -299,7 +299,7 @@ public class ProcessInstanceServiceTest {
Assert
.
assertEquals
(
Status
.
SUCCESS
,
workerExistRes
.
get
(
Constants
.
STATUS
));
Assert
.
assertEquals
(
Status
.
SUCCESS
,
workerExistRes
.
get
(
Constants
.
STATUS
));
when
(
processService
.
findProcessDefinition
(
processInstance
.
getProcessDefinitionCode
(),
when
(
processService
.
findProcessDefinition
(
processInstance
.
getProcessDefinitionCode
(),
processInstance
.
getProcessDefinitionVersion
())).
thenReturn
(
null
);
;
processInstance
.
getProcessDefinitionVersion
())).
thenReturn
(
null
);
workerExistRes
=
processInstanceService
.
queryProcessInstanceById
(
loginUser
,
projectCode
,
1
);
workerExistRes
=
processInstanceService
.
queryProcessInstanceById
(
loginUser
,
projectCode
,
1
);
Assert
.
assertEquals
(
Status
.
PROCESS_DEFINE_NOT_EXIST
,
workerExistRes
.
get
(
Constants
.
STATUS
));
Assert
.
assertEquals
(
Status
.
PROCESS_DEFINE_NOT_EXIST
,
workerExistRes
.
get
(
Constants
.
STATUS
));
}
}
...
@@ -430,7 +430,7 @@ public class ProcessInstanceServiceTest {
...
@@ -430,7 +430,7 @@ public class ProcessInstanceServiceTest {
when
(
projectService
.
checkProjectAndAuth
(
loginUser
,
project
,
projectCode
)).
thenReturn
(
result
);
when
(
projectService
.
checkProjectAndAuth
(
loginUser
,
project
,
projectCode
)).
thenReturn
(
result
);
when
(
processService
.
findProcessInstanceDetailById
(
1
)).
thenReturn
(
null
);
when
(
processService
.
findProcessInstanceDetailById
(
1
)).
thenReturn
(
null
);
Map
<
String
,
Object
>
processInstanceNullRes
=
processInstanceService
.
updateProcessInstance
(
loginUser
,
projectCode
,
1
,
Map
<
String
,
Object
>
processInstanceNullRes
=
processInstanceService
.
updateProcessInstance
(
loginUser
,
projectCode
,
1
,
shellJson
,
taskJson
,
"2020-02-21 00:00:00"
,
true
,
""
,
""
,
0
,
""
);
shellJson
,
taskJson
,
"2020-02-21 00:00:00"
,
true
,
""
,
""
,
0
,
""
);
Assert
.
assertEquals
(
Status
.
PROCESS_INSTANCE_NOT_EXIST
,
processInstanceNullRes
.
get
(
Constants
.
STATUS
));
Assert
.
assertEquals
(
Status
.
PROCESS_INSTANCE_NOT_EXIST
,
processInstanceNullRes
.
get
(
Constants
.
STATUS
));
//process instance not finish
//process instance not finish
...
@@ -438,7 +438,7 @@ public class ProcessInstanceServiceTest {
...
@@ -438,7 +438,7 @@ public class ProcessInstanceServiceTest {
processInstance
.
setState
(
ExecutionStatus
.
RUNNING_EXECUTION
);
processInstance
.
setState
(
ExecutionStatus
.
RUNNING_EXECUTION
);
putMsg
(
result
,
Status
.
SUCCESS
,
projectCode
);
putMsg
(
result
,
Status
.
SUCCESS
,
projectCode
);
Map
<
String
,
Object
>
processInstanceNotFinishRes
=
processInstanceService
.
updateProcessInstance
(
loginUser
,
projectCode
,
1
,
Map
<
String
,
Object
>
processInstanceNotFinishRes
=
processInstanceService
.
updateProcessInstance
(
loginUser
,
projectCode
,
1
,
shellJson
,
taskJson
,
"2020-02-21 00:00:00"
,
true
,
""
,
""
,
0
,
""
);
shellJson
,
taskJson
,
"2020-02-21 00:00:00"
,
true
,
""
,
""
,
0
,
""
);
Assert
.
assertEquals
(
Status
.
PROCESS_INSTANCE_STATE_OPERATION_ERROR
,
processInstanceNotFinishRes
.
get
(
Constants
.
STATUS
));
Assert
.
assertEquals
(
Status
.
PROCESS_INSTANCE_STATE_OPERATION_ERROR
,
processInstanceNotFinishRes
.
get
(
Constants
.
STATUS
));
//process instance finish
//process instance finish
...
@@ -463,7 +463,7 @@ public class ProcessInstanceServiceTest {
...
@@ -463,7 +463,7 @@ public class ProcessInstanceServiceTest {
putMsg
(
result
,
Status
.
SUCCESS
,
projectCode
);
putMsg
(
result
,
Status
.
SUCCESS
,
projectCode
);
when
(
taskPluginManager
.
checkTaskParameters
(
Mockito
.
any
())).
thenReturn
(
true
);
when
(
taskPluginManager
.
checkTaskParameters
(
Mockito
.
any
())).
thenReturn
(
true
);
Map
<
String
,
Object
>
processInstanceFinishRes
=
processInstanceService
.
updateProcessInstance
(
loginUser
,
projectCode
,
1
,
Map
<
String
,
Object
>
processInstanceFinishRes
=
processInstanceService
.
updateProcessInstance
(
loginUser
,
projectCode
,
1
,
taskRelationJson
,
taskDefinitionJson
,
"2020-02-21 00:00:00"
,
true
,
""
,
""
,
0
,
"root"
);
taskRelationJson
,
taskDefinitionJson
,
"2020-02-21 00:00:00"
,
true
,
""
,
""
,
0
,
"root"
);
Assert
.
assertEquals
(
Status
.
SUCCESS
,
processInstanceFinishRes
.
get
(
Constants
.
STATUS
));
Assert
.
assertEquals
(
Status
.
SUCCESS
,
processInstanceFinishRes
.
get
(
Constants
.
STATUS
));
//success
//success
...
@@ -472,7 +472,7 @@ public class ProcessInstanceServiceTest {
...
@@ -472,7 +472,7 @@ public class ProcessInstanceServiceTest {
when
(
processService
.
saveProcessDefine
(
loginUser
,
processDefinition
,
Boolean
.
FALSE
,
Boolean
.
FALSE
)).
thenReturn
(
1
);
when
(
processService
.
saveProcessDefine
(
loginUser
,
processDefinition
,
Boolean
.
FALSE
,
Boolean
.
FALSE
)).
thenReturn
(
1
);
Map
<
String
,
Object
>
successRes
=
processInstanceService
.
updateProcessInstance
(
loginUser
,
projectCode
,
1
,
Map
<
String
,
Object
>
successRes
=
processInstanceService
.
updateProcessInstance
(
loginUser
,
projectCode
,
1
,
taskRelationJson
,
taskDefinitionJson
,
"2020-02-21 00:00:00"
,
Boolean
.
FALSE
,
""
,
""
,
0
,
"root"
);
taskRelationJson
,
taskDefinitionJson
,
"2020-02-21 00:00:00"
,
Boolean
.
FALSE
,
""
,
""
,
0
,
"root"
);
Assert
.
assertEquals
(
Status
.
SUCCESS
,
successRes
.
get
(
Constants
.
STATUS
));
Assert
.
assertEquals
(
Status
.
SUCCESS
,
successRes
.
get
(
Constants
.
STATUS
));
}
}
...
@@ -542,7 +542,7 @@ public class ProcessInstanceServiceTest {
...
@@ -542,7 +542,7 @@ public class ProcessInstanceServiceTest {
processInstance
.
setScheduleTime
(
new
Date
());
processInstance
.
setScheduleTime
(
new
Date
());
processInstance
.
setGlobalParams
(
""
);
processInstance
.
setGlobalParams
(
""
);
when
(
processInstanceMapper
.
queryDetailById
(
1
)).
thenReturn
(
processInstance
);
when
(
processInstanceMapper
.
queryDetailById
(
1
)).
thenReturn
(
processInstance
);
Map
<
String
,
Object
>
successRes
=
processInstanceService
.
viewVariables
(
1L
,
1
);
Map
<
String
,
Object
>
successRes
=
processInstanceService
.
viewVariables
(
1L
,
1
);
Assert
.
assertEquals
(
Status
.
SUCCESS
,
successRes
.
get
(
Constants
.
STATUS
));
Assert
.
assertEquals
(
Status
.
SUCCESS
,
successRes
.
get
(
Constants
.
STATUS
));
when
(
processInstanceMapper
.
queryDetailById
(
1
)).
thenReturn
(
null
);
when
(
processInstanceMapper
.
queryDetailById
(
1
)).
thenReturn
(
null
);
...
...
dolphinscheduler-bom/pom.xml
浏览文件 @
c3a98dd9
...
@@ -87,6 +87,7 @@
...
@@ -87,6 +87,7 @@
<hibernate-validator.version>
6.2.2.Final
</hibernate-validator.version>
<hibernate-validator.version>
6.2.2.Final
</hibernate-validator.version>
<aws-sdk.version>
1.12.160
</aws-sdk.version>
<aws-sdk.version>
1.12.160
</aws-sdk.version>
<joda-time.version>
2.10.13
</joda-time.version>
<joda-time.version>
2.10.13
</joda-time.version>
<gson.version>
2.9.1
</gson.version>
</properties>
</properties>
...
...
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DateUtilsTest.java
浏览文件 @
c3a98dd9
...
@@ -171,50 +171,50 @@ public class DateUtilsTest {
...
@@ -171,50 +171,50 @@ public class DateUtilsTest {
public
void
testFormat2Duration
()
{
public
void
testFormat2Duration
()
{
// days hours minutes seconds
// days hours minutes seconds
Date
d1
=
DateUtils
.
stringToDate
(
"2020-01-20 11:00:00"
);
Date
start
=
DateUtils
.
stringToDate
(
"2020-01-20 11:00:00"
);
Date
d2
=
DateUtils
.
stringToDate
(
"2020-01-21 12:10:10"
);
Date
end
=
DateUtils
.
stringToDate
(
"2020-01-21 12:10:10"
);
String
duration
=
DateUtils
.
format2Duration
(
d2
,
d1
);
String
duration
=
DateUtils
.
format2Duration
(
start
,
end
);
Assert
.
assertEquals
(
"1d 1h 10m 10s"
,
duration
);
Assert
.
assertEquals
(
"1d 1h 10m 10s"
,
duration
);
duration
=
DateUtils
.
format2Duration
(
d2
,
d1
);
duration
=
DateUtils
.
format2Duration
(
end
,
start
);
Assert
.
assertNull
(
duration
);
Assert
.
assertNull
(
duration
);
// hours minutes seconds
// hours minutes seconds
d1
=
DateUtils
.
stringToDate
(
"2020-01-20 11:00:00"
);
start
=
DateUtils
.
stringToDate
(
"2020-01-20 11:00:00"
);
d2
=
DateUtils
.
stringToDate
(
"2020-01-20 12:10:10"
);
end
=
DateUtils
.
stringToDate
(
"2020-01-20 12:10:10"
);
duration
=
DateUtils
.
format2Duration
(
d2
,
d1
);
duration
=
DateUtils
.
format2Duration
(
start
,
end
);
Assert
.
assertEquals
(
"1h 10m 10s"
,
duration
);
Assert
.
assertEquals
(
"1h 10m 10s"
,
duration
);
// minutes seconds
// minutes seconds
d1
=
DateUtils
.
stringToDate
(
"2020-01-20 11:00:00"
);
start
=
DateUtils
.
stringToDate
(
"2020-01-20 11:00:00"
);
d2
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:10"
);
end
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:10"
);
duration
=
DateUtils
.
format2Duration
(
d2
,
d1
);
duration
=
DateUtils
.
format2Duration
(
start
,
end
);
Assert
.
assertEquals
(
"10m 10s"
,
duration
);
Assert
.
assertEquals
(
"10m 10s"
,
duration
);
// minutes seconds
// minutes seconds
d1
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:00"
);
start
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:00"
);
d2
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:10"
);
end
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:10"
);
duration
=
DateUtils
.
format2Duration
(
d2
,
d1
);
duration
=
DateUtils
.
format2Duration
(
start
,
end
);
Assert
.
assertEquals
(
"10s"
,
duration
);
Assert
.
assertEquals
(
"10s"
,
duration
);
d1
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:00"
);
start
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:00"
);
d2
=
DateUtils
.
stringToDate
(
"2020-01-21 11:10:10"
);
end
=
DateUtils
.
stringToDate
(
"2020-01-21 11:10:10"
);
duration
=
DateUtils
.
format2Duration
(
d2
,
d1
);
duration
=
DateUtils
.
format2Duration
(
start
,
end
);
Assert
.
assertEquals
(
"1d 10s"
,
duration
);
Assert
.
assertEquals
(
"1d 10s"
,
duration
);
d1
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:00"
);
start
=
DateUtils
.
stringToDate
(
"2020-01-20 11:10:00"
);
d2
=
DateUtils
.
stringToDate
(
"2020-01-20 16:10:10"
);
end
=
DateUtils
.
stringToDate
(
"2020-01-20 16:10:10"
);
duration
=
DateUtils
.
format2Duration
(
d2
,
d1
);
duration
=
DateUtils
.
format2Duration
(
start
,
end
);
Assert
.
assertEquals
(
"5h 10s"
,
duration
);
Assert
.
assertEquals
(
"5h 10s"
,
duration
);
}
}
@Test
@Test
public
void
testNullDuration
()
{
public
void
durationShouldNotBeNullWhenOnlyEndDateIsNull
()
{
// days hours minutes seconds
// days hours minutes seconds
Date
d1
=
DateUtils
.
stringToDate
(
"2020-01-20 11:00:00"
);
Date
d1
=
DateUtils
.
stringToDate
(
"2020-01-20 11:00:00"
);
Date
d2
=
null
;
Date
d2
=
null
;
Assert
.
assertNull
(
DateUtils
.
format2Duration
(
d1
,
d2
));
Assert
.
assertN
otN
ull
(
DateUtils
.
format2Duration
(
d1
,
d2
));
}
}
@Test
@Test
...
...
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java
浏览文件 @
c3a98dd9
...
@@ -393,11 +393,11 @@ public class ProcessDefinition {
...
@@ -393,11 +393,11 @@ public class ProcessDefinition {
this
.
projectCode
=
projectCode
;
this
.
projectCode
=
projectCode
;
}
}
public
int
getWarningGroupId
()
{
public
Integer
getWarningGroupId
()
{
return
warningGroupId
;
return
warningGroupId
;
}
}
public
void
setWarningGroupId
(
int
warningGroupId
)
{
public
void
setWarningGroupId
(
Integer
warningGroupId
)
{
this
.
warningGroupId
=
warningGroupId
;
this
.
warningGroupId
=
warningGroupId
;
}
}
...
...
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/WorkflowUtils.java
浏览文件 @
c3a98dd9
...
@@ -34,7 +34,7 @@ public class WorkflowUtils {
...
@@ -34,7 +34,7 @@ public class WorkflowUtils {
* @return workflow duration
* @return workflow duration
*/
*/
public
static
String
getWorkflowInstanceDuration
(
ProcessInstance
processInstance
)
{
public
static
String
getWorkflowInstanceDuration
(
ProcessInstance
processInstance
)
{
return
processInstance
.
getState
()
!=
null
&&
processInstance
.
getState
().
i
sFinished
()
?
return
processInstance
.
getState
()
!=
null
&&
processInstance
.
getState
().
typeI
sFinished
()
?
DateUtils
.
format2Duration
(
processInstance
.
getStartTime
(),
processInstance
.
getEndTime
())
:
DateUtils
.
format2Duration
(
processInstance
.
getStartTime
(),
processInstance
.
getEndTime
())
:
DateUtils
.
format2Duration
(
processInstance
.
getStartTime
(),
new
Date
());
DateUtils
.
format2Duration
(
processInstance
.
getStartTime
(),
new
Date
());
}
}
...
...
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/WorkflowUtilsTest.java
浏览文件 @
c3a98dd9
...
@@ -18,9 +18,9 @@
...
@@ -18,9 +18,9 @@
package
org.apache.dolphinscheduler.dao.utils
;
package
org.apache.dolphinscheduler.dao.utils
;
import
java.util.Date
;
import
java.util.Date
;
import
org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus
;
import
org.apache.dolphinscheduler.common.utils.DateUtils
;
import
org.apache.dolphinscheduler.common.utils.DateUtils
;
import
org.apache.dolphinscheduler.dao.entity.ProcessInstance
;
import
org.apache.dolphinscheduler.dao.entity.ProcessInstance
;
import
org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -40,11 +40,11 @@ class WorkflowUtilsTest {
...
@@ -40,11 +40,11 @@ class WorkflowUtilsTest {
System
.
currentTimeMillis
();
System
.
currentTimeMillis
();
Assertions
.
assertNotEquals
(
"1d 1h 10m 10s"
,
noStateDuration
);
Assertions
.
assertNotEquals
(
"1d 1h 10m 10s"
,
noStateDuration
);
processInstance
.
setState
(
Workflow
ExecutionStatus
.
RUNNING_EXECUTION
);
processInstance
.
setState
(
ExecutionStatus
.
RUNNING_EXECUTION
);
String
notFinishDuration
=
WorkflowUtils
.
getWorkflowInstanceDuration
(
processInstance
);
String
notFinishDuration
=
WorkflowUtils
.
getWorkflowInstanceDuration
(
processInstance
);
Assertions
.
assertNotEquals
(
"1d 1h 10m 10s"
,
notFinishDuration
);
Assertions
.
assertNotEquals
(
"1d 1h 10m 10s"
,
notFinishDuration
);
processInstance
.
setState
(
Workflow
ExecutionStatus
.
SUCCESS
);
processInstance
.
setState
(
ExecutionStatus
.
SUCCESS
);
String
successDuration
=
WorkflowUtils
.
getWorkflowInstanceDuration
(
processInstance
);
String
successDuration
=
WorkflowUtils
.
getWorkflowInstanceDuration
(
processInstance
);
Assertions
.
assertEquals
(
"1d 1h 10m 10s"
,
successDuration
);
Assertions
.
assertEquals
(
"1d 1h 10m 10s"
,
successDuration
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录