Install Chaos Toolkit & required drivers as mentioned here:
- Setting up ChaosToolkit Execution Environment
Make sure the virtual environment is activated.
Create the following file:
{ "version": "1.0.0", "title": "random website testing", "description": "Just checking the chaostoolkit base stuff", "steady-state-hypothesis": { "title": "Website is OK", "probes": [ { "type": "probe", "name": "website-must-be-up", "tolerance": 200, "provider": { "type": "http", "timeout": [ 3, 5 ], "url": "https://httpbin.org/forms/post", "method": "GET" } } ] }, "method": [ { "type": "probe", "name": "website-must-return-202", "tolerance": 202, "provider": { "type": "http", "url": "https://httpbin.org/status/202" } }, { "type": "probe", "name": "response should be json", "tolerance": { "type": "jsonpath", "path": "$.slideshow.author", "expect": [ "failed" ], "target": "body" }, "provider": { "type": "http", "url": "https://httpbin.org/json" } } ], "rollbacks": [] }
Running the experiment:
chaos run SimpleExperiment.json
ScreenGrab:
The same can be run in a Jenkins Pipeline:
The jenkins pipeline script is as follows:
pipeline { agent any stages { stage('Deploy') { steps { // Get some code from a GitHub repository git 'https://github.com/mikotian/resilientchaos.git' } post { success { echo 'Hello World' } } } stage('Run Chaos Script') { steps { sh ". /home/mithun/.venvs/chaostk/bin/activate && chaos run SimpleExperiment.json" } post { success { echo 'Success' } } } } }
The execution looks like this:
Top comments (0)