Skip to content

Commit 7a147b3

Browse files
Gamecockdekobon
authored andcommitted
Update test scripts to work on Windows
Fixes nginx#45 Closes nginx#47 Signed-off-by: Elijah Zupancic <e.zupancic@f5.com>
1 parent 0835bd0 commit 7a147b3

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

test.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ if [ "${nginx_type}" = "plus" ]; then
102102
fi
103103

104104
compose() {
105-
${docker_compose_cmd} -f "${test_compose_config}" -p "${test_compose_project}" "$@"
105+
"${docker_compose_cmd}" -f "${test_compose_config}" -p "${test_compose_project}" "$@"
106106
}
107107

108108
integration_test() {
@@ -116,26 +116,28 @@ integration_test() {
116116
printf "\e[1m Integration test suite with APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=%s\e[22m\n" "$4"
117117

118118
# See if Minio is already running, if it isn't then we don't need to build it
119-
if [ -z "$(docker ps -q -f name=${test_compose_project}_minio_1)" ]; then
119+
# COMPOSE_COMPATIBILITY=true Supports older style compose filenames with _ vs -
120+
121+
if [ -z "$(docker ps -q -f name=${test_compose_project}_minio-_1)" ]; then
120122
p "Building Docker Compose environment"
121123
COMPOSE_COMPATIBILITY=true AWS_SIGS_VERSION=$1 ALLOW_DIRECTORY_LIST=$2 PROVIDE_INDEX_PAGE=$3 APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=$4 compose up --no-start
122124

123125
p "Adding test data to container"
124126
echo "Copying contents of ${test_dir}/data to Docker container ${test_compose_project}_minio_1:/"
125-
${docker_cmd} cp "${test_dir}/data" ${test_compose_project}_minio_1:/
127+
"${docker_cmd}" cp "${test_dir}/data" "${test_compose_project}"_minio_1:/
126128
echo "Docker diff output:"
127-
${docker_cmd} diff ${test_compose_project}_minio_1
129+
"${docker_cmd}" diff "${test_compose_project}"_minio_1
128130
fi
129131

130132
p "Starting Docker Compose Environment"
131133
COMPOSE_COMPATIBILITY=true AWS_SIGS_VERSION=$1 ALLOW_DIRECTORY_LIST=$2 PROVIDE_INDEX_PAGE=$3 APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=$4 compose up -d
132134

133-
if [ ${wait_for_it_installed} ]; then
135+
if [ "${wait_for_it_installed}" ]; then
134136
# Hit minio's health check end point to see if it has started up
135137
for (( i=1; i<=3; i++ ))
136138
do
137139
echo "Querying minio server to see if it is ready"
138-
minio_is_up="$(${curl_cmd} -s -o /dev/null -w '%{http_code}' ${minio_server}/minio/health/cluster)"
140+
minio_is_up="$(${curl_cmd} -s -o /dev/null -w '%{http_code}' "${minio_server}"/minio/health/cluster)"
139141
if [ "${minio_is_up}" = "200" ]; then
140142
break
141143
else
@@ -144,13 +146,13 @@ integration_test() {
144146
done
145147

146148
if [ -x "${wait_for_it_cmd}" ]; then
147-
$wait_for_it_cmd -h ${nginx_server_host} -p ${nginx_server_port}
149+
"${wait_for_it_cmd}" -h "${nginx_server_host}" -p "${nginx_server_port}"
148150
fi
149151
fi
150152

151153
p "Starting HTTP API tests (v$1 signatures)"
152154
echo " test/integration/test_api.sh \"$test_server\" \"$test_dir\" $1 $2 $3 $4"
153-
bash "${test_dir}/integration/test_api.sh" "$test_server" "$test_dir" "$1" "$2" "$3" "$4";
155+
bash "${test_dir}/integration/test_api.sh" "${test_server}" "${test_dir}" "$1" "$2" "$3" "$4";
154156

155157
# We check to see if NGINX is in fact using the correct version of AWS
156158
# signatures as it was configured to do.
@@ -209,7 +211,9 @@ fi
209211
### UNIT TESTS
210212

211213
p "Running unit tests in Docker image"
212-
${docker_cmd} run \
214+
#MSYS_NO_PATHCONV=1 added to resolve automatic path conversion
215+
# https://github.com/docker/for-win/issues/6754#issuecomment-629702199
216+
MSYS_NO_PATHCONV=1 "${docker_cmd}" run \
213217
--rm \
214218
-v "$(pwd)/test/unit:/var/tmp" \
215219
--workdir /var/tmp \

test/integration/test_api.sh

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ test_fail_exit_code=2
3030
no_dep_exit_code=3
3131
checksum_length=32
3232

33+
## Check for Windows Machine. Temporary fix to skip non-ascii characters on Windows to run Integration Tests
34+
## I know there could be other windows machines that display OS differently or don't have the issue with UTF-8
35+
## but I don't have them to test.
36+
## remove this once UTF-8 issue solved.
37+
38+
is_windows="0"
39+
if [ -z "${OS}" ] && [ "${OS}" == "Windows_NT" ]; then
40+
is_windows="1"
41+
elif command -v uname > /dev/null; then
42+
uname_output="$(uname -s)"
43+
if [[ "${uname_output}" == *"_NT-"* ]]; then
44+
is_windows="1"
45+
fi
46+
fi
47+
3348
e() {
3449
>&2 echo "$1"
3550
}
@@ -138,15 +153,17 @@ assertHttpRequestEquals "HEAD" "b/c/d.txt" "200"
138153
assertHttpRequestEquals "HEAD" "b/c/../e.txt" "200"
139154
assertHttpRequestEquals "HEAD" "b/e.txt" "200"
140155
assertHttpRequestEquals "HEAD" "b//e.txt" "200"
141-
assertHttpRequestEquals "HEAD" "b/ブツブツ.txt" "200"
142156

143157
# Weird filenames
144158
assertHttpRequestEquals "HEAD" "b/c/=" "200"
145159
assertHttpRequestEquals "HEAD" "b/c/@" "200"
146-
assertHttpRequestEquals "HEAD" "a/c/あ" "200"
147-
assertHttpRequestEquals "HEAD" "b/クズ箱/ゴミ.txt" "200"
148-
assertHttpRequestEquals "HEAD" "системы/system.txt" "200"
149160
assertHttpRequestEquals "HEAD" "%D1%81%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D1%8B/%25bad%25file%25name%25" "200"
161+
if [ ${is_windows} == "0" ]; then
162+
assertHttpRequestEquals "HEAD" "a/c/あ" "200"
163+
assertHttpRequestEquals "HEAD" "b/クズ箱/ゴミ.txt" "200"
164+
assertHttpRequestEquals "HEAD" "системы/system.txt" "200"
165+
assertHttpRequestEquals "HEAD" "b/ブツブツ.txt" "200"
166+
fi
150167

151168
# Expected 400s
152169
# curl will not send this to server now
@@ -204,12 +221,15 @@ assertHttpRequestEquals "GET" "a.txt?some=param&that=should&be=stripped#aaah" "d
204221
assertHttpRequestEquals "GET" "b/c/d.txt" "data/bucket-1/b/c/d.txt"
205222
assertHttpRequestEquals "GET" "b/c/=" "data/bucket-1/b/c/="
206223
assertHttpRequestEquals "GET" "b/e.txt" "data/bucket-1/b/e.txt"
207-
assertHttpRequestEquals "GET" "a/c/あ" "data/bucket-1/a/c/あ"
208-
assertHttpRequestEquals "GET" "b/ブツブツ.txt" "data/bucket-1/b/ブツブツ.txt"
209-
assertHttpRequestEquals "GET" "b/クズ箱/ゴミ.txt" "data/bucket-1/b/クズ箱/ゴミ.txt"
210-
assertHttpRequestEquals "GET" "системы/system.txt" "data/bucket-1/системы/system.txt"
211224
assertHttpRequestEquals "GET" "%D1%81%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D1%8B/%25bad%25file%25name%25" "data/bucket-1/системы/%bad%file%name%"
212225

226+
if [ ${is_windows} == "0" ]; then
227+
assertHttpRequestEquals "GET" "a/c/あ" "data/bucket-1/a/c/あ"
228+
assertHttpRequestEquals "GET" "b/ブツブツ.txt" "data/bucket-1/b/ブツブツ.txt"
229+
assertHttpRequestEquals "GET" "b/クズ箱/ゴミ.txt" "data/bucket-1/b/クズ箱/ゴミ.txt"
230+
assertHttpRequestEquals "GET" "системы/system.txt" "data/bucket-1/системы/system.txt"
231+
fi
232+
213233
if [ "${index_page}" == "1" ]; then
214234
assertHttpRequestEquals "GET" "/statichost/" "data/bucket-1/statichost/index.html"
215235
assertHttpRequestEquals "GET" "/statichost/noindexdir/multipledir/" "data/bucket-1/statichost/noindexdir/multipledir/index.html"

0 commit comments

Comments
 (0)