Following this blog post will incur some costs for AWS services. To deploy the chaos experiment and test application you will need an AWS account. We also assume that you are using AWS CloudShell or have the AWS CLI installed and have configured a profile with administrator permissions.
Please ensure you have installed a recent and working version of Python (i.e. 3.9 or later).
Website availability tests are executed from your machine in the sample code used in this blog. If you are traversing a busy corporate proxy or a network connection that is not stable then it can impact the results.
Clone the git repository aws-fis-behaviour-driven-chaos that contains the blog resources using the below command:
git clone https://github.com/aws-samples/aws-fis-behaviour-driven-chaos.git
recommended - create a new, clean Python virtual environment somewhere and activate it
python3 -m venv behavefisvenv
source behavefisvenv/bin/activate
To be carried out from the root of the repo:
-
Install the Python dependencies in the venv
pip install -r requirements.txt
-
Create the test stack and wait for completion:
aws cloudformation create-stack --stack-name my-chaos-stack --template-body file://cloudformation/infrastructure.yaml --region=eu-west-1 --capabilities CAPABILITY_IAM aws cloudformation wait stack-create-complete --stack-name my-chaos-stack --region=eu-west-1
-
Once the deployment reaches a create-complete state, retrieve the stack outputs:
aws cloudformation describe-stacks --stack-name my-chaos-stack --region=eu-west-1
-
Copy the OutputValue of the stack Outputs for AlbHostname and FisExperimentId into the
behave/userconfig.json
, replacing the placeholder values for website_hostname and fis_experiment_id respectively. -
Replace the region value in the
behave/userconfig.json
file with the region you built the stack in (if altered in step 2). -
change directory into behave/
cd behave/
-
execute behave:
behave
-
Once execution completes, Locust results will appear inside the behave folder, output similar to the below will be shown at the CLI.
There are a few different ways to format your results when using Behave so that they are more easy to pull into a report, Allure is a nice example; see the official documentation for reference.
To delete the stack run
aws cloudformation delete-stack --stack-name my-chaos-stack --region=eu-west-1 &&
aws cloudformation wait stack-delete-complete --stack-name my-chaos-stack --region=eu-west-1