Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(performance): Adjust thresholds #1870

Merged
merged 10 commits into from
Feb 13, 2025
Merged

Conversation

dagfinno
Copy link
Collaborator

Description

Adjust smoketests thresholds for p95 and removed thresholds for p99.
Use k8s k6 operator cluster instead of github runner

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • Documentation is updated (either in docs-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)

@dagfinno dagfinno requested review from a team as code owners February 13, 2025 05:50
Copy link
Contributor

coderabbitai bot commented Feb 13, 2025

📝 Walkthrough

Walkthrough

This pull request updates the performance testing configuration and associated test scripts. The CI/CD workflows now reference a new performance testing workflow file and use Azure credentials instead of token-based secrets. Additional parameters have been added to better control test execution. In the test scripts, performance thresholds have been modified by removing certain conditions, and the dialog creation script has been refactored with updated imports and a new function signature. A new performance test script for creating transmissions has also been introduced.

Changes

File(s) Change Summary
.github/workflows/ci-cd-yt01.yml, .github/workflows/workflow-run-k6-performance.yml Updated CI/CD workflows for performance tests: switched from workflow-run-k6-ci-cd-yt01.yml to workflow-run-k6-performance.yml, replaced token-based secrets with AZURE_CLIENT_ID/AZURE_TENANT_ID, added parameters (parallelism, breakpoint, abortOnFail), and introduced a new ref input parameter.
tests/k6/tests/enduser/performance/enduserSearchWithThresholds.js, tests/k6/tests/serviceowner/performance/serviceOwnerSearchWithThresholds.js Adjusted performance thresholds in search tests by removing the p(99) condition and updating the p(95) thresholds.
tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js Refactored the dialog creation script by updating imports, changing the function signature (removing parameters), and tightening the threshold for "create dialog" to p(95)<200.
tests/k6/tests/serviceowner/performance/createTransmissionsWithThresholds.js Introduced a new performance test script for transmissions with defined options, thresholds, and configurable environment variable usage.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • arealmaas
  • knuhau

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd62bec and 37677cb.

📒 Files selected for processing (2)
  • tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js (1 hunks)
  • tests/k6/tests/serviceowner/performance/createTransmissionsWithThresholds.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/k6/tests/serviceowner/performance/createTransmissionsWithThresholds.js
  • tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Dry run deploy infrastructure / Deploy to test
  • GitHub Check: build / build-and-test

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
tests/k6/tests/serviceowner/performance/createTransmissionsWithThresholds.js (1)

17-20: Consider documenting environment variables.

The environment variables provide good flexibility for test configuration. Consider adding documentation about these variables and their impact.

Add a comment block explaining the environment variables:

+// Environment variables:
+// - traceCalls: Enable/disable tracing (default: false)
+// - numberOfTransmissions: Number of transmissions to create (default: 10)
+// - maxTransmissionsInThread: Maximum transmissions per thread (default: 100)
+// - TESTID: Identifier for the test run (default: createTransmissions)
 const traceCalls = (__ENV.traceCalls ?? 'false') === 'true';
 const numberOfTransmissions = (__ENV.numberOfTransmissions ?? '10');
 const maxTransmissionsInThread = (__ENV.maxTransmissionsInThread ?? '100');
 const testid = (__ENV.TESTID ?? 'createTransmissions');
.github/workflows/ci-cd-yt01.yml (1)

117-117: Remove commented out code.

The commented out needs line should be removed as it's no longer needed.

-    #needs: [deploy-apps, check-for-changes]
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be62584 and 3f20ee0.

📒 Files selected for processing (6)
  • .github/workflows/ci-cd-yt01.yml (2 hunks)
  • .github/workflows/workflow-run-k6-performance.yml (1 hunks)
  • tests/k6/tests/enduser/performance/enduserSearchWithThresholds.js (1 hunks)
  • tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js (1 hunks)
  • tests/k6/tests/serviceowner/performance/createTransmissionsWithThresholds.js (1 hunks)
  • tests/k6/tests/serviceowner/performance/serviceOwnerSearchWithThresholds.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Dry run deploy infrastructure / Deploy to test
  • GitHub Check: build / build-and-test
🔇 Additional comments (13)
tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js (3)

1-3: LGTM! Good modularization.

The imports have been refactored to use common modules, improving code reusability and maintainability.


14-14: LGTM! Clean implementation with environment variable support.

The implementation has been simplified and now supports tracing through environment variables, making it more configurable and maintainable.

Also applies to: 16-18


9-9:

❓ Verification inconclusive

Verify the impact of removing p99 threshold.

The p99 threshold has been removed and p95 has been made stricter (from 300ms to 200ms). While this aligns with the PR objectives, please ensure this doesn't impact the reliability of performance testing.


🌐 Web query:

What are the best practices for setting performance test thresholds in k6?

💡 Result:

When setting performance test thresholds in k6, these best practices ensure effective evaluation of system performance against service-level objectives (SLOs):

Error Rate Thresholds

  • Set maximum acceptable error rates using http_req_failed metric
    rate<=0.05 (5% max errors) [1][2][7]
  • Combine with HTTP status checks for additional validation:
    check(res, {'status is 200': (r) => r.status === 200})[2][5]

