Fix up e2e test for update demo.

Use the scripts that are in the example directory.  Also actually run the update as part of the test.
pull/6/head
Joe Beda 2014-09-02 14:15:01 -07:00
parent c47b405841
commit ce34eacd2c
5 changed files with 63 additions and 44 deletions

View File

@ -19,6 +19,9 @@ if [ -z "$DOCKER_HUB_USER" ] ; then
exit 1 exit 1
fi fi
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
export KUBECFG=${KUBECFG-$KUBE_REPO_ROOT/cluster/kubecfg.sh}
set -x set -x
../../cluster/kubecfg.sh -p 8080:80 run $DOCKER_HUB_USER/update-demo:nautilus 2 update-demo $KUBECFG -p 8080:80 run $DOCKER_HUB_USER/update-demo:nautilus 2 update-demo

View File

@ -16,6 +16,9 @@
NEW_SIZE=${1:-4} NEW_SIZE=${1:-4}
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
export KUBECFG=${KUBECFG-$KUBE_REPO_ROOT/cluster/kubecfg.sh}
set -x set -x
../../cluster/kubecfg.sh resize update-demo $NEW_SIZE $KUBECFG resize update-demo $NEW_SIZE

View File

@ -20,7 +20,10 @@ if [ -z "$DOCKER_HUB_USER" ] ; then
fi fi
NEW_IMAGE=${1:-kitten} NEW_IMAGE=${1:-kitten}
TIMING=${2:-10s}
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
export KUBECFG=${KUBECFG-$KUBE_REPO_ROOT/cluster/kubecfg.sh}
set -x set -x
../../cluster/kubecfg.sh -image $DOCKER_HUB_USER/update-demo:$NEW_IMAGE -u 10s rollingupdate update-demo $KUBECFG -image $DOCKER_HUB_USER/update-demo:$NEW_IMAGE -u $TIMING rollingupdate update-demo

View File

@ -14,7 +14,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
export KUBE_REPO_ROOT=${KUBE_REPO_ROOT-$(dirname $0)/../..}
export KUBECFG=${KUBECFG-$KUBE_REPO_ROOT/cluster/kubecfg.sh}
set -x set -x
../../cluster/kubecfg.sh stop update-demo $KUBECFG stop update-demo
../../cluster/kubecfg.sh rm update-demo $KUBECFG rm update-demo

View File

@ -16,65 +16,72 @@
# Launches an nginx container and verifies it can be reached. Assumes that # Launches an nginx container and verifies it can be reached. Assumes that
# we're being called by hack/e2e-test.sh (we use some env vars it sets up). # we're being called by hack/e2e-test.sh (we use some env vars it sets up).
set -o errexit
# Exit on error set -o nounset
set -e set -o pipefail
set -x
source "${KUBE_REPO_ROOT}/cluster/kube-env.sh" source "${KUBE_REPO_ROOT}/cluster/kube-env.sh"
source "${KUBE_REPO_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh" source "${KUBE_REPO_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
function validate() {
POD_ID_LIST=$($KUBECFG '-template={{range.Items}}{{.ID}} {{end}}' -l name=$controller list pods)
# Container turn up on a clean cluster can take a while for the docker image pull.
ALL_RUNNING=0
while [ $ALL_RUNNING -ne 1 ]; do
echo "Waiting for all containers in pod to come up."
sleep 5
ALL_RUNNING=1
for id in $POD_ID_LIST; do
CURRENT_STATUS=$($KUBECFG -template '{{and .CurrentState.Info.datacontroller.State.Running .CurrentState.Info.net.State.Running}}' get pods/$id)
if [ "$CURRENT_STATUS" != "true" ]; then
ALL_RUNNING=0
fi
done
done
ids=($POD_ID_LIST) CONTROLLER_NAME=update-demo
if [ ${#ids[@]} -ne $1 ]; then
echo "Unexpected number of pods: ${#ids[@]}. Expected $1" function validate() {
exit 1 NUM_REPLICAS=$1
fi CONTAINER_IMAGE_VERSION=$2
POD_ID_LIST=$($KUBECFG '-template={{range.Items}}{{.ID}} {{end}}' -l replicationController=${CONTROLLER_NAME} list pods)
# Container turn up on a clean cluster can take a while for the docker image pull.
ALL_RUNNING=0
while [ $ALL_RUNNING -ne 1 ]; do
echo "Waiting for all containers in pod to come up."
sleep 5
ALL_RUNNING=1
for id in $POD_ID_LIST; do
TEMPLATE_STRING="{{and ((index .CurrentState.Info \"${CONTROLLER_NAME}\").State.Running) .CurrentState.Info.net.State.Running}}"
CURRENT_STATUS=$($KUBECFG -template "${TEMPLATE_STRING}" get pods/$id)
if [ "$CURRENT_STATUS" != "true" ]; then
ALL_RUNNING=0
fi
CURRENT_IMAGE=$($KUBECFG -template "{{(index .CurrentState.Info \"${CONTROLLER_NAME}\").Config.Image}}" get pods/$id)
if [ "$CURRENT_IMAGE" != "${DOCKER_HUB_USER}/update-demo:${CONTAINER_IMAGE_VERSION}" ]; then
ALL_RUNNING=0
fi
done
done
ids=($POD_ID_LIST)
if [ ${#ids[@]} -ne $NUM_REPLICAS ]; then
echo "Unexpected number of pods: ${#ids[@]}. Expected $NUM_REPLICAS"
exit 1
fi
} }
controller=dataController DOCKER_HUB_USER=jbeda
# Launch a container # Launch a container
$KUBECFG -p 8080:80 run brendanburns/data 2 $controller ${KUBE_REPO_ROOT}/examples/update-demo/1-create-replication-controller.sh
function teardown() { function teardown() {
echo "Cleaning up test artifacts" echo "Cleaning up test artifacts"
$KUBECFG stop $controller ${KUBE_REPO_ROOT}/examples/update-demo/4-down.sh
$KUBECFG rm $controller
} }
trap "teardown" EXIT trap "teardown" EXIT
validate 2 validate 2 nautilus
$KUBECFG resize $controller 1 ${KUBE_REPO_ROOT}/examples/update-demo/2-scale.sh 1
sleep 2 sleep 2
validate 1 validate 1 nautilus
$KUBECFG resize $controller 2 ${KUBE_REPO_ROOT}/examples/update-demo/2-scale.sh 2
sleep 2 sleep 2
validate 2 validate 2 nautilus
# TODO: test rolling update here, but to do so, we need to make the update blocking ${KUBE_REPO_ROOT}/examples/update-demo/3-rolling-update.sh kitten 1s
# $KUBECFG -u=20s rollingupdate $controller sleep 2
# validate 2 kitten
# Wait for the replica controller to recreate
# sleep 10
#
# validate 2
exit 0 exit 0