Use mc functional tests for verifying build (#4934)

master
Bala FA 7 years ago committed by Harshavardhana
parent 3c0d3f7510
commit 6d7df1d1cb
  1. 185
      buildscripts/verify-build.sh

@ -15,56 +15,35 @@
# limitations under the License. # limitations under the License.
# #
WORK_DIR="$PWD/verify-$RANDOM" set -e
MINIO_CONFIG_DIR="$WORK_DIR/.minio" set -E
MC_CONFIG_DIR="$WORK_DIR/.mc" set -o pipefail
SERVER_ALIAS="myminio"
ACCESS_KEY="minio"
SECRET_KEY="minio123"
BUCKET_NAME="mc-test-bucket-$RANDOM"
MINIO="$PWD/minio"
MC_CMD="$WORK_DIR/mc"
FILE_1_MB="$WORK_DIR/datafile-1-MB"
FILE_65_MB="$WORK_DIR/datafile-65-MB"
function create_minio_config()
{
## version is purposefully set to '3' for minio to migrate configuration file
echo '{"version": "3", "credential": {"accessKey": "minio", "secretKey": "minio123"}, "region": "us-east-1"}' > "$MINIO_CONFIG_DIR/config.json"
}
function assert_run_mc_command() if [ ! -x "$PWD/minio" ]; then
{ echo "minio executable binary not found in current directory"
outfile="$WORK_DIR/cmd.out.$RANDOM" exit 1
fi
rv=0 WORK_DIR="$PWD/.verify-$RANDOM"
if ! "${MC_CMD}" --config-folder "$MC_CONFIG_DIR" --quiet --no-color "$@" >"$outfile" 2>&1; then
echo "failed to run command: ${MC_CMD}" "$@"
cat "$outfile"
rv=1
fi
rm -f "$outfile" export MINT_MODE=core
export MINT_DATA_DIR="$WORK_DIR/data"
export SERVER_ENDPOINT="127.0.0.1:9000"
export ACCESS_KEY="minio"
export SECRET_KEY="minio123"
export ENABLE_HTTPS=0
if [ "$rv" -ne 0 ]; then MINIO_CONFIG_DIR="$WORK_DIR/.minio"
exit 1 MINIO=( "$PWD/minio" --config-dir "$MINIO_CONFIG_DIR" )
fi
}
function assert_download_mc() FILE_1_MB="$MINT_DATA_DIR/datafile-1-MB"
{ FILE_65_MB="$MINT_DATA_DIR/datafile-65-MB"
if ! wget -q -O "${MC_CMD}" https://dl.minio.io/client/mc/release/linux-amd64/mc; then
echo "failed to download 'mc'"
exit 1
fi
chmod a+x "${MC_CMD}" FUNCTIONAL_TESTS="$WORK_DIR/functional-tests.sh"
assert_run_mc_command config host add "${SERVER_ALIAS}" http://127.0.0.1:9000 minio minio123
}
function start_minio_fs() function start_minio_fs()
{ {
"$MINIO" --config-dir "$MINIO_CONFIG_DIR" server "${WORK_DIR}/fs-disk" >"$WORK_DIR/fs-minio.log" 2>&1 & "${MINIO[@]}" server "${WORK_DIR}/fs-disk" >"$WORK_DIR/fs-minio.log" 2>&1 &
minio_pid=$! minio_pid=$!
sleep 3 sleep 3
@ -73,7 +52,7 @@ function start_minio_fs()
function start_minio_xl() function start_minio_xl()
{ {
"$MINIO" --config-dir "$MINIO_CONFIG_DIR" server "${WORK_DIR}/xl-disk1" "${WORK_DIR}/xl-disk2" "${WORK_DIR}/xl-disk3" "${WORK_DIR}/xl-disk4" >"$WORK_DIR/xl-minio.log" 2>&1 & "${MINIO[@]}" server "${WORK_DIR}/xl-disk1" "${WORK_DIR}/xl-disk2" "${WORK_DIR}/xl-disk3" "${WORK_DIR}/xl-disk4" >"$WORK_DIR/xl-minio.log" 2>&1 &
minio_pid=$! minio_pid=$!
sleep 3 sleep 3
@ -83,85 +62,24 @@ function start_minio_xl()
function start_minio_dist() function start_minio_dist()
{ {
declare -a minio_pids declare -a minio_pids
"$MINIO" --config-dir "$MINIO_CONFIG_DIR" server --address=:9000 "http://127.0.0.1:9000${WORK_DIR}/dist-disk1" "http://127.0.0.1:9001${WORK_DIR}/dist-disk2" "http://127.0.0.1:9002${WORK_DIR}/dist-disk3" "http://127.0.0.1:9003${WORK_DIR}/dist-disk4" >"$WORK_DIR/dist-minio-9000.log" 2>&1 & "${MINIO[@]}" server --address=:9000 "http://127.0.0.1:9000${WORK_DIR}/dist-disk1" "http://127.0.0.1:9001${WORK_DIR}/dist-disk2" "http://127.0.0.1:9002${WORK_DIR}/dist-disk3" "http://127.0.0.1:9003${WORK_DIR}/dist-disk4" >"$WORK_DIR/dist-minio-9000.log" 2>&1 &
minio_pids[0]=$! minio_pids[0]=$!
"$MINIO" --config-dir "$MINIO_CONFIG_DIR" server --address=:9001 "http://127.0.0.1:9000${WORK_DIR}/dist-disk1" "http://127.0.0.1:9001${WORK_DIR}/dist-disk2" "http://127.0.0.1:9002${WORK_DIR}/dist-disk3" "http://127.0.0.1:9003${WORK_DIR}/dist-disk4" >"$WORK_DIR/dist-minio-9001.log" 2>&1 & "${MINIO[@]}" server --address=:9001 "http://127.0.0.1:9000${WORK_DIR}/dist-disk1" "http://127.0.0.1:9001${WORK_DIR}/dist-disk2" "http://127.0.0.1:9002${WORK_DIR}/dist-disk3" "http://127.0.0.1:9003${WORK_DIR}/dist-disk4" >"$WORK_DIR/dist-minio-9001.log" 2>&1 &
minio_pids[1]=$! minio_pids[1]=$!
"$MINIO" --config-dir "$MINIO_CONFIG_DIR" server --address=:9002 "http://127.0.0.1:9000${WORK_DIR}/dist-disk1" "http://127.0.0.1:9001${WORK_DIR}/dist-disk2" "http://127.0.0.1:9002${WORK_DIR}/dist-disk3" "http://127.0.0.1:9003${WORK_DIR}/dist-disk4" >"$WORK_DIR/dist-minio-9002.log" 2>&1 & "${MINIO[@]}" server --address=:9002 "http://127.0.0.1:9000${WORK_DIR}/dist-disk1" "http://127.0.0.1:9001${WORK_DIR}/dist-disk2" "http://127.0.0.1:9002${WORK_DIR}/dist-disk3" "http://127.0.0.1:9003${WORK_DIR}/dist-disk4" >"$WORK_DIR/dist-minio-9002.log" 2>&1 &
minio_pids[2]=$! minio_pids[2]=$!
"$MINIO" --config-dir "$MINIO_CONFIG_DIR" server --address=:9003 "http://127.0.0.1:9000${WORK_DIR}/dist-disk1" "http://127.0.0.1:9001${WORK_DIR}/dist-disk2" "http://127.0.0.1:9002${WORK_DIR}/dist-disk3" "http://127.0.0.1:9003${WORK_DIR}/dist-disk4" >"$WORK_DIR/dist-minio-9003.log" 2>&1 & "${MINIO[@]}" server --address=:9003 "http://127.0.0.1:9000${WORK_DIR}/dist-disk1" "http://127.0.0.1:9001${WORK_DIR}/dist-disk2" "http://127.0.0.1:9002${WORK_DIR}/dist-disk3" "http://127.0.0.1:9003${WORK_DIR}/dist-disk4" >"$WORK_DIR/dist-minio-9003.log" 2>&1 &
minio_pids[3]=$! minio_pids[3]=$!
sleep 30 sleep 30
echo "${minio_pids[@]}" echo "${minio_pids[@]}"
} }
function test_make_bucket()
{
bucket_name="mc-test-bucket-$RANDOM"
assert_run_mc_command mb "${SERVER_ALIAS}/${bucket_name}"
assert_run_mc_command rm "${SERVER_ALIAS}/${bucket_name}"
}
function setup()
{
assert_run_mc_command mb "${SERVER_ALIAS}/${BUCKET_NAME}"
}
function teardown()
{
assert_run_mc_command rm --force --recursive "${SERVER_ALIAS}/${BUCKET_NAME}"
}
function test_put_object()
{
object_name="mc-test-object-$RANDOM"
assert_run_mc_command cp "${FILE_1_MB}" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}"
assert_run_mc_command rm "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}"
}
function test_put_object_multipart()
{
object_name="mc-test-object-$RANDOM"
assert_run_mc_command cp "${FILE_65_MB}" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}"
assert_run_mc_command rm "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}"
}
function test_get_object()
{
object_name="mc-test-object-$RANDOM"
assert_run_mc_command cp "${FILE_1_MB}" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}"
assert_run_mc_command cp "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" "${object_name}.downloaded"
assert_run_mc_command rm "${object_name}.downloaded" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}"
}
function test_get_object_multipart()
{
object_name="mc-test-object-$RANDOM"
assert_run_mc_command cp "${FILE_65_MB}" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}"
assert_run_mc_command cp "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}" "${object_name}.downloaded"
assert_run_mc_command rm "${object_name}.downloaded" "${SERVER_ALIAS}/${BUCKET_NAME}/${object_name}"
}
function run_test()
{
test_make_bucket
setup
test_put_object
test_put_object_multipart
test_get_object
test_get_object_multipart
teardown
}
function run_test_fs() function run_test_fs()
{ {
minio_pid="$(start_minio_fs)" minio_pid="$(start_minio_fs)"
( run_test ) (cd "$WORK_DIR" && "$FUNCTIONAL_TESTS")
rv=$? rv=$?
kill "$minio_pid" kill "$minio_pid"
@ -179,7 +97,7 @@ function run_test_xl()
{ {
minio_pid="$(start_minio_xl)" minio_pid="$(start_minio_xl)"
( run_test ) (cd "$WORK_DIR" && "$FUNCTIONAL_TESTS")
rv=$? rv=$?
kill "$minio_pid" kill "$minio_pid"
@ -197,7 +115,7 @@ function run_test_dist()
{ {
minio_pids=( $(start_minio_dist) ) minio_pids=( $(start_minio_dist) )
( run_test ) (cd "$WORK_DIR" && "$FUNCTIONAL_TESTS")
rv=$? rv=$?
for pid in "${minio_pids[@]}"; do for pid in "${minio_pids[@]}"; do
@ -221,44 +139,51 @@ function run_test_dist()
return "$rv" return "$rv"
} }
function main() function __init__()
{ {
mkdir "$WORK_DIR" echo "Initializing environment"
mkdir "$MINIO_CONFIG_DIR" mkdir -p "$WORK_DIR"
mkdir "$MC_CONFIG_DIR" mkdir -p "$MINIO_CONFIG_DIR"
mkdir -p "$MINT_DATA_DIR"
if ! base64 /dev/urandom | head -c 1048576 >"$FILE_1_MB"; then if ! wget -q -O "$WORK_DIR/mc" https://dl.minio.io/client/mc/release/linux-amd64/mc; then
echo "unable to create 1 MiB file" echo "failed to download https://dl.minio.io/client/mc/release/linux-amd64/mc"
exit 1 exit 1
fi fi
if ! base64 /dev/urandom | head -c 68157440 >"$FILE_65_MB"; then chmod a+x "$WORK_DIR/mc"
echo "unable to create 65 MiB file"
exit 1 base64 /dev/urandom | head -c 1048576 >"$FILE_1_MB"
fi base64 /dev/urandom | head -c 68157440 >"$FILE_65_MB"
create_minio_config ## version is purposefully set to '3' for minio to migrate configuration file
echo '{"version": "3", "credential": {"accessKey": "minio", "secretKey": "minio123"}, "region": "us-east-1"}' > "$MINIO_CONFIG_DIR/config.json"
echo "downloading mc" if ! wget -q -O "$FUNCTIONAL_TESTS" https://raw.githubusercontent.com/minio/mc/master/functional-tests.sh; then
assert_download_mc echo "failed to download https://raw.githubusercontent.com/minio/mc/master/functional-tests.sh"
exit 1
fi
cd "$WORK_DIR" chmod a+x "$FUNCTIONAL_TESTS"
}
echo "running test in FS setup" function main()
{
echo "Testing in FS setup"
if ! run_test_fs; then if ! run_test_fs; then
echo "running test for FS setup failed" echo "running test for FS setup failed"
rm -fr "$WORK_DIR" rm -fr "$WORK_DIR"
exit 1 exit 1
fi fi
echo "running test in XL setup" echo "Testing in XL setup"
if ! run_test_xl; then if ! run_test_xl; then
echo "running test for XL setup" echo "running test for XL setup"
rm -fr "$WORK_DIR" rm -fr "$WORK_DIR"
exit 1 exit 1
fi fi
echo "running test in Distribute XL setup" echo "Testing in Distribute XL setup"
if ! run_test_dist; then if ! run_test_dist; then
echo "running test for Distribute setup" echo "running test for Distribute setup"
rm -fr "$WORK_DIR" rm -fr "$WORK_DIR"
@ -268,5 +193,7 @@ function main()
rm -fr "$WORK_DIR" rm -fr "$WORK_DIR"
} }
set -e ( __init__ "$@" && main "$@" )
main "$@" rv=$?
rm -fr "$WORK_DIR"
exit "$rv"

Loading…
Cancel
Save