Skip to content
Snippets Groups Projects

Added the tests

2 files
+ 29
22
Compare changes
  • Side-by-side
  • Inline

Files

#!/bin/bash
DOCKER_OPTS="--log-level ERROR"
S3CMD_OPTS="--config=/app/.s3cfg"
S3_BUCKET="dbrepo"
export S3_ACCESS_KEY_ID="seaweedfsadmin"
export S3_BUCKET="dbrepo"
export S3_SECRET_ACCESS_KEY="seaweedfsadmin"
export STORAGE_ENDPOINT="localhost:9000"
function clean () {
echo "[debug] Shutting down environment ..."
echo "[DEBUG] Shutting down environment ..."
docker $DOCKER_OPTS compose down
docker $DOCKER_OPTS rm $(docker volume ls -q) || true
echo "[debug] Starting new environment ..."
echo "[DEBUG] Starting new environment ..."
docker $DOCKER_OPTS compose up -d dbrepo-storage-service-init
echo "[DEBUG] Waiting 10s ..."
sleep 10
}
# BeforeAll
cat << EOF > /app/.s3cfg
access_key = seaweedfsadmin
secret_key = seaweedfsadmin
# Setup endpoint
host_base = localhost:9000
host_bucket = localhost:9000
use_https = False
# Enable S3 v4 signature APIs
signature_v2 = False
EOF
clean
sleep 15
# Test
echo "[DEBUG] run test find_bucket_succeeds"
if s3cmd $S3CMD_OPTS ls s3:// | grep -q "s3://${S3_BUCKET}"; then
echo "[DEBUG] run test init_succeeds"
bash ./dbrepo-storage-service/init/init.sh
if ! s3cmd $S3CMD_OPTS ls s3:// | grep -q "s3://${S3_BUCKET}"; then
echo "[ERROR] Failed to find bucket s3://${S3_BUCKET}" > /dev/stderr
exit 1
fi
# Test
echo "[DEBUG] run test init_idempotent_succeeds"
bash ./dbrepo-storage-service/init/init.sh
if ! s3cmd $S3CMD_OPTS ls s3:// | grep -q "s3://${S3_BUCKET}"; then
echo "[ERROR] Failed to find bucket s3://${S3_BUCKET}" > /dev/stderr
exit 1
fi
# Test
echo "[DEBUG] run test find_expiry_config_enabled_succeeds"
XPATH="//Rule/Status/text()"
XPATH="string(//Rule/Status/text())"
RES=$(s3cmd $S3CMD_OPTS getlifecycle s3://${S3_BUCKET} | xmllint --xpath $XPATH -)
if [[ $RES != "Enabled" ]]; then
echo "[ERROR] Failed to find xpath $XPATH for bucket s3://${S3_BUCKET}" > /dev/stderr
@@ -43,7 +47,7 @@ fi
# Test
echo "[DEBUG] run test find_expiry_config_prefix_succeeds"
XPATH="//Rule/Prefix/text()"
XPATH="string(//Rule/Prefix/text())"
RES=$(s3cmd $S3CMD_OPTS getlifecycle s3://${S3_BUCKET} | xmllint --xpath $XPATH -)
if [[ $RES != "" ]]; then
echo "[ERROR] Failed to find xpath $XPATH for bucket s3://${S3_BUCKET}" > /dev/stderr
@@ -51,10 +55,13 @@ if [[ $RES != "" ]]; then
fi
# Test
echo "[DEBUG] run test find_expiry_config_prefix_succeeds"
XPATH="//Rule/Expiration/Days/text()"
echo "[DEBUG] run test find_expiry_config_expiration_days_succeeds"
XPATH="number(//Rule/Expiration/Days/text())"
RES=$(s3cmd $S3CMD_OPTS getlifecycle s3://${S3_BUCKET} | xmllint --xpath $XPATH -)
if [[ $RES -ne 1 ]]; then
echo "[ERROR] Failed to find xpath $XPATH for bucket s3://${S3_BUCKET}" > /dev/stderr
exit 1
fi
\ No newline at end of file
fi
echo "[INFO] Finished successfully"
exit 0
Loading