spawn/sh
Ahmed Abushagur 5b5e7d4706
test: add cron-triggered Telegram reminder to soak test (#2519)
* test: add cron-triggered Telegram reminder to soak test

Tests OpenClaw's ability to stay alive and execute scheduled tasks.
Installs a one-shot cron on the VM before the 1h soak wait that sends
a Telegram message at ~55 min, then verifies the message was sent
after the wait completes. Also moves Telegram config injection before
the soak wait so the cron can use the bot token immediately.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: use OpenClaw's cron scheduler instead of system crontab

Replaces the raw system cron approach with OpenClaw's built-in cron
scheduler (`openclaw cron add`). This properly tests that OpenClaw's
gateway stays alive after 1 hour and can execute scheduled tasks.

The test now:
1. Injects Telegram config + schedules an OpenClaw cron job (--at +55min)
2. Waits 1 hour (soak)
3. Verifies the job fired via `openclaw cron runs` and `openclaw cron list`

Uses --delete-after-run for one-shot semantics. Verification checks both
the run history and the auto-deletion as proof of execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: verify cron message on Telegram side via forwardMessage

Instead of trusting OpenClaw's self-reported cron status, we now verify
the message actually exists in the Telegram chat:

1. Extract message_id from OpenClaw's cron execution logs (tries
   `openclaw cron runs`, then ~/.openclaw/cron/ directory)
2. Call Telegram's forwardMessage API with that message_id
3. If Telegram can forward it → message EXISTS in the chat (proof
   from Telegram itself, not OpenClaw)

This catches cases where OpenClaw reports success but the message
never actually reached Telegram.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: address security review findings in soak test

- Add validate_positive_int() and validate SOAK_WAIT_SECONDS +
  SOAK_CRON_DELAY_SECONDS at startup (prevents command injection via
  crafted env vars)
- Validate TELEGRAM_TEST_CHAT_ID is numeric in soak_validate_telegram_env
- Use per-app marker file /tmp/.spawn-cron-scheduled-${app} to avoid
  race conditions when multiple soak tests run on the same VM

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 04:49:42 -04:00
..
aws docs: add missing agent entries to all cloud READMEs (#2494) 2026-03-11 05:49:50 -04:00
cli fix: verify bun installer SHA-256 before executing in install.sh (#2463) (#2473) 2026-03-10 18:39:41 -07:00
digitalocean fix: correct DigitalOcean default droplet size in README and stale getUserHome path (#2513) 2026-03-11 21:25:30 -07:00
docker fix: pin bun install to v1.3.9 in all agent scripts (#2345) 2026-03-08 12:47:18 -04:00
e2e test: add cron-triggered Telegram reminder to soak test (#2519) 2026-03-12 04:49:42 -04:00
gcp docs: add missing agent entries to all cloud READMEs (#2494) 2026-03-11 05:49:50 -04:00
hetzner docs: add missing agent entries to all cloud READMEs (#2494) 2026-03-11 05:49:50 -04:00
local docs: add missing agent entries to all cloud READMEs (#2494) 2026-03-11 05:49:50 -04:00
shared fix: replace stale bun -e with bun eval in key-request.sh (#2506) 2026-03-11 17:22:56 -07:00
sprite docs: add missing agent entries to all cloud READMEs (#2494) 2026-03-11 05:49:50 -04:00
test refactor: Remove dead code and stale references (#2062) 2026-03-01 11:45:24 -05:00