Skip to content

Commit

Permalink
Improve bash scripts
Browse files Browse the repository at this point in the history
Bash sanitization in test image builder script and integration test
runner.
  • Loading branch information
rhcarvalho committed Apr 4, 2016
1 parent fb6df26 commit 56e1260
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 40 deletions.
45 changes: 23 additions & 22 deletions hack/build-test-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,29 @@ set -o errexit
set -o nounset
set -o pipefail

STI_ROOT=$(dirname "${BASH_SOURCE}")/..
readonly STI_ROOT=$(dirname "${BASH_SOURCE}")/..

# Go to the top of the tree.
cd "${STI_ROOT}"


function buildimage()
{
tag=$1
src=$2
cp -R test/integration/scripts $src
docker build -t "${tag}" "${src}"
rm -rf $src/scripts
s2i::build_test_image() {
local image_name="$1"
local tag="sti_test/${image_name}"
local src="test/integration/images/${image_name}"
cp -R test/integration/scripts "${src}"
docker build -t "${tag}" "${src}"
rm -rf "${src}/scripts"
}

buildimage sti_test/sti-fake test/integration/images/sti-fake
buildimage sti_test/sti-fake-env test/integration/images/sti-fake-env
buildimage sti_test/sti-fake-user test/integration/images/sti-fake-user
buildimage sti_test/sti-fake-scripts test/integration/images/sti-fake-scripts
buildimage sti_test/sti-fake-scripts-no-save-artifacts test/integration/images/sti-fake-scripts-no-save-artifacts
buildimage sti_test/sti-fake-no-tar test/integration/images/sti-fake-no-tar
buildimage sti_test/sti-fake-onbuild test/integration/images/sti-fake-onbuild
buildimage sti_test/sti-fake-numericuser test/integration/images/sti-fake-numericuser
buildimage sti_test/sti-fake-onbuild-rootuser test/integration/images/sti-fake-onbuild-rootuser
buildimage sti_test/sti-fake-onbuild-numericuser test/integration/images/sti-fake-onbuild-numericuser
(
# Go to the top of the tree.
cd "${STI_ROOT}"

s2i::build_test_image sti-fake
s2i::build_test_image sti-fake-env
s2i::build_test_image sti-fake-user
s2i::build_test_image sti-fake-scripts
s2i::build_test_image sti-fake-scripts-no-save-artifacts
s2i::build_test_image sti-fake-no-tar
s2i::build_test_image sti-fake-onbuild
s2i::build_test_image sti-fake-numericuser
s2i::build_test_image sti-fake-onbuild-rootuser
s2i::build_test_image sti-fake-onbuild-numericuser
)
27 changes: 9 additions & 18 deletions hack/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,24 @@ set -o errexit
set -o nounset
set -o pipefail

STI_ROOT=$(dirname "${BASH_SOURCE}")/..
readonly STI_ROOT=$(dirname "${BASH_SOURCE}")/..

function cleanup()
{
set +e
echo
echo "Complete"
s2i::cleanup() {
echo
echo "Complete"
}

set +e
img_count=$(docker images | grep -c sti_test/sti-fake)
set -e
readonly img_count="$(docker images | grep -c sti_test/sti-fake || :)"

if [ "${img_count}" != "10" ]; then
echo "You do not have necessary test images, be sure to run "hack/build-test-images.sh" beforehand."
echo "Missing test images, run "hack/build-test-images.sh" and try again."
exit 1
fi

trap cleanup EXIT SIGINT

export STI_TIMEOUT="-timeout 600s"
mkdir -p /tmp/sti
export LOG_FILE="$(mktemp -p /tmp/sti --suffix=integration.log)"
trap s2i::cleanup EXIT SIGINT

echo
echo Integration test cases ...
echo Log file: ${LOG_FILE}
echo "Running integration tests ..."
echo

"${STI_ROOT}/hack/test-go.sh" test/integration -v -tags "integration" "${@:1}" 2> ${LOG_FILE}
STI_TIMEOUT="-timeout 600s" "${STI_ROOT}/hack/test-go.sh" test/integration -v -tags "integration" "${@:1}"

0 comments on commit 56e1260

Please sign in to comment.