@@ -264,6 +264,91 @@ describe("scripts/lib/live-docker-auth.sh", () => {
|
264 | 264 | ]); |
265 | 265 | }); |
266 | 266 | |
| 267 | +it("normalizes live Docker pids limits", () => { |
| 268 | +const binDir = makeTempBin("openclaw-live-docker-auth-pids-"); |
| 269 | +writeExecutable( |
| 270 | +path.join(binDir, "timeout"), |
| 271 | +[ |
| 272 | +"#!/bin/sh", |
| 273 | +'if [ "$1" = "--kill-after=1s" ] && [ "$2" = "1s" ] && [ "$3" = "true" ]; then', |
| 274 | +" exit 0", |
| 275 | +"fi", |
| 276 | +"exit 64", |
| 277 | +"", |
| 278 | +].join("\n"), |
| 279 | +); |
| 280 | + |
| 281 | +const result = spawnSync( |
| 282 | +"/bin/bash", |
| 283 | +[ |
| 284 | +"-c", |
| 285 | +[ |
| 286 | +"source scripts/lib/live-docker-auth.sh", |
| 287 | +"ARGS=()", |
| 288 | +"OPENCLAW_LIVE_DOCKER_PIDS_LIMIT=0008 openclaw_live_init_docker_run_args ARGS 42s", |
| 289 | +"printf '%s\\n' \"${ARGS[@]}\"", |
| 290 | +].join("\n"), |
| 291 | +], |
| 292 | +{ |
| 293 | +cwd: process.cwd(), |
| 294 | +encoding: "utf8", |
| 295 | +env: { |
| 296 | + ...process.env, |
| 297 | +PATH: binDir, |
| 298 | +}, |
| 299 | +}, |
| 300 | +); |
| 301 | + |
| 302 | +expect(result.status).toBe(0); |
| 303 | +expect(result.stdout.trimEnd().split("\n")).toContain("8"); |
| 304 | +}); |
| 305 | + |
| 306 | +it.each([ |
| 307 | +["live", "OPENCLAW_LIVE_DOCKER_PIDS_LIMIT"], |
| 308 | +["shared", "OPENCLAW_DOCKER_E2E_PIDS_LIMIT"], |
| 309 | +])("rejects invalid %s Docker pids limits before live Docker setup", (_label, envName) => { |
| 310 | +const binDir = makeTempBin("openclaw-live-docker-auth-invalid-pids-"); |
| 311 | +writeExecutable( |
| 312 | +path.join(binDir, "timeout"), |
| 313 | +[ |
| 314 | +"#!/bin/sh", |
| 315 | +'if [ "$1" = "--kill-after=1s" ] && [ "$2" = "1s" ] && [ "$3" = "true" ]; then', |
| 316 | +" exit 0", |
| 317 | +"fi", |
| 318 | +"exit 64", |
| 319 | +"", |
| 320 | +].join("\n"), |
| 321 | +); |
| 322 | + |
| 323 | +const result = spawnSync( |
| 324 | +"/bin/bash", |
| 325 | +[ |
| 326 | +"-c", |
| 327 | +[ |
| 328 | +"source scripts/lib/live-docker-auth.sh", |
| 329 | +"ARGS=()", |
| 330 | +"openclaw_live_init_docker_run_args ARGS 42s", |
| 331 | +].join("\n"), |
| 332 | +], |
| 333 | +{ |
| 334 | +cwd: process.cwd(), |
| 335 | +encoding: "utf8", |
| 336 | +env: { |
| 337 | + ...process.env, |
| 338 | +OPENCLAW_DOCKER_E2E_PIDS_LIMIT: |
| 339 | +envName === "OPENCLAW_DOCKER_E2E_PIDS_LIMIT" ? "many" : "", |
| 340 | +OPENCLAW_LIVE_DOCKER_PIDS_LIMIT: |
| 341 | +envName === "OPENCLAW_LIVE_DOCKER_PIDS_LIMIT" ? "many" : "", |
| 342 | +PATH: binDir, |
| 343 | +}, |
| 344 | +}, |
| 345 | +); |
| 346 | + |
| 347 | +expect(result.status).toBe(2); |
| 348 | +expect(result.stderr).toContain(`invalid ${envName}: many`); |
| 349 | +expect(result.stdout).toBe(""); |
| 350 | +}); |
| 351 | + |
267 | 352 | it("fails fast when no timeout wrapper is available", () => { |
268 | 353 | const binDir = makeTempBin("openclaw-live-docker-auth-no-timeout-"); |
269 | 354 | |
|