-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:smartcontractkit/chainlink-testing-…
…framework into flakeguardAggregations
- Loading branch information
Showing
39 changed files
with
689 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Chaos Testing | ||
|
||
We offer Docker and Kubernetes boilerplates designed to test the resilience of `NodeSet` and `Blockchain`, which you can customize and integrate into your pipeline. | ||
|
||
|
||
## Goals | ||
|
||
We recommend structuring your tests as a linear suite that applies various chaos experiments and verifies the outcomes using a [load](../../libs/wasp.md) testing suite. Focus on critical user metrics, such as: | ||
|
||
- The ratio of successful responses to failed responses | ||
- The nth percentile of response latency | ||
|
||
Next, evaluate observability: | ||
|
||
- Ensure proper alerts are triggered during failures (manual or automated) | ||
- Verify the service recovers within the expected timeframe (manual or automated) | ||
|
||
In summary, the **primary** focus is on meeting user expectations and maintaining SLAs, while the **secondary** focus is on observability and making operational part smoother. | ||
|
||
|
||
## Docker | ||
|
||
For Docker, we utilize [Pumba](https://github.com/alexei-led/pumba) to conduct chaos experiments, including: | ||
|
||
- Container reboots | ||
- Network simulations (such as delays, packet loss, corruption, etc., using the tc tool) | ||
- Stress testing for CPU and memory usage | ||
|
||
Additionally, we offer a [resources](../../framework/components/resources.md) API that allows you to test whether your software can operate effectively in low-resource environments. | ||
|
||
You can also use [fake](../../framework/components/mocking.md) package to create HTTP chaos experiments. | ||
|
||
Given the complexity of `Kubernetes`, we recommend starting with `Docker` first. Identifying faulty behavior in your services early—such as cascading latency—can prevent more severe issues when scaling up. Addressing these problems at a smaller scale can save significant time and effort later. | ||
|
||
Check `NodeSet` + `Blockchain` template [here](). | ||
|
||
## Kubernetes | ||
|
||
We utilize a subset of [ChaosMesh](https://chaos-mesh.org/) experiments that can be safely executed on an isolated node group. These include: | ||
|
||
- [Pod faults](https://chaos-mesh.org/docs/simulate-pod-chaos-on-kubernetes/) | ||
|
||
- [Network faults](https://chaos-mesh.org/docs/simulate-network-chaos-on-kubernetes/) – We focus on delay and partition experiments, as others may impact pods outside the dedicated node group. | ||
|
||
- [HTTP faults](https://chaos-mesh.org/docs/simulate-http-chaos-on-kubernetes/) | ||
|
||
Check `NodeSet` + `Blockchain` template [here](). | ||
|
||
## Blockchain | ||
|
||
We also offer a set of blockchain-specific experiments, which typically involve API calls to blockchain simulators to execute certain actions. These include: | ||
|
||
- Adjusting gas prices | ||
|
||
- Introducing chain reorganizations (setting a new head) | ||
|
||
- Utilizing developer APIs (e.g., Anvil) | ||
|
||
Check [gas]() and [reorg]() examples. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Allow multiple node sets simultaneously | ||
- Add chaos examples for gas, reorg, k8s and docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ func checkBasicOutputs(t *testing.T, output *clnode.Output) { | |
require.Contains(t, output.Node.DockerP2PUrl, "cl-node") | ||
require.NotNil(t, output.PostgreSQL) | ||
require.Contains(t, output.PostgreSQL.Url, "postgresql://chainlink:[email protected]") | ||
require.Contains(t, output.PostgreSQL.DockerInternalURL, "postgresql://chainlink:thispasswordislongenough@ns-postgresql") | ||
require.Contains(t, output.PostgreSQL.DockerInternalURL, "postgresql://chainlink:thispasswordislongenough@pg") | ||
} | ||
|
||
func TestComponentDockerNodeWithSharedDB(t *testing.T) { | ||
|
@@ -35,6 +35,7 @@ func TestComponentDockerNodeWithSharedDB(t *testing.T) { | |
DbInput: &postgres.Input{ | ||
Image: "postgres:12.0", | ||
Port: 16000, | ||
Name: "pg-1", | ||
VolumeName: "a", | ||
}, | ||
Node: &clnode.NodeInput{ | ||
|
@@ -70,6 +71,7 @@ func TestComponentDockerNodeWithDB(t *testing.T) { | |
DbInput: &postgres.Input{ | ||
Image: "postgres:12.0", | ||
Port: 15000, | ||
Name: "pg-2", | ||
VolumeName: "b", | ||
}, | ||
Node: &clnode.NodeInput{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,13 @@ func checkBasicOutputs(t *testing.T, output *ns.Output) { | |
require.NotNil(t, output.CLNodes) | ||
require.Len(t, output.CLNodes, 2) | ||
require.Contains(t, output.CLNodes[0].PostgreSQL.Url, "postgresql://chainlink:[email protected]") | ||
require.Contains(t, output.CLNodes[0].PostgreSQL.DockerInternalURL, "postgresql://chainlink:thispasswordislongenough@ns-postgresql-") | ||
require.Contains(t, output.CLNodes[0].PostgreSQL.DockerInternalURL, "postgresql://chainlink:thispasswordislongenough@don") | ||
require.Contains(t, output.CLNodes[0].Node.HostURL, "127.0.0.1") | ||
require.Contains(t, output.CLNodes[0].Node.DockerURL, "node") | ||
require.Contains(t, output.CLNodes[0].Node.DockerP2PUrl, "node") | ||
|
||
require.Contains(t, output.CLNodes[1].PostgreSQL.Url, "postgresql://chainlink:[email protected]") | ||
require.Contains(t, output.CLNodes[1].PostgreSQL.DockerInternalURL, "postgresql://chainlink:thispasswordislongenough@ns-postgresql-") | ||
require.Contains(t, output.CLNodes[1].PostgreSQL.DockerInternalURL, "postgresql://chainlink:thispasswordislongenough@don") | ||
require.Contains(t, output.CLNodes[1].Node.HostURL, "127.0.0.1") | ||
require.Contains(t, output.CLNodes[1].Node.DockerURL, "node") | ||
require.Contains(t, output.CLNodes[1].Node.DockerP2PUrl, "node") | ||
|
@@ -47,6 +47,7 @@ func TestComponentDockerNodeSetSharedDB(t *testing.T) { | |
ChainID: "31337", | ||
}, | ||
nodeSetInput: &ns.Input{ | ||
Name: "don-1", | ||
Nodes: 2, | ||
OverrideMode: "all", | ||
DbInput: &postgres.Input{ | ||
|
@@ -74,6 +75,7 @@ func TestComponentDockerNodeSetSharedDB(t *testing.T) { | |
ChainID: "31337", | ||
}, | ||
nodeSetInput: &ns.Input{ | ||
Name: "don-2", | ||
Nodes: 2, | ||
OverrideMode: "each", | ||
HTTPPortRangeStart: 20000, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
framework/examples/myproject/chaos.toml → ...ework/examples/myproject/chaos/chaos.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.