feat(orchestrator): add external agent container to test topology#20
feat(orchestrator): add external agent container to test topology#20erenaslandev wants to merge 1 commit into
Conversation
WalkthroughAdds an optional ChangesAgent Container Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/config/case.go (1)
542-644:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd validation for Agent.Image when Agent is configured.
When
Agentis set butAgent.Imageis empty, validation passes but compose rendering will fail at runtime with an unclear error. Following the pattern used for Endpoint validation (lines 593-594), the Agent should validate that Image is required.🛡️ Proposed fix to add Agent validation
Add this validation block after the endpoint validation (after line 609):
epNames[e.Name] = struct{}{} } + // Agent: require image when agent block is present. + if tc.Agent != nil && tc.Agent.Image == "" { + return fmt.Errorf("case %q: agent missing required `image`", tc.Name) + } // Kafka types require the broker block + a generator producing in kafka mode.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/config/case.go` around lines 542 - 644, The Validate method on TestCase does not validate that Agent.Image is required when Agent is configured, which causes compose rendering to fail at runtime with unclear errors. Add a validation check after the endpoint validation block that follows the same pattern used for endpoint validation: check if tc.Agent is not nil and if so, verify that tc.Agent.Image is not empty, returning a descriptive error message if validation fails.
🧹 Nitpick comments (1)
internal/orchestrator/compose_render_test.go (1)
738-810: ⚡ Quick winConsider adding test coverage for MountsSharedData and "$" escaping.
The test verifies core agent rendering but has two coverage gaps:
MountsSharedData: Line 784's comment acknowledges
MountsSharedDatais untested. When true, it should render theshared-data:/datavolume mount anduser: "0:0"."$" escaping: The feature escapes
$to$$in command/env (lines 1932-1938 in docker.go) to prevent Docker Compose interpolation, but this behavior isn't verified.📋 Suggested test additions
Add assertions after line 782 to test MountsSharedData:
// Test with MountsSharedData enabled tcWithMount := &config.TestCase{ Name: "agent-with-mount", Type: "correctness", Duration: "60s", Receiver: config.ReceiverConfig{Mode: "tcp", Listen: ":9001"}, Agent: &config.AgentConfig{ Image: "vmetric/director-enterprise:2.0.0", MountsSharedData: true, }, } // ... writeCompose and assertions ... mustContain(t, out, "shared-data:/data") mustContain(t, out, "user: \"0:0\"")Add a test for "$" escaping:
// Test command with $ characters (should be escaped to $$) tcWithDollar := &config.TestCase{ Name: "agent-dollar-escape", Type: "correctness", Duration: "60s", Receiver: config.ReceiverConfig{Mode: "tcp", Listen: ":9001"}, Agent: &config.AgentConfig{ Image: "test:1.0", Command: []string{"sh", "-c", "echo $VAR $(date)"}, Env: map[string]string{"KEY": "$VALUE"}, }, } // ... writeCompose and assertions ... mustContain(t, out, "$$VAR") mustContain(t, out, "$$(date)") mustContain(t, out, "$$VALUE")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/orchestrator/compose_render_test.go` around lines 738 - 810, The TestComposeRendersAgent test lacks coverage for two features: the MountsSharedData configuration and the "$" escaping behavior in commands/env. Add two new test cases within this test function to cover these gaps. First, create a test case where Agent.MountsSharedData is set to true and verify the output contains "shared-data:/data" and "user: \"0:0\"" using writeCompose and mustContain assertions similar to existing checks. Second, create another test case with an Agent.Command containing dollar sign characters like "echo $VAR $(date)" and verify the composed output escapes them to "$$VAR" and "$$(date)", ensuring the "$" escaping behavior mentioned in docker.go is properly tested. Place these additional test cases after the initial agent rendering checks and before the "no-agent" test case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@internal/config/case.go`:
- Around line 542-644: The Validate method on TestCase does not validate that
Agent.Image is required when Agent is configured, which causes compose rendering
to fail at runtime with unclear errors. Add a validation check after the
endpoint validation block that follows the same pattern used for endpoint
validation: check if tc.Agent is not nil and if so, verify that tc.Agent.Image
is not empty, returning a descriptive error message if validation fails.
---
Nitpick comments:
In `@internal/orchestrator/compose_render_test.go`:
- Around line 738-810: The TestComposeRendersAgent test lacks coverage for two
features: the MountsSharedData configuration and the "$" escaping behavior in
commands/env. Add two new test cases within this test function to cover these
gaps. First, create a test case where Agent.MountsSharedData is set to true and
verify the output contains "shared-data:/data" and "user: \"0:0\"" using
writeCompose and mustContain assertions similar to existing checks. Second,
create another test case with an Agent.Command containing dollar sign characters
like "echo $VAR $(date)" and verify the composed output escapes them to "$$VAR"
and "$$(date)", ensuring the "$" escaping behavior mentioned in docker.go is
properly tested. Place these additional test cases after the initial agent
rendering checks and before the "no-agent" test case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f13208d8-9150-4553-b975-3ee9d8ad9390
📒 Files selected for processing (3)
internal/config/case.gointernal/orchestrator/compose_render_test.gointernal/orchestrator/docker.go
Summary by CodeRabbit
Release Notes
New Features
Tests