aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver-test/compute-tests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add generic fmt::formatter for types with free ToString functionsStefan Boberg2 hours1-56/+48
| | | | | | | | | | | Add a HasFreeToString concept that detects types with a free ToString(T) function returning a string-like type, and a corresponding fmt::formatter partial specialization. This eliminates the need for int() casts or explicit ToString() calls when formatting enums like HttpResponseCode, SessionState, etc. Convert compute-tests.cpp to use the new formatter directly instead of int() casts for HTTP response codes.
* Consolidate action map locks and fix immediate query visibilityStefan Boberg11 hours1-0/+35
| | | | | | | | | | | | | | | | Replace three separate RwLocks (m_PendingLock, m_RunningLock, m_ResultsLock) with a single m_ActionMapLock guarding all three action maps. This eliminates lock-ordering requirements and prevents actions from being temporarily absent from all maps during state transitions. Additionally, insert actions into m_PendingActions immediately during EnqueueResolvedAction so they are visible to GetActionResult and FindActionResult right away, without waiting for the scheduler thread to process the update. Previously, eager clients could get a spurious 404 if they queried before the scheduler's HandleActionUpdates ran. Also adds debug logging for worker manifest, process launch and exit on Windows, and ANSI color helper macros for log formatting.
* Add crash handling tests and suppress crash dialogs via job objectsStefan Boberg37 hours1-0/+233
| | | | | | | | | | | | | | | | | | - Add "Crash" function to zentest-appstub with two modes: "abort" (std::abort) and "nullptr" (null pointer dereference) for testing hard process crashes - Add job object to WindowsProcessRunner that assigns all child processes, configured with: - JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION to suppress WER dialogs - JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE for cleanup on runner teardown - JOB_OBJECT_UILIMIT_ERRORMODE to prevent children from clearing the inherited SEM_NOGPFAULTERRORBOX error mode - Create child processes suspended so job assignment takes effect before any code runs - Add three new test cases: - crash.abort: std::abort() results in failed action - crash.nullptr: null pointer dereference results in failed action - crash.auto_retry: crashed actions are retried correctly
* Add tests for process exit code handling in compute local runnersStefan Boberg37 hours1-0/+295
| | | | | | | | | | | | | | | | | - Add "Fail" function to zentest-appstub that exits with a configurable exit code read from the action's Constants, enabling controlled failure testing without needing command-line flags - Fix GetMaxRetriesForQueue to use -1 as sentinel default so that max_retries=0 in queue config correctly disables retries - Add four new test cases: - exit_code.failed_action: non-zero exit produces failed queue status and succeeded=false in history - exit_code.auto_retry: retries exhaust before final failure with correct retry_count in history - exit_code.reschedule_failed: manual reschedule returns 409 when retry limit is reached - exit_code.mixed_success_and_failure: queue counters are correct when actions succeed and fail in the same queue
* Compute batching (#849)Stefan Boberg2 days1-38/+359
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Compute Batch Submission - Consolidate duplicated action submission logic in `httpcomputeservice` into a single `HandleSubmitAction` supporting both single-action and batch (actions array) payloads - Group actions by queue in `RemoteHttpRunner` and submit as batches with configurable chunk size, falling back to individual submission on failure - Extract shared helpers: `MakeErrorResult`, `ValidateQueueForEnqueue`, `ActivateActionInQueue`, `RemoveActionFromActiveMaps` ### Retracted Action State - Add `Retracted` state to `RunnerAction` for retry-free rescheduling — an explicit request to pull an action back and reschedule it on a different runner without incrementing `RetryCount` - Implement idempotent `RetractAction()` on `RunnerAction` and `ComputeServiceSession` - Add `POST jobs/{lsn}/retract` and `queues/{queueref}/jobs/{lsn}/retract` HTTP endpoints - Add state machine documentation and per-state comments to `RunnerAction` ### Compute Race Fixes - Fix race in `HandleActionUpdates` where actions enqueued between session abandon and scheduler tick were never abandoned, causing `GetActionResult` to return 202 indefinitely - Fix queue `ActiveCount` race where `NotifyQueueActionComplete` was called after releasing `m_ResultsLock`, allowing callers to observe stale counters immediately after `GetActionResult` returned OK ### Logging Optimization and ANSI improvements - Improve `AnsiColorStdoutSink` write efficiency — single write call, dirty-flag flush, `RwLock` instead of `std::mutex` - Move ANSI color emission from sink into formatters via `Formatter::SetColorEnabled()`; remove `ColorRangeStart`/`End` from `LogMessage` - Extract color helpers (`AnsiColorForLevel`, `StripAnsiSgrSequences`) into `helpers.h` - Strip upstream ANSI SGR escapes in non-color output mode. This enables colour in log messages without polluting log files with ANSI control sequences - Move `RotatingFileSink`, `JsonFormatter`, and `FullFormatter` from header-only to pimpl with `.cpp` files ### CLI / Exec Refactoring - Extract `ExecSessionRunner` class from ~920-line `ExecUsingSession` into focused methods and a `ExecSessionConfig` struct - Replace monolithic `ExecCommand` with subcommand-based architecture (`http`, `inproc`, `beacon`, `dump`, `buildlog`) - Allow parent options to appear after subcommand name by parsing subcommand args permissively and forwarding unmatched tokens to the parent parser ### Testing Improvements - Fix `--test-suite` filter being ignored due to accumulation with default wildcard filter - Add test suite banners to test listener output - Made `function.session.abandon_pending` test more robust ### Startup / Reliability Fixes - Fix silent exit when a second zenserver instance detects a port conflict — use `ZEN_CONSOLE_*` for log calls that precede `InitializeLogging()` - Fix two potential SIGSEGV paths during early startup: guard `sentry_options_new()` returning nullptr, and throw on `ZenServerState::Register()` returning nullptr instead of dereferencing - Fail on unrecognized zenserver `--mode` instead of silently defaulting to store ### Other - Show host details (hostname, platform, CPU count, memory) when discovering new compute workers - Move frontend `html.zip` from source tree into build directory - Add format specifications for Compact Binary and Compressed Buffer wire formats - Add `WriteCompactBinaryObject` to zencore - Extended `ConsoleTui` with additional functionality - Add `--vscode` option to `xmake sln` for clangd / `compile_commands.json` support - Disable compute/horde/nomad in release builds (not yet production-ready) - Disable unintended `ASIO_HAS_IO_URING` enablement - Fix crashpad patch missing leading whitespace - Clean up code triggering gcc false positives
* compute orchestration (#763)Stefan Boberg2026-03-041-0/+1700
- Added local process runners for Linux/Wine, Mac with some sandboxing support - Horde & Nomad provisioning for development and testing - Client session queues with lifecycle management (active/draining/cancelled), automatic retry with configurable limits, and manual reschedule API - Improved web UI for orchestrator, compute, and hub dashboards with WebSocket push updates - Some security hardening - Improved scalability and `zen exec` command Still experimental - compute support is disabled by default