[quality] add unit tests for 6 untested compat/delegation files in pkg/agent#19937
Conversation
Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dModeConfig Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ases Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole canceled.
|
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
✅ Deploy Preview for kubestellarconsole canceled.
|
|
🐝 Hi @clubanderson! I'm Trusted users — org members and contributors with write access — can mention Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies. |
…ory not Messages) Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ProcAttr check Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds Go unit tests to improve coverage for pkg/agent compatibility/delegation shims and a few lightweight provider/type re-exports, aligning with the coverage gap identified in #19907.
Changes:
- Adds new test suites validating backward-compatibility aliases and delegations (workers, providers, kagent, config, procgroup).
- Adds basic sanity checks for exported constants/vars and zero-value/type-alias compilation.
- Adds targeted edge-case coverage for a few small helper functions exposed via compat layers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/agent/config_compat_test.go | Tests config-manager singleton and provider→env-key mapping delegations. |
| pkg/agent/providers_compat_test.go | Tests provider compat re-exports and small helper delegations (URL helpers, truncation, HTTP client, loopback flag). |
| pkg/agent/procgroup_compat_test.go | Tests procgroup delegation wiring for exec.Cmd process-group setup. |
| pkg/agent/workers_compat_test.go | Tests worker constructor var delegations, constants, and type alias instantiation. |
| pkg/agent/kagent_compat_test.go | Tests kagent GVR var delegations and type alias compilation/zero values. |
| pkg/agent/provider_test.go | Tests provider-facing constants, limits, and alias types/struct zero-values. |
| {"at limit", "hello", 5, "hello"}, | ||
| {"over limit", "hello world", 5, "hello"}, | ||
| {"zero max", "hello", 0, ""}, |
| {"vllm", true}, | ||
| {"lmstudio", true}, | ||
| {"nonexistent-provider", false}, |
| import ( | ||
| "os/exec" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestConfigureProcessGroup(t *testing.T) { | ||
| // configureProcessGroup should not panic on a valid Cmd | ||
| cmd := exec.Command("echo", "test") | ||
| configureProcessGroup(cmd) | ||
|
|
||
| // Verify SysProcAttr was set (on Unix, this sets Setpgid) | ||
| if cmd.SysProcAttr == nil { | ||
| t.Error("configureProcessGroup did not set SysProcAttr") | ||
| } | ||
| } | ||
|
|
||
| func TestConfigureProcessGroupNilFields(t *testing.T) { | ||
| // Should handle a freshly created Cmd without panicking | ||
| cmd := &exec.Cmd{Path: "/bin/echo"} | ||
| configureProcessGroup(cmd) | ||
| if cmd.SysProcAttr == nil { | ||
| t.Error("configureProcessGroup did not set SysProcAttr on bare Cmd") | ||
| } | ||
| } |
| func TestGroqValidationURL(t *testing.T) { | ||
| url := groqValidationURL() | ||
| if url == "" { | ||
| t.Error("groqValidationURL() returned empty string") | ||
| } | ||
| if len(url) < 10 { | ||
| t.Errorf("groqValidationURL() too short: %q", url) | ||
| } | ||
| } |
| func TestSetAllowLoopbackForTests(t *testing.T) { | ||
| // Should not panic | ||
| SetAllowLoopbackForTests(true) | ||
| SetAllowLoopbackForTests(false) | ||
| } |
… in providers_compat_test.go Signed-off-by: clubanderson <clubanderson@users.noreply.github.com>
…onfig_compat - Fix TruncateString expected values: implementation appends '...' on truncation - Fix provider key 'lmstudio' → 'lm-studio' to match actual GetBaseURLEnvKeyForProvider switch - Make TestGroqValidationURL hermetic by setting GROQ_BASE_URL via t.Setenv - Restore loopback flag in TestSetAllowLoopbackForTests via t.Cleanup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: clubanderson <clubanderson@users.noreply.github.com>
Test Fixes PushedPushed commit
Note on
|
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
✅ Post-Merge Verification: passedCommit: |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
Test Improvement
Adds 35 test cases across 5 new test files for the remaining untested compatibility/delegation files in
pkg/agent:config_compat_test.go(9 tests)GetConfigManagersingleton behaviorgetBaseURLEnvKeyForProviderfor known and unknown providersgetEnvKeyForProviderfor known and unknown providersgetModelEnvKeyForProviderfor known and unknown providersisolateConfigManagertest isolationproviders_compat_test.go(11 tests)groqValidationURL()returns valid URLtruncateStringedge cases (empty, within limit, at limit, over limit, zero max)newRestrictedAIProviderHTTPClienttimeout and transport validationmaxLLMResponseBytesbounds checkSetAllowLoopbackForTestsno-panicprocgroup_compat_test.go(2 tests)configureProcessGroupsets SysProcAttr onexec.Command*exec.Cmdworkers_compat_test.go(8 tests)NewPredictionWorker,NewInsightWorker, etc.) non-nilInsightEnrichmentCacheTTLandInsightEnrichmentTimeoutboundsPredictionSettings,InsightSummary,DeviceAlert,MetricsSnapshotkagent_compat_test.go(5 tests)provider_test.go(5 tests)CapabilityChatandCapabilityToolExecnon-zero and distinctmaxStderrBytes= 1MBMixedModeConfigzero-value and field assignmentChatRequestandChatResponsezero-valuePartially addresses #19907 — covers 6 of the 12 files identified in the coverage gap analysis (the remaining files have tests via PRs #19921 and #19933).
Filed by quality agent (ACMM L4/L6 — full mode)