Skip to content

Commit 7c0bf16

Browse files
aplusdekobon
authored andcommitted
New minio
1 parent bc22903 commit 7c0bf16

File tree

3 files changed

+52
-33
lines changed

3 files changed

+52
-33
lines changed

docs/development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ additional modules.
5555

5656
## Testing
5757

58-
Automated tests require `docker`, `docker-compose`, `curl` and `md5sum` to be
58+
Automated tests require `docker`, `docker-compose`, `curl`, `mc` and `md5sum` to be
5959
installed. To run all unit tests and integration tests, run the following command.
6060
If you invoke the test script with a plus parameter, you will need to add your
6161
NGINX repository keys to the `plus/etc/ssl/nginx` directory

test.sh

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ set -o pipefail # don't hide errors within pipes
2222
nginx_server_proto="http"
2323
nginx_server_host="localhost"
2424
nginx_server_port="8989"
25-
minio_server="http://localhost:9090"
25+
2626
test_server="${nginx_server_proto}://${nginx_server_host}:${nginx_server_port}"
2727
test_fail_exit_code=2
2828
no_dep_exit_code=3
@@ -31,6 +31,12 @@ test_dir="${script_dir}/test"
3131
test_compose_config="${test_dir}/docker-compose.yaml"
3232
test_compose_project="ngt"
3333

34+
minio_server="http://localhost:9090"
35+
minio_user="AKIAIOSFODNN7EXAMPLE"
36+
minio_passwd="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
37+
minio_name="${test_compose_project}_minio_1"
38+
minio_bucket="bucket-1"
39+
3440
is_windows="0"
3541
if [ -z "${OS}" ] && [ "${OS}" == "Windows_NT" ]; then
3642
is_windows="1"
@@ -137,6 +143,12 @@ if ! [ -x "${curl_cmd}" ]; then
137143
exit ${no_dep_exit_code}
138144
fi
139145

146+
mc_cmd="$(command -v mc)"
147+
if ! [ -x "${mc_cmd}" ]; then
148+
e "required dependency not found: mc not found in the path or not executable"
149+
exit ${no_dep_exit_code}
150+
fi
151+
140152
wait_for_it_cmd="$(command -v wait-for-it || true)"
141153
if [ -x "${wait_for_it_cmd}" ]; then
142154
wait_for_it_installed=1
@@ -168,16 +180,7 @@ compose() {
168180
${docker_compose_cmd} -f "${test_compose_config}" -p "${test_compose_project}" "$@"
169181
}
170182

