aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-02-03 13:59:04 +0100
committerGerd Hoffmann <kraxel@redhat.com>2020-02-03 13:59:04 +0100
commit995a0c1221fda4f16488f988254e971d16531f1d (patch)
treed1cfbb77838328fd92bce82bdcddc08950d3fd31
parent06529ce594d4d580eadd28e99d64e00b621287ee (diff)
downloads2i-jekyll-995a0c1221fda4f16488f988254e971d16531f1d.tar.gz
build tweak
-rwxr-xr-xs2i/bin/assemble10
-rwxr-xr-xs2i/bin/run5
-rwxr-xr-xtest/run155
-rw-r--r--test/test-app/index.html10
4 files changed, 8 insertions, 172 deletions
diff --git a/s2i/bin/assemble b/s2i/bin/assemble
index 554b195..8dd3930 100755
--- a/s2i/bin/assemble
+++ b/s2i/bin/assemble
@@ -12,11 +12,9 @@ if [[ "$1" == "-h" ]]; then
exec /usr/libexec/s2i/usage
fi
-set -e
-
-echo "---> Enabling s2i support in httpd24 image ..."
-source ${HTTPD_CONTAINER_SCRIPTS_PATH}/common.sh
-config_s2i
+echo "--- debug ---"
+id -a
+echo "---"
if [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then
echo "---> Restoring build artifacts ..."
@@ -52,4 +50,4 @@ cp -av . "$dest"
popd
echo "---> Fix permissions ..."
-fix-permissions ./
+chmod -R +r .
diff --git a/s2i/bin/run b/s2i/bin/run
index e63ae48..6692e10 100755
--- a/s2i/bin/run
+++ b/s2i/bin/run
@@ -1,2 +1,5 @@
#!/bin/sh
-exec "${0}.httpd" "$@"
+echo "--- debug ---"
+find /etc/httpd -type f | xargs egrep -i -e '(listen)'
+echo "---"
+exec httpd -D FOREGROUND
diff --git a/test/run b/test/run
deleted file mode 100755
index 7e6ed7a..0000000
--- a/test/run
+++ /dev/null
@@ -1,155 +0,0 @@
-#!/bin/bash
-#
-# The 'run' performs a simple test that verifies the S2I image.
-# The main focus here is to exercise the S2I scripts.
-#
-# For more information see the documentation:
-# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
-#
-# IMAGE_NAME specifies a name of the candidate image used for testing.
-# The image has to be available before this script is executed.
-#
-IMAGE_NAME=${IMAGE_NAME-kraxel/s2i-jekyll-candidate}
-
-# Determining system utility executables (darwin compatibility check)
-READLINK_EXEC="readlink -zf"
-MKTEMP_EXEC="mktemp --suffix=.cid"
-if [[ "$OSTYPE" =~ 'darwin' ]]; then
- READLINK_EXEC="readlink"
- MKTEMP_EXEC="mktemp"
- ! type -a "greadlink" &>"/dev/null" || READLINK_EXEC="greadlink"
- ! type -a "gmktemp" &>"/dev/null" || MKTEMP_EXEC="gmktemp"
-fi
-
-_dir="$(dirname "${BASH_SOURCE[0]}")"
-test_dir="$($READLINK_EXEC ${_dir} || echo ${_dir})"
-image_dir=$($READLINK_EXEC ${test_dir}/.. || echo ${test_dir}/..)
-scripts_url="${image_dir}/.s2i/bin"
-cid_file=$($MKTEMP_EXEC -u)
-
-# Since we built the candidate image locally, we don't want S2I to attempt to pull
-# it from Docker hub
-s2i_args="--pull-policy=never --loglevel=2"
-
-# Port the image exposes service to be tested
-test_port=8080
-
-image_exists() {
- docker inspect $1 &>/dev/null
-}
-
-container_exists() {
- image_exists $(cat $cid_file)
-}
-
-container_ip() {
- docker inspect --format="{{(index .NetworkSettings.Ports \"$test_port/tcp\" 0).HostIp }}" $(cat $cid_file) | sed 's/0.0.0.0/localhost/'
-}
-
-container_port() {
- docker inspect --format="{{(index .NetworkSettings.Ports \"$test_port/tcp\" 0).HostPort }}" "$(cat "${cid_file}")"
-}
-
-run_s2i_build() {
- s2i build --incremental=true ${s2i_args} ${test_dir}/test-app ${IMAGE_NAME} ${IMAGE_NAME}-testapp
-}
-
-prepare() {
- if ! image_exists ${IMAGE_NAME}; then
- echo "ERROR: The image ${IMAGE_NAME} must exist before this script is executed."
- exit 1
- fi
- # s2i build requires the application is a valid 'Git' repository
- pushd ${test_dir}/test-app >/dev/null
- git init
- git config user.email "build@localhost" && git config user.name "builder"
- git add -A && git commit -m "Sample commit"
- popd >/dev/null
- run_s2i_build
-}
-
-run_test_application() {
- docker run --rm --cidfile=${cid_file} -p ${test_port}:${test_port} ${IMAGE_NAME}-testapp
-}
-
-cleanup() {
- if [ -f $cid_file ]; then
- if container_exists; then
- docker stop $(cat $cid_file)
- fi
- fi
- if image_exists ${IMAGE_NAME}-testapp; then
- docker rmi ${IMAGE_NAME}-testapp
- fi
-}
-
-check_result() {
- local result="$1"
- if [[ "$result" != "0" ]]; then
- echo "S2I image '${IMAGE_NAME}' test FAILED (exit code: ${result})"
- cleanup
- exit $result
- fi
-}
-
-wait_for_cid() {
- local max_attempts=10
- local sleep_time=1
- local attempt=1
- local result=1
- while [ $attempt -le $max_attempts ]; do
- [ -f $cid_file ] && break
- echo "Waiting for container to start..."
- attempt=$(( $attempt + 1 ))
- sleep $sleep_time
- done
-}
-
-test_usage() {
- echo "Testing 's2i usage'..."
- s2i usage ${s2i_args} ${IMAGE_NAME} &>/dev/null
-}
-
-test_connection() {
- echo "Testing HTTP connection (http://$(container_ip):$(container_port))"
- local max_attempts=10
- local sleep_time=1
- local attempt=1
- local result=1
- while [ $attempt -le $max_attempts ]; do
- echo "Sending GET request to http://$(container_ip):$(container_port)/"
- response_code=$(curl -s -w %{http_code} -o /dev/null http://$(container_ip):$(container_port)/)
- status=$?
- if [ $status -eq 0 ]; then
- if [ $response_code -eq 200 ]; then
- result=0
- fi
- break
- fi
- attempt=$(( $attempt + 1 ))
- sleep $sleep_time
- done
- return $result
-}
-
-# Build the application image twice to ensure the 'save-artifacts' and
-# 'restore-artifacts' scripts are working properly
-prepare
-run_s2i_build
-check_result $?
-
-# Verify the 'usage' script is working properly
-test_usage
-check_result $?
-
-# Verify that the HTTP connection can be established to test application container
-run_test_application &
-
-# Wait for the container to write its CID file
-wait_for_cid
-
-test_connection
-check_result $?
-
-cleanup
-
diff --git a/test/test-app/index.html b/test/test-app/index.html
deleted file mode 100644
index 7bca10c..0000000
--- a/test/test-app/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <title>Hello World!</title>
- </head>
- <body>
- <h1>Hello World!</h1>
- </body>
-</html>
- \ No newline at end of file