Skip to content

Commit

Permalink
Fix readmes and remove generate_tokens.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
dagfinno committed Jan 14, 2025
1 parent 4b85a6d commit 632ee73
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 178 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ dotnet ef migrations add TestMigration

Besides ordinary unit and integration tests, there are test suites for both functional and non-functional end-to-end tests implemented with [K6](https://k6.io/).

See `tests/k6/README.md` for more information.
See [tests/k6/README.md](tests/k6/README.md) for more information.

## Health Checks

Expand Down
8 changes: 8 additions & 0 deletions tests/k6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ Run `Get-Help .\run.ps1` or `./run.sh --help` for usage information.

The scripts will use locally installed `k6` if available. Failing that, it will attempt to use Docker with [grafana/k6](https://hub.docker.com/r/grafana/k6)

## Performance tests

For information about the performance tests, see the following README files:

- [ServiceOwner](tests/serviceowner/performance/README.md)
- [GraphQL](tests/graphql/performance/README.md)
- [EndUser](tests/enduser/performance/README.md)

## Test suites

Various test suites are defined withing the `suites` directory. A suite consists of
Expand Down
29 changes: 7 additions & 22 deletions tests/k6/tests/enduser/performance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The test file associated with this performance test is
- `enduser-search.js`

## Test description
The test has a list of enduser (ssn) with pre-generated tokens, and the following endpoints are visited in
The test has a list of enduser (ssn), and the following endpoints are visited in
sequence for each enduser:
- api/v1/enduser/dialogs?Party=urn:altinn:person:identifier-no:`<ssn>`
- api/v1/enduser/dialogs/`<dialogId>`
Expand All @@ -28,19 +28,14 @@ sequence for each enduser:
```shell
cd tests/k6/tests/enduser/performance
```
2. Generate tokens using the script below. Make sure to replace `<username>`, `<passwd>` and `<test|staging|yt01>` with your desired values:
```shell
TOKEN_GENERATOR_USERNAME=<username> \
TOKEN_GENERATOR_PASSWORD=<passwd> API_ENVIRONMENT=<test|staging|yt01> \
../../scripts/generate_tokens.sh ../../performancetest_data personal
```
3. Run the test using the following command. Replace `<test|staging|yt01>`, `<vus>`, and `<duration>` with the desired values:
2. Run the test using the following command. Replace `<test|staging|yt01>`, `<vus>`, and `<duration>` with the desired values:
```shell
TOKEN_GENERATOR_USERNAME=<username> TOKEN_GENERATOR_PASSWORD=<passwd> \
k6 run enduser-search.js -e API_VERSION=v1 \
-e API_ENVIRONMENT=<test|staging|yt01> \
--vus=<vus> --duration=<duration>
```
4. Refer to the k6 documentation for more information on usage.
3. Refer to the k6 documentation for more information on usage.

### From GitHub Actions
To run the performance test using GitHub Actions, follow these steps:
Expand All @@ -56,26 +51,16 @@ To run the performance test locally using GitHub Actions and act, perform the fo
```file
TOKEN_GENERATOR_USERNAME:<username>
TOKEN_GENERATOR_PASSWORD:<passwd>
K6_CLOUD_PROJECT_ID=**
K6_CLOUD_TOKEN=**
K6_PROMETHEUS_RW_USERNAME=**
K6_PROMETHEUS_RW_PASSWORD=**
K6_PROMETHEUS_RW_SERVER_URL=**
```
Replace `<username>` and `<passwd>`, same as for generating tokens above. Fill in the K6_* values if available,
used for reporting to Grafana cloud
Replace `<username>` and `<passwd>`, same as for generating tokens above.
##### IMPORTANT: Ensure this file is added to .gitignore to prevent accidental commits of sensitive information. Never commit actual credentials to version control.
4. Run `act` using the command below. Replace `<vus>` and `<duration>` with the desired values:
```shell
act workflow_dispatch -j k6-performance -s GITHUB_TOKEN=`gh auth token` \
--container-architecture linux/amd64 --artifact-server-path $HOME/.act \
--input vus=<vus> --input duration=<duration> \
--input testSuitePath=tests/k6/tests/enduser/performance/enduser-search.js \
--input tokens=personal
--input testSuitePath=tests/k6/tests/enduser/performance/enduser-search.js
```

## Test Results
Test results can be found in GitHub action run log and in App Insights. We are prepared for exporting results to grafana, but so far results are exported to a private grafana instance only, as can be seen from the `.secrets`listed earlier

## TODO
Fix reporting
Test results can be found in GitHub action run log, grafana and in App Insights.
27 changes: 6 additions & 21 deletions tests/k6/tests/graphql/performance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ The test file associated with this performance test is
```shell
cd tests/k6/tests/graphql/performance
```
2. Generate tokens using the script below. Make sure to replace `<username>`, `<passwd>` and `(<test|staging|yt01>)` with your desired values:
```shell
TOKEN_GENERATOR_USERNAME=<username> \
TOKEN_GENERATOR_PASSWORD=<passwd> API_ENVIRONMENT=<(test|staging|yt01)> \
../../scripts/generate_tokens.sh ../../performancetest_data personal
```
3. Run the test using the following command. Replace `<(test|staging|yt01)>`, `<vus>`, and `<duration>` with the desired values:
2. Run the test using the following command. Replace `<(test|staging|yt01)>`, `<vus>`, and `<duration>` with the desired values:
```shell
TOKEN_GENERATOR_USERNAME=<username> TOKEN_GENERATOR_PASSWORD=<passwd> \
k6 run graphql-search.js -e API_VERSION=v1 \
-e API_ENVIRONMENT=<(test|staging|yt01)> \
--vus=<vus> --duration=<duration>
```
4. Refer to the k6 documentation for more information on usage.
3. Refer to the k6 documentation for more information on usage.
### From GitHub Actions
To run the performance test using GitHub Actions, follow these steps:
1. Go to the [GitHub Actions](https://github.com/digdir/dialogporten/actions/workflows/dispatch-k6-performance.yml) page.
Expand All @@ -42,26 +37,16 @@ To run the performance test locally using GitHub Actions and act, perform the fo
```file
TOKEN_GENERATOR_USERNAME:<username>
TOKEN_GENERATOR_PASSWORD:<passwd>
K6_CLOUD_PROJECT_ID=**
K6_CLOUD_TOKEN=**
K6_PROMETHEUS_RW_USERNAME=**
K6_PROMETHEUS_RW_PASSWORD=**
K6_PROMETHEUS_RW_SERVER_URL=**
```
Replace `<username>` and `<passwd>`, same as for generating tokens above. Fill in the K6_* values if available,
used for reporting to Grafana cloud
Replace `<username>` and `<passwd>`, same as for generating tokens above.
##### IMPORTANT: Ensure this file is added to .gitignore to prevent accidental commits of sensitive information. Never commit actual credentials to version control.
4. Run `act` using the command below. Replace `<vus>` and `<duration>` with the desired values:
```shell
act workflow_dispatch -j k6-performance -s GITHUB_TOKEN=`gh auth token` \
--container-architecture linux/amd64 --artifact-server-path $HOME/.act \
--input vus=<vus> --input duration=<duration> \
--input testSuitePath=tests/k6/tests/graphql/performance/graphql-search.js \
--input tokens=personal
--input testSuitePath=tests/k6/tests/graphql/performance/graphql-search.js
```

## Test Results
Test results can be found in GitHub action run log and in App Insights. We are prepared for exporting results to grafana, but so far results are exported to a private grafana instance only, as can be seen from the `.secrets`listed earlier

## TODO
Fix reporting
Test results can be found in GitHub action run log, grafana and in App Insights.
111 changes: 0 additions & 111 deletions tests/k6/tests/scripts/generate_tokens.sh

This file was deleted.

31 changes: 8 additions & 23 deletions tests/k6/tests/serviceowner/performance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Before running the performance test, make sure you have met the following prereq
The test files associated with this performance test are
- `create-dialog.js`
- `create-remove-dialog.js`
- `create-transmissions.js`
- `serviceowner-search.js`
- `purge-dialogs.js` (used for cleanup after test)

Expand All @@ -21,19 +22,14 @@ To run the performance test, follow the instructions below:
```shell
cd tests/k6/tests/serviceowner/performance
```
2. Generate tokens using the script below. Make sure to replace `<username>`, `<passwd>` and `<(test|staging|yt01)>` with your actual desired values:
```shell
TOKEN_GENERATOR_USERNAME=<username> \
TOKEN_GENERATOR_PASSWORD=<passwd> API_ENVIRONMENT=<(test|staging|yt01)> \
../../scripts/generate_tokens.sh ../../performancetest_data both
```
3. Run the test using the following command. Replace `<test-file>`, `<(test|staging|yt01)>`, `<vus>`, and `<duration>` with the desired values:
2. Run the test using the following command. Replace `<test-file>`, `<(test|staging|yt01)>`, `<vus>`, and `<duration>` with the desired values:
```shell
TOKEN_GENERATOR_USERNAME=<username> TOKEN_GENERATOR_PASSWORD=<passwd> \
k6 run <test-file> -e API_VERSION=v1 \
-e API_ENVIRONMENT=<(test|staging|yt01)> \
--vus=<vus> --duration=<duration>
```
4. Refer to the k6 documentation for more information on usage.
3. Refer to the k6 documentation for more information on usage.

#### From GitHub Actions
To run the performance test using GitHub Actions, follow these steps:
Expand All @@ -49,31 +45,23 @@ To run the performance test locally using GitHub Actions and act, perform the fo
```file
TOKEN_GENERATOR_USERNAME:<username>
TOKEN_GENERATOR_PASSWORD:<passwd>
K6_CLOUD_PROJECT_ID=**
K6_CLOUD_TOKEN=**
K6_PROMETHEUS_RW_USERNAME=**
K6_PROMETHEUS_RW_PASSWORD=**
K6_PROMETHEUS_RW_SERVER_URL=**
```
Replace `<username>` and `<passwd>`, same as for generating tokens above. Fill in the K6_* values if available,
used for reporting to Grafana cloud
Replace `<username>` and `<passwd>`, same as for generating tokens above.
##### IMPORTANT: Ensure this file is added to .gitignore to prevent accidental commits of sensitive information. Never commit actual credentials to version control.
4. Run `act` using the command below. Replace `<path-to-testscript>`, `<vus>`, `<duration>` and `<(personal|enterprise|both)>` with the desired values:
```shell
act workflow_dispatch -j k6-performance -s GITHUB_TOKEN=`gh auth token` \
--container-architecture linux/amd64 --artifact-server-path $HOME/.act \
--input vus=<vus> --input duration=<duration> \
--input testSuitePath=<path-to-testscript> \
--input tokens=<(personal|enterprise|both)>
--input testSuitePath=<path-to-testscript>
```

Example of command:
```shell
act workflow_dispatch -j k6-performance -s GITHUB_TOKEN=`gh auth token` \
--container-architecture linux/amd64 --artifact-server-path $HOME/.act \
--input vus=10 --input duration=5m \
--input testSuitePath=tests/k6/tests/serviceowner/performance/create-dialog.js \
--input tokens=enterprise
--input testSuitePath=tests/k6/tests/serviceowner/performance/create-dialog.js
```

#### Clean up
Expand All @@ -97,7 +85,4 @@ Replace `<(test|staging|yt01)>` with the appropriate environment where the test
This script will remove any dialogs created during the performance test, ensuring a clean state for future tests.

### Test Results
The test results can be found in the GitHub Actions run log and in App Insights. Currently, the results are exported to a private Grafana instance. Refer to the `.secrets` file mentioned earlier for more details.

### TODO
- Fix reporting
The test results can be found in the GitHub Actions run log, grafana and in App Insights.

0 comments on commit 632ee73

Please sign in to comment.