171-
integration_test() {
172-
printf "\033[34;1m▶\033[0m"
173-
printf "\e[1m Integration test suite for v%s signatures\e[22m\n" "$1"
174-
printf "\033[34;1m▶\033[0m"
175-
printf "\e[1m Integration test suite with ALLOW_DIRECTORY_LIST=%s\e[22m\n" "$2"
176-
printf "\033[34;1m▶\033[0m"
177-
printf "\e[1m Integration test suite with PROVIDE_INDEX_PAGE=%s\e[22m\n" "$3"
178-
printf "\033[34;1m▶\033[0m"
179-
printf "\e[1m Integration test suite with APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=%s\e[22m\n" "$4"
180-
183+
integration_test_data() {
181184

182185
# Write problematic files to disk if we are not on Windows. Originally,
183186
# these files were checked in, but that prevented the git repository from
@@ -187,23 +190,10 @@ integration_test() {
187190
echo 'We are but selling water next to a river.' > "${test_dir}"'/data/bucket-1/a/%@!*()=$#^&|.txt'
188191
fi
189192

190-
# See if Minio is already running, if it isn't then we don't need to build it
191-
# COMPOSE_COMPATIBILITY=true Supports older style compose filenames with _ vs -
192-
193-
if [ -z "$(docker ps -q -f name=${test_compose_project}_minio-_1)" ]; then
194-
p "Building Docker Compose environment"
195-
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
196-
197-
p "Adding test data to container"
198-
echo "Copying contents of ${test_dir}/data to Docker container ${test_compose_project}_minio_1:/"
199-
"${docker_cmd}" cp "${test_dir}/data" "${test_compose_project}"_minio_1:/
200-
echo "Docker diff output:"
201-
"${docker_cmd}" diff "${test_compose_project}"_minio_1
202-
fi
203-
204193
p "Starting Docker Compose Environment"
205-
COMPOSE_COMPATIBILITY=true AWS_SIGS_VERSION=$1 ALLOW_DIRECTORY_LIST=$2 PROVIDE_INDEX_PAGE=$3 APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=$4 compose up -d
206-
194+
# COMPOSE_COMPATIBILITY=true Supports older style compose filenames with _ vs -
195+
COMPOSE_COMPATIBILITY=true compose up -d
196+
207197
if [ "${wait_for_it_installed}" ]; then
208198
# Hit minio's health check end point to see if it has started up
209199
for (( i=1; i<=3; i++ ))
@@ -216,7 +206,32 @@ integration_test() {
216206
sleep 2
217207
fi
218208
done
209+
fi
210+
211+
p "Adding test data to container"
212+
"${mc_cmd}" alias set "$minio_name" "$minio_server" "$minio_user" "$minio_passwd"
213+
"${mc_cmd}" mb "$minio_name/$minio_bucket"
214+
echo "Copying contents of ${test_dir}/data/$minio_bucket to Docker container $minio_name"
215+
"${mc_cmd}" cp -r "${test_dir}/data/$minio_bucket/" "$minio_name/"
216+
echo "Docker diff output:"
217+
"${docker_cmd}" diff "$minio_name"
218+
}
219+
220+
integration_test() {
221+
printf "\033[34;1m▶\033[0m"
222+
printf "\e[1m Integration test suite for v%s signatures\e[22m\n" "$1"
223+
printf "\033[34;1m▶\033[0m"
224+
printf "\e[1m Integration test suite with ALLOW_DIRECTORY_LIST=%s\e[22m\n" "$2"
225+
printf "\033[34;1m▶\033[0m"
226+
printf "\e[1m Integration test suite with PROVIDE_INDEX_PAGE=%s\e[22m\n" "$3"
227+
printf "\033[34;1m▶\033[0m"
228+
printf "\e[1m Integration test suite with APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=%s\e[22m\n" "$4"
219229

230+
p "Starting Docker Compose Environment"
231+
# COMPOSE_COMPATIBILITY=true Supports older style compose filenames with _ vs -
232+
COMPOSE_COMPATIBILITY=true AWS_SIGS_VERSION=$1 ALLOW_DIRECTORY_LIST=$2 PROVIDE_INDEX_PAGE=$3 APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=$4 compose up -d
233+
234+
if [ "${wait_for_it_installed}" ]; then
220235
if [ -x "${wait_for_it_cmd}" ]; then
221236
"${wait_for_it_cmd}" -h "${nginx_server_host}" -p "${nginx_server_port}"
222237
fi
@@ -247,7 +262,8 @@ finish() {
247262

248263
p "Cleaning up Docker compose environment"
249264
compose stop
250-
compose rm -f
265+
compose rm -f -v
266+
"${mc_cmd}" alias rm "$minio_name"
251267

252268
exit ${result}
253269
}
@@ -352,6 +368,8 @@ runUnitTestWithSessionToken "s3gateway_test.js"
352368

353369
### INTEGRATION TESTS
354370

371+
integration_test_data
372+
355373
p "Testing API with AWS Signature V2 and allow directory listing off"
356374
integration_test 2 0 0 0
357375

test/docker-compose.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ services:
3535
PROXY_CACHE_VALID_FORBIDDEN: "30s"
3636

3737
minio:
38-
image: "minio/minio:RELEASE.2021-02-19T04-38-02Z"
38+
image: quay.io/minio/minio:RELEASE.2023-06-09T07-32-12Z
3939
ports:
4040
- "9090:9000/tcp"
4141
restart: "no"
42-
command: "server --address :9000 /data"
42+
command: minio server /data
4343
environment:
44-
MINIO_ACCESS_KEY: "AKIAIOSFODNN7EXAMPLE"
45-
MINIO_SECRET_KEY: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
44+
MINIO_ADDRESS: :9000
45+
MINIO_ROOT_USER: "AKIAIOSFODNN7EXAMPLE"
46+
MINIO_ROOT_PASSWORD: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
4647
MINIO_REGION_NAME: "us-east-1"
4748
MINIO_DOMAIN: "minio"
4849
MINIO_BROWSER: "off"

0 commit comments

Comments
 (0)