Update test.sh
This commit is contained in:
35
test.sh
35
test.sh
@@ -119,12 +119,34 @@ EOF
|
||||
function start_test_server() {
|
||||
log_info "Starting SOS test server on port ${TEST_PORT}..."
|
||||
|
||||
# Ensure the config file exists and is readable
|
||||
if [ ! -f "${TEST_DIR}/sos_config.json" ]; then
|
||||
die "Config file ${TEST_DIR}/sos_config.json does not exist"
|
||||
fi
|
||||
|
||||
# Use absolute path for volume mount to avoid issues in CI
|
||||
# Use realpath if available, otherwise fallback to readlink or pwd
|
||||
if command -v realpath &> /dev/null; then
|
||||
local config_path=$(realpath "${TEST_DIR}/sos_config.json")
|
||||
local storage_path=$(realpath "${TEST_DIR}/storage")
|
||||
elif command -v readlink &> /dev/null; then
|
||||
local config_path=$(readlink -f "${TEST_DIR}/sos_config.json")
|
||||
local storage_path=$(readlink -f "${TEST_DIR}/storage")
|
||||
else
|
||||
# Fallback to constructing absolute path manually
|
||||
local config_path="$(cd "${TEST_DIR}" && pwd)/sos_config.json"
|
||||
local storage_path="$(cd "${TEST_DIR}" && pwd)/storage"
|
||||
fi
|
||||
|
||||
log_info "Using config path: ${config_path}"
|
||||
log_info "Using storage path: ${storage_path}"
|
||||
|
||||
# Start the container (server runs on port 80 inside container)
|
||||
local container_id=$(docker run -d \
|
||||
--name "${CONTAINER_NAME}" \
|
||||
-p "${TEST_PORT}:80" \
|
||||
-v "${TEST_DIR}/sos_config.json:/data/sos_config.json:ro" \
|
||||
-v "${TEST_DIR}/storage:/data/storage" \
|
||||
-v "${config_path}:/data/sos_config.json:ro" \
|
||||
-v "${storage_path}:/data/storage" \
|
||||
gitea.jde.nz/public/simple-object-server 2>&1)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -141,6 +163,15 @@ function start_test_server() {
|
||||
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
log_error "Container stopped unexpectedly. Logs:"
|
||||
docker logs "${CONTAINER_NAME}" 2>&1
|
||||
|
||||
# Additional debugging for CI environment
|
||||
log_error "Debug: Checking mounted paths in container:"
|
||||
docker run --rm -v "${config_path}:/data/sos_config.json:ro" alpine ls -la /data/ 2>&1 || true
|
||||
log_error "Debug: Config file on host:"
|
||||
ls -la "${config_path}" 2>&1 || true
|
||||
log_error "Debug: Config file contents:"
|
||||
cat "${config_path}" 2>&1 || true
|
||||
|
||||
die "Container failed to stay running"
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user