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: Load Tests run in CI #324

Merged
merged 14 commits into from
Aug 6, 2024
Merged

Chore: Load Tests run in CI #324

merged 14 commits into from
Aug 6, 2024

Conversation

wilwade
Copy link
Contributor

@wilwade wilwade commented Aug 1, 2024

Problem

We want to run the k6 tests in CI so that they also function as semi-integration test system.

Closes: #317

Solution

@wilwade wilwade force-pushed the chore/load-test-ci-317 branch 5 times, most recently from 2e1e1ba to a9b3da4 Compare August 6, 2024 12:53
Run the tests

Everything has tests now

WIP

WIP 2

Trying a different way to run the k6 tests
Give a bit more time before starting

Fix health check urls

Fix issue with GHA script

Move just to node

More documentation on the wait for ready check

Javascript :(

Change wait method

Fix endpoint
Add the rust webhook server to the docker compose for k6 account service
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 follows the pattern from the Unit test workflow

steps:
- uses: actions/checkout@v4

- name: Install Node.js
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why node?

Because we need to run the setup script npm run main in tools/ci-k6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Each service has a docker-compose-k6.{service}.yaml. This overrides the base docker-compose.

  • Switches to use the production docker
  • configures other services and conditions as needed.

PROVIDER_BASE_URL: 'http://account-service-webhook:3001/webhooks/account-service'
WEBHOOK_BASE_URL: 'http://account-service-webhook:3001/webhooks'

account-service-webhook:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great example of an additional service needed.

Comment on lines +55 to +56
profiles:
- skip
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 so these services don't start by default. Easiest way to do this I found

@@ -55,7 +56,7 @@ services:
- redis_data:/data/redis

frequency:
image: dsnp/instant-seal-node-with-deployed-schemas:latest
image: frequencychain/standalone-node:v1.13.0-rc3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going ahead and switching to the new base image

@@ -159,7 +160,6 @@ services:
- graph_node_cache:/app/services/graph/node_modules
depends_on:
- redis
- ipfs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

graph service doesn't need ipfs

@@ -10,7 +10,7 @@
<mxCell id="34" value="" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="280" y="330" width="390" height="330" as="geometry" />
</mxCell>
<mxCell id="35" value="GET/api/health" style="endArrow=classic;html=1;rounded=0;fillColor=#d5e8d4;strokeColor=#82b366;strokeWidth=3;exitX=0.996;exitY=0.17;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0;entryY=0.172;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="45" target="41" edge="1">
<mxCell id="35" value="GET/healthz" style="endArrow=classic;html=1;rounded=0;fillColor=#d5e8d4;strokeColor=#82b366;strokeWidth=3;exitX=0.996;exitY=0.17;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0;entryY=0.172;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="45" target="41" edge="1">
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 think this is the correct one, but I didn't generate the pngs for it. Let me know if it is correct.

@@ -1,7 +1,7 @@
# Generated k6 script

The `account-service-load.js` file contains most of the Swagger/OpenAPI specification and you can customize it to your needs.
The `health-check.js` file contains a simple health check script that can be used to check the health of the service.
The `account-service-load.k6.js` file contains most of the Swagger/OpenAPI specification and you can customize it to your needs.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

First place this shows up...

So why?

  • I needed to be able to know when something was specifically for k6
  • This felt easier than trying to put all non-k6 test files into a subdirectory

```

## Generating Test Data
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a script to generate the information needed to run this test. I went for committing the generated code, as it works fine for running in CI and most runs. I'd be open to generating this as needed as well.

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 file I needed to move to skip as it requires more setup than we currently have in place. Various options to do this setup (including generating data like we do for signup) to using the same setup script that creates the provider.

@@ -36,63 +36,7 @@ const SLEEP_DURATION = 0.1;
// Global variables should be initialized.

export default function () {
group('health', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Health and siwf signup are in other test files now.

}
});

// Needs 255 generated accounts
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Annotated these with what they need to get it unskipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generator script

@@ -43,38 +46,39 @@ const CALLBACK_URL = 'http://localhost:3001/webhooks/account-service';
const BASE_URL = 'http://localhost:3000';
// Sleep duration between successive requests.
const SLEEP_DURATION = 0.1;
const BLOCKTIME_SECONDS = 12;
const BLOCKTIME_SECONDS = 13; // Add 1 second for additional loop buffer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps there is a better way to do this, but it works consistently.

@@ -22,7 +22,7 @@ const WEBHOOK_ENDPOINT: &str = "/account-service";

#[actix_web::main]
async fn main() -> Result<(), impl Error> {
const HOST: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1);
const HOST: Ipv4Addr = Ipv4Addr::new(0, 0, 0, 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allows this to bind to the external interface in docker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the basic health check to the content watcher so everything has k6 tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's the chain setup script

@wilwade wilwade marked this pull request as ready for review August 6, 2024 17:48
ipfs:
condition: service_healthy
account-service-webhook:
condition: service_healthy
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, didn't know you could have conditions on dependencies.

console.log('Block finalized. Checking callback...');
checkCallback();
console.log('Block finalized. Checking callback...', { referenceId });
checkCallback(referenceId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, love this improvement.

Copy link
Contributor

@mattheworris mattheworris left a comment

Choose a reason for hiding this comment

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

LGTM!!!

@wilwade wilwade merged commit ff4539b into main Aug 6, 2024
11 checks passed
@wilwade wilwade deleted the chore/load-test-ci-317 branch August 6, 2024 20:10
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.

Run Load Tests in CI
2 participants