:-'Generic Commit'
Some checks failed
Build-Test-Publish / Build (push) Failing after 3s

This commit is contained in:
Your Name
2025-05-30 21:21:03 +12:00
parent 8bd04aa95f
commit 0bdb3ac066
6 changed files with 39 additions and 63 deletions

View File

@@ -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
}
}

View File

@@ -3,14 +3,14 @@ services:
image: gitea.jde.nz/public/simple-object-storage:test
container_name: sos-test
ports:
- 7703:80
- 7703:7703
volumes:
- ${LOCALCONFIG}:/data/sos_config.json:ro
environment:
- SOS_CONFIG=/data/sos_config.json
restart: no
healthcheck:
test: ["CMD", "wget", "-qO-", "http://0.0.0.0/status"]
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:7703/status"]
interval: 1s
timeout: 1s
retries: 3

View File

@@ -7,5 +7,6 @@
"rate_limiting": {
"auth_rate_limit": 5,
"auth_window_seconds": 2
}
},
"port": 7703
}

View File

@@ -1,7 +1,9 @@
#!/bin/bash
set -euo pipefail
set -x
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
MAIN_DIR=$(cd "${SCRIPT_DIR}/.." && pwd)
# FUNCTIONS
function title() {
@@ -46,34 +48,21 @@ function wait_for_container {
#------------------------------------------------------------------------------------------------
# build the executable
title "Building amd64 executable"
"${SCRIPT_DIR}/build.sh" amd64
"${MAIN_DIR}/build.sh" amd64
#------------------------------------------------------------------------------------------------
# build the 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
title "Running docker container"
export LOCALCONFIG="${SCRIPT_DIR}/.test-docker/config.json"
ls -l "$LOCALCONFIG"
export LOCALCONFIG="${SCRIPT_DIR}/config.json"
export COMPOSE_FILE="${SCRIPT_DIR}/compose.yaml"
if [ ! -f "${LOCALCONFIG}" ]; then
echo "PWD = $(pwd)"
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
[ -f "${LOCALCONFIG}" ] || die "Config file not found: ${LOCALCONFIG}"
[ -f "${COMPOSE_FILE}" ] || die "Compose file not found: ${COMPOSE_FILE}"
#------------------------------------------------------------------------------------------------
title "Running tests"
@@ -82,11 +71,7 @@ title "Running tests"
docker compose -f "${COMPOSE_FILE}" down
docker compose -f "${COMPOSE_FILE}" rm -v
# run the container.
docker compose -f "${COMPOSE_FILE}" up -d
# wait a bit.
sleep 1
LOCALCONFIG=${LOCALCONFIG} docker compose -f "${COMPOSE_FILE}" up -d
# wait until healthy.
if ! wait_for_container "sos-test"; then

View File

@@ -3,7 +3,7 @@
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
# 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
echo "config file not found at ${CONFIG_PATH}"
exit 1
@@ -91,11 +91,13 @@ EOF
# Test 1: Verify extra metadata fields are preserved
title "1: Upload script to ${BASE_TAG}:test1"
TEST_FILE="${SCRIPT_DIR}/${SCRIPT_NAME}"
# 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 \
-H "Authorization: Bearer ${WRITE_TOKEN}" \
-F "file=@${SCRIPT_DIR}/${SCRIPT_NAME}" \
-F "file=@${TEST_FILE}" \
-F "metadata=${METADATA_JSON}" \
"${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"
# get md5sum of this file
MD5SUM=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}" | awk '{print $1}')
echo "md5sum of ${SCRIPT_DIR}/${SCRIPT_NAME} is ${MD5SUM}"
MD5SUM=$(md5sum "${TEST_FILE}" | awk '{print $1}')
echo "md5sum of ${TEST_FILE} is ${MD5SUM}"
# download the object
echo "downloading ${OBJECT_HASH} to ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1"
if ! curl -s "${HOSTURL}/${OBJECT_HASH}" -o "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1"; then
die "failed to download ${OBJECT_HASH}"
DOWNLOAD_FILE="_${TEST_FILE}.downloaded"
echo "downloading ${OBJECT_HASH} to ${DOWNLOAD_FILE}1"
if ! curl -s "${HOSTURL}/${OBJECT_HASH}" -o "${DOWNLOAD_FILE}1"; then
die "failed to download ${HOSTURL}/${OBJECT_HASH} to ${DOWNLOAD_FILE}1"
fi
# download the object again via the label:tag
echo "downloading ${BASE_TAG}:test1 to ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2"
if ! curl -s "${HOSTURL}/${BASE_TAG}:test1" -o "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2"; then
echo "downloading ${BASE_TAG}:test1 to ${DOWNLOAD_FILE}2"
if ! curl -s "${HOSTURL}/${BASE_TAG}:test1" -o "${DOWNLOAD_FILE}2"; then
die "failed to download ${BASE_TAG}:test1"
fi
# get md5sum of the downloaded file
MD5SUM_DOWNLOADED1=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1" | awk '{print $1}')
echo "md5sum of ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1 is ${MD5SUM_DOWNLOADED1}"
MD5SUM_DOWNLOADED1=$(md5sum "${DOWNLOAD_FILE}1" | awk '{print $1}')
echo "md5sum of ${DOWNLOAD_FILE}1 is ${MD5SUM_DOWNLOADED1}"
[ "${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"
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded1"
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded2"
rm "${DOWNLOAD_FILE}1"
rm "${DOWNLOAD_FILE}2"
#------------------------------------------------------------------------------------------------
LABELTAG="finangle-wrangler:fuzzy_test"
@@ -156,10 +159,10 @@ METADATA_JSON=$(cat <<EOF
EOF
)
# 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 \
-H "Authorization: Bearer ${WRITE_TOKEN}" \
-F "file=@${SCRIPT_DIR}/${SCRIPT_NAME}" \
-F "file=@${TEST_FILE}" \
-F "metadata=${METADATA_JSON}" \
"${HOSTURL}/upload")
@@ -185,17 +188,17 @@ if ! echo "${METADATA_RESPONSE}" | jq -r '.metadata.custom_field' | grep -q "Upl
fi
# download via the label:tag
echo "downloading ${LABELTAG} to ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3"
if ! curl -s "${HOSTURL}/${LABELTAG}" -o "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3"; then
echo "downloading ${LABELTAG} to ${DOWNLOAD_FILE}3"
if ! curl -s "${HOSTURL}/${LABELTAG}" -o "${DOWNLOAD_FILE}3"; then
die "failed to download ${LABELTAG}"
fi
# get md5sum of the downloaded file
MD5SUM_DOWNLOADED3=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3" | awk '{print $1}')
echo "md5sum of ${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3 is ${MD5SUM_DOWNLOADED3}"
MD5SUM_DOWNLOADED3=$(md5sum "${DOWNLOAD_FILE}3" | awk '{print $1}')
echo "md5sum of ${DOWNLOAD_FILE}3 is ${MD5SUM_DOWNLOADED3}"
[ "${MD5SUM}" != "${MD5SUM_DOWNLOADED3}" ] && die "md5sums do not match"
rm "${SCRIPT_DIR}/${SCRIPT_NAME}.downloaded3"
rm "${DOWNLOAD_FILE}3"