Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. #Assuming same user name for all hosts
  4. USER_NAME='gatling'
  5. #Remote hosts list
  6. HOSTS=(node1-load.some.host node2-load.some.host node3-load.some.host node4-load.some.host)
  7. #Assuming all Gatling installation in same path (with write permissions)
  8. GATLING_HOME=/opt/loadtest/
  9. #No need to change this
  10. REMOTE_REPORT_DIR=/opt/loadtest/target/gatling/
  11. LOCAL_REPORT_DIR=%system.teamcity.build.workingDir%/target/gatling/
  12.  
  13. #Change to your simulation class name
  14. SIMULATION_NAME='ClusterLoadTest'
  15.  
  16. echo "Starting Gatling cluster simulation: $SIMULATION_NAME"
  17.  
  18. echo "Cleaning previous runs from localhost"
  19. rm -rf ${LOCAL_REPORT_DIR}*
  20. for HOST in "${HOSTS[@]}"
  21. do
  22. echo "Cleaning previous runs from host: $HOST"
  23. ssh -p 22 -n -f ${USER_NAME}@${HOST} "sh -c 'rm -rf $REMOTE_REPORT_DIR*'"
  24. done
  25.  
  26. for HOST in "${HOSTS[@]}"
  27. do
  28. echo "Running simulation on host: $HOST"
  29. # TODO: add `git pull` on remote hosts
  30. 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 &'"
  31. done
  32.  
  33. echo "Running simulation on localhost"
  34. cd %system.teamcity.build.workingDir% && sbt -Xms2G -Xmx8G -Dloadtest.inventory.host=%host% -Dquery=%query% -DtargetRPS=%targetRPS% -DpartDuration=%partDuration% "gatling:testOnly *.$SIMULATION_NAME"
  35.  
  36. # synchronization delay
  37. sleep 10
  38.  
  39. for HOST in "${HOSTS[@]}"
  40. do
  41. echo "Gathering result file from host: $HOST"
  42. 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'"
  43. scp -P 22 ${USER_NAME}@${HOST}:${REMOTE_REPORT_DIR}report/simulation.log ${LOCAL_REPORT_DIR}simulation-${HOST}.log
  44. done
  45.  
  46. mv ${LOCAL_REPORT_DIR}*.log ${LOCAL_REPORT_DIR}clusterloadtest*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement