Skip to content

[quality] add unit tests for 6 untested compat/delegation files in pkg/agent#19937

Merged
clubanderson merged 10 commits into
mainfrom
quality/test-compat-files
Jun 29, 2026
Merged

[quality] add unit tests for 6 untested compat/delegation files in pkg/agent#19937
clubanderson merged 10 commits into
mainfrom
quality/test-compat-files

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

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)

  • GetConfigManager singleton behavior
  • getBaseURLEnvKeyForProvider for known and unknown providers
  • getEnvKeyForProvider for known and unknown providers
  • getModelEnvKeyForProvider for known and unknown providers
  • isolateConfigManager test isolation

providers_compat_test.go (11 tests)

  • Provider constant re-exports non-empty
  • Default URL vars non-empty
  • groqValidationURL() returns valid URL
  • truncateString edge cases (empty, within limit, at limit, over limit, zero max)
  • newRestrictedAIProviderHTTPClient timeout and transport validation
  • maxLLMResponseBytes bounds check
  • SetAllowLoopbackForTests no-panic

procgroup_compat_test.go (2 tests)

  • configureProcessGroup sets SysProcAttr on exec.Command
  • Same behavior on bare *exec.Cmd

workers_compat_test.go (8 tests)

  • Constructor vars (NewPredictionWorker, NewInsightWorker, etc.) non-nil
  • InsightEnrichmentCacheTTL and InsightEnrichmentTimeout bounds
  • Type alias instantiation for PredictionSettings, InsightSummary, DeviceAlert, MetricsSnapshot

kagent_compat_test.go (5 tests)

  • All 6 kagent GVR vars have non-empty Group/Version/Resource
  • Type alias zero-value compilation for 8 kagent types

provider_test.go (5 tests)

  • CapabilityChat and CapabilityToolExec non-zero and distinct
  • maxStderrBytes = 1MB
  • MixedModeConfig zero-value and field assignment
  • ChatRequest and ChatResponse zero-value

Partially 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)

clubanderson and others added 6 commits June 29, 2026 14:39
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>
Copilot AI review requested due to automatic review settings June 29, 2026 18:41
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 29, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit f5f4739
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a42bc5b450cc80008b4b8e6

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit 271fda8
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a42c7d2300b08000831df77

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Jun 29, 2026
@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 29, 2026
clubanderson and others added 2 commits June 29, 2026 14:42
…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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pkg/agent/providers_compat_test.go Outdated
Comment on lines +61 to +63
{"at limit", "hello", 5, "hello"},
{"over limit", "hello world", 5, "hello"},
{"zero max", "hello", 0, ""},
Comment on lines +29 to +31
{"vllm", true},
{"lmstudio", true},
{"nonexistent-provider", false},
Comment on lines +3 to +26
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")
}
}
Comment on lines +42 to +50
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)
}
}
Comment on lines +101 to +105
func TestSetAllowLoopbackForTests(t *testing.T) {
// Should not panic
SetAllowLoopbackForTests(true)
SetAllowLoopbackForTests(false)
}
clubanderson and others added 2 commits June 29, 2026 15:16
… 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>
@clubanderson

Copy link
Copy Markdown
Collaborator Author

Test Fixes Pushed

Pushed commit 271fda8 addressing all 5 Copilot review findings:

  1. TestTruncateString — fixed expected values: TruncateString appends "..." when truncating, so "hello world" truncated to 5 → "hello..." not "hello", and zero-max → "..." not ""
  2. TestGetBaseURLEnvKeyForProvider — fixed "lmstudio""lm-studio" to match the actual switch case key
  3. TestGroqValidationURL — made hermetic with t.Setenv("GROQ_BASE_URL", ...)
  4. TestSetAllowLoopbackForTests — added t.Cleanup to restore loopback flag after test
  5. procgroup_compat_test.go — already had correct //go:build !windows constraint (no change needed)

Note on pr-check nilaway failure

The nilaway failure (registry.go:166:6, solver.go:258:6) is not caused by this PR — it's a baseline drift issue where .github/nilaway-baseline.json has stale line numbers. This PR only adds test files. Tracking separately.

@clubanderson clubanderson merged commit 9d65630 into main Jun 29, 2026
26 of 28 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the quality/test-compat-files branch June 29, 2026 19:39
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: 9d656302706a4cf35269e2182518b20b65d0c695
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/28397881966

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 9d656302706a4cf35269e2182518b20b65d0c695.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants