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

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

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

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 ready!

Name Link
🔨 Latest commit d4e11ea
🔍 Latest deploy log https://app.netlify.com/sites/brilliant-pasca-3e80ec/deploys/67c0b9f97f2d6a000836ecb0
😎 Deploy Preview https://deploy-preview-3274--brilliant-pasca-3e80ec.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@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
- not sure if config outpute by script will reflect options passed in, probably not.
config in gh pr comment may not be accurate.
Comment on lines +205 to +210
- name: Post/Update Performance Test Results as PR Comment
if: always()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am in-lining the javascript here because I found it easier than passing everything from the actions context in and it was just easier for development. We can move this to a file and just run it with node if we prefer though.

@interledger interledger deleted a comment from github-actions bot Feb 13, 2025
Comment on lines +195 to +205
- name: Run performance tests
id: perf_test
run: |
pnpm --filter performance run-tests:testenv -k --vus 4 --duration 1m | tee performance.log
continue-on-error: true # Don't fail here, allows showing logs

- name: Print MASE logs
if: always()
run: cat mases.log

- name: Post/Update Performance Test Results as PR Comment
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a grafana/k6 action that runs the tests and exports to grafana cloud and leaves a comment here with a link:
https://grafana.com/blog/2024/07/15/performance-testing-with-grafana-k6-and-github-actions/

I opted for doing it more manually as a start - was simpler to get going. And even with that action we might need to manual write/edit a comment if we want the actual metrics in the PR comment (looks like the comment just leaves a link). But that could probably be mitigated by setting good thresholds (fail if iterations < x etc. ) and just use the job for pass/fail and venture into grafana when it fails for more details.

It does appear like the free tier is fairly generous and it probably gives us a lot of stuff for free like a centralized view of the history of runs. Open to reworking if we want that but I think this gives us what we're looking for for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the comment generated: #3274 (comment)

It just upserts with the latest results and test logs.

- name: Run performance tests
id: perf_test
run: |
pnpm --filter performance run-tests:testenv -k --vus 4 --duration 1m | tee performance.log
Copy link
Contributor Author

@BlairCurrey BlairCurrey Feb 13, 2025

Choose a reason for hiding this comment

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

What do we want the test config to be?

I opted for 4VUs and 1M after testing some different values. I think we want to:

  1. not make the duration longer than necessary. Just dont want to extend the time it takes CI to finish if we can help it. So I prefered more VUs for a shorter time to some extent. There may still be some room to increase duration if we want. This is taking ~3m while the docker builds are taking 4-5m
  2. reliably complete the tests without failures as a baseline. But approaching the point where we do see issues. I saw some errors at 5VUs so I backed off.

I think the hardware is determined by runs-on: ubuntu-22.04 and should always be the same across runs.

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
Contributor Author

Choose a reason for hiding this comment

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

this is how we're saving the results for use in the comment. the stdout will preserve the normal output and the k6-test-summary.txt saves the details we want to report.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lots of changes here but it basically just makes the target environment configurable.

@BlairCurrey BlairCurrey marked this pull request as ready for review February 13, 2025 19:14
and a process for the Mock Account Servicing Entities:

```sh
pnpm --filter perfromance start-mases
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: perfromance -> performance

@@ -0,0 +1,8 @@
C9_BACKEND_HOST="cloud-nine-wallet-backend"
HLB_BACKEND_HOST="happy-life-bank-backend"
C9_AUTH_HOST="cloud-nine-wallet-backend"
Copy link
Contributor

@njlie njlie Feb 21, 2025

Choose a reason for hiding this comment

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

Isn't the auth host here supposed to be (cloud-nine-wallet/happy-life-bank)-auth?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, fixed. Thanks.

@@ -0,0 +1,8 @@
C9_BACKEND_HOST="cloud-nine-wallet-test-backend"
HLB_BACKEND_HOST="happy-life-bank-test-backend"
C9_AUTH_HOST="cloud-nine-wallet-test-backend"
Copy link
Contributor

Choose a reason for hiding this comment

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

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
2 participants