|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +if [ -z "${maxVusers}" ]; then |
| 4 | + echo "maxVusers is unset or set to the empty string" |
| 5 | + exit 1 |
| 6 | +fi |
| 7 | + |
| 8 | +if [ -z "${duration}" ]; then |
| 9 | + echo "duration is unset or set to the empty string" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +if [ -z "${environment}" ]; then |
| 14 | + echo "environment is unset or set to the empty string" |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +if [ -z "${arrivalRate}" ]; then |
| 19 | + echo "arrivalRate is unset or set to the empty string" |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | + |
| 23 | +if [ -z "${rampUpDuration}" ]; then |
| 24 | + echo "rampUpDuration is unset or set to the empty string" |
| 25 | + exit 1 |
| 26 | +fi |
| 27 | + |
| 28 | +if ! [[ "${environment}" =~ ^(dev|ref)$ ]] |
| 29 | +then |
| 30 | + echo "environment must be dev or ref" |
| 31 | + exit 1 |
| 32 | +fi |
| 33 | + |
| 34 | +security_group=$(aws cloudformation list-exports --output json | jq -r '.Exports[] | select(.Name == "artillery-resources:ArtillerySecurityGroupId") | .Value' | grep -o '[^:]*$') |
| 35 | +export security_group |
| 36 | +vpc_subnets=$(aws cloudformation list-exports --output json | jq -r '.Exports[] | select(.Name == "vpc-resources:PrivateSubnets") | .Value' | grep -o '[^:]*$') |
| 37 | +export vpc_subnets |
| 38 | + |
| 39 | +artillery_worker_role_name=$(aws cloudformation list-exports --output json | jq -r '.Exports[] | select(.Name == "artillery-resources:ArtilleryWorkerRoleName") | .Value' | grep -o '[^:]*$') |
| 40 | +export artillery_worker_role_name |
| 41 | + |
| 42 | +cat <<EOF > runtimeenv.env |
| 43 | +maxVusers=$maxVusers |
| 44 | +duration=$duration |
| 45 | +arrivalRate=$arrivalRate |
| 46 | +rampUpDuration=$rampUpDuration |
| 47 | +EOF |
| 48 | + |
| 49 | +echo ${launch_config} |
| 50 | + |
| 51 | +# shellcheck disable=SC2090,SC2086 |
| 52 | +npx artillery run-fargate \ |
| 53 | + --environment "${environment}" \ |
| 54 | + --secret psu_api_key \ |
| 55 | + --secret psu_private_key \ |
| 56 | + --secret psu_kid \ |
| 57 | + --region eu-west-2 \ |
| 58 | + --cluster artilleryio-cluster \ |
| 59 | + --security-group-ids "${security_group}" \ |
| 60 | + --subnet-ids "${vpc_subnets}" \ |
| 61 | + --task-role-name "${artillery_worker_role_name}" \ |
| 62 | + --dotenv runtimeenv.env \ |
| 63 | + --output notify_load_test.json \ |
| 64 | + artillery/notify_load_test.yml |
| 65 | + |
| 66 | +npx artillery report notify_load_test.json |
0 commit comments