-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add params for delay in k8s * Add ChaosService * Move ChaosSpec to ChaosResource file * tmp * tmp * Fix selector * Address comments * Remove logs * minor fix * minor correctoions on chaosResource * add delay to example * add logic to set the delay config at `node` level in the networkSpec * temporary update test * refactor gen Chaos resource * fmt * Fix words * Fix words * fix example chaos delay * fmt * default correlation * add chaos test * typo * refactor: inject chaos after network spawn * fmt * remove commented code --------- Co-authored-by: Javier Viola <[email protected]> Co-authored-by: Javier Viola <[email protected]>
- Loading branch information
1 parent
aedf2bb
commit 84d83f3
Showing
24 changed files
with
4,274 additions
and
13 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,32 @@ | ||
[settings] | ||
timeout = 666 | ||
|
||
[relaychain] | ||
default_image = "docker.io/parity/polkadot:latest" | ||
default_command = "polkadot" | ||
default_args = [ "-lparachain=debug" ] | ||
chain = "rococo-local" | ||
[relaychain.default_delay_network_settings] | ||
latency = "200ms" | ||
|
||
[[relaychain.nodes]] | ||
name = "alice" | ||
[relaychain.nodes.delay_network_settings] | ||
latency = "1000ms" | ||
|
||
|
||
[[relaychain.nodes]] | ||
name = "bob" | ||
|
||
|
||
[[parachains]] | ||
id = 100 | ||
|
||
[parachains.collator] | ||
name = "collator01" | ||
image = "docker.io/parity/polkadot-parachain:latest" | ||
command = "polkadot-parachain" | ||
[parachains.collator.delay_network_settings] | ||
latency = "4000ms" | ||
jitter = "4000ms" | ||
correlation = "100" |
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,7 @@ | ||
Description: Big Network test | ||
Network: ./0005-big-network-w-delay.toml | ||
Creds: config | ||
|
||
# metrics | ||
alice: run ./delay_check.sh within 30 seconds | ||
bob: run ./delay_check.sh within 30 seconds |
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,8 @@ | ||
#!/bin/bash | ||
|
||
ping -q -c 2 8.8.8.8 | tail -1 | awk -F "/" '{print $5}' | ||
ping -q -c 2 8.8.8.8 | tail -1 | awk -F "/" '{print $5}' | ||
ping -q -c 2 8.8.8.8 | tail -1 | awk -F "/" '{print $5}' | ||
ping -q -c 2 8.8.8.8 | tail -1 | awk -F "/" '{print $5}' | ||
ping -q -c 2 8.8.8.8 | tail -1 | awk -F "/" '{print $5}' | ||
ping -q -c 2 8.8.8.8 | tail -1 | awk -F "/" '{print $5}' |
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
58 changes: 58 additions & 0 deletions
58
javascript/packages/orchestrator/src/providers/k8s/resources/chaosResource.ts
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,58 @@ | ||
import { ChaosSpec } from "./types"; | ||
|
||
import { DelayNetworkSettings } from "../../../sharedTypes"; | ||
|
||
export class ChaosResource { | ||
constructor( | ||
protected readonly name: string, | ||
protected readonly namespace: string, | ||
protected readonly delay: DelayNetworkSettings, | ||
) {} | ||
|
||
public generateSpec() { | ||
if (this.delay.latency.slice(-2) !== "ms") { | ||
throw Error( | ||
"Latency value should include the 'ms' indicator (e.g. '100ms')", | ||
); | ||
} | ||
|
||
if (this.delay.jitter && this.delay.jitter.slice(-2) !== "ms") { | ||
throw Error( | ||
"Jitter value should include the 'ms' indicator (e.g. '100ms')", | ||
); | ||
} | ||
|
||
if (this.delay.correlation) { | ||
const correlation = parseFloat(this.delay.correlation); | ||
if (Number.isNaN(correlation)) { | ||
throw Error( | ||
"Correlation value should be parsable as Float by k8s api (e.g. '100')", | ||
); | ||
} else { | ||
this.delay.correlation = correlation.toString(); | ||
} | ||
} else { | ||
// set default correlation (100) | ||
this.delay.correlation = "100"; | ||
} | ||
return this.generateChaosSpec(); | ||
} | ||
|
||
private generateChaosSpec(): ChaosSpec { | ||
return { | ||
apiVersion: "chaos-mesh.org/v1alpha1", | ||
kind: "NetworkChaos", | ||
metadata: { name: this.name }, | ||
spec: { | ||
mode: "all", | ||
action: "delay", | ||
selector: { | ||
pods: { | ||
[this.namespace]: [this.name], | ||
}, | ||
}, | ||
delay: this.delay, | ||
}, | ||
}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
javascript/packages/orchestrator/src/providers/k8s/resources/index.ts
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { BootNodeResource } from "./bootNodeResource"; | ||
export { ChaosResource } from "./chaosResource"; | ||
export { NodeResource } from "./nodeResource"; | ||
export { ServiceResource } from "./serviceResource"; |
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.