Files
leleka/control-plane/tests/fixtures/mock_engine.sh
T
Pavlo Ratushnyi 4013e0c9bd
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
Import tracked Strata Next source snapshot
2026-10-05 18:15:08 +02:00

127 lines
3.1 KiB
Bash
Executable File

#!/bin/sh
if [ "$1" != "--serve" ]; then
exit 2
fi
case "$2" in
ready)
printf 'INFO engine=mock\nREADY 262144 stop\n'
while IFS= read -r line; do
if [ "$line" = QUIT ]; then
exit 0
fi
done
;;
crash)
printf 'READY 262144 stop\n'
exit 7
;;
slow)
sleep 2
;;
exchange)
printf 'READY 262144 stop\n'
while IFS= read -r line; do
case "$line" in
'GEN 3 temperature=0.5 top_p=0.9 10,20')
printf 'RESUME 0\nPP 2 2 1 2.0\nREUSED 0\nT 31\nT 32\nDONE 2 2 1.0 2.0 stop 0 0 0 0 0 0 0 0.0\n'
;;
QUIT) exit 0 ;;
*) printf 'ERR unexpected request\n' ;;
esac
done
;;
blocked-input)
printf 'READY 262144 stop\n'
exec sleep 30
;;
flood)
printf 'READY 262144 stop\n'
IFS= read -r line || exit 3
while :; do printf 'T 31\n'; done
;;
cancel)
printf 'READY 262144 stop\n'
while IFS= read -r line; do
case "$line" in
'GEN 3 10,20')
: > "$3"
printf 'T 31\n'
IFS= read -r stop || exit 3
[ "$stop" = STOP ] || exit 4
printf 'DONE 1 2 1.0 2.0 cancel\n'
;;
'GEN 1 99')
printf 'T 42\nDONE 1 1 1.0 2.0 stop\n'
;;
QUIT) exit 0 ;;
*) printf 'ERR unexpected request\n' ;;
esac
done
;;
cancel-drain)
printf 'READY 262144 stop\n'
IFS= read -r line || exit 3
printf 'T 31\n'
IFS= read -r line || exit 3
[ "$line" = STOP ] || exit 4
: > "$3/stopped"
while [ ! -e "$3/release" ]; do sleep 0.01; done
printf 'DONE 1 2 1.0 2.0 cancel\n'
while IFS= read -r line; do
[ "$line" = QUIT ] && exit 0
done
;;
cancel-stall)
printf 'READY 262144 stop\n'
IFS= read -r line || exit 3
[ "$line" = 'GEN 3 10,20' ] || exit 4
printf 'T 31\n'
IFS= read -r stop || exit 3
[ "$stop" = STOP ] || exit 4
: > "$3"
printf 'T 32\nPP 2 2 1 2.0\n'
# Consume STOP but never report DONE. A following GEN would demonstrate
# unsafe reuse of this still-active generation.
while IFS= read -r line; do
case "$line" in
'GEN 1 99') printf 'T 42\nDONE 1 1 1.0 2.0 stop\n' ;;
QUIT) exit 0 ;;
esac
done
;;
restart-once)
printf 'boot\n' >> "$3/boots"
if [ ! -e "$3/crashed" ]; then
printf 'READY 262144 stop\n'
IFS= read -r line || exit 3
printf '%s\n' "$line" >> "$3/requests"
printf 'T 31\n'
: > "$3/active"
while [ ! -e "$3/release" ]; do sleep 0.01; done
: > "$3/crashed"
exit 7
fi
sleep 1
printf 'READY 262144 stop\n'
while IFS= read -r line; do
case "$line" in
'GEN 1 99')
printf '%s\n' "$line" >> "$3/requests"
printf 'T 42\nDONE 1 1 1.0 2.0 stop\n' ;;
QUIT) exit 0 ;;
*) printf 'ERR unexpected request\n' ;;
esac
done
;;
restart-loop)
printf 'boot\n' >> "$3/boots"
printf 'READY 262144 stop\n'
exit 7
;;
restart-bad)
printf 'boot\n' >> "$3/boots"
printf 'READY invalid\n'
;;
*) exit 2 ;;
esac