From 6f260ac95eedc40d592eed9823e3ee6ab21bfcda Mon Sep 17 00:00:00 2001 From: Cameron Yick Date: Mon, 15 Oct 2018 22:08:10 -0400 Subject: [PATCH] Factor integration test into dedicated bash script --- .travis.yml | 13 ++++--------- tests/test_metrics_up.sh | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 tests/test_metrics_up.sh diff --git a/.travis.yml b/.travis.yml index 7587b6e..b2417f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,8 @@ services: env: global: - DOCKER_COMPOSE_VERSION=1.9.0 - - AIRFLOW_SLEEP_DURATION=60 # Number of seconds to wait for airflow to start - - METRICS_ENDPOINT=http://localhost:8080/admin/metrics/ - - CURL_FLAGS=--show-error --fail - + - INTEGRATION_TEST_SCRIPT=../test_metrics_up.sh + before_install: - sudo rm /usr/local/bin/docker-compose - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose @@ -19,15 +17,12 @@ before_install: - sudo mv docker-compose /usr/local/bin script: - # Test Airflow 1.8 with Python 2 - cd tests/airflow1.8-py2 && docker-compose up -d - - sleep ${AIRFLOW_SLEEP_DURATION} - - curl ${CURL_FLAGS} ${METRICS_ENDPOINT} + - ${INTEGRATION_TEST_SCRIPT} - docker-compose down # Test Airflow 1.9 with Python 3 - cd ../../tests/airflow1.9-py3 && docker-compose up -d - - sleep ${AIRFLOW_SLEEP_DURATION} - - curl ${CURL_FLAGS} ${METRICS_ENDPOINT} + - ${INTEGRATION_TEST_SCRIPT} - docker-compose down diff --git a/tests/test_metrics_up.sh b/tests/test_metrics_up.sh new file mode 100644 index 0000000..78979f4 --- /dev/null +++ b/tests/test_metrics_up.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Integration test that +# 1. Waits for Airflow to come up within 60 seconds +# 2. Ensures the Metrics endpoint returned a valid response +# Depends on Curl + +AIRFLOW_SLEEP_DURATION=60 # Number of seconds to wait for airflow to start +METRICS_ENDPOINT="http://localhost:8080/admin/metrics/" + +# Return nonzero status code if endpoint does not return 200 +CURL_FLAGS="--show-error --fail" + +sleep ${AIRFLOW_SLEEP_DURATION} +curl ${CURL_FLAGS} ${METRICS_ENDPOINT} + +# TODO: validate the contents of the CURLed data