test: Add 2, update 4 and remove 1 files
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Download dshash utility
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
trap "rm -rf $TEMP_DIR" EXIT
|
||||
DSHASH="$TEMP_DIR/dshash"
|
||||
|
||||
echo "Downloading dshash utility..."
|
||||
ARCH=$(uname -m)
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
ARCH="x86_64"
|
||||
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
|
||||
ARCH="aarch64"
|
||||
else
|
||||
echo "Unsupported architecture: $ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -L -o "$DSHASH" "https://getbin.xyz/dshash:latest-$ARCH" 2>/dev/null || { echo "Failed to download dshash"; exit 1; }
|
||||
chmod +x "$DSHASH"
|
||||
echo "dshash downloaded successfully"
|
||||
|
||||
# read ~/.config/simple_object_storage/sos_config.json
|
||||
CONFIG_PATH="./sos_config.json"
|
||||
if [ ! -f "${CONFIG_PATH}" ]; then
|
||||
@@ -15,7 +35,7 @@ dd if=/dev/urandom of=test_file.bin bs=1M count=100
|
||||
|
||||
# Calculate original file hash
|
||||
echo "Calculating original file hash..."
|
||||
ORIGINAL_HASH=$(sha256sum test_file.bin | cut -d' ' -f1)
|
||||
ORIGINAL_HASH=$("$DSHASH" test_file.bin)
|
||||
echo "Original hash: $ORIGINAL_HASH"
|
||||
|
||||
# get the host and port from the config
|
||||
@@ -74,8 +94,8 @@ curl -o downloaded_by_tag.bin "http://${HOST}:${PORT}/object/test:latest"
|
||||
|
||||
# Verify downloaded files
|
||||
echo "Verifying downloaded files..."
|
||||
HASH_BY_HASH=$(sha256sum downloaded_by_hash.bin | cut -d' ' -f1)
|
||||
HASH_BY_TAG=$(sha256sum downloaded_by_tag.bin | cut -d' ' -f1)
|
||||
HASH_BY_HASH=$("$DSHASH" downloaded_by_hash.bin)
|
||||
HASH_BY_TAG=$("$DSHASH" downloaded_by_tag.bin)
|
||||
|
||||
echo "Original hash: $ORIGINAL_HASH"
|
||||
echo "Hash of file downloaded by hash: $HASH_BY_HASH"
|
||||
|
Reference in New Issue
Block a user