Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use docker-compose for running gatling tests in CI #4424

Merged
merged 8 commits into from
Dec 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion gatling/src/test/scala/MosaicTmsSimulation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
43 changes: 13 additions & 30 deletions scripts/cigatling
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/bin/bash
set -e

if [[ -n "${RF_DEBUG}" ]]; then
set -x
fi
set -eu

GIT_COMMIT="${GIT_COMMIT:-latest}"

Expand All @@ -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