This commit is contained in:
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"write_tokens": [
|
|
||||||
"fizzle1",
|
|
||||||
"fizzle2",
|
|
||||||
"fizzle3"
|
|
||||||
],
|
|
||||||
"port": 8123,
|
|
||||||
"object_store_path": "/tmp/temp-test-path",
|
|
||||||
"rate_limiting": {
|
|
||||||
"auth_rate_limit": 5,
|
|
||||||
"auth_window_seconds": 2
|
|
||||||
}
|
|
||||||
}
|
|
@@ -3,14 +3,14 @@ services:
|
|||||||
image: gitea.jde.nz/public/simple-object-storage:test
|
image: gitea.jde.nz/public/simple-object-storage:test
|
||||||
container_name: sos-test
|
container_name: sos-test
|
||||||
ports:
|
ports:
|
||||||
- 7703:80
|
- 7703:7703
|
||||||
volumes:
|
volumes:
|
||||||
- ${LOCALCONFIG}:/data/sos_config.json:ro
|
- ${LOCALCONFIG}:/data/sos_config.json:ro
|
||||||
environment:
|
environment:
|
||||||
- SOS_CONFIG=/data/sos_config.json
|
- SOS_CONFIG=/data/sos_config.json
|
||||||
restart: no
|
restart: no
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "wget", "-qO-", "http://0.0.0.0/status"]
|
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:7703/status"]
|
||||||
interval: 1s
|
interval: 1s
|
||||||
timeout: 1s
|
timeout: 1s
|
||||||
retries: 3
|
retries: 3
|
@@ -7,5 +7,6 @@
|
|||||||
"rate_limiting": {
|
"rate_limiting": {
|
||||||
"auth_rate_limit": 5,
|
"auth_rate_limit": 5,
|
||||||
"auth_window_seconds": 2
|
"auth_window_seconds": 2
|
||||||
}
|
},
|
||||||
|
"port": 7703
|
||||||
}
|
}
|
@@ -1,7 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
set -x
|
||||||
|
|
||||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
MAIN_DIR=$(cd "${SCRIPT_DIR}/.." && pwd)
|
||||||
|
|
||||||
# FUNCTIONS
|
# FUNCTIONS
|
||||||
function title() {
|
function title() {
|
||||||
@@ -46,34 +48,21 @@ function wait_for_container {
|
|||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
# build the executable
|
# build the executable
|
||||||
title "Building amd64 executable"
|
title "Building amd64 executable"
|
||||||
"${SCRIPT_DIR}/build.sh" amd64
|
"${MAIN_DIR}/build.sh" amd64
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
# build the docker image
|
# build the docker image
|
||||||
title "Building docker image"
|
title "Building docker image"
|
||||||
docker buildx build --no-cache --load -t gitea.jde.nz/public/simple-object-storage:test --platform linux/amd64 "${SCRIPT_DIR}"
|
docker buildx build --no-cache --load -t gitea.jde.nz/public/simple-object-storage:test --platform linux/amd64 "${MAIN_DIR}"
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
# run the docker container
|
# run the docker container
|
||||||
title "Running docker container"
|
title "Running docker container"
|
||||||
export LOCALCONFIG="${SCRIPT_DIR}/.test-docker/config.json"
|
export LOCALCONFIG="${SCRIPT_DIR}/config.json"
|
||||||
ls -l "$LOCALCONFIG"
|
export COMPOSE_FILE="${SCRIPT_DIR}/compose.yaml"
|
||||||
|
|
||||||
if [ ! -f "${LOCALCONFIG}" ]; then
|
[ -f "${LOCALCONFIG}" ] || die "Config file not found: ${LOCALCONFIG}"
|
||||||
echo "PWD = $(pwd)"
|
[ -f "${COMPOSE_FILE}" ] || die "Compose file not found: ${COMPOSE_FILE}"
|
||||||
echo "SCRIPT_DIR = ${SCRIPT_DIR}"
|
|
||||||
ls -la "${SCRIPT_DIR}"
|
|
||||||
ls -la "${SCRIPT_DIR}/.test-docker"
|
|
||||||
echo "Config file not found: ${LOCALCONFIG}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
COMPOSE_FILE="${SCRIPT_DIR}/.test-docker/compose.yaml"
|
|
||||||
|
|
||||||
if [ ! -f "${COMPOSE_FILE}" ]; then
|
|
||||||
echo "Compose file not found: ${COMPOSE_FILE}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
title "Running tests"
|
title "Running tests"
|
||||||
@@ -82,11 +71,7 @@ title "Running tests"
|
|||||||
docker compose -f "${COMPOSE_FILE}" down
|
docker compose -f "${COMPOSE_FILE}" down
|
||||||
docker compose -f "${COMPOSE_FILE}" rm -v
|
docker compose -f "${COMPOSE_FILE}" rm -v
|
||||||
|
|
||||||
# run the container.
|
LOCALCONFIG=${LOCALCONFIG} docker compose -f "${COMPOSE_FILE}" up -d
|
||||||
docker compose -f "${COMPOSE_FILE}" up -d
|
|
||||||
|
|
||||||
# wait a bit.
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
# wait until healthy.
|
# wait until healthy.
|
||||||
if ! wait_for_container "sos-test"; then
|
if ! wait_for_container "sos-test"; then
|
@@ -3,7 +3,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
||||||
HOSTURL="${1:-http://localhost:8123}"
|
HOSTURL="${1:-http://127.0.0.1:7703}"
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
@@ -54,7 +54,7 @@ if ! command -v jq &> /dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# read ~/.config/simple_object_storage/config.json
|
# read ~/.config/simple_object_storage/config.json
|
||||||
CONFIG_PATH="${SCRIPT_DIR}/.test-docker/config.json"
|
CONFIG_PATH="${SCRIPT_DIR}/config.json"
|
||||||
if [ ! -f "${CONFIG_PATH}" ]; then
|
if [ ! -f "${CONFIG_PATH}" ]; then
|
||||||
echo "config file not found at ${CONFIG_PATH}"
|
echo "config file not found at ${CONFIG_PATH}"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -91,11 +91,13 @@ EOF
|
|||||||
# Test 1: Verify extra metadata fields are preserved
|
# Test 1: Verify extra metadata fields are preserved
|
||||||
title "1: Upload script to ${BASE_TAG}:test1"
|
title "1: Upload script to ${BASE_TAG}:test1"
|
||||||
|
|
||||||
|
TEST_FILE="${SCRIPT_DIR}/${SCRIPT_NAME}"
|
||||||
|
|
||||||
# upload this script as an object
|
# upload this script as an object
|
||||||
echo "uploading ${SCRIPT_DIR}/${SCRIPT_NAME} to ${BASE_TAG}:test1"
|
echo "uploading ${TEST_FILE} to ${BASE_TAG}:test1"
|
||||||
UPLOAD_RESPONSE=$(curl -X PUT \
|
UPLOAD_RESPONSE=$(curl -X PUT \
|
||||||
-H "Authorization: Bearer ${WRITE_TOKEN}" \
|
-H "Authorization: Bearer ${WRITE_TOKEN}" \
|
||||||
-F "file=@${SCRIPT_DIR}/${SCRIPT_NAME}" \
|
-F "file=@${TEST_FILE}" \
|
||||||
-F "metadata=${METADATA_JSON}" \
|
-F "metadata=${METADATA_JSON}" \
|
||||||
"${HOSTURL}/upload")
|
"${HOSTURL}/upload")
|
||||||
|
|
||||||
@@ -117,30 +119,31 @@ CHECK_HASH=$(curl -s "${CMD}" | jq -r '.hash')
|
|||||||
title "3: Check MD5Sum matches, for both label:tag and hash downloads"
|
title "3: Check MD5Sum matches, for both label:tag and hash downloads"
|
||||||
|
|
||||||
# get md5sum of this file
|
# get md5sum of this file
|
||||||
MD5SUM=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}" | awk '{print $1}')
|
MD5SUM=$(md5sum "${TEST_FILE}" | awk '{print $1}')
|
||||||
echo "md5sum of ${SCRIPT_DIR}/${SCRIPT_NAME} is ${MD5SUM}"
|
echo "md5sum of ${TEST_FILE} is ${MD5SUM}"
|
||||||
|
|
||||||
# download the object
|
# download the object
|
||||||
echo "downloading ${OBJECT_HASH} to ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1"
|
DOWNLOAD_FILE="_${TEST_FILE}.downloaded"
|
||||||
if ! curl -s "${HOSTURL}/${OBJECT_HASH}" -o "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1"; then
|
echo "downloading ${OBJECT_HASH} to ${DOWNLOAD_FILE}1"
|
||||||
die "failed to download ${OBJECT_HASH}"
|
if ! curl -s "${HOSTURL}/${OBJECT_HASH}" -o "${DOWNLOAD_FILE}1"; then
|
||||||
|
die "failed to download ${HOSTURL}/${OBJECT_HASH} to ${DOWNLOAD_FILE}1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# download the object again via the label:tag
|
# download the object again via the label:tag
|
||||||
echo "downloading ${BASE_TAG}:test1 to ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2"
|
echo "downloading ${BASE_TAG}:test1 to ${DOWNLOAD_FILE}2"
|
||||||
if ! curl -s "${HOSTURL}/${BASE_TAG}:test1" -o "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2"; then
|
if ! curl -s "${HOSTURL}/${BASE_TAG}:test1" -o "${DOWNLOAD_FILE}2"; then
|
||||||
die "failed to download ${BASE_TAG}:test1"
|
die "failed to download ${BASE_TAG}:test1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# get md5sum of the downloaded file
|
# get md5sum of the downloaded file
|
||||||
MD5SUM_DOWNLOADED1=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1" | awk '{print $1}')
|
MD5SUM_DOWNLOADED1=$(md5sum "${DOWNLOAD_FILE}1" | awk '{print $1}')
|
||||||
echo "md5sum of ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1 is ${MD5SUM_DOWNLOADED1}"
|
echo "md5sum of ${DOWNLOAD_FILE}1 is ${MD5SUM_DOWNLOADED1}"
|
||||||
[ "${MD5SUM}" != "${MD5SUM_DOWNLOADED1}" ] && die "md5sums do not match"
|
[ "${MD5SUM}" != "${MD5SUM_DOWNLOADED1}" ] && die "md5sums do not match"
|
||||||
MD5SUM_DOWNLOADED2=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2" | awk '{print $1}')
|
MD5SUM_DOWNLOADED2=$(md5sum "${DOWNLOAD_FILE}2" | awk '{print $1}')
|
||||||
[ "${MD5SUM}" != "${MD5SUM_DOWNLOADED2}" ] && die "md5sums do not match"
|
[ "${MD5SUM}" != "${MD5SUM_DOWNLOADED2}" ] && die "md5sums do not match"
|
||||||
|
|
||||||
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1"
|
rm "${DOWNLOAD_FILE}1"
|
||||||
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2"
|
rm "${DOWNLOAD_FILE}2"
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
LABELTAG="finangle-wrangler:fuzzy_test"
|
LABELTAG="finangle-wrangler:fuzzy_test"
|
||||||
@@ -156,10 +159,10 @@ METADATA_JSON=$(cat <<EOF
|
|||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
# upload this script as an object
|
# upload this script as an object
|
||||||
echo "uploading ${SCRIPT_DIR}/${SCRIPT_NAME} to ${LABELTAG}"
|
echo "uploading ${TEST_FILE} to ${LABELTAG}"
|
||||||
UPLOAD_RESPONSE=$(curl -X PUT \
|
UPLOAD_RESPONSE=$(curl -X PUT \
|
||||||
-H "Authorization: Bearer ${WRITE_TOKEN}" \
|
-H "Authorization: Bearer ${WRITE_TOKEN}" \
|
||||||
-F "file=@${SCRIPT_DIR}/${SCRIPT_NAME}" \
|
-F "file=@${TEST_FILE}" \
|
||||||
-F "metadata=${METADATA_JSON}" \
|
-F "metadata=${METADATA_JSON}" \
|
||||||
"${HOSTURL}/upload")
|
"${HOSTURL}/upload")
|
||||||
|
|
||||||
@@ -185,17 +188,17 @@ if ! echo "${METADATA_RESPONSE}" | jq -r '.metadata.custom_field' | grep -q "Upl
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# download via the label:tag
|
# download via the label:tag
|
||||||
echo "downloading ${LABELTAG} to ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3"
|
echo "downloading ${LABELTAG} to ${DOWNLOAD_FILE}3"
|
||||||
if ! curl -s "${HOSTURL}/${LABELTAG}" -o "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3"; then
|
if ! curl -s "${HOSTURL}/${LABELTAG}" -o "${DOWNLOAD_FILE}3"; then
|
||||||
die "failed to download ${LABELTAG}"
|
die "failed to download ${LABELTAG}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# get md5sum of the downloaded file
|
# get md5sum of the downloaded file
|
||||||
MD5SUM_DOWNLOADED3=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3" | awk '{print $1}')
|
MD5SUM_DOWNLOADED3=$(md5sum "${DOWNLOAD_FILE}3" | awk '{print $1}')
|
||||||
echo "md5sum of ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3 is ${MD5SUM_DOWNLOADED3}"
|
echo "md5sum of ${DOWNLOAD_FILE}3 is ${MD5SUM_DOWNLOADED3}"
|
||||||
[ "${MD5SUM}" != "${MD5SUM_DOWNLOADED3}" ] && die "md5sums do not match"
|
[ "${MD5SUM}" != "${MD5SUM_DOWNLOADED3}" ] && die "md5sums do not match"
|
||||||
|
|
||||||
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3"
|
rm "${DOWNLOAD_FILE}3"
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user