Last active
July 24, 2017 03:24
-
-
Save vanclist/e8e18029131accacd844b3eb9239db07 to your computer and use it in GitHub Desktop.
Gatling cluster with Teamcity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#Assuming same user name for all hosts | |
USER_NAME='gatling' | |
#Remote hosts list | |
HOSTS=(node1-load.some.host node2-load.some.host node3-load.some.host node4-load.some.host) | |
#Assuming all Gatling installation in same path (with write permissions) | |
GATLING_HOME=/opt/loadtest/ | |
#No need to change this | |
REMOTE_REPORT_DIR=/opt/loadtest/target/gatling/ | |
LOCAL_REPORT_DIR=%system.teamcity.build.workingDir%/target/gatling/ | |
#Change to your simulation class name | |
SIMULATION_NAME='ClusterLoadTest' | |
echo "Starting Gatling cluster simulation: $SIMULATION_NAME" | |
echo "Cleaning previous runs from localhost" | |
rm -rf ${LOCAL_REPORT_DIR}* | |
for HOST in "${HOSTS[@]}" | |
do | |
echo "Cleaning previous runs from host: $HOST" | |
ssh -p 22 -n -f ${USER_NAME}@${HOST} "sh -c 'rm -rf $REMOTE_REPORT_DIR*'" | |
done | |
for HOST in "${HOSTS[@]}" | |
do | |
echo "Running simulation on host: $HOST" | |
# TODO: add `git pull` on remote hosts | |
ssh -p 22 -n -f ${USER_NAME}@${HOST} "sh -c 'cd $GATLING_HOME && sbt -Xms2G -Xmx8G -Dloadtest.inventory.host=%host% -Dquery=%query% -DtargetRPS=%targetRPS% -DpartDuration=%partDuration% \"gatling:testOnly *.$SIMULATION_NAME\" 2>&1 &'" | |
done | |
echo "Running simulation on localhost" | |
cd %system.teamcity.build.workingDir% && sbt -Xms2G -Xmx8G -Dloadtest.inventory.host=%host% -Dquery=%query% -DtargetRPS=%targetRPS% -DpartDuration=%partDuration% "gatling:testOnly *.$SIMULATION_NAME" | |
# synchronization delay | |
sleep 10 | |
for HOST in "${HOSTS[@]}" | |
do | |
echo "Gathering result file from host: $HOST" | |
ssh -p 22 -n -f ${USER_NAME}@${HOST} "sh -c 'ls -t $REMOTE_REPORT_DIR | head -n 1 | xargs -I {} mv ${REMOTE_REPORT_DIR}{} ${REMOTE_REPORT_DIR}report'" | |
scp -P 22 ${USER_NAME}@${HOST}:${REMOTE_REPORT_DIR}report/simulation.log ${LOCAL_REPORT_DIR}simulation-${HOST}.log | |
done | |
mv ${LOCAL_REPORT_DIR}*.log ${LOCAL_REPORT_DIR}clusterloadtest*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment