Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement