#!/usr/bin/env bash # 契约冒烟:对单个引擎实例逐端点断言 /api/Flow/* 的响应,覆盖 27 端点的错误码/空数据路径。 # 用法:./contract-smoke.sh [引擎base,默认 http://127.0.0.1:31000] # # 作为 A/B 对比用(新旧引擎逐字节比对)时,把两个实例分别跑一遍再 diff 输出,例如: # ./contract-smoke.sh http://127.0.0.1:31000 > /tmp/a.txt # ./contract-smoke.sh http://127.0.0.1:31001 > /tmp/b.txt # diff /tmp/a.txt /tmp/b.txt # 已知非契约差异:move 系列参数校验的多字段错误消息 join 顺序(Bean Validation 未定义遍历序, # 调用方 jnpf-flowable 只判 success/code 不解析 msg),A/B diff 时可忽略该行。 set -uo pipefail BASE="${1:-http://127.0.0.1:31000}" J='-H Content-Type:application/json' run() { local d="$1"; shift; printf '%-42s %s\n' "$d" "$(curl -sS --noproxy '*' "$@")"; } run 'task/list 空实例' "$BASE/api/Flow/task/list/nonexistent-id" run 'definition/list' "$BASE/api/Flow/definition/list" run 'instance/get→9003' "$BASE/api/Flow/instance/nonexistent-id" run 'task/fallbacks→9004' "$BASE/api/Flow/task/fallbacks/nonexistent" run 'complete 空校验→9701' -X POST $J -d '{}' "$BASE/api/Flow/task/complete" run 'complete 假id→9004' -X POST $J -d '{"taskId":"nope"}' "$BASE/api/Flow/task/complete" run 'start 假dep→9002' -X POST $J -d '{"deploymentId":"nope"}' "$BASE/api/Flow/instance/start" run 'jump 假实例→9003' -X POST $J -d '{"instanceId":"nope","source":["a"],"target":["b"]}' "$BASE/api/Flow/task/jump" run 'historic 空' "$BASE/api/Flow/task/historic/nonexistent" run 'historic/end 空' "$BASE/api/Flow/task/historic/end/nonexistent" run 'tobe/pass 空' "$BASE/api/Flow/task/tobe/pass/nonexistent" run 'finished/keys→9003' "$BASE/api/Flow/task/finished/keys/nonexistent" run 'definition/structure 空' "$BASE/api/Flow/definition/nonexistent-dep" run 'task/prev→9004' "$BASE/api/Flow/task/prev?taskId=nope" run 'task/next→9004' "$BASE/api/Flow/task/next?taskId=nope" run 'outgoing/flows→9004' "$BASE/api/Flow/task/outgoing/flows?taskId=nope" run 'incoming/flows null' "$BASE/api/Flow/task/incoming/flows/nope" run 'element/info→9002' "$BASE/api/Flow/task/element/info?deploymentId=nope&key=k" run 'flow/target→9002' "$BASE/api/Flow/task/flow/target?deploymentId=nope&flowKey=k" run 'task/after→9002' -X POST $J -d '{"deploymentId":"nope","taskKeys":["a"]}' "$BASE/api/Flow/task/after" run 'back 空校验→9701' -X POST $J -d '{}' "$BASE/api/Flow/task/back" run 'retract 假id→1108' -X POST "$BASE/api/Flow/task/retract/nope" run 'move single 校验→9701' -X POST $J -d '{}' "$BASE/api/Flow/task/move/single/to/multi" run 'move multi 假实例→9003' -X POST $J -d '{"instanceId":"nope","sourceKeys":["a"],"targetKey":"b"}' "$BASE/api/Flow/task/move/multi/to/single" run 'instance/delete→1102' -X DELETE "$BASE/api/Flow/instance?instanceId=nope&deleteReason=t" run 'definition/delete→1102' -X DELETE "$BASE/api/Flow/definition?deploymentId=nope" run 'deploy 空校验→9701' -X POST $J -d '{}' "$BASE/api/Flow/definition/deploy"