Skip to content

test: Performance tests suite #21226

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

test: Performance tests suite #21226

wants to merge 8 commits into from

Conversation

anikdhabal
Copy link
Contributor

@anikdhabal anikdhabal commented May 10, 2025

What does this PR do?

Summary by mrge

Added performance tests suite using k6

@graphite-app graphite-app bot requested a review from a team May 10, 2025 20:18
Copy link
Contributor

github-actions bot commented May 10, 2025

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Perf tests". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@keithwillcode keithwillcode added the core area: core, team members only label May 10, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge reviewed this PR and found no issues. Review PR in mrge.io.

Copy link

graphite-app bot commented May 10, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (05/10/25)

1 reviewer was added to this PR based on Keith Williams's automation.

Copy link

vercel bot commented May 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Aug 11, 2025 4:21pm
cal-eu ⬜️ Ignored (Inspect) Visit Preview Aug 11, 2025 4:21pm

@anikdhabal anikdhabal changed the title Perf tests test: Perf tests suite [WIP] May 10, 2025
@anikdhabal anikdhabal marked this pull request as draft May 10, 2025 20:23
@anikdhabal anikdhabal changed the title test: Perf tests suite [WIP] test: Performance tests suite [WIP] May 12, 2025
@anikdhabal anikdhabal marked this pull request as ready for review May 12, 2025 16:39
@anikdhabal anikdhabal changed the title test: Performance tests suite [WIP] test: Performance tests suite May 12, 2025
@dosubot dosubot bot added automated-tests area: unit tests, e2e tests, playwright performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive labels May 12, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge found 9 issues across 8 files. Review them in mrge.io

}

export function randomSleep(min = SLEEP_DURATION.SHORT, max = SLEEP_DURATION.MEDIUM) {
const sleepTime = Math.random() * (max - min) + min;
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing validation that min is less than max

}

