You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2015/03/04 01:03:42 UTC
incubator-aurora git commit: Clean up end-to-end tests.
Repository: incubator-aurora
Updated Branches:
refs/heads/master 048b93274 -> 4e159e3f3
Clean up end-to-end tests.
Reviewed at https://reviews.apache.org/r/31659/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/4e159e3f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/4e159e3f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/4e159e3f
Branch: refs/heads/master
Commit: 4e159e3f3002cf8aabe78fbe4166d100bcd3e9f5
Parents: 048b932
Author: Bill Farner <wf...@apache.org>
Authored: Tue Mar 3 16:02:32 2015 -0800
Committer: Bill Farner <wf...@apache.org>
Committed: Tue Mar 3 16:02:32 2015 -0800
----------------------------------------------------------------------
.../apache/aurora/e2e/http/http_example.aurora | 6 +
.../aurora/e2e/http/http_example_docker.aurora | 8 +-
.../e2e/http/http_example_docker_updated.aurora | 2 +-
.../aurora/e2e/http/http_example_updated.aurora | 2 +-
.../sh/org/apache/aurora/e2e/test_common.sh | 67 ------
.../sh/org/apache/aurora/e2e/test_end_to_end.sh | 226 ++++++++++++++-----
src/test/sh/org/apache/aurora/e2e/test_run.sh | 30 ---
7 files changed, 181 insertions(+), 160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4e159e3f/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora b/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora
index 0f64235..c1a10d8 100644
--- a/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora
+++ b/src/test/sh/org/apache/aurora/e2e/http/http_example.aurora
@@ -29,10 +29,15 @@ test_task = Task(
processes = [stage_server, run_server],
constraints = order(stage_server, run_server))
+update_config = UpdateConfig(watch_secs=10, batch_size=2)
+health_check_config = HealthCheckConfig(initial_interval_secs=5, interval_secs=1)
+
job = Service(
name = 'http_example',
cluster = 'devcluster',
instances = 2,
+ update_config = update_config,
+ health_check_config = health_check_config,
task = test_task,
role = getpass.getuser(),
environment = 'test',
@@ -41,6 +46,7 @@ job = Service(
constraints = {
'host': 'limit:2',
},
+ announce = Announcer(),
)
jobs = [ job ]
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4e159e3f/src/test/sh/org/apache/aurora/e2e/http/http_example_docker.aurora
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/http/http_example_docker.aurora b/src/test/sh/org/apache/aurora/e2e/http/http_example_docker.aurora
index 00fa2fb..870b3e6 100644
--- a/src/test/sh/org/apache/aurora/e2e/http/http_example_docker.aurora
+++ b/src/test/sh/org/apache/aurora/e2e/http/http_example_docker.aurora
@@ -29,10 +29,15 @@ test_task = Task(
processes = [stage_server, run_server],
constraints = order(stage_server, run_server))
-job = Job(
+update_config = UpdateConfig(watch_secs=10, batch_size=2)
+health_check_config = HealthCheckConfig(initial_interval_secs=5, interval_secs=1)
+
+job = Service(
name = 'http_example_docker',
cluster = 'devcluster',
instances = 2,
+ update_config = update_config,
+ health_check_config = health_check_config,
task = test_task,
role = getpass.getuser(),
environment = 'test',
@@ -41,6 +46,7 @@ job = Job(
constraints = {
'host': 'limit:2',
},
+ announce = Announcer(),
container = Container(docker=Docker(image = 'http_example')),
)
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4e159e3f/src/test/sh/org/apache/aurora/e2e/http/http_example_docker_updated.aurora
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/http/http_example_docker_updated.aurora b/src/test/sh/org/apache/aurora/e2e/http/http_example_docker_updated.aurora
index d987d63..e55aad3 100644
--- a/src/test/sh/org/apache/aurora/e2e/http/http_example_docker_updated.aurora
+++ b/src/test/sh/org/apache/aurora/e2e/http/http_example_docker_updated.aurora
@@ -29,7 +29,7 @@ test_task = Task(
processes = [stage_server, run_server],
constraints = order(stage_server, run_server))
-update_config = UpdateConfig(watch_secs=10, batch_size=2)
+update_config = UpdateConfig(watch_secs=10, batch_size=3)
health_check_config = HealthCheckConfig(initial_interval_secs=5, interval_secs=1)
job = Service(
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4e159e3f/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora b/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora
index 072bbb7..423dd4d 100644
--- a/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora
+++ b/src/test/sh/org/apache/aurora/e2e/http/http_example_updated.aurora
@@ -29,7 +29,7 @@ test_task = Task(
processes = [stage_server, run_server],
constraints = order(stage_server, run_server))
-update_config = UpdateConfig(watch_secs=10, batch_size=2)
+update_config = UpdateConfig(watch_secs=10, batch_size=3)
health_check_config = HealthCheckConfig(initial_interval_secs=5, interval_secs=1)
job = Service(
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4e159e3f/src/test/sh/org/apache/aurora/e2e/test_common.sh
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/test_common.sh b/src/test/sh/org/apache/aurora/e2e/test_common.sh
deleted file mode 100644
index b621975..0000000
--- a/src/test/sh/org/apache/aurora/e2e/test_common.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/bash -x
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#
-# Common utility functions used by different variants of the
-# end to end tests.
-
-# Preserve original stderr so output from signal handlers doesn't get redirected to /dev/null.
-exec 4>&2
-
-_curl() { curl --silent --fail --retry 4 --retry-delay 10 "$@" ; }
-
-collect_result() {
- (
- if [[ $RETCODE = 0 ]]
- then
- echo "***"
- echo "OK (all tests passed)"
- echo "***"
- else
- echo "!!!"
- echo "FAIL (something returned non-zero)"
- echo ""
- echo "This may be a transient failure (as in scheduler failover) or it could be a real issue"
- echo "with your code. Either way, this script DNR merging to master. Note you may need to"
- echo "reconcile state manually."
- echo "!!!"
- vagrant ssh -c "aurora job cancel-update devcluster/vagrant/test/http_example"
- vagrant ssh -c "aurora job killall devcluster/vagrant/test/http_example"
- fi
- exit $RETCODE
- ) >&4 # Send to the stderr we had at startup.
-}
-
-validate_serverset() {
- # default python return code
- local retcode=0
-
- # launch aurora client in interpreter mode to get access to the kazoo client
- vagrant ssh -c \
- "env SERVERSET="$1" PEX_INTERPRETER=1 aurora /vagrant/src/test/sh/org/apache/aurora/e2e/validate_serverset.py" \
- || retcode=$?
-
- if [[ $retcode = 1 ]]; then
- echo "Validated announced job."
- return 0
- elif [[ $retcode = 2 ]]; then
- echo "Job failed to announce in serverset."
- elif [[ $retcode = 3 ]]; then
- echo "Job failed to re-announce when expired."
- else
- echo "Unknown failure in test script."
- fi
-
- return 1
-}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4e159e3f/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh b/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh
index 1d599c3..6a75528 100755
--- a/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh
+++ b/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh
@@ -13,92 +13,207 @@
# limitations under the License.
#
#
-# A simple integration test for the mesos client, intended to be run before checkin of major
-#client changes, and as a part of an integrated build process.
-#
-# This test uses the vagrant demonstration environment. It loads up a virtual cluster, and then
-# launches a job, verifies that it's running, updates it, verifies that the update succeeded,
-# and then kills the job.
+# An integration test for the client, using the vagrant environment as a testbed.
+
+# Determine if we are already in the vagrant environment. If not, start it up and invoke the script
+# from within the environment.
+if [ "$USER" != "vagrant" ]; then
+ vagrant up
+ vagrant ssh -c /vagrant/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh "$@"
+ exit $?
+fi
set -u -e -x
+set -o pipefail
+
+TEST_SCHEDULER_IP=192.168.33.7
+
+_curl() { curl --silent --fail --retry 4 --retry-delay 10 "$@" ; }
-. src/test/sh/org/apache/aurora/e2e/test_common.sh
+tear_down() {
+ set +x # Disable command echo, as this makes it more difficult see which command failed.
+ for job in http_example http_example_docker; do
+ aurora job cancel-update devcluster/vagrant/test/$job >/dev/null 2>&1
+ aurora job killall --no-batching devcluster/vagrant/test/$job >/dev/null 2>&1
+ done
+}
-function check_url_live() {
+collect_result() {
+ if [[ $RETCODE = 0 ]]
+ then
+ echo "OK (all tests passed)"
+ else
+ echo "!!! FAIL (something returned non-zero)"
+ # Attempt to clean up any state we left behind.
+ tear_down
+ fi
+ exit $RETCODE
+}
+
+check_url_live() {
test $(curl -sL -w '%{http_code}' $1 -o /dev/null) == 200
}
test_version() {
- test $(vagrant ssh -c "aurora --version" | tr -d '\r') = $(cat .auroraversion)
+ # The version number is written to stderr, making it necessary to redirect the output.
+ test $(aurora --version 2>&1) = $(cat /vagrant/.auroraversion)
}
-test_http_example() {
- local _cluster=$1 _role=$2 _env=$3 _job=$4 _sched_ip=$5
- local _base_config=$6 _updated_config=$7
- jobkey="$_cluster/$_role/$_env/$_job"
+test_config() {
+ local _config=$1 _jobkey=$2
+
+ joblist=$(aurora config list $_config | tr -dc '[[:print:]]')
+ test "$joblist" = "jobs=[$_jobkey]"
+}
- # The vagrant/ssh command brings a trailing carriage return and newline, tr strips that.
- joblist=$(vagrant ssh -c "aurora config list $_base_config" | tr -dc '[[:print:]]')
- test "$joblist" = "jobs=[$jobkey]"
+test_inspect() {
+ local _jobkey=$1 _config=$2
- vagrant ssh -c "aurora job inspect $jobkey $_base_config"
+ aurora job inspect $_jobkey $_config
+}
+
+test_create() {
+ local _jobkey=$1 _config=$2
+
+ aurora job create $_jobkey $_config
+}
- echo '== Creating job'
- vagrant ssh -c "aurora job create $jobkey $_base_config"
+test_job_status() {
+ local _cluster=$1 _role=$2 _env=$3 _job=$4
+ local _jobkey="$_cluster/$_role/$_env/$_job"
echo "== Checking job status"
- vagrant ssh -c "aurora job list $_cluster/$_role/$_env" | grep "$jobkey"
- vagrant ssh -c "aurora job status $jobkey"
+ aurora job list $_cluster/$_role/$_env | grep "$_jobkey"
+ aurora job status $_jobkey
+}
+
+test_scheduler_ui() {
+ local _role=$1 _env=$2 _job=$3
+
# Check that scheduler UI pages shown
- base_url="http://$_sched_ip:8081"
+ base_url="localhost:8081"
check_url_live "$base_url/scheduler"
check_url_live "$base_url/scheduler/$_role"
check_url_live "$base_url/scheduler/$_role/$_env/$_job"
+}
+
+test_observer_ui() {
+ local _cluster=$1 _role=$2 _job=$3
+
# Check the observer page
- observer_url="http://$_sched_ip:1338"
- task_id=$(vagrant ssh -c "aurora_admin query -l '%taskId%' --states=RUNNING $_cluster $_role $_job | tr -d '\n'")
+ observer_url="localhost:1338"
check_url_live "$observer_url"
- check_url_live "$observer_url/task/$task_id"
- echo "== Restarting test job"
+ # Poll the observer, waiting for it to receive and show information about the task.
+ local _success=0
+ for i in $(seq 1 120); do
+ task_id=$(aurora_admin query -l '%taskId%' --shards=0 --states=RUNNING $_cluster $_role $_job)
+ if check_url_live "$observer_url/task/$task_id"; then
+ _success=1
+ break
+ else
+ sleep 1
+ fi
+ done
+
+ if [ "$_success" -ne "1" ]; then
+ echo "Observer task detail page is not available."
+ exit 1
+ fi
+}
+
+test_restart() {
+ local _jobkey=$1
+
+ aurora job restart --batch-size=2 $_jobkey
+}
- vagrant ssh -c "aurora job restart $jobkey"
+test_update() {
+ local _jobkey=$1 _config=$2
- echo '== Updating test job'
- vagrant ssh -c "aurora job update $jobkey $_updated_config"
+ aurora job update $_jobkey $_config
+}
- echo '== Validating announce'
- validate_serverset "/aurora/$_role/$_env/$_job"
+test_announce() {
+ local _role=$1 _env=$2 _job=$3
- # In order for `aurora task run` to work, the VM needs to be forwarded a local ssh identity. To avoid
- # polluting the global ssh-agent with this identity, we run this test in the context of a local
- # agent. A slightly cleaner solution would be to use a here doc (ssh-agent sh <<EOF ...), but
- # due to a strange confluence of issues, this required some unpalatable hacks. Simply putting
- # the meat of this test in a separate file seems preferable.
- ssh-agent src/test/sh/org/apache/aurora/e2e/test_run.sh $jobkey $_sched_ip
- test $? -eq 0
+ # default python return code
+ local retcode=0
- # Run a kill without specifying instances, and verify that it gets an error, and the job
- # isn't affected. (TODO(maxim): the failed kill should return non-zero!)
- vagrant ssh -c "aurora job kill $jobkey" 2>&1 | grep -q "The instances list cannot be omitted in a kill command"
- check_url_live "$base_url/scheduler/$_role/$_env/$_job"
+ # launch aurora client in interpreter mode to get access to the kazoo client
+ env SERVERSET="/aurora/$_role/$_env/$_job" PEX_INTERPRETER=1 \
+ aurora /vagrant/src/test/sh/org/apache/aurora/e2e/validate_serverset.py || retcode=$?
- vagrant ssh -c "aurora job kill $jobkey/1"
+ if [[ $retcode = 1 ]]; then
+ echo "Validated announced job."
+ return 0
+ elif [[ $retcode = 2 ]]; then
+ echo "Job failed to announce in serverset."
+ elif [[ $retcode = 3 ]]; then
+ echo "Job failed to re-announce when expired."
+ else
+ echo "Unknown failure in test script."
+ fi
- vagrant ssh -c "aurora job killall $jobkey"
+ exit 1
- vagrant ssh -c "aurora quota get $_cluster/$_role"
+ validate_serverset "/aurora/$_jobkey"
}
-test_admin() {
- local _cluster=$1 _sched_ip=$2
+test_run() {
+ local _jobkey=$1
+
+ # Create an SSH public key so that local SSH works without a password.
+ local _ssh_key=~/.ssh/id_rsa
+ rm -f ${_ssh_key}*
+ ssh-keygen -t rsa -N "" -f $_ssh_key
+ cat ${_ssh_key}.pub >> ~/.ssh/authorized_keys
+
+ # Using the sandbox contents as a proxy for functioning SSH. List sandbox contents, we expect
+ # 3 instances of the same thing - our python script.
+ sandbox_contents=$(aurora task run $_jobkey 'ls' | awk '{print $2}' | sort | uniq -c)
+ echo "$sandbox_contents"
+ test "$sandbox_contents" = " 3 http_example.py"
+}
+
+test_kill() {
+ local _jobkey=$1
- base_url="http://$_sched_ip:8081"
+ aurora job kill $_jobkey/1
+ aurora job killall $_jobkey
+}
+
+test_quota() {
+ local _cluster=$1 _role=$2
+
+ aurora quota get $_cluster/$_role
+}
+
+test_http_example() {
+ local _cluster=$1 _role=$2 _env=$3 _job=$4
+ local _base_config=$5 _updated_config=$6
+ local _jobkey="$_cluster/$_role/$_env/$_job"
- echo '== Testing Aurora Admin commands...'
+ test_config $_base_config $_jobkey
+ test_inspect $_jobkey $_base_config
+ test_create $_jobkey $_base_config
+ test_job_status $_cluster $_role $_env $_job
+ test_scheduler_ui $_role $_env $_job
+ test_observer_ui $_cluster $_role $_job
+ test_restart $_jobkey
+ test_update $_jobkey $_updated_config
+ test_announce $_role $_env $_job
+ test_run $_jobkey
+ test_kill $_jobkey
+ test_quota $_cluster $_role
+}
+
+test_admin() {
+ local _cluster=$1
+ echo '== Testing admin commands'
echo '== Getting leading scheduler'
- vagrant ssh -c "aurora_admin get_scheduler $_cluster" | grep ":8081"
+ aurora_admin get_scheduler $_cluster | grep ":8081"
}
RETCODE=1
@@ -111,20 +226,17 @@ TEST_ROLE=vagrant
TEST_ENV=test
TEST_JOB=http_example
TEST_DOCKER_JOB=http_example_docker
-TEST_SCHEDULER_IP=192.168.33.7
TEST_ARGS=(
$TEST_CLUSTER
$TEST_ROLE
$TEST_ENV
$TEST_JOB
- $TEST_SCHEDULER_IP
$EXAMPLE_DIR/http_example.aurora
$EXAMPLE_DIR/http_example_updated.aurora
)
TEST_ADMIN_ARGS=(
$TEST_CLUSTER
- $TEST_SCHEDULER_IP
)
TEST_DOCKER_ARGS=(
@@ -132,23 +244,17 @@ TEST_DOCKER_ARGS=(
$TEST_ROLE
$TEST_ENV
$TEST_DOCKER_JOB
- $TEST_SCHEDULER_IP
$EXAMPLE_DIR/http_example_docker.aurora
$EXAMPLE_DIR/http_example_docker_updated.aurora
)
trap collect_result EXIT
-vagrant up
-vagrant ssh -c "aurorabuild all"
-# wipe the pseudo-deploy dir, and then create it fresh, to guarantee that the
-# test runs clean.
test_version
test_http_example "${TEST_ARGS[@]}"
# build the test docker image
-vagrant ssh -c "sudo docker build -t http_example ${TEST_ROOT}"
-
+sudo docker build -t http_example ${TEST_ROOT}
test_http_example "${TEST_DOCKER_ARGS[@]}"
test_admin "${TEST_ADMIN_ARGS[@]}"
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4e159e3f/src/test/sh/org/apache/aurora/e2e/test_run.sh
----------------------------------------------------------------------
diff --git a/src/test/sh/org/apache/aurora/e2e/test_run.sh b/src/test/sh/org/apache/aurora/e2e/test_run.sh
deleted file mode 100755
index ab91b95..0000000
--- a/src/test/sh/org/apache/aurora/e2e/test_run.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#
-# Test aurora run/aurora task run. This script is meant to be run within an ssh-agent to
-# avoid polluting the global ssh-agent w/ the vagrant private key.
-
-set -u -e -x
-
-jobkey=$1
-scheduler_ip=$2
-aurora_command=${3:-"aurora task run"}
-
-ssh-add $HOME/.vagrant.d/insecure_private_key
-vagrant ssh -c "$aurora_command $jobkey 'pwd'" -- -A -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
- | grep "^$scheduler_ip" | awk '{print $2}' | cut -c 1-14 \
- | while read line; do
- test "$line" = "/var/lib/mesos"
- done