test: Add 2, update 4 and remove 1 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 54s
Build-Test-Publish / build (linux/arm64) (push) Successful in 1m15s
Build-Test-Publish / create-manifest (push) Successful in 12s

This commit is contained in:
Your Name
2025-09-02 17:53:06 +12:00
parent 4857754618
commit 96ed3e0553
7 changed files with 466 additions and 7463 deletions

View File

@@ -10,6 +10,26 @@ HOSTURL="${1:-http://127.0.0.1:7703}"
SCRIPT_DIR=$(dirname "$0")
SCRIPT_NAME=$(basename "$0")
# Download dshash utility if not already present
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 || die "Failed to download dshash"
chmod +x "$DSHASH"
echo "dshash downloaded successfully"
# FUNCTIONS
function title() {
echo "----------------------------------------"
@@ -146,9 +166,9 @@ function test3() {
#------------------------------------------------------------------------------------------------
title "3: Check MD5Sum matches, for both label:tag and hash downloads"
# get md5sum of this file
MD5SUM=$(md5sum "${TEST_FILE}" | awk '{print $1}')
echo "md5sum of ${TEST_FILE} is ${MD5SUM}"
# get SHA256 hash of this file
HASH_SUM=$("$DSHASH" "${TEST_FILE}")
echo "SHA256 hash of ${TEST_FILE} is ${HASH_SUM}"
# download the object
DOWNLOAD_FILE="${TEST_FILE}.downloaded"
@@ -163,12 +183,12 @@ title "3: Check MD5Sum matches, for both label:tag and hash downloads"
die "failed to download ${BASE_TAG}:test1"
fi
# get md5sum of the downloaded file
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 "${DOWNLOAD_FILE}2" | awk '{print $1}')
[ "${MD5SUM}" != "${MD5SUM_DOWNLOADED2}" ] && die "md5sums do not match"
# get SHA256 hash of the downloaded file
HASH_SUM_DOWNLOADED1=$("$DSHASH" "${DOWNLOAD_FILE}1")
echo "SHA256 hash of ${DOWNLOAD_FILE}1 is ${HASH_SUM_DOWNLOADED1}"
[ "${HASH_SUM}" != "${HASH_SUM_DOWNLOADED1}" ] && die "SHA256 hashes do not match"
HASH_SUM_DOWNLOADED2=$("$DSHASH" "${DOWNLOAD_FILE}2")
[ "${HASH_SUM}" != "${HASH_SUM_DOWNLOADED2}" ] && die "SHA256 hashes do not match"
rm "${DOWNLOAD_FILE}1"
rm "${DOWNLOAD_FILE}2"
@@ -223,10 +243,10 @@ EOF
die "failed to download ${LABELTAG}"
fi
# get md5sum of the downloaded file
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"
# get SHA256 hash of the downloaded file
HASH_SUM_DOWNLOADED3=$("$DSHASH" "${DOWNLOAD_FILE}3")
echo "SHA256 hash of ${DOWNLOAD_FILE}3 is ${HASH_SUM_DOWNLOADED3}"
[ "${HASH_SUM}" != "${HASH_SUM_DOWNLOADED3}" ] && die "SHA256 hashes do not match"
rm "${DOWNLOAD_FILE}3"
}
@@ -344,10 +364,10 @@ EOF
if ! curl -s --fail-with-body "${HOSTURL}/${BASE_TAG}" -o "${DOWNLOAD_FILE}4"; then
die "failed to download ${BASE_TAG}"
fi
# get md5sum of the downloaded file
MD5SUM_DOWNLOADED4=$(md5sum "${DOWNLOAD_FILE}4" | awk '{print $1}')
MD5SUM_ORIGINAL=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}" | awk '{print $1}')
[ "${MD5SUM_ORIGINAL}" != "${MD5SUM_DOWNLOADED4}" ] && die "md5sums do not match"
# get SHA256 hash of the downloaded file
HASH_SUM_DOWNLOADED4=$("$DSHASH" "${DOWNLOAD_FILE}4")
HASH_SUM_ORIGINAL=$("$DSHASH" "${SCRIPT_DIR}/${SCRIPT_NAME}")
[ "${HASH_SUM_ORIGINAL}" != "${HASH_SUM_DOWNLOADED4}" ] && die "SHA256 hashes do not match"
# Store first version's metadata before uploading second version
FIRST_METADATA=$(curl -s "${HOSTURL}/meta/${FIRST_HASH}")

View File

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

View File

@@ -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=1024
# 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"