Skip to content

Conversation

@Sagar-6203620715
Copy link
Contributor

Description

Added test files, coverage extended to 34%

  • pkg/workloadmanager/auth_test.go
  • pkg/workloadmanager/client_cache_test.go
  • pkg/workloadmanager/codeinterpreter_controller_test.go
  • pkg/workloadmanager/sandbox_helper_test.go

Related Issue

Partially fixes #88

Type of Change

  • Test addition/update

Changes Made

Added test for two files in pkg/router

Testing

  • Unit tests added/updated
  • Integration tests pass

Before
image

After
image

Signed-off-by: Sagar Choudhary <sagar6203620715@gmail.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Sagar-6203620715, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly boosts the unit test coverage for the pkg/workloadmanager package, elevating it from 16% to 34%. By introducing new test files and expanding existing test suites, the changes aim to fortify the reliability and correctness of critical components such as authentication, client caching, the CodeInterpreter controller, and sandbox management. This ensures that these core functionalities behave as expected under various conditions and edge cases.

Highlights

  • Enhanced Authentication Test Coverage: Comprehensive unit tests have been added for the authentication middleware and token caching mechanisms within pkg/workloadmanager/auth.go, covering various scenarios like disabled auth, invalid headers, and service account parsing.
  • Improved Client Cache Testing: New unit tests for pkg/workloadmanager/client_cache.go validate JWT expiry parsing, cache eviction (LRU behavior), and concurrent access for both client and token caches, ensuring robust caching logic.
  • Code Interpreter Controller Logic Validation: Unit tests for the CodeInterpreterReconciler in pkg/workloadmanager/codeinterpreter_controller.go now verify the convertToPodTemplate function's behavior across different configurations, including runtime class, environment variable injection based on auth mode, and command/argument handling.
  • Sandbox Helper Function Reliability: Tests have been introduced for sandbox helper functions in pkg/workloadmanager/sandbox_helper.go, confirming the correct construction of sandbox placeholders and detailed sandbox information, as well as accurate status reporting from Kubernetes conditions.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request significantly improves test coverage for the pkg/workloadmanager package by adding new test files for authentication, client caching, CodeInterpreter controller logic, and sandbox helpers. The new tests cover various scenarios, including authentication flows, JWT parsing, cache behaviors (LRU, eviction, expiration), and Kubernetes resource conversions. This is a valuable contribution to the project's stability and maintainability.

@codecov-commenter
Copy link

codecov-commenter commented Jan 22, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@ecea52a). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #163   +/-   ##
=======================================
  Coverage        ?   42.29%           
=======================================
  Files           ?       29           
  Lines           ?     2549           
  Branches        ?        0           
=======================================
  Hits            ?     1078           
  Misses          ?     1339           
  Partials        ?      132           
Flag Coverage Δ
unittests 42.29% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Sagar Choudhary <sagar6203620715@gmail.com>
Signed-off-by: Sagar Choudhary <sagar6203620715@gmail.com>
@Sagar-6203620715
Copy link
Contributor Author

/cc @hzxuzhonghu

@volcano-sh-bot
Copy link
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 yaozengzeng for approval. For more information see the Kubernetes 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

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

No big issue, please read https://go.dev/wiki/TableDrivenTests#

Signed-off-by: Sagar Choudhary <sagar6203620715@gmail.com>
Signed-off-by: Sagar Choudhary <sagar6203620715@gmail.com>
@Sagar-6203620715
Copy link
Contributor Author

@hzxuzhonghu I have refactored and reviewed the code and removed unrequired redundant tests

Ready for final review->merge

@Sagar-6203620715
Copy link
Contributor Author

HI @hzxuzhonghu Apologies to ping you but I would like to request you to review this pull request as I have merged the two functions as you instructed and refactored the code.

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

Thanks for the big coverage bump! The tests are useful overall, but please refactor several groups to follow Go table-driven style and reduce a flaky sleep. Details:

Table-driven refactors requested

  • pkg/workloadmanager/client_cache_test.go: consolidate TestParseJWTExpiry_* cases into one table test (valid/invalid/no-exp/float/int). Also consider table-driven grouping for cache eviction/update/remove variants.
  • pkg/workloadmanager/codeinterpreter_controller_test.go: combine RuntimeClassName and AuthMode variants into table-driven cases.
  • pkg/workloadmanager/sandbox_helper_test.go: combine buildSandboxInfo variants into a table-driven test.
  • pkg/workloadmanager/auth_test.go: merge the two cache-hit tests into a small table.

Stability note

  • TestTokenCache_Get_Expired currently sleeps 2s. Please reduce to a short TTL (e.g., 50–100ms) and a small sleep to avoid slow/flaky tests.

Once these are addressed, the test suite looks good to me.

Signed-off-by: Sagar Choudhary <sagar6203620715@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Umbrella: strengthen unit test coverage across AgentCube components

4 participants