export function randomQueryParam() {
return `nocache=${new Date().getTime()}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Using Date.now() would be more efficient than new Date().getTime()

},
};

export const TEST_USERS = new SharedArray("users", function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hardcoded test credentials in source code

import { viewBookingPage } from "../utils/helpers.js";

export const options = {
stages: [
Copy link
Contributor

Choose a reason for hiding this comment

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

The spike test has a very aggressive ramp-up (1m to reach 5000 VUs) which may not accurately simulate real-world traffic patterns and could overwhelm the system too quickly.

export default function () {
viewBookingPage("pro", "30min");

sleep(0.01);
Copy link
Contributor

Choose a reason for hiding this comment

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

Sleep duration is too short for a spike test. The 0.01s sleep time may not provide enough pause between iterations, potentially causing excessive load beyond what's intended.

import { sleep } from "k6";

import { THRESHOLDS } from "../utils/config.js";
import { viewBookingPage } from "../utils/helpers.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

Importing from a file that doesn't appear to exist in the repository

@@ -0,0 +1,26 @@
import { sleep } from "k6";

import { THRESHOLDS } from "../utils/config.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

Importing from a file that doesn't appear to exist in the repository

return group("View Booking Page", () => {
const url = `${BASE_URL}/${username}/${eventSlug}?${randomQueryParam()}`;

const response = http.get(url, {
Copy link
Contributor

Choose a reason for hiding this comment

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

No timeout specified for HTTP request


check(response, {
"Booking page loaded": (r) => r.status === 200,
"Has booking form": (r) => r.body.includes('data-testid="day"'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Brittle test that relies on specific DOM element

Copy link
Contributor

github-actions bot commented Jun 6, 2025

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Jun 6, 2025
Copy link
Contributor

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Jun 22, 2025
Copy link
Contributor

coderabbitai bot commented Jul 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

A new performance testing framework using Grafana k6 was added for the booking flow. A GitHub Actions workflow (.github/workflows/performance-tests.yml) runs tests on release creation or manual dispatch. The repository now includes categorized k6 test scripts for smoke, load, stress, and spike scenarios, shared configuration and helper modules (base URL, thresholds, test users, sleep utilities, viewBookingPage helper), and a README describing setup, execution, and how to extend the suite. Each test simulates users viewing a booking page with varying VU profiles and thresholds.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ed0508 and 09f40cd.

📒 Files selected for processing (5)
  • .github/workflows/performance-tests.yml (1 hunks)
  • tests/performance/README.md (1 hunks)
  • tests/performance/spike/booking.js (1 hunks)
  • tests/performance/utils/config.js (1 hunks)
  • tests/performance/utils/helpers.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/performance/utils/helpers.js
  • tests/performance/README.md
  • .github/workflows/performance-tests.yml
  • tests/performance/utils/config.js
  • tests/performance/spike/booking.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch perf-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

delve-auditor bot commented Jul 16, 2025

No security or compliance issues detected. Reviewed everything up to 8ed0508.

Security Overview
  • 🔎 Scanned files: 8 changed file(s)
Detected Code Changes
Change Type Relevant files
Configuration changes ► .github/workflows/performance-tests.yml
    Add performance testing workflow
Enhancement ► tests/performance/README.md
    Add performance testing documentation
► tests/performance/load/booking.js
    Add load testing script
► tests/performance/smoke/booking.js
    Add smoke testing script
► tests/performance/spike/booking.js
    Add spike testing script
► tests/performance/stress/booking.js
    Add stress testing script
► tests/performance/utils/config.js
    Add performance test configuration
► tests/performance/utils/helpers.js
    Add performance test helper functions
Refactor ► bookings.e2e-spec.ts
    Refactor booking tests
► assign-all-team-members.e2e-spec.ts
    Simplify test assertions
► teams-event-types.controller.e2e-spec.ts
    Remove redundant test setup

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

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: 3

♻️ Duplicate comments (7)
tests/performance/utils/config.js (3)

35-40: Hardcoded test credentials pose a security risk.

Test credentials are hardcoded in source code, which is a security vulnerability. Consider using environment variables or a secure configuration file.


47-47: Use Date.now() for better performance.

Date.now() is more efficient than new Date().getTime() for getting timestamps.


50-53: Add validation for min/max parameters.

The function doesn't validate that min is less than max, which could lead to unexpected behavior.

tests/performance/utils/helpers.js (2)

10-12: Specify timeout for HTTP requests.

HTTP requests should have explicit timeout configurations to prevent hanging requests during performance testing.


16-16: Avoid brittle DOM element checks.

The test relies on a specific DOM element (data-testid="day"), making it fragile to UI changes. Consider checking for more stable indicators of successful page load.

tests/performance/spike/booking.js (2)

7-12: Spike test ramp-up pattern may be too aggressive for realistic simulation.

The current spike test rapidly increases from 500 to 5000 VUs in just 2 minutes, which may not accurately represent real-world traffic spike patterns and could overwhelm the system too quickly to gather meaningful performance data.


23-23: Sleep duration is too short for realistic load simulation.

The 0.01 second sleep time may not provide sufficient pause between iterations, potentially causing excessive load beyond what's intended and not reflecting realistic user behavior patterns.

🧹 Nitpick comments (3)
tests/performance/load/booking.js (1)

23-23: Consider increasing sleep duration for more realistic load simulation.

The 0.1 second sleep might be too aggressive and not representative of real user behavior. Consider increasing to 0.5-1 second for more realistic think time.

-  sleep(0.1);
+  sleep(0.5);
tests/performance/README.md (1)

62-62: Consider expanding the test scenarios section.

The documentation mentions that the test suite "focuses specifically on the booking flow" but only describes one scenario. Consider adding more details about what aspects of the booking flow are being tested or potential future scenarios.

tests/performance/stress/booking.js (1)

25-25: Consider making sleep duration configurable.

The sleep duration could be made configurable through the shared config to maintain consistency across different test types and allow for easy adjustment.

You could add a sleep configuration to utils/config.js:

export const SLEEP_DURATION = {
  SMOKE: 0.1,
  LOAD: 0.08,
  STRESS: 0.05,
  SPIKE: 0.01,
};

Then import and use it in the test:

+import { THRESHOLDS, SLEEP_DURATION } from "../utils/config.js";
-  sleep(0.05);
+  sleep(SLEEP_DURATION.STRESS);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df30f5c and 8ed0508.

📒 Files selected for processing (8)
  • .github/workflows/performance-tests.yml (1 hunks)
  • tests/performance/README.md (1 hunks)
  • tests/performance/load/booking.js (1 hunks)
  • tests/performance/smoke/booking.js (1 hunks)
  • tests/performance/spike/booking.js (1 hunks)
  • tests/performance/stress/booking.js (1 hunks)
  • tests/performance/utils/config.js (1 hunks)
  • tests/performance/utils/helpers.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
tests/performance/utils/helpers.js (1)
tests/performance/utils/config.js (2)
  • randomQueryParam (46-48)
  • randomSleep (50-53)
tests/performance/load/booking.js (5)
tests/performance/smoke/booking.js (2)
  • options (6-13)
  • options (6-13)
tests/performance/stress/booking.js (2)
  • options (6-20)
  • options (6-20)
tests/performance/spike/booking.js (2)
  • options (6-18)
  • options (6-18)
tests/performance/utils/config.js (2)
  • THRESHOLDS (12-33)
  • THRESHOLDS (12-33)
tests/performance/utils/helpers.js (1)
  • viewBookingPage (6-22)
tests/performance/stress/booking.js (5)
tests/performance/load/booking.js (2)
  • options (6-18)
  • options (6-18)
tests/performance/smoke/booking.js (2)
  • options (6-13)
  • options (6-13)
tests/performance/spike/booking.js (2)
  • options (6-18)
  • options (6-18)
tests/performance/utils/config.js (2)
  • THRESHOLDS (12-33)
  • THRESHOLDS (12-33)
tests/performance/utils/helpers.js (1)
  • viewBookingPage (6-22)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
🔇 Additional comments (8)
tests/performance/smoke/booking.js (1)

1-19: LGTM! Well-structured smoke test configuration.

The smoke test configuration is appropriate with 10 VUs for 2 minutes and uses proper thresholds. The test function correctly simulates user behavior with reasonable pacing.

tests/performance/load/booking.js (1)

6-18: LGTM! Well-designed load test stages.

The staged load profile effectively ramps up to 2000 VUs with proper warm-up and cool-down phases. The threshold configuration is appropriate for load testing.

tests/performance/README.md (1)

68-70: All VU counts in README.md match test configurations

The documented virtual user counts in tests/performance/README.md (lines 68–70) have been verified against their respective test scripts and accurately reflect the peak targets:

  • Load Tests: 2,000 VUs
  • Stress Tests: 4,000 VUs
  • Spike Tests: 5,000 VUs

No updates required.

tests/performance/spike/booking.js (2)

1-4: LGTM: Imports are correctly structured.

The imports follow k6 best practices and correctly reference the shared utilities for configuration and helper functions.


14-18: LGTM: Thresholds configuration is appropriate.

The threshold configuration correctly uses the SPIKE-specific thresholds from the shared config, which are appropriately more lenient for spike testing scenarios.

tests/performance/stress/booking.js (3)

3-4: Imports are now valid with the addition of utility files.

The previous concerns about importing from non-existent files are resolved as the utility files are being added in this PR.


6-20: LGTM: Stress test configuration is well-designed.

The staged load pattern provides a realistic stress testing scenario with gradual ramp-up to 4000 VUs, appropriate hold periods, and proper threshold configuration for stress testing conditions.


22-26: LGTM: Test function implementation is consistent.

The test function correctly uses the shared helper function and has a reasonable sleep duration (0.05s) that provides better pacing compared to the spike test.

- Add validation to randomSleep function to ensure min <= max
- Replace new Date().getTime() with Date.now() for better performance
- Move hardcoded test credentials to environment variables
- Add HTTP timeout to requests in helpers.js
- Improve DOM element checking to be less brittle
- Fix spike test sleep duration from 0.01s to 0.1s
- Make GitHub workflow BASE_URL configurable with inputs
- Fix README filename reference from booking_flow.js to booking.js
- Add documentation for new environment variables

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automated-tests area: unit tests, e2e tests, playwright core area: core, team members only performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants