Skip to content

[quality] unit tests for LLMd utility functions (KVCacheMonitor.utils + nightlyE2E.constants)#19662

Merged
clubanderson merged 3 commits into
mainfrom
quality/test-llmd-utils
Jun 26, 2026
Merged

[quality] unit tests for LLMd utility functions (KVCacheMonitor.utils + nightlyE2E.constants)#19662
clubanderson merged 3 commits into
mainfrom
quality/test-llmd-utils

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Test Improvement

Adds 50+ unit tests for two previously-untested pure utility modules in web/src/components/cards/llmd/:

KVCacheMonitor.utils.test.ts (40+ tests)

  • calculateAggregateMetrics: empty input, single stat, multiple stats averaging
  • calculateTrend: empty, single, increasing, decreasing, flat history
  • updatePodHistory: new pod creation, appending, history trimming to 20-item limit
  • getGaugeGridClass: flex vs grid layout selection for expanded/collapsed states
  • getGaugeSize: size scaling by item count and expansion state
  • getHorseshoeGridClass: grid column adaptation
  • getHorseshoeSize: size scaling
  • getHeatCellColors: all 5 threshold bands + boundary values
  • getDisplayPodName: aggregate name translation, vllm- prefix stripping, truncation
  • generateMonitorStats: empty stack, demo mode, aggregated/disaggregated modes
  • exported constants: HEATMAP_LEGEND structure, DIV_STYLE constants

nightlyE2E.constants.test.ts (15+ tests)

  • getGuideMeta: full data, missing fields, partial data
  • computeAvgDurationMin: empty array, no completed runs, average calculation, filtering non-completed, missing timestamps
  • formatDuration: minutes-only, hours-only, hours+minutes formatting
  • constants: PLATFORM_ORDER, PLATFORM_COLORS, chart dimensions

Partially addresses #19631 — targets the remaining untested utility files in web/src/components/cards/llmd/.


Filed by quality agent (ACMM L4/L6 — full mode)

clubanderson and others added 2 commits June 25, 2026 20: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>
Copilot AI review requested due to automatic review settings June 26, 2026 00:40
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 26, 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 clubanderson 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 26, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit bb45b95
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a3dcfc633023b0007952c69
😎 Deploy Preview https://deploy-preview-19662.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@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.

@github-actions github-actions Bot added ai-generated Pull request generated by AI tier/1-lightweight labels Jun 26, 2026
@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 26, 2026
@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

Copy link
Copy Markdown
Contributor

✅ Test Coverage Check

All new source files in this PR have corresponding test files.

Checked web/src/hooks/ and web/src/components/ against origin/main.

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 improves frontend test coverage by adding Vitest unit tests for two pure utility modules under web/src/components/cards/llmd/, targeting previously untested logic called out by #19631.

Changes:

  • Adds unit tests for KVCacheMonitor.utils helpers (aggregation, trend, history trimming, layout sizing/classes, heatmap thresholds, display name formatting, and exported constants).
  • Adds unit tests for nightlyE2E.constants helpers (guide metadata extraction, average duration computation, duration formatting, and key constants).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
web/src/components/cards/llmd/tests/KVCacheMonitor.utils.test.ts Adds coverage for KV cache monitor utility functions and constants.
web/src/components/cards/llmd/tests/nightlyE2E.constants.test.ts Adds coverage for nightly E2E constants and helper functions.

Comment on lines +46 to +49
it('returns zeros for null/undefined-like input', () => {
const result = calculateAggregateMetrics([] as KVCacheStats[])
expect(result.avgUtil).toBe(0)
})
Comment on lines +269 to +284
const stack = {
cluster: 'test-cluster',
namespace: 'llmd',
name: 'test-stack',
components: {
prefill: [{ name: 'prefill-svc', replicas: 2, readyReplicas: 2, podNames: ['p-0', 'p-1'] }],
decode: [{ name: 'decode-svc', replicas: 1, readyReplicas: 1, podNames: ['d-0'] }],
both: [],
},
}
const result = generateMonitorStats({
aggregationMode: 'aggregated',
isDemoMode: false,
prometheusMetrics: null,
selectedStack: stack as any,
})
Comment on lines +290 to +305
const stack = {
cluster: 'test-cluster',
namespace: 'llmd',
name: 'test-stack',
components: {
prefill: [{ name: 'prefill-svc', replicas: 2, readyReplicas: 2, podNames: ['p-0', 'p-1'] }],
decode: [],
both: [],
},
}
const result = generateMonitorStats({
aggregationMode: 'disaggregated',
isDemoMode: false,
prometheusMetrics: null,
selectedStack: stack as any,
})
Comment on lines +80 to +81
{ status: 'failed', createdAt: '2026-01-01T00:00:00Z', updatedAt: '2026-01-01T00:30:00Z' },
] as unknown as NightlyRun[]
Comment on lines +110 to +114
{
status: 'failed',
createdAt: '2026-01-01T00:00:00Z',
updatedAt: '2026-01-01T02:00:00Z',
},
@clubanderson clubanderson merged commit b6bcefd into main Jun 26, 2026
28 of 30 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the quality/test-llmd-utils branch June 26, 2026 01:03
@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: b6bcefd96f72f736538c95d82564f06ef0ae6639
Specs run: Dashboard.spec.ts smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/28210431580

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit b6bcefd96f72f736538c95d82564f06ef0ae6639.

clubanderson added a commit that referenced this pull request Jun 26, 2026
Fixes the shared root cause that broke render tests across card components
and mission components after PR #19662 merged.

Root cause: The new test files (KVCacheMonitor.utils.test.ts and
nightlyE2E.constants.test.ts) were running in the default jsdom environment
instead of Node.js environment. Since they test pure utility functions that
import React types, these tests were polluting the global scope when they ran,
affecting subsequent jsdom tests in CI (where tests run sequentially with 1
worker).

Fix: Added @vitest-environment node directive to both test files so they run
in Node.js environment instead of jsdom, preventing global scope pollution.

This follows the same pattern as the fix in #19663 which resolved the previous
168 test failure cascade.

Signed-off-by: Copilot <copilot@users.noreply.github.com>
Co-authored-by: Copilot <copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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