2021-08-26 21:53:32 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-06-10 12:51:18 +00:00
|
|
|
USAGE='Usage for local run:
|
|
|
|
|
|
|
|
./docker/test/stateless/setup_minio.sh { stateful | stateless } ./tests/
|
|
|
|
|
|
|
|
'
|
2021-08-30 08:33:17 +00:00
|
|
|
|
|
|
|
set -e -x -a -u
|
2021-08-26 21:53:32 +00:00
|
|
|
|
2022-06-10 12:51:18 +00:00
|
|
|
TEST_TYPE="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
case $TEST_TYPE in
|
|
|
|
stateless) QUERY_DIR=0_stateless ;;
|
|
|
|
stateful) QUERY_DIR=1_stateful ;;
|
|
|
|
*) echo "unknown test type $TEST_TYPE"; echo "${USAGE}"; exit 1 ;;
|
|
|
|
esac
|
2022-06-03 18:47:26 +00:00
|
|
|
|
2021-08-29 19:32:37 +00:00
|
|
|
ls -lha
|
2021-08-27 14:22:04 +00:00
|
|
|
|
2021-08-30 08:33:17 +00:00
|
|
|
mkdir -p ./minio_data
|
|
|
|
|
|
|
|
if [ ! -f ./minio ]; then
|
2022-09-09 14:54:03 +00:00
|
|
|
MINIO_SERVER_VERSION=${MINIO_SERVER_VERSION:-2022-09-07T22-25-02Z}
|
|
|
|
MINIO_CLIENT_VERSION=${MINIO_CLIENT_VERSION:-2022-08-28T20-08-11Z}
|
2022-06-10 12:51:18 +00:00
|
|
|
case $(uname -m) in
|
|
|
|
x86_64) BIN_ARCH=amd64 ;;
|
|
|
|
aarch64) BIN_ARCH=arm64 ;;
|
|
|
|
*) echo "unknown architecture $(uname -m)"; exit 1 ;;
|
|
|
|
esac
|
2021-08-30 08:33:17 +00:00
|
|
|
echo 'MinIO binary not found, downloading...'
|
|
|
|
|
|
|
|
BINARY_TYPE=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
2022-06-10 16:11:45 +00:00
|
|
|
wget "https://dl.min.io/server/minio/release/${BINARY_TYPE}-${BIN_ARCH}/archive/minio.RELEASE.${MINIO_SERVER_VERSION}" -O ./minio \
|
|
|
|
&& wget "https://dl.min.io/client/mc/release/${BINARY_TYPE}-${BIN_ARCH}/archive/mc.RELEASE.${MINIO_CLIENT_VERSION}" -O ./mc \
|
2022-06-10 12:51:18 +00:00
|
|
|
&& chmod +x ./mc ./minio
|
2021-08-30 08:33:17 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
MINIO_ROOT_USER=${MINIO_ROOT_USER:-clickhouse}
|
|
|
|
MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-clickhouse}
|
|
|
|
|
2022-06-03 18:47:26 +00:00
|
|
|
./minio --version
|
2021-08-30 08:33:17 +00:00
|
|
|
./minio server --address ":11111" ./minio_data &
|
2021-08-29 19:32:37 +00:00
|
|
|
|
2022-06-03 18:47:26 +00:00
|
|
|
i=0
|
2021-08-30 10:45:46 +00:00
|
|
|
while ! curl -v --silent http://localhost:11111 2>&1 | grep AccessDenied
|
2021-08-29 19:32:37 +00:00
|
|
|
do
|
2022-06-03 18:47:26 +00:00
|
|
|
if [[ $i == 60 ]]; then
|
|
|
|
echo "Failed to setup minio"
|
|
|
|
exit 0
|
|
|
|
fi
|
2021-08-29 19:32:37 +00:00
|
|
|
echo "Trying to connect to minio"
|
|
|
|
sleep 1
|
2022-06-03 18:47:26 +00:00
|
|
|
i=$((i + 1))
|
2021-08-29 19:32:37 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
lsof -i :11111
|
|
|
|
|
2021-08-29 23:08:12 +00:00
|
|
|
sleep 5
|
|
|
|
|
2021-08-29 19:32:37 +00:00
|
|
|
./mc alias set clickminio http://localhost:11111 clickhouse clickhouse
|
|
|
|
./mc admin user add clickminio test testtest
|
|
|
|
./mc admin policy set clickminio readwrite user=test
|
|
|
|
./mc mb clickminio/test
|
2022-06-10 12:51:18 +00:00
|
|
|
if [ "$TEST_TYPE" = "stateless" ]; then
|
|
|
|
./mc policy set public clickminio/test
|
|
|
|
fi
|
2021-08-26 21:53:32 +00:00
|
|
|
|
2021-08-27 13:12:19 +00:00
|
|
|
|
|
|
|
# Upload data to Minio. By default after unpacking all tests will in
|
|
|
|
# /usr/share/clickhouse-test/queries
|
|
|
|
|
2021-08-30 08:33:17 +00:00
|
|
|
TEST_PATH=${1:-/usr/share/clickhouse-test}
|
2022-06-10 12:51:18 +00:00
|
|
|
MINIO_DATA_PATH=${TEST_PATH}/queries/${QUERY_DIR}/data_minio
|
2021-08-29 20:31:54 +00:00
|
|
|
|
2021-08-31 12:51:11 +00:00
|
|
|
# Iterating over globs will cause redudant FILE variale to be a path to a file, not a filename
|
|
|
|
# shellcheck disable=SC2045
|
|
|
|
for FILE in $(ls "${MINIO_DATA_PATH}"); do
|
|
|
|
echo "$FILE";
|
|
|
|
./mc cp "${MINIO_DATA_PATH}"/"$FILE" clickminio/test/"$FILE";
|
2021-08-29 22:21:05 +00:00
|
|
|
done
|
2022-02-15 13:12:08 +00:00
|
|
|
|
2022-02-17 07:39:33 +00:00
|
|
|
mkdir -p ~/.aws
|
2022-02-15 13:12:08 +00:00
|
|
|
cat <<EOT >> ~/.aws/credentials
|
|
|
|
[default]
|
2022-06-10 12:51:18 +00:00
|
|
|
aws_access_key_id=${MINIO_ROOT_USER}
|
|
|
|
aws_secret_access_key=${MINIO_ROOT_PASSWORD}
|
2022-02-15 13:12:08 +00:00
|
|
|
EOT
|