Skip to content

Add benchmark installation for LM tests with minimum sleep - #2012

Open
khansaad wants to merge 4 commits into
kruize:mvp_demofrom
khansaad:lm-tests-fix
Open

Add benchmark installation for LM tests with minimum sleep#2012
khansaad wants to merge 4 commits into
kruize:mvp_demofrom
khansaad:lm-tests-fix

Conversation

@khansaad

@khansaad khansaad commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds benchmarks installation at the script level with appropriate sleep to get the minimum datapoints required to get the recommendations.
Fixes # (issue)

Type of change

  • Bug fix
  • New feature
  • Docs update
  • Breaking change (What changes might users need to make in their application due to this PR?)
  • Requires DB changes

How has this been tested?

Please describe the tests that were run to verify your changes and steps to reproduce. Please specify any test configuration required.

  • New Test X
  • Functional testsuite

Test Configuration

  • Kubernetes clusters tested on:

Checklist 🎯

  • Followed coding guidelines
  • Comments added
  • Dependent changes merged
  • Documentation updated
  • Tests added or updated

Additional information

Include any additional information such as links, test results, screenshots here

Summary by Sourcery

Add automated benchmark setup and teardown to local monitoring tests and ensure sufficient metrics collection time before running recommendations.

New Features:

  • Introduce automatic installation of TFB, Spring Petclinic, and Sysbench benchmarks as part of local monitoring test execution.
  • Add configurable control to skip benchmark setup for test runs that do not require benchmarks.

Enhancements:

  • Resolve script path detection when the local monitoring test script is sourced by using BASH_SOURCE for repository root discovery.
  • Add a timed wait loop with periodic progress messages to allow metrics data collection before generating recommendations.
  • Automatically clean up the cloned benchmarks directory after the local monitoring test suite completes.
  • Extend the generic benchmarks_install helper to support deploying the Sysbench benchmark alongside existing benchmarks.

Signed-off-by: Saad Khan <saakhan@ibm.com>
@khansaad khansaad added this to the Kruize 0.12.0 Release milestone Jul 2, 2026
@khansaad
khansaad requested a review from chandrams July 2, 2026 11:49
@khansaad khansaad self-assigned this Jul 2, 2026
@khansaad khansaad added the test label Jul 2, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds automated benchmark installation and cleanup to local monitoring tests, introduces a minimum metrics collection wait period, and extends benchmark support to include sysbench in the common benchmark installer.

File-Level Changes

Change Details Files
Initialize script paths using BASH_SOURCE for correct repo root resolution when sourced.
  • Compute CURRENT_DIR using realpath on BASH_SOURCE[0].
  • Derive KRUIZE_REPO from CURRENT_DIR and reuse it for LOCAL_MONITORING_TEST_DIR and METRIC_PROFILE_DIR initialization.
tests/scripts/local_monitoring_tests/local_monitoring_tests.sh
Integrate benchmark setup/teardown into local monitoring tests with logging and configurable skipping.
  • Create per-test benchmark_setup.log in the test suite directory.
  • Add skip_benchmark_setup flag gate around benchmark installation.
  • Clone benchmarks repo on demand via clone_repos if missing.
  • Delete pre-existing load generator jobs before installing benchmarks.
  • Install tfb and petclinic using kruize-demos manifests and sysbench using default_manifests.
  • Add post-suite cleanup that removes the local benchmarks directory.
tests/scripts/local_monitoring_tests/local_monitoring_tests.sh
tests/scripts/common/common_functions.sh
Introduce a fixed-duration metrics collection wait with periodic progress logging before running tests.
  • Add a 30-minute total sleep implemented as repeated shorter intervals to avoid appearing stuck.
  • Log progress messages with remaining time and timestamps during the wait.
  • Announce completion of the data collection period before executing tests.
tests/scripts/local_monitoring_tests/local_monitoring_tests.sh
Extend benchmarks_install function to support sysbench and tighten branching logic.
  • Convert the petclinic branch from a separate if to an elif to enforce mutual exclusivity with tfb.
  • Add a new sysbench branch that applies manifests from either a named manifests directory or all manifests/*.yaml.
  • Ensure each benchmark branch checks for startup errors via check_err after kubectl apply.
tests/scripts/common/common_functions.sh
Add global control flag for benchmark setup to the common test configuration.
  • Introduce skip_benchmark_setup variable defaulting to 0 in common_functions.sh to control benchmark installation.
  • Use this flag in local_monitoring_tests to optionally skip benchmark setup while retaining other behaviors.
tests/scripts/common/common_functions.sh
tests/scripts/local_monitoring_tests/local_monitoring_tests.sh

Possibly linked issues

  • #0: Issue: LM tests lack recommendations; PR installs benchmarks and waits for metrics, enabling recommendation generation.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@khansaad khansaad moved this to Under Review in Monitoring Jul 2, 2026

@sourcery-ai sourcery-ai Bot 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.

Hey - I've left some high level feedback:

  • The wait-for-metrics block has a mismatch between comments/messages and actual timing (180 total sleep with 30-second intervals vs. “30 minutes” and “5 minutes”), which can confuse users; either adjust the sleep values to match the stated duration or correct the messages to reflect the real wait period.
  • You’ve repurposed LOG for benchmark setup logging, but it’s also used later in the Kruize setup section; consider using a separate variable for benchmark logs to avoid mixing different concerns into a single file and make troubleshooting easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The wait-for-metrics block has a mismatch between comments/messages and actual timing (180 total sleep with 30-second intervals vs. “30 minutes” and “5 minutes”), which can confuse users; either adjust the sleep values to match the stated duration or correct the messages to reflect the real wait period.
- You’ve repurposed `LOG` for benchmark setup logging, but it’s also used later in the Kruize setup section; consider using a separate variable for benchmark logs to avoid mixing different concerns into a single file and make troubleshooting easier.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

khansaad added 3 commits July 8, 2026 22:13
Signed-off-by: Saad Khan <saakhan@ibm.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
Signed-off-by: Saad Khan <saakhan@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Under Review

Development

Successfully merging this pull request may close these issues.

1 participant