7647d70
#!/bin/bash
7647d70
7647d70
# This script is used to test the OpenShift Docker images.
7647d70
#
7647d70
# TEST_MODE - If set, run regular test suite
7647d70
# TEST_OPENSHIFT_MODE - If set, run OpenShift tests (if present)
7647d70
# VERSIONS - Must be set to a list with possible versions (subdirectories)
7647d70
7647d70
set -e
7647d70
7647d70
for dir in ${VERSIONS}; do
7647d70
  [ ! -e "${dir}/.image-id" ] && echo "-> Image for version $dir not built, skipping tests." && continue
7647d70
  pushd "${dir}" > /dev/null
7647d70
  IMAGE_ID=$(cat .image-id)
7647d70
  export IMAGE_ID
7647d70
  # Kept also IMAGE_NAME as some tests might still use that.
7647d70
  IMAGE_NAME=$(docker inspect -f "{{.Config.Labels.name}}" "$IMAGE_ID")
7647d70
  export IMAGE_NAME
7647d70
7647d70
  if [ -n "${TEST_MODE}" ]; then
7647d70
    VERSION=$dir test/run
7647d70
  fi
7647d70
7647d70
  if [ -n "${TEST_CONU_MODE}" ]; then
7647d70
    if [[ -x test/run-conu ]]; then
7647d70
      if [ -n "${CONU_IMAGE}" ]; then
7647d70
        echo "-> Running conu tests in a container"
7647d70
        docker run \
7647d70
          --net=host \
7647d70
          -e VERSION="${dir}" \
7647d70
          -e IMAGE_NAME \
7647d70
          --rm \
7647d70
          --security-opt label=disable \
7647d70
          -ti \
7647d70
          -v /var/run/docker.sock:/var/run/docker.sock \
7647d70
          -v "${PWD}"/../:/src \
7647d70
          -w "/src/${dir}/" \
7647d70
          -ti \
7647d70
          "${CONU_IMAGE}" \
7647d70
          ./test/run-conu
7647d70
      else
7647d70
        VERSION="${dir}" ./test/run-conu
7647d70
      fi
7647d70
    else
7647d70
      echo "-> conu tests are not present, skipping"
7647d70
    fi
7647d70
  fi
7647d70
7647d70
  if [ -n "${TEST_OPENSHIFT_MODE}" ]; then
7647d70
    if [[ -x test/run-openshift ]]; then
7647d70
      VERSION=$dir test/run-openshift
7647d70
    else
7647d70
      echo "-> OpenShift tests are not present, skipping"
7647d70
    fi
7647d70
  fi
7647d70
7647d70
  popd > /dev/null
7647d70
done