Read more about it in my blog post here.
- ECR repository for Gatling Docker image
- S3 bucket for Gatling logs
- ECS cluster for running Docker containers, see below
- aws-cli. Install using
pip install awscli
- ecs-cli. Download from here
- Docker
The test consists of 3 steps:
- Building the Docker image
- Running the loadtest on AWS
- Creating the HTML report
Since all steps use aws-cli or ecs-cli, make sure to setup your AWS env variables:
export AWS_DEFAULT_REGION=<region>
export AWS_ACCESS_KEY_ID=<id>
export AWS_SECRET_ACCESS_KEY=<key>
./scripts/buildDockerImage.sh -r <ECR_REPOSITORY_NAME>
./scripts/runLoadtestOnAWS.sh -r <S3_BUCKET> -c <NR_CONTAINERS> -u <NR_USERS_PER_CONTAINER> -d <DURATION_IN_MIN> -ramp <RAMPUP_TIME_IN_SEC> -cl <ECS_CLUSTER>
./scripts/generateHTMLReport.sh -r <S3_BUCKET>
mvn clean gatling:test
docker build -t gatling-runner .
Use docker volume to add your AWS credentials that has permission to write to the S3 bucket. You can also optionally provide the AWS profile:
docker run --rm -v ${HOME}/.aws/credentials:/root/.aws/credentials:ro gatling-runner -r <bucketname> [-p <profile]
ecs-cli configure --cluster gatlingCluster --region eu-west-1 --config-name gatlingConfiguration
ecs-cli up --capability-iam --instance-type t3.large --size 1
IMPORTANT: The command will generate all the needed stuff, but make sure to add to the generated IAM role the policy for writing to your S3 bucket.
ecs-cli configure --cluster gatlingCluster --region eu-west-1 --default-launch-type FARGATE --config-name gatlingConfiguration
ecs-cli up
ecs-cli compose ps
ecs-cli logs --task-id <task_id> --follow
ecs-cli down --force