From 66048b34435706d717059ad1f4bb2e4dcbe4be02 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 30 May 2025 21:35:19 +1200 Subject: [PATCH] :-'Generic Commit' --- testing/test_1GB_file_upload.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/testing/test_1GB_file_upload.sh b/testing/test_1GB_file_upload.sh index 04acda4..4899272 100755 --- a/testing/test_1GB_file_upload.sh +++ b/testing/test_1GB_file_upload.sh @@ -1,5 +1,15 @@ #!/bin/bash + +# read ~/.config/simple_object_storage/config.json +CONFIG_PATH="./config.json" +if [ ! -f "${CONFIG_PATH}" ]; then + echo "config file not found at ${CONFIG_PATH}" + exit 1 +fi +CONFIG=$(cat "${CONFIG_PATH}") + + # Create a temporary test file (1024MB!) echo "Creating test file..." dd if=/dev/urandom of=test_file.bin bs=1M count=1024 @@ -9,20 +19,14 @@ echo "Calculating original file hash..." ORIGINAL_HASH=$(sha256sum test_file.bin | cut -d' ' -f1) echo "Original hash: $ORIGINAL_HASH" -# read ~/.config/simple_object_storage/config.json -CONFIG_PATH="${HOME}/.config/simple_object_storage/config.json" -if [ ! -f "${CONFIG_PATH}" ]; then - echo "config file not found at ${CONFIG_PATH}" - exit 1 -fi -CONFIG=$(cat "${CONFIG_PATH}") + # get the host and port from the config -HOST=$(echo $CONFIG | jq -r '.host') -PORT=$(echo $CONFIG | jq -r '.port') +HOST=$(echo "$CONFIG" | jq -r '.host') +PORT=$(echo "$CONFIG" | jq -r '.port') # extract the first write token from the config -WRITE_TOKEN=$(echo $CONFIG | jq -r '.write_tokens[0]') +WRITE_TOKEN=$(echo "$CONFIG" | jq -r '.write_tokens[0]') # Upload the file echo "Uploading file..." @@ -34,7 +38,7 @@ RESPONSE=$(curl -X PUT \ echo "Upload response: $RESPONSE" # Extract the hash from the response -HASH=$(echo $RESPONSE | jq -r '.hash') +HASH=$(echo "$RESPONSE" | jq -r '.hash') echo "Hash: $HASH" # Check if the file exists by hash