mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
fix(live): validate model sweep limits
This commit is contained in:
parent
5570a10bf4
commit
aba6f7ad21
2 changed files with 50 additions and 2 deletions
|
|
@ -30,6 +30,15 @@ openclaw_live_truthy() {
|
|||
esac
|
||||
}
|
||||
|
||||
LIVE_MAX_MODELS="${OPENCLAW_LIVE_MAX_MODELS:-}"
|
||||
if [[ -n "$LIVE_MAX_MODELS" && ! "$LIVE_MAX_MODELS" =~ ^\+?[0-9]+$ ]]; then
|
||||
echo "invalid OPENCLAW_LIVE_MAX_MODELS: $LIVE_MAX_MODELS" >&2
|
||||
exit 2
|
||||
fi
|
||||
LIVE_MODEL_TIMEOUT_MS="${OPENCLAW_LIVE_MODEL_TIMEOUT_MS:-}"
|
||||
if [[ -n "$LIVE_MODEL_TIMEOUT_MS" ]]; then
|
||||
LIVE_MODEL_TIMEOUT_MS="$(openclaw_live_read_positive_int_env OPENCLAW_LIVE_MODEL_TIMEOUT_MS "$LIVE_MODEL_TIMEOUT_MS")"
|
||||
fi
|
||||
TEMP_DIRS=()
|
||||
DOCKER_HOME_MOUNT=()
|
||||
cleanup_temp_dirs() {
|
||||
|
|
@ -228,8 +237,8 @@ DOCKER_RUN_ARGS+=(--rm -t \
|
|||
-e OPENCLAW_LIVE_TEST=1 \
|
||||
-e OPENCLAW_LIVE_MODELS="${OPENCLAW_LIVE_MODELS:-modern}" \
|
||||
-e OPENCLAW_LIVE_PROVIDERS="${OPENCLAW_LIVE_PROVIDERS:-}" \
|
||||
-e OPENCLAW_LIVE_MAX_MODELS="${OPENCLAW_LIVE_MAX_MODELS:-}" \
|
||||
-e OPENCLAW_LIVE_MODEL_TIMEOUT_MS="${OPENCLAW_LIVE_MODEL_TIMEOUT_MS:-}" \
|
||||
-e OPENCLAW_LIVE_MAX_MODELS="$LIVE_MAX_MODELS" \
|
||||
-e OPENCLAW_LIVE_MODEL_TIMEOUT_MS="$LIVE_MODEL_TIMEOUT_MS" \
|
||||
-e OPENCLAW_LIVE_REQUIRE_PROFILE_KEYS="${OPENCLAW_LIVE_REQUIRE_PROFILE_KEYS:-}" \
|
||||
-e OPENCLAW_LIVE_GATEWAY_MODELS="${OPENCLAW_LIVE_GATEWAY_MODELS:-}" \
|
||||
-e OPENCLAW_LIVE_GATEWAY_PROVIDERS="${OPENCLAW_LIVE_GATEWAY_PROVIDERS:-}" \
|
||||
|
|
|
|||
39
test/scripts/test-live-models-docker.test.ts
Normal file
39
test/scripts/test-live-models-docker.test.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Test Live Models Docker tests cover direct live model Docker script behavior.
|
||||
import { spawnSync } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const SCRIPT_PATH = path.resolve(import.meta.dirname, "../../scripts/test-live-models-docker.sh");
|
||||
|
||||
describe("scripts/test-live-models-docker.sh", () => {
|
||||
it("validates optional live model limits before auth or Docker setup", () => {
|
||||
const script = fs.readFileSync(SCRIPT_PATH, "utf8");
|
||||
|
||||
expect(script).toContain('LIVE_MAX_MODELS="${OPENCLAW_LIVE_MAX_MODELS:-}"');
|
||||
expect(script).toContain('[[ -n "$LIVE_MAX_MODELS" && ! "$LIVE_MAX_MODELS" =~ ^\\+?[0-9]+$ ]]');
|
||||
expect(script).toContain(
|
||||
'openclaw_live_read_positive_int_env OPENCLAW_LIVE_MODEL_TIMEOUT_MS "$LIVE_MODEL_TIMEOUT_MS"',
|
||||
);
|
||||
expect(script).toContain('-e OPENCLAW_LIVE_MAX_MODELS="$LIVE_MAX_MODELS"');
|
||||
expect(script).toContain('-e OPENCLAW_LIVE_MODEL_TIMEOUT_MS="$LIVE_MODEL_TIMEOUT_MS"');
|
||||
});
|
||||
|
||||
it.each([
|
||||
["max models", "OPENCLAW_LIVE_MAX_MODELS", "3models"],
|
||||
["model timeout", "OPENCLAW_LIVE_MODEL_TIMEOUT_MS", "45s"],
|
||||
])("rejects invalid %s values before live Docker setup", (_label, envName, value) => {
|
||||
const result = spawnSync("bash", [SCRIPT_PATH], {
|
||||
encoding: "utf8",
|
||||
env: {
|
||||
...process.env,
|
||||
[envName]: value,
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.status).toBe(2);
|
||||
expect(result.stderr).toContain(`invalid ${envName}: ${value}`);
|
||||
expect(result.stderr).not.toContain("docker");
|
||||
expect(result.stderr).not.toContain("Cannot find package 'tsx'");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue