DEV Community

mikotian
mikotian

Posted on

1

Running a simple chaos toolkit experiment

Install Chaos Toolkit & required drivers as mentioned here:

  1. 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": []
}
Enter fullscreen mode Exit fullscreen mode

Running the experiment:

chaos run SimpleExperiment.json
Enter fullscreen mode Exit fullscreen mode

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'
                }
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

The execution looks like this:

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more