Repository navigation
test: Add unit tests for BotManager Incus path - #60
Merged
Merged
Conversation
- Add ContainerPool.exec(botId, command, options) convenience method
that gets the container, finds the correct backend, and delegates exec
- Add ContainerPool.getBackend(botId) public method for direct backend access
- Refactor bash-tool.js to use containerPool.exec() instead of
getContainer() + dockerManager.exec() pattern
- Refactor file-tools.js (readFile, writeFile, glob, grep) similarly
- Refactor tool-executor.js (bash, readFile, writeFile) similarly
- Keep containerPool.dockerManager working for backward compatibility
- Tools no longer care which backend runs the command — they just
call exec() and get { stdout, stderr, exitCode }
- Update all unit tests to use the new exec() abstraction in mocks
Co-Authored-By: Claude <noreply@anthropic.com>
…areness - ContainerPool._getBackend() now instantiates IncusBackend instead of throwing - ContainerPool._getBackend() accepts options object with dockerHost and incusHost - BotManager.startBot() passes incusHost from worker assignment to ContainerPool - BotManager._hasSandboxChanged() detects incusImage and incusProfile changes - Orchestrator imports BACKEND_TYPES and logs available sandbox backends on startup - Update ContainerPool test to expect IncusBackend creation instead of throw Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive unit tests covering Incus-specific functionality: - Test `_hasSandboxChanged()` with Incus fields (incusImage, incusProfile) - Test sandbox type changes between docker and incus - Test `startBot()` passes Incus config to ContainerPool correctly - Test `reloadBot()` recreates container when Incus fields change - Test `reloadBot()` handles sandbox type migration (docker ↔ incus) All 119 BotManager tests pass (6 new Incus-specific tests + 4 new _hasSandboxChanged tests for Incus fields). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Allows underscore-prefixed variables in array destructuring (e.g., _botId) - Consistent with existing argsIgnorePattern and caughtErrorsIgnorePattern - Fixes CI lint failure for unused destructured array variables in tests Co-Authored-By: Claude <noreply@anthropic.com>
- Mirror the Docker backend pattern by lazily creating and reusing a shared default IncusBackend when no remote incusHost is specified - Prevents creating redundant HTTP agents all pointing at the same Unix socket when multiple Incus bots use the local daemon - Add _defaultIncusBackend property with lazy initialization Addresses PR #60 review feedback from greptile-apps[bot] Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add comprehensive unit tests for BotManager's Incus sandbox support:
_hasSandboxChanged()Incus tests: Test detection of changes inincusImageandincusProfilefieldsstartBot()Incus test: Verify Incus config is correctly passed to ContainerPoolreloadBot()Incus tests: Test container recreation when Incus-specific fields changeTest Coverage
_hasSandboxChanged()section for Incus-specific fieldsIncus sandbox supportsection covering:incusImagechangeincusProfilechangeTest Results
All 119 BotManager unit tests pass (10 new Incus-related tests added).
Part of PR Group
PR Group: Tool Layer Adaptation & Integration
Branch:
claudetm/feat/abstract-tool-executionThis is the final task in the PR group that abstracts tool execution away from Docker specifics and adds Incus support throughout the codebase.
🤖 Generated with Claude Task Master
Greptile Overview
Greptile Summary
This PR completes the Incus sandbox support implementation by adding comprehensive unit tests for BotManager's Incus-related functionality. The PR includes 10 new tests covering Incus-specific sandbox change detection (
incusImageandincusProfilefields), sandbox type migration between docker and incus, and proper configuration passing through the ContainerPool.Key Changes:
_hasSandboxChanged()for Incus fields (incusImage,incusProfile) and type transitionsstartBot()andreloadBot()covering config passing, container recreation on Incus field changes, and sandbox type migrationsexec()/getBackend()methodscontainerPool.exec()abstractiondestructuredArrayIgnorePatternto eslint config to support the[_botId, ...]pattern in testsThe implementation correctly mirrors the Docker backend pattern by reusing a shared default IncusBackend instance for local bots (addressing the previous review comment). All 119 tests pass successfully.
Confidence Score: 5/5
_hasSandboxChanged(),incusHostoption passing) are simple and well-tested. The previous concern about IncusBackend instantiation has been addressed in a prior commit. Tests are thorough, well-structured, and all 119 tests pass.Important Files Changed
incusHostoption to ContainerPool and checksincusImage/incusProfilefields in_hasSandboxChanged()exec()andgetBackend()convenience methodscontainerPool.exec()instead of directly accessingdockerManager.exec()for backend abstractioncontainerPool.exec()instead of direct dockerManager accesscontainerPool.exec()instead of direct dockerManager access_hasSandboxChanged(),startBot(),reloadBot(), and sandbox type migrationexec()andgetBackend()methodsSequence Diagram
sequenceDiagram participant BM as BotManager participant CP as ContainerPool participant IB as IncusBackend participant DB as DockerBackend participant TE as ToolExecutor participant BT as BashTool Note over BM,BT: Incus Support Integration BM->>CP: startBot(botId, config)<br/>{sandbox.type: 'incus', incusImage: 'ai-army-base'} CP->>CP: _getBackend(botId, config, {incusHost}) alt No incusHost (local) CP->>IB: new IncusBackend() [shared instance] else With incusHost (remote) CP->>IB: new IncusBackend({socketPath: incusHost}) end CP->>IB: createContainer(config) IB-->>CP: container CP-->>BM: container Note over TE,BT: Tool Execution Abstraction BT->>CP: exec(botId, command, options) CP->>CP: getContainer(botId) CP->>CP: _getBackendForBot(botId) alt Incus Backend CP->>IB: exec(container, command, options) IB-->>CP: {exitCode, stdout, stderr} else Docker Backend CP->>DB: exec(container, command, options) DB-->>CP: {exitCode, stdout, stderr} end CP-->>BT: result Note over BM: Sandbox Change Detection BM->>BM: _hasSandboxChanged(oldSandbox, newSandbox) Note right of BM: Checks incusImage<br/>and incusProfileLast reviewed commit: 6e96f64