This is an automated email from the ASF dual-hosted git repository.
xincheng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 4d6af516b9 [Bug][Task Api] fix 'MACPATTERN' in ProcessUtils and cover
all cases on MacOS in ProcessUtilsTest (#15480) (#15529)
4d6af516b9 is described below
commit 4d6af516b9bbc1587318f9a305d82b461c124a30
Author: dada Sun <[email protected]>
AuthorDate: Mon Feb 5 11:41:21 2024 +0800
[Bug][Task Api] fix 'MACPATTERN' in ProcessUtils and cover all cases on
MacOS in ProcessUtilsTest (#15480) (#15529)
Co-authored-by: Rick Cheng <[email protected]>
---
.../apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java | 2 +-
.../dolphinscheduler/plugin/task/api/utils/ProcessUtilsTest.java | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git
a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java
b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java
index 46b8ff4c7b..7b61a1eaec 100644
---
a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java
+++
b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java
@@ -71,7 +71,7 @@ public final class ProcessUtils {
* Initialization regularization, solve the problem of pre-compilation
performance,
* avoid the thread safety problem of multi-thread operation
*/
- private static final Pattern MACPATTERN =
Pattern.compile("-[+|-]-\\s(\\d+)");
+ private static final Pattern MACPATTERN =
Pattern.compile("-[+|-][-|=]\\s(\\d+)");
/**
* Expression of PID recognition in Windows scene
diff --git
a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtilsTest.java
b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtilsTest.java
index ef10e73325..14caf470d7 100644
---
a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtilsTest.java
+++
b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtilsTest.java
@@ -38,6 +38,7 @@ public class ProcessUtilsTest {
String command;
MockedStatic<OSUtils> osUtilsMockedStatic =
Mockito.mockStatic(OSUtils.class);
if (SystemUtils.IS_OS_MAC) {
+ pids = "-+= 6279 sudo -+- 6282 558_1497.sh --- 6354 sleep";
command = String.format("%s -sp %d", TaskConstants.PSTREE,
processId);
} else if (SystemUtils.IS_OS_LINUX) {
command = String.format("%s -p %d", TaskConstants.PSTREE,
processId);
@@ -54,6 +55,7 @@ public class ProcessUtilsTest {
String exceptPidsStr2 = "2000 2100 2101";
String command2;
if (SystemUtils.IS_OS_MAC) {
+ pids2 = "-+= 2000 apache2 -+- 2100 222332-apache2-submit_task.py
--- 2101 apache2";
command2 = String.format("%s -sp %d", TaskConstants.PSTREE,
processId2);
} else if (SystemUtils.IS_OS_LINUX) {
command2 = String.format("%s -p %d", TaskConstants.PSTREE,
processId2);
@@ -70,6 +72,7 @@ public class ProcessUtilsTest {
String exceptPidsStr3 = "5000 6000 7000 7100";
String command3;
if (SystemUtils.IS_OS_MAC) {
+ pids3 = "-+= 5000 sshd -+- 6000 sshd --= 7000 bash --- 7100
python";
command3 = String.format("%s -sp %d", TaskConstants.PSTREE,
processId3);
} else if (SystemUtils.IS_OS_LINUX) {
command3 = String.format("%s -p %d", TaskConstants.PSTREE,
processId3);