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

ci: add performance script to PR jobs #3274

Merged
merged 81 commits into from
Mar 17, 2025
Merged

Conversation

BlairCurrey
Copy link
Contributor

@BlairCurrey BlairCurrey commented Feb 5, 2025

Changes proposed in this pull request

  • Decouples testenv from integration tests such that it can be re-used for performance tests in CI
    • MockASE handles seeding and hosting integration endpoints required for rafiki to properly function (rates, webhooks). This is located in the integration tests in main so I moved it out for re-use when running performance tests.
    • Performance tests in main run against our localenv. I changed it to be configurable by parameterizing the run script and test and reading from a config to get the correct environment details (network name, urls). So now you could run performance tests locally against the testenv without interference with your localenv. And can still run against localenv if you want to use the grafana dashboard.
  • Adds github action job to run k6 test and upsert comment to PR with result

The PR comment got buried here (shouldnt happen normally, will be one of the first comments w/ netlift): #3274 (comment)

Context

fixes: #3240

Checklist

  • Related issues linked using fixes #number
  • Tests added/updated
  • Make sure that all checks pass
  • Bruno collection updated (if necessary)
  • Documentation issue created with user-docs label (if necessary)
  • OpenAPI specs updated (if necessary)

- currently requires running tests to setup db
(waiting to avoid actually running tests and spinning down tests/env)
- loses ability to run k6 against rafiki w/ telemetry
- in preparation for switching performance test
to target testenv
- ensured integration tests pass
- supports reuse in setup script for performance tests
which will allow running performance test against testenv
- also bumps graphql pacakge version across monorepo.
added to test-lib which caused some type errors
in backend and auth due to a version mismatch
@github-actions github-actions bot added type: tests Testing related pkg: backend Changes in the backend package. labels Feb 5, 2025
Copy link

netlify bot commented Feb 5, 2025

Deploy Preview for brilliant-pasca-3e80ec canceled.

Name Link
🔨 Latest commit 1ae69f9
🔍 Latest deploy log https://app.netlify.com/sites/brilliant-pasca-3e80ec/deploys/67d45052dbfa970008583a35

@github-actions github-actions bot added the type: source Changes business logic label Feb 5, 2025
@github-actions github-actions bot added the type: ci Changes to the CI label Feb 7, 2025
@BlairCurrey BlairCurrey changed the title Bc/3240/performance ci ci: add performance script to PR jobs Feb 7, 2025
@koekiebox koekiebox self-requested a review March 7, 2025 10:33
Copy link
Collaborator

@koekiebox koekiebox left a comment

Choose a reason for hiding this comment

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

Minor requests / updates. Rest looks good. 👍

C9_OPEN_PAYMENTS_PORT="3000"
C9_GRAPHQL_PORT="3001"
HLB_OPEN_PAYMENTS_PORT="4000"
DOCKER_NETWORK="rafiki_rafiki"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing new line.

C9_OPEN_PAYMENTS_PORT="3100"
C9_GRAPHQL_PORT="3101"
HLB_OPEN_PAYMENTS_PORT="4100"
DOCKER_NETWORK="rafiki-test_rafiki-test"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing new line.

Comment on lines +165 to +188
export function handleSummary(data) {
const requestsPerSecond = data.metrics.http_reqs.values.rate
const iterationsPerSecond = data.metrics.iterations.values.rate
const failedRequests = data.metrics.http_req_failed.values.passes
const failureRate = data.metrics.http_req_failed.values.rate
const requests = data.metrics.http_reqs.values.count

const summaryText = `
**Test Configuration**:
- VUs: ${options.vus}
- Duration: ${options.duration}

**Test Metrics**:
- Requests/s: ${requestsPerSecond.toFixed(2)}
- Iterations/s: ${iterationsPerSecond.toFixed(2)}
- Failed Requests: ${failureRate.toFixed(2)}% (${failedRequests} of ${requests})
`

return {
// Preserve standard output w/ textSummary
stdout: textSummary(data, { enableColors: false }),
'k6-test-summary.txt': summaryText // saves to file
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also save a summary HTML report via:

import { htmlReport } from 'https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js';

// Report handling
/**
 * Report Generation
 * Handles the generation of test result reports
 * @param {Object} data - Test result data from K6
 * @returns {Object} Report configuration object
 */
export function handleSummary(data) {
    return {
        'reports/summary.html': htmlReport(data)
    };
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like it!

@BlairCurrey
Copy link
Contributor Author

@koekiebox Tried out the html report. Looks nice. I dont see a straightforward way to get in the PR. Perhaps it could be used locally, although I think in that case the cli has the same info and you dont have to go hunt it down.

image

@BlairCurrey BlairCurrey requested a review from koekiebox March 11, 2025 16:22
mkurapov
mkurapov previously approved these changes Mar 12, 2025
njlie
njlie previously approved these changes Mar 12, 2025
@BlairCurrey BlairCurrey dismissed stale reviews from njlie and mkurapov via 1ae69f9 March 14, 2025 15:50
Copy link
Collaborator

@koekiebox koekiebox left a comment

Choose a reason for hiding this comment

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

LGTM

@BlairCurrey BlairCurrey merged commit bf43ccc into main Mar 17, 2025
44 checks passed
@BlairCurrey BlairCurrey deleted the bc/3240/performance-ci branch March 17, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: auth Changes in the GNAP auth package. pkg: backend Changes in the backend package. type: ci Changes to the CI type: source Changes business logic type: tests Testing related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add performance monitoring for each PR
4 participants