chaostoolkit / chaostoolkit-documentation

The Chaos Toolkit documentation

Home Page:https://chaostoolkit.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to run experiments

sabil05 opened this issue · comments

Hello Team,

I am very new to chaostoolkit and I just wanted to know how to run the chaostoolkit experiments. I have Python3 installed Venv is ready. /aws/credantials file has been updated.
Just want to know where to store the experiment file and following paragraph will be enough to run the simple exeriment in experiment file?

{
"name": "stop-an-ec2-instance-in-az-at-random",
"provider": {
"type": "python",
"module": "chaosaws.ec2.actions",
"func": "stop_instance",
"arguments": {
"az": "us-west-1",
"instance_id": "i-xxxxxxx"
}
}
}

If I get more insights on chaostoolkit would be really appreciate.

Thanks,
Sabil.

Hi Sabil,

That's not a complete experiment - you've only defined the action but you need a few additional sections. Check out the minimal example in the docs. You at least need the top-level properties from that object, and the method object (which you have almost written in your comment.

https://chaostoolkit.org/reference/api/experiment/#minimal-experiment

Here's an example of an ec2 stop experiment:

{
    "version": "1.0.0",
    "title": "Not set",
    "description": "Not set",
    "tags": [],
    "configuration": {
        "aws_region": "us-east-1"
    },
    "steady-state-hypothesis": {
        "title": "The instance will stay up during the attack",
        "probes": [
            {
                "name": "instance-state",
                "type": "probe",
                "tolerance": true,
                "provider": {
                    "type": "python",
                    "module": "chaosaws.ec2.probes",
                    "func": "instance_state",
                    "arguments": {
                        "state": "running",
                        "instance_ids": [
                            "YOUR_INSTANCE_ID"
                        ]
                    }
                }
            }
        ]
    },
    "method": [
        {
            "name": "stop-an-ec2-instance",
            "type": "action",
            "provider": {
                "type": "python",
                "module": "chaosaws.ec2.actions",
                "func": "stop_instances",
                "arguments": {
                    "instance_ids": [
                        "YOUR_INSTANCE_ID"
                    ]
                }
            }
        }
    ],
    "rollbacks": [
        {
            "name": "start-an-ec2-instances",
            "type": "action",
            "provider": {
                "type": "python",
                "module": "chaosaws.ec2.actions",
                "func": "start_instances",
                "arguments": {
                    "instance_ids": [
                        "YOUR_INSTANCE_ID"
                    ]
                }
            }
        }
    ]
}