Skip to content

Instantly share code, notes, and snippets.

@ivanthelad
Created January 15, 2021 14:28
Show Gist options
  • Save ivanthelad/b530528e1e901c456f1980a461b2d184 to your computer and use it in GitHub Desktop.
Save ivanthelad/b530528e1e901c456f1980a461b2d184 to your computer and use it in GitHub Desktop.
Dockerfile
## Resource group where it should all live
RUNNAME="baselineerror"
locustfile="/home/locust/runs/errors.py"
#locustfile="/home/locust/runs/baseline.py"
RG="aksdemoload-$RUNNAME"
##location
LOCATION="westeurope"
#name of the master ACI instance
MASTER_NAME="locustmaster$RUNNAME"
# prefix name of the slaves
SLAVE_NAME="wrk"
## the dns prefix of the master
DNS_LABEL="aksdemoload$RUNNAME"
##the fqdn that is generated
MASTER_FQDN="$DNS_LABEL.$LOCATION.azurecontainer.io"
URL="$targeturl"
URLPATH="/api/v1/users"
IMAGE="springapp/locustloadtest:v1.0.1"
registry_username=""
registry_password="/"
regions=("westeurope" "uksouth" "centralus")
echo Spinning up master
## create group
az group create -n $RG -l $LOCATION
#create master with public ip
az container create --registry-username $registry_username --registry-password $registry_password -g $RG --image $IMAGE --ports 8089 5557 -l $LOCATION --name $MASTER_NAME --ip-address public --dns-name-label $DNS_LABEL -e URL=$URL URLPATH=$URLPATH --command-line="locust --master -f ${locustfile} "
if [ $? -eq 0 ]
then
echo "Success"
else
echo "Could not create master container"
exit -1;
fi
##worker
for region in ${regions[@]}; do
for i in {1..1}; do echo spinning up slave $i; az container create --registry-username $registry_username --registry-password $registry_password -g $RG --image $IMAGE --name $region$SLAVE_NAME$i -l $region --command-line="locust -f ${locustfile} --worker --master-host=${MASTER_FQDN}" --no-wait; echo spinning up worker; done
done
FROM locustio/locust:1.4.1
##e TARGET_URL=http://localhost:8080 runtest:latest
## can be master, slace, standalone
## run on ACIU using , where -f i referencing runs/errors.py
## az container create --registry-username $registry_username --registry-password $registry_password -g $RG --image $IMAGE --ports 8089 5557 -l $LOCATION --name $MASTER_NAME --ip-address public --dns-name-label $DNS_LABEL -e URL=$URL URLPATH=$URLPATH --command-line="locust --master -f ${locustfile} "
EXPOSE 5557 8089
## tell the slace how to connect
#ENV LOCUST_MASTER_HOST=
ENV URL="http://192.168.1.115:8080"
ENV URLPATH="/api/v1/users"
RUN pip install Faker
RUN mkdir runs
#ADD locustest/errors.py errors.py
ADD locustest/baseline.py runs/baseline.py
ADD locustest/errors.py runs/errors.py
#ADD startMaster.sh startMaster.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment