Skip to content

Commit 4c8999d

Browse files
authored
Merge branch 'main' into tt-1806-required-labels
2 parents 81ce7c3 + 279fb34 commit 4c8999d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4639
-955
lines changed

book/README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
# Chainlink Testing Framework Docs
2-
3-
We use [mdBook](https://github.com/rust-lang/mdBook) for our docs. They can be found [here](https://smartcontractkit.github.io/chainlink-testing-framework/).
4-
5-
## Development
6-
7-
First [install Rust](https://doc.rust-lang.org/cargo/getting-started/installation.html), then [mdbook](https://github.com/rust-lang/mdBook).
8-
9-
```sh
10-
# Install mdBook
1+
## MDBook
2+
Install [mdbook](https://github.com/rust-lang/mdBook)
3+
```
114
cargo install mdbook && \
125
cargo install mdbook-alerts && \
13-
cargo install mdbook-cmdrun
14-
# Run the mdBook
6+
cargo install mdbook-cmdrun &&
7+
cargo install mdbook-mermaid
8+
```
9+
10+
Run it locally
11+
```
1512
make run
1613
```
14+
Open your browser [here](http://localhost:9999/)
1715

18-
Visit [localhost:9999](http://localhost:9999) to see your local version.
16+
GitHub hosted [version](https://smartcontractkit.github.io/chainlink-testing-framework/overview.html)

book/book.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ build-dir = "docs"
1010

1111
[output.html]
1212
default-theme = "ayu"
13+
additional-js = ["mermaid.min.js", "mermaid-init.js"]
1314

1415
[preprocessor.alerts]
15-
[preprocessor.cmdrun]
16+
[preprocessor.cmdrun]
17+
18+
[preprocessor.mermaid]
19+
command = "mdbook-mermaid"

book/mermaid-init.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
(() => {
2+
const darkThemes = ['ayu', 'navy', 'coal'];
3+
const lightThemes = ['light', 'rust'];
4+
5+
const classList = document.getElementsByTagName('html')[0].classList;
6+
7+
let lastThemeWasLight = true;
8+
for (const cssClass of classList) {
9+
if (darkThemes.includes(cssClass)) {
10+
lastThemeWasLight = false;
11+
break;
12+
}
13+
}
14+
15+
const theme = lastThemeWasLight ? 'default' : 'dark';
16+
mermaid.initialize({ startOnLoad: true, theme });
17+
18+
// Simplest way to make mermaid re-render the diagrams in the new theme is via refreshing the page
19+
20+
for (const darkTheme of darkThemes) {
21+
document.getElementById(darkTheme).addEventListener('click', () => {
22+
if (lastThemeWasLight) {
23+
window.location.reload();
24+
}
25+
});
26+
}
27+
28+
for (const lightTheme of lightThemes) {
29+
document.getElementById(lightTheme).addEventListener('click', () => {
30+
if (!lastThemeWasLight) {
31+
window.location.reload();
32+
}
33+
});
34+
}
35+
})();

book/mermaid.min.js

Lines changed: 2186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

book/src/SUMMARY.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,33 @@
4949
- [Interactive](framework/interactive.md)
5050
- [Libraries](./libraries.md)
5151
- [Seth](./libs/seth.md)
52-
- [WASP](./libs/wasp.md)
52+
- [WASP](./libs/wasp/overview.md)
53+
- [Getting started](./libs/wasp/getting_started.md)
54+
- [First test (RPS test)](./libs/wasp/first_test.md)
55+
- [Stateful test](./libs/wasp/stateful_test.md)
56+
- [User Journey test](./libs/wasp/user_journey_test.md)
57+
- [Profile test](./libs/wasp/profile_test.md)
58+
- [Testing alerts]()
59+
- [Configuration](./libs/wasp/configuration.md)
60+
- [k8s](./libs/wasp/k8s.md)
61+
- [Components](./libs/wasp/components/overview.md)
62+
- [Alert Checker]()
63+
- [Dashboard](./libs/wasp/components/dashboard.md)
64+
- [Generator](./libs/wasp/components/generator.md)
65+
- [Loki](./libs/wasp/components/loki.md)
66+
- [Profile](./libs/wasp/components/profile.md)
67+
- [Sampler](./libs/wasp/components/sampler.md)
68+
- [Schedule](./libs/wasp/components/schedule.md)
69+
- [How to](./libs/wasp/how-to/overview.md)
70+
- [Start local observability stack](./libs/wasp/how-to/start_local_observability_stack.md)
71+
- [Try it out quickly](./libs/wasp/how-to/run_included_tests.md)
72+
- [Chose between RPS and VUs](./libs/wasp/how-to/chose_rps_vu.md)
73+
- [Define NFRs and check alerts](./libs/wasp/how-to/define_nfr_check_alerts.md)
74+
- [Use labels](./libs/wasp/how-to/use_labels.md)
75+
- [Incorporate load tests in your workflow](./libs/wasp/how-to/incorporate_load_tests.md)
76+
- [Reuse dashboard components](./libs/wasp/how-to/reuse_dashboard_components.md)
77+
- [Parallelize load](./libs/wasp/how-to/parallelise_load.md)
78+
- [Debug Loki errors](./libs/wasp/how-to/debug_loki_errors.md)
5379
- [Havoc](./libs/havoc.md)
5480
- [K8s Test Runner](k8s-test-runner/k8s-test-runner.md)
5581

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Try it out quickly
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# WASP - Alert Checker
2+
3+
> [!WARNING]
4+
> The API used by `AlertChecker` is unstable, and this section may be out of date.
5+
6+
`AlertChecker` is a simple yet powerful component that allows you to verify which alerts fired during test execution.
7+
8+
It supports the following functionalities:
9+
* Checking if **any alert** fired during a specified time range for a given dashboard.
10+
* Checking if **any group of alerts** fired for a given dashboard.
11+
12+
The first mode is more suitable for existing dashboards, while the second mode is ideal for dashboards created specifically for the test (as it does not support time range selection).
13+
14+
> [!NOTE]
15+
> To use this component, you need to set certain Grafana-specific variables as described in the [Configuration](../configuration.md) section.
16+
17+
For a practical example of how to use `AlertChecker`, refer to the [Testing Alerts](../testing_alerts.md) section.
18+
19+
> [!WARNING]
20+
> If you define alerts yourself, ensure they are grouped by adding a label named `requirement_name` with a value representing the alert group.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# WASP - Dashboard
2+
3+
> [!WARNING]
4+
> The API used to check and create alerts is unstable, and the information related to them may be out of date.
5+
6+
7+
WASP comes with a built-in dashboard that allows you to monitor test runs in real-time.
8+
The dashboard includes several built-in metrics that integrate seamlessly with the `AlertChecker` component.
9+
10+
It is built using the [Grabana](https://pkg.go.dev/github.com/K-Phoen/grabana) library, which you can use to further customize and extend the dashboard by adding your own rows and panels.
11+
12+
> [!NOTE]
13+
> To create new dashboards, you need to set certain dashboard-specific variables as described in the [Configuration](../configuration.md) section.
14+
15+
---
16+
17+
### Predefined Alerts
18+
19+
WASP comes with predefined alerts for:
20+
* **99th percentile of the response time**
21+
* **Response errors**
22+
* **Response timeouts**
23+
24+
You can use these predefined metrics to add simple alerts to your dashboard for conditions such as:
25+
* Values above or below a threshold
26+
* Averages above or below a threshold
27+
* Percentages of the total above or below a threshold
28+
29+
For a complete list of available conditions, refer to Grabana's [ConditionEvaluator](https://pkg.go.dev/github.com/K-Phoen/[email protected]/alert#ConditionEvaluator).
30+
31+
---
32+
33+
### Custom Alerts
34+
35+
Custom alerts can be composed of:
36+
* The simple conditions mentioned above
37+
* Arbitrary Loki queries
38+
39+
Custom alerts use Grabana's [timeseries.Alert](https://pkg.go.dev/github.com/K-Phoen/[email protected]/timeseries#Alert) and must be timeseries-based.
40+
41+
> [!NOTE]
42+
> Adding a built-in alert will also add a new row to the dashboard to display the monitored metric.
43+
> In contrast, custom alerts do not automatically add rows to the dashboard to prevent clutter.
44+
45+
Each generator has its own metrics, matched by the generator name.
46+
47+
---
48+
49+
### Default Dashboard Panels
50+
51+
The default dashboard includes the following panels:
52+
* Current RPS/VUs (depending on the generator)
53+
* Responses per second
54+
* Total successful requests
55+
* Total failed requests
56+
* Total timeout requests
57+
* RPS/VUs per schedule segment
58+
* Responses per second
59+
* Latency quantiles over groups (p99, p90, p50)
60+
* Response latencies over time
61+
* Logs size per second
62+
* Sampling statistics
63+
* Failed & timed-out responses
64+
* Logs of the statistics-pushing service
65+
66+
![Dashboard](../images/dashboard_basic.png)
67+
68+
Where applicable, these panels group results by generator name (`gen_name` label) and call group (`call_group` label).
69+
70+
> [!NOTE]
71+
> You can read more about using labels in the [Use labels](../how-to/use_labels.md) section.
72+
73+
---
74+
75+
### Creating a New Dashboard with Alerts
76+
77+
For a practical example of how to create a new dashboard with alerts, see the [Testing Alerts](../testing_alerts.md) section.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# WASP - Generator
2+
3+
A **Generator** is a component that encapsulates all the characteristics of load generation, including:
4+
* Load type:
5+
* RPS (requests per second)
6+
* VUs (virtual users)
7+
* [Load schedule](./schedule.md)
8+
* Call logic
9+
* Response data
10+
* [Sampling](./sampler.md)
11+
* Timeouts
12+
13+
> [!WARNING]
14+
> RPS load type can only be used with a `Gun`, while VUs can only be used with a `VirtualUser`.
15+
16+
---
17+
18+
### Choosing Between `Gun` and `VirtualUser`
19+
20+
#### **`Gun`**
21+
* Best for **stateless protocols** (e.g., HTTP).
22+
* Simplistic in nature; ideal for executing a single operation that does not require setup or teardown.
23+
* Operates using an **open model**, where:
24+
* The number of requests is fixed.
25+
* The load adjusts to meet the target RPS, regardless of the system's response time.
26+
* There's no feedback from the system.
27+
* Recommended for scenarios focused on measuring **throughput**.
28+
29+
#### **`VirtualUser`**
30+
* Designed for **stateful protocols** (e.g., `WebSocket`) or workflows involving multiple operations (e.g., authenticating, executing tasks, and logging out).
31+
* More complex, with dedicated methods for setup and teardown.
32+
* Operates using a **closed model**, where:
33+
* New iterations start only after the previous one completes.
34+
* The RPS fluctuates based on the system's response time. Longer response times reduce RPS.
35+
* Feedback from the system is used to adjust the load.
36+
---
37+
38+
### Closed vs. Open Models
39+
40+
* A `Gun` follows an **open model**:
41+
- It controls the rate of requests being sent.
42+
- The system's response time does not impact the load generation rate.
43+
44+
* A `VirtualUser` follows a **closed model**:
45+
- It controls the rate of receiving responses.
46+
- The system's response time directly impacts the load generation rate. If the system slows down, iterations take longer, reducing the RPS.
47+
48+
---
49+
50+
### Summary
51+
52+
In simpler terms:
53+
* A **`Gun`** limits the load during the **sending** phase, making it ideal for throughput measurements.
54+
* A **`VirtualUser`** limits the load during the **receiving** phase, reflecting the system's performance under load.
55+
56+
---
57+
58+
This distinction helps you decide which tool to use based on the protocol type and the goals of your test.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# WASP - Loki
2+
3+
Loki is a component responsible for pushing batches of statistics to a Loki instance. It operates in the background using a `promtail` client.
4+
5+
Key features include:
6+
* Optional basic authentication support.
7+
* Configurable batch sizes.
8+
* Support for configurable backoff retries, among others.
9+
10+
By default, a test will fail on the first error encountered while pushing data. You can modify this behavior by setting the maximum allowed errors:
11+
* Setting the value to `-1` disables error checks entirely.
12+
13+
> [!NOTE]
14+
> While it is technically possible to execute a WASP test without Loki, doing so means you won't have access to load-generation-related metrics.
15+
> Unless your sole interest is in the metrics sent by your application, it is highly recommended to use Loki.
16+
> For this reason, Loki is considered an integral part of the WASP stack.

0 commit comments

Comments
 (0)