diff --git a/CHANGELOG.md b/CHANGELOG.md index 329af86ded..2d7ab22a45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Added graphite reporter to dropwizard metrics [\#4398](https://github.com/raster-foundry/raster-foundry/pull/4398) - Added alternative development runner/setup for testing API server and backsplash [\#4402](https://github.com/raster-foundry/raster-foundry/pull/4402) - Added configuration and helper script for gatling integration test results [\#4410](https://github.com/raster-foundry/raster-foundry/pull/4410) +- Added gatling tests script that can be run in CI [\#4424](https://github.com/raster-foundry/raster-foundry/pull/4424) - Created AuthedAutoSlash middleware to make authentication and route matching cooperate [\#4425](https://github.com/raster-foundry/raster-foundry/pull/4425) ### Changed diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 4467bfb76c..51282b6b6a 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -70,6 +70,30 @@ services: volumes: - ./app-tasks/rf/:/opt/raster-foundry/app-tasks/rf/ + gatling-sbt: + image: openjdk:8-jre + environment: + - COURSIER_CACHE=/root/.coursier + - RF_API_HOST + - RF_PROJECT_IDS + - TOKEN_ROUTE + - REFRESH_TOKEN + - RANDOM_SEED + - PROJECT_ROUTE + - USER_COUNT + - RAMPUP_TIME + - BACKSPLASH_TMS_URL_TEMPLATE + - MIN_ZOOM + - MAX_ZOOM + volumes: + - ./gatling:/opt/gatling + - $HOME/.coursier:/root/.coursier + - $HOME/.sbt:/root/.sbt + - $HOME/.ivy2:/root/.ivy2 + - $HOME/.aws:/root/.aws:ro + working_dir: /opt/gatling/ + entrypoint: ./sbt + build: image: raster-foundry-build:${GIT_COMMIT:-latest} build: diff --git a/gatling/src/test/scala/MosaicTmsSimulation.scala b/gatling/src/test/scala/MosaicTmsSimulation.scala index 612474102e..2b0c8f6517 100644 --- a/gatling/src/test/scala/MosaicTmsSimulation.scala +++ b/gatling/src/test/scala/MosaicTmsSimulation.scala @@ -49,8 +49,9 @@ class MosaicTmsSimulation extends Simulation { .set("z", tile._2) .set("x", tile._3) .set("y", tile._4) + .set("authToken", ApiUtils.getAuthToken) }).exec { - http("tiles at ${projectId}/${z}/${x}/${y}") + http("tiles at ${projectId}/${z}/${x}/${y}?token=${authToken}") .get(Config.TMS.template) .header("authorization", "Bearer ${authToken}") .check(status.is(200)) diff --git a/scripts/cigatling b/scripts/cigatling index f35140ecf5..0e01a06035 100755 --- a/scripts/cigatling +++ b/scripts/cigatling @@ -1,9 +1,5 @@ #!/bin/bash -set -e - -if [[ -n "${RF_DEBUG}" ]]; then - set -x -fi +set -eu GIT_COMMIT="${GIT_COMMIT:-latest}" @@ -21,32 +17,19 @@ then usage else echo "Firing gatling at staging..." - docker run --rm \ - -v "$(pwd)/gatling:/opt/gatling" \ - -v "$HOME/.ivy2:/root/.ivy2" \ - -w /opt/gatling/ \ - -e RF_API_HOST \ - -e RF_PROJECT_IDS \ - -e TOKEN_ROUTE \ - -e REFRESH_TOKEN \ - -e RANDOM_SEED \ - -e PROJECT_ROUTE \ - -e USER_COUNT \ - -e RAMPUP_TIME \ - -e BACKSPLASH_TMS_URL_TEMPLATE \ - -e MIN_ZOOM \ - -e MAX_ZOOM \ - openjdk:8-jre \ - ./sbt gatling:test || true + docker-compose -f docker-compose.test.yml run gatling-sbt gatling:test || true + + BASE_REPORT_DIR="./gatling/target/gatling/" + LATEST_REPORT=$(ls -lah "${BASE_REPORT_DIR}" | grep "mosaictmssimulation" | tail -n 1 | cut -c 43-) + REPORT_DIR="${BASE_REPORT_DIR}${LATEST_REPORT}" + RESULTS_S3_URI="s3://${RESULTS_BUCKET}/gatling/${BUILD_NUMBER}/" - echo "Uploading results to '$RESULTS_BUCKET'..." - # Most recent report will always be last, since they're timestamped - reportDir=$(find ./gatling/target/gatling/ -maxdepth 1 -type d | tail -n 1) - zippedName=$(basename "$reportDir").zip - zippedDir=$(dirname "$reportDir") - zip -r9 "$zippedDir/$zippedName" "$reportDir" - aws s3 cp "$zippedDir/$zippedName" "s3://$RESULTS_BUCKET/$GIT_COMMIT/" + echo "SYNCING RESULTS TO S3 ${REPORT_DIR} => ${RESULTS_S3_URI}" + aws s3 sync "${REPORT_DIR}" "${RESULTS_S3_URI}" + RESULTS_URL="https://s3.amazonaws.com/rasterfoundry-staging-it-us-east-1/gatling/${BUILD_NUMBER}/index.html" + + echo "VIEW RESULTS AT: ${RESULTS_URL}" + curl -X POST --data-urlencode "payload={\"channel\": \"#raster-foundry\", \"username\": \"RF Gatling\", \"text\": \"Finished load testing for build ${BUILD_NUMBER}. Results are available <${RESULTS_URL}|here>.\", \"icon_emoji\": \":gatling:\"}" "${SLACK_URL}" fi exit fi -