aws-samples / aws-fis-behaviour-driven-chaos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pre-requisites

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.

Environment preparation

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

Deployment Steps

To be carried out from the root of the repo:

  1. Install the Python dependencies in the venv

    pip install -r requirements.txt
  2. 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
  3. 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
  4. 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.

  5. Replace the region value in the behave/userconfig.json file with the region you built the stack in (if altered in step 2).

  6. change directory into behave/

    cd behave/
  7. execute behave:

    behave
  8. Once execution completes, Locust results will appear inside the behave folder, output similar to the below will be shown at the CLI.

behave

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.

Clean-up

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

About

License:MIT No Attribution


Languages

Language:Python 94.6%Language:Gherkin 5.4%