刘光辉
昨天 bb638871a7fb692d80f1b7a758f991dc0879002c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
# 完整流程生命周期回归:deploy→start→next→complete→back(JumpCmd 节点跳转)→historic→delete。
# 覆盖契约冒烟测不到的写路径与状态机逻辑(Flowable ChangeActivityState / 自定义跳转命令)。
# 用法:./lifecycle.sh [引擎base,默认 http://127.0.0.1:31000] [标签,默认 LIFECYCLE]
#
# A/B 对比:分别对新旧引擎跑,抽 taskKey/code/name 骨架 diff(时间戳与雪花 id 天然不同):
#   ./lifecycle.sh http://127.0.0.1:31000 A 2>&1 | grep -oE 'taskKey":"[^"]*"|"code":"[0-9]+"|"name":"[^"]*"' > /tmp/a.txt
#   ./lifecycle.sh http://127.0.0.1:31001 B 2>&1 | grep -oE 'taskKey":"[^"]*"|"code":"[0-9]+"|"name":"[^"]*"' > /tmp/b.txt
#   diff /tmp/a.txt /tmp/b.txt   # 应为空 = 语义骨架一致
set -euo pipefail
BASE="${1:-http://127.0.0.1:31000}"
TAG="${2:-LIFECYCLE}"
J='-H Content-Type:application/json'
 
BPMN='<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:flowable="http://flowable.org/bpmn" targetNamespace="test">
  <process id="rebuildTest" name="重建验证流程" isExecutable="true">
    <startEvent id="start"/>
    <sequenceFlow id="f1" sourceRef="start" targetRef="task1"/>
    <userTask id="task1" name="审批一" flowable:assignee="u1"/>
    <sequenceFlow id="f2" sourceRef="task1" targetRef="task2"/>
    <userTask id="task2" name="审批二" flowable:assignee="u2"/>
    <sequenceFlow id="f3" sourceRef="task2" targetRef="end"/>
    <endEvent id="end"/>
  </process>
</definitions>'
BPMN_JSON=$(python3 -c 'import json,sys;print(json.dumps(sys.stdin.read()))' <<< "$BPMN")
pick() { python3 -c "import sys,json;print(json.load(sys.stdin)$1)"; }
C() { curl -sS --noproxy '*' "$@"; }
 
echo "### [$TAG] deploy"
DEP=$(C -X POST $J -d "{\"name\":\"rebuildTest\",\"key\":\"rebuildTest\",\"bpmnXml\":$BPMN_JSON}" "$BASE/api/Flow/definition/deploy"); echo "$DEP"
DEPID=$(echo "$DEP" | pick "['data']['deploymentId']")
 
echo "### [$TAG] start"
INS=$(C -X POST $J -d "{\"deploymentId\":\"$DEPID\"}" "$BASE/api/Flow/instance/start"); echo "$INS"
INSID=$(echo "$INS" | pick "['data']['instanceId']")
 
echo "### [$TAG] task/list(应有 task1=审批一)"
T=$(C "$BASE/api/Flow/task/list/$INSID"); echo "$T"
TID=$(echo "$T" | pick "['data'][0]['taskId']")
 
echo "### [$TAG] next(task1 下一节点应为 task2)"
C "$BASE/api/Flow/task/next?taskId=$TID"; echo
 
echo "### [$TAG] complete task1"
C -X POST $J -d "{\"taskId\":\"$TID\"}" "$BASE/api/Flow/task/complete"; echo
 
echo "### [$TAG] task/list(应流转到 task2=审批二)"
T2=$(C "$BASE/api/Flow/task/list/$INSID"); echo "$T2"
TASKID2=$(echo "$T2" | pick "['data'][0]['taskId']")
 
echo "### [$TAG] back(从 task2 退回 task1,走 JumpCmd)"
C -X POST $J -d "{\"taskId\":\"$TASKID2\",\"targetKey\":\"task1\"}" "$BASE/api/Flow/task/back"; echo
 
echo "### [$TAG] task/list(退回后应回到 task1=审批一)"
C "$BASE/api/Flow/task/list/$INSID"; echo
 
echo "### [$TAG] historic(历史节点)"
C "$BASE/api/Flow/task/historic/$INSID"; echo
 
echo "### [$TAG] cleanup: delete instance + definition"
C -X DELETE "$BASE/api/Flow/instance?instanceId=$INSID&deleteReason=test"; echo
C -X DELETE "$BASE/api/Flow/definition?deploymentId=$DEPID"; echo