Response Time Thresholds

  • Use percentile-based targets for realistic performance assessment:
    http_req_duration: ['p(95)<500', 'p(99)<1000'][1][7]
  • Layer multiple percentiles for comprehensive analysis:
    ['p(90) < 400', 'p(95) < 800', 'p(99.9) < 2000'][7]

Threshold Configuration Strategies

  1. Abort tests on critical failures using abortOnFail:
    thresholds: {
      http_req_failed: [{ 
        threshold: 'rate<=0.01', 
        abortOnFail: true 
      }]
    }[1]
  2. Validate check success rates:
    checks: ['rate>0.9'][5]
  3. Monitor system capacity metrics:
    • vus_max for maximum allocated users[2][10]
    • iterations for completed test cycles[4]

CI/CD Integration

  • Return non-zero exit codes for automated failure detection[1][7]
  • Combine with trend metrics for historical comparison:
    'iteration_duration{scenario:default}': ['max>=0'][10]

Maintenance Best Practices

  • Modularize configurations for reusability across test suites[9]
  • Set explicit duration targets in load profiles:
    stages: [
      {duration: '5m', target: 100}, 
      {duration: '30m', target: 100}
    ][1][10]

These practices enable teams to establish clear performance benchmarks while maintaining flexibility to adapt thresholds as systems evolve[3][7]. Always validate threshold values against actual business requirements and historical performance data[9].

Citations:


Action Required: Review Impact of Removing p99 Threshold

The updated code now uses a stricter p95 threshold (from 300ms to 200ms) and removes the p99 threshold. While this change aligns with the PR objectives, best practices for k6 performance testing recommend layering multiple percentiles (e.g., combining p95 and p99) to capture both overall and tail performance metrics. Please verify that the removal of the p99 threshold does not overlook potential latency issues, especially under peak conditions or edge cases. Consider reviewing historical performance data and current SLOs to ensure that relying solely on a stricter p95 value meets reliability requirements.

tests/k6/tests/serviceowner/performance/serviceOwnerSearchWithThresholds.js (1)

10-17:

❓ Verification inconclusive

Consistent threshold configuration across endpoints.

The thresholds have been standardized to p95<300ms for all endpoints, which aligns with the PR objectives. This consistency makes it easier to monitor and maintain performance standards.

Let's verify if these thresholds are reasonable for all endpoints:


🏁 Script executed:

#!/bin/bash
# Description: Check historical performance data for these endpoints

# Get the last 5 performance test runs
gh run list --workflow "Performance Tests" --limit 5 --json conclusion,url | jq -r '.[] | "\(.conclusion) \(.url)"'

Length of output: 237


Update: Threshold Consistency Verified – Manual Performance Verification Needed

The standardized thresholds (p(95) < 300ms) across the endpoints appear consistent with the PR’s objectives. However, the automated check for historical performance data failed (due to the repository not being recognized as a git repository), so we cannot conclusively verify the thresholds’ adequacy. Please manually review recent performance test outcomes to confirm that these thresholds are appropriate.

  • File: tests/k6/tests/serviceowner/performance/serviceOwnerSearchWithThresholds.js (Lines 10-17)
tests/k6/tests/enduser/performance/enduserSearchWithThresholds.js (1)

10-18: LGTM! Consistent with service owner thresholds.

The threshold configuration mirrors the changes in service owner endpoints, maintaining consistency across the codebase.

tests/k6/tests/serviceowner/performance/createTransmissionsWithThresholds.js (2)

1-15: LGTM! Well-structured performance test configuration.

The configuration follows the established pattern from other performance tests, with appropriate thresholds and reusable modules.


22-24: LGTM! Clean implementation.

The test function is concise and follows the same pattern as other performance tests.

.github/workflows/workflow-run-k6-performance.yml (3)

30-34: LGTM! Well-documented optional parameter.

The new ref parameter is properly documented with a clear description and sensible default value.


50-55: LGTM! Secure authentication implementation.

The workflow uses OIDC-based Azure authentication which is more secure than using long-lived credentials.


60-73: LGTM! Robust error handling in k8s setup.

The script properly checks for failures at each step of the k8s setup process and provides clear error messages.

.github/workflows/ci-cd-yt01.yml (3)

118-121: LGTM! Secure authentication transition.

Good transition from token-based authentication to Azure OIDC, which is more secure and follows best practices.


136-138: LGTM! Enhanced test control parameters.

The addition of parallelism, breakpoint, and abortOnFail parameters provides better control over test execution, aligning with the PR's objective to adjust performance testing.


122-129: LGTM! Well-structured test matrix.

The matrix strategy is well-organized with proper fail-fast configuration and max-parallel limit to prevent resource contention.

@dagfinno dagfinno merged commit 3e6e3b9 into main Feb 13, 2025
23 checks passed
@dagfinno dagfinno deleted the performance/set-thresholds branch February 13, 2025 09:39
oskogstad pushed a commit that referenced this pull request Feb 13, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.50.5](v1.50.4...v1.50.5)
(2025-02-13)


### Miscellaneous Chores

* **k6:** Consolidate k6-utils import URLs
([#1869](#1869))
([09b3722](09b3722))
* Misc. formatting, typos
([#1868](#1868))
([5de894f](5de894f))
* **performance:** Adjust thresholds
([#1870](#1870))
([3e6e3b9](3e6e3b9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants