-
Notifications
You must be signed in to change notification settings - Fork 288
/
run
executable file
·132 lines (107 loc) · 3.57 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
#
# The 'run' performs a simple test that verifies that STI image.
# The main focus here is to exercise the STI scripts.
#
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
#
# EXPRESS_REVISION specifies which express.js branch or tag should be tested;
# by default it uses the latest released version as reported by
# `npm show express version`.
THISDIR=$(dirname ${BASH_SOURCE[0]})
TEST_LIST_APP="\
test_run_app_application
test_s2i_usage
test_scl_usage
test_connection
test_docker_run_usage
test_check_build_using_dockerfile
test_nodemon_removed
test_npm_cache_cleared
test_npm_tmp_cleared
kill_test_application
test_dev_mode_true_development
test_dev_mode_false_production
"
TEST_LIST_NODE_ENV="\
test_run_app_application
test_connection
test_nodemon_present
test_npm_cache_exists
kill_test_application
test_dev_mode_true_development
test_dev_mode_false_development
"
TEST_LIST_DEV_MODE="\
test_run_app_application
test_connection
test_nodemon_present
test_npm_cache_exists
kill_test_application
test_dev_mode_true_development
test_dev_mode_false_production
"
TEST_LIST_HW="\
test_safe_logging
test_run_hw_application
"
source "${THISDIR}/test-lib.sh"
source "${THISDIR}/test-lib-nodejs.sh"
test -n $IMAGE_NAME \
-a -n $VERSION
readonly EXPRESS_REVISION="${EXPRESS_REVISION:-$(docker run --rm "${IMAGE_NAME}" -- npm show express version)}"
test_dir="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
image_dir="$(readlink -f ${test_dir}/..)"
# Since we built the candidate image locally, we don't want S2I attempt to pull
# it from Docker hub
s2i_args="--pull-policy=never "
# TODO: This should be part of the image metadata
test_port=8080
# Common git configuration
readonly -A gitconfig=(
[user.name]="builder"
[user.email]="build@localhost"
[commit.gpgsign]="false"
)
if [ "$DEBUG" != "" ]; then
set -x
fi
ct_init
cid_file=$CID_FILE_DIR/$(mktemp -u -p . --suffix=.cid)
# Build the application image twice to ensure the 'save-artifacts' and
# 'restore-artifacts' scripts are working properly
prepare app
check_prep_result $? app || exit
echo "Testing the production image build"
FULL_IMAGE=${FULL_IMAGE:-${IMAGE_NAME//-minimal:1/}}
# if FULL_IMAGE is not found, try to pull it, if that does not work, try to pull ubi9 one
if [ -z "$(docker images -q "$FULL_IMAGE")" ] ; then
echo "Image $FULL_IMAGE not found, trying to pull $FULL_IMAGE from registry"
docker pull "$FULL_IMAGE"
fi
if [ -z "$(docker images -q "$FULL_IMAGE")" ] ; then
echo "Image $FULL_IMAGE still not found, trying to use ubi9/nodejs-${VERSION//-minimal/}:latest and pull it"
FULL_IMAGE="ubi9/nodejs-${VERSION//-minimal/}:latest"
docker pull "$FULL_IMAGE"
fi
if [ -z "$(docker images -q "$FULL_IMAGE")" ] ; then
echo "Image $FULL_IMAGE could not be found nor pulled, giving up."
exit 1
fi
prepare_minimal_build testapp
TEST_SET=${TESTS:-$TEST_LIST_APP} ct_run_tests_from_testset "app"
echo "Testing proxy safe logging..."
prepare hw
check_prep_result $? hw || exit
prepare_minimal_build testhw
TEST_SET=${TESTS:-$TEST_LIST_HW} ct_run_tests_from_testset "hw"
# Start of testing regular s2i build for minimal image
echo "Testing the development image build: s2i build -e \"NODE_ENV=development\")"
run_s2i_build "-e NODE_ENV=development"
check_result $?
TEST_SET=${TESTS:-$TEST_LIST_NODE_ENV} ct_run_tests_from_testset "node_env_development"
echo "Testing the development image build: s2i build -e \"DEV_MODE=true\")"
run_s2i_build "-e DEV_MODE=true"
check_result $?
TEST_SET=${TESTS:-$TEST_LIST_DEV_MODE} ct_run_tests_from_testset "dev_mode"