Skip to content

Bump dependencies #1087

Bump dependencies

Bump dependencies #1087

Workflow file for this run

name: ZFS on ZeroFS Test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
zfs-test:
name: Run ZFS on top of ZeroFS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start MinIO
run: |
docker run -d \
--name minio \
-p 9000:9000 \
-e MINIO_ROOT_USER=minioadmin \
-e MINIO_ROOT_PASSWORD=minioadmin \
minio/minio server /data
# Wait for MinIO to be ready
for i in {1..30}; do
if curl -f http://localhost:9000/minio/health/live; then
echo "MinIO is ready"
break
fi
sleep 1
done
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y nbd-client zfsutils-linux wget pigz pixz parallel
- name: Setup MinIO bucket
run: |
# Install mc (MinIO client)
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
./mc alias set myminio http://localhost:9000 minioadmin minioadmin
./mc mb myminio/zerofs-zfs-test || true
- name: Build ZeroFS
working-directory: zerofs
run: cargo build --profile ci
- name: Start ZeroFS
working-directory: zerofs
run: |
# Create cache directory
mkdir -p /tmp/zerofs-cache
# Create ZeroFS configuration
cat > zerofs-ci.toml << EOF
[cache]
dir = "/tmp/zerofs-cache"
disk_size_gb = 2.0
memory_size_gb = 2.0
[storage]
url = "s3://zerofs-zfs-test/zfs-test"
encryption_password = "test-password-123"
[servers.ninep]
addresses = ["127.0.0.1:5564"]
[servers.nbd]
addresses = ["127.0.0.1:10809"]
[aws]
access_key_id = "minioadmin"
secret_access_key = "minioadmin"
endpoint = "http://localhost:9000"
allow_http = "true"
EOF
# Start ZeroFS with NBD support in the background
./target/ci/zerofs run -c zerofs-ci.toml &
# Wait for ZeroFS NBD server to start
echo "Waiting for ZeroFS NBD server to start..."
for i in {1..30}; do
if nc -z 127.0.0.1 10809; then
echo "ZeroFS NBD server is ready"
break
fi
sleep 1
done
# Verify ZeroFS NBD server is running
if ! nc -z 127.0.0.1 10809; then
echo "ZeroFS NBD server failed to start"
exit 1
fi
- name: Mount 9P and create NBD device
run: |
echo "Mounting ZeroFS via 9P..."
sudo mkdir -p /mnt/zerofs
sudo mount -t 9p -o trans=tcp,port=5564,version=9p2000.L 127.0.0.1 /mnt/zerofs
echo "Creating NBD device file..."
sudo mkdir -p /mnt/zerofs/.nbd
sudo truncate -s 3G /mnt/zerofs/.nbd/test-device
sudo umount /mnt/zerofs
- name: Connect NBD device
run: |
echo "Connecting to NBD device..."
sudo nbd-client 127.0.0.1 10809 /dev/nbd0 -N test-device
sudo blockdev --getsize64 /dev/nbd0
sudo fdisk -l /dev/nbd0
- name: Create ZFS pool
run: |
# Create ZFS pool directly on NBD block device
echo "Creating ZFS pool on NBD device..."
sudo zpool create testpool /dev/nbd0
# Check pool status
sudo zpool status testpool
sudo zpool list testpool
- name: Create ZFS filesystem
run: |
# Create a ZFS filesystem
sudo zfs create testpool/data
# Set mountpoint
sudo zfs set mountpoint=/mnt/zfsdata testpool/data
# Set copies=2 for redundancy (allows scrub to detect/repair corruption)
sudo zfs set copies=2 testpool/data
# List filesystems
sudo zfs list
- name: Download and extract Linux kernel
run: |
# Download Linux kernel source
echo "Downloading Linux kernel 6.15.6..."
cd /mnt/zfsdata
sudo wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.15.6.tar.xz
# Show download size
ls -lh linux-6.15.6.tar.xz
echo "Extracting kernel source..."
time sudo tar -I pixz -xf linux-6.15.6.tar.xz
# Count files to verify extraction
echo "Counting extracted files..."
sudo find linux-6.15.6 -type f | wc -l
- name: Test ZFS operations
run: |
# Create a snapshot
echo "Creating ZFS snapshot..."
sudo zfs snapshot testpool/data@after-kernel
# List snapshots
sudo zfs list -t snapshot
# Show pool I/O statistics
sudo zpool iostat testpool 1 5
# Create some test files
echo "Creating test files..."
sudo dd if=/dev/urandom of=/mnt/zfsdata/random.dat bs=1M count=100
# Create another snapshot
sudo zfs snapshot testpool/data@after-random
# Show space usage
sudo zfs list -o name,used,avail,refer,mountpoint
- name: Create tarball and checksum for durability test
run: |
echo "Creating tarball of ZFS data..."
cd /mnt/zfsdata
sudo tar -I pigz -cf /tmp/zfsdata-backup.tar.gz .
echo "Calculating checksum..."
sudo sha256sum /tmp/zfsdata-backup.tar.gz > /tmp/zfsdata-backup.sha256
cat /tmp/zfsdata-backup.sha256
# Also create checksum of individual files for comparison
sudo find . -type f -print0 | parallel -0 -j+0 sha256sum | sort > /tmp/file-checksums.txt
echo "Number of files checksummed: $(wc -l < /tmp/file-checksums.txt)"
- name: Sync and prepare for durability test
run: |
echo "Syncing filesystem..."
sync
sudo zpool sync testpool
echo "Running ZFS TRIM..."
sudo zpool trim testpool
# Wait for trim to complete
echo "Waiting for TRIM to complete..."
while sudo zpool status testpool | grep -q 'trimming'; do
sleep 2
echo "TRIM in progress..."
sudo zpool status testpool
done
echo "TRIM completed"
echo "Starting ZFS scrub..."
sudo zpool scrub testpool
# Wait for scrub to complete
echo "Waiting for scrub to complete..."
while sudo zpool status testpool | grep -q 'scrub in progress'; do
sleep 2
echo "Scrub in progress..."
sudo zpool status testpool
done
echo "Scrub completed"
# Show final pool status before restart
sudo zpool status testpool
- name: Unmount and export ZFS pool
run: |
echo "Unmounting ZFS filesystem..."
sudo zfs unmount testpool/data
echo "Exporting ZFS pool..."
sudo zpool export testpool
# Verify pool is exported
if sudo zpool list testpool 2>/dev/null; then
echo "ERROR: Pool still imported!"
exit 1
fi
echo "Pool successfully exported"
- name: Disconnect NBD and stop ZeroFS
run: |
echo "Disconnecting NBD device..."
sudo nbd-client -d /dev/nbd0
# Wait for NBD to fully disconnect - check if device is actually in use
echo "Waiting for NBD device to disconnect..."
for i in {1..10}; do
# Check if the NBD device is in use by looking at /sys/block/nbd0/size
# When disconnected, this should be 0
if [ ! -e /sys/block/nbd0/size ] || [ "$(cat /sys/block/nbd0/size 2>/dev/null)" = "0" ]; then
echo "NBD device disconnected successfully"
break
fi
echo "Waiting for NBD disconnect... attempt $i/10"
sleep 1
done
# Also check using nbd-client -c to see if device is connected
if sudo nbd-client -c /dev/nbd0 2>/dev/null; then
echo "WARNING: NBD device reports as still connected, but continuing..."
else
echo "NBD device confirmed disconnected"
fi
echo "Stopping ZeroFS..."
# Find and kill the zerofs process
ZEROFS_PID=$(pgrep -f "zerofs.*run.*zerofs-ci.toml" || true)
if [ -n "$ZEROFS_PID" ]; then
echo "Found ZeroFS process: $ZEROFS_PID"
kill -TERM $ZEROFS_PID || true
else
echo "No ZeroFS process found (may have already stopped)"
fi
# Wait for ZeroFS to stop
for i in {1..10}; do
if ! pgrep -f "zerofs.*run.*zerofs-ci.toml" > /dev/null; then
echo "ZeroFS stopped"
break
fi
echo "Waiting for ZeroFS to stop... attempt $i/10"
sleep 1
done
# Final check if ZeroFS stopped
if pgrep -f "zerofs.*run.*zerofs-ci.toml" > /dev/null; then
echo "WARNING: ZeroFS may still be running, forcing kill..."
pkill -KILL -f "zerofs.*run.*zerofs-ci.toml" || true
sleep 1
fi
# Ensure port is free
echo "Waiting for port 10809 to be free..."
for i in {1..10}; do
if ! nc -z 127.0.0.1 10809 2>/dev/null; then
echo "Port 10809 is free"
break
fi
echo "Waiting for port to be released... attempt $i/10"
sleep 1
done
# Final check
if nc -z 127.0.0.1 10809 2>/dev/null; then
echo "ERROR: Port 10809 still in use after 10 seconds!"
exit 1
fi
- name: Restart ZeroFS
working-directory: zerofs
run: |
echo "Starting ZeroFS again..."
# Config file should still exist from earlier
./target/ci/zerofs run -c zerofs-ci.toml &
# Wait for ZeroFS NBD server to start
echo "Waiting for ZeroFS NBD server to restart..."
for i in {1..30}; do
if nc -z 127.0.0.1 10809; then
echo "ZeroFS NBD server is ready"
break
fi
sleep 1
done
# Verify ZeroFS NBD server is running
if ! nc -z 127.0.0.1 10809; then
echo "ZeroFS NBD server failed to restart"
exit 1
fi
- name: Reconnect NBD and import pool
run: |
echo "Reconnecting NBD device..."
sudo nbd-client 127.0.0.1 10809 /dev/nbd0 -N test-device
# Verify NBD device is available
sudo blockdev --getsize64 /dev/nbd0
sudo fdisk -l /dev/nbd0
echo "Importing ZFS pool..."
sudo zpool import testpool
# Check pool status
sudo zpool status testpool
sudo zfs list
- name: Verify data integrity
run: |
echo "Creating new tarball of restored data..."
cd /mnt/zfsdata
sudo tar -I pigz -cf /tmp/zfsdata-restored.tar.gz .
echo "Calculating checksum of restored data..."
sudo sha256sum /tmp/zfsdata-restored.tar.gz > /tmp/zfsdata-restored.sha256
cat /tmp/zfsdata-restored.sha256
# Compare checksums
echo "Comparing tarball checksums..."
ORIGINAL_SUM=$(cut -d' ' -f1 < /tmp/zfsdata-backup.sha256)
RESTORED_SUM=$(cut -d' ' -f1 < /tmp/zfsdata-restored.sha256)
if [ "$ORIGINAL_SUM" = "$RESTORED_SUM" ]; then
echo "SUCCESS: Checksums match! Data integrity verified."
else
echo "ERROR: Checksums do not match!"
echo "Original: $ORIGINAL_SUM"
echo "Restored: $RESTORED_SUM"
exit 1
fi
# Also verify individual file checksums
echo "Verifying individual file checksums..."
sudo find . -type f -print0 | parallel -0 -j+0 sha256sum | sort > /tmp/file-checksums-restored.txt
if diff /tmp/file-checksums.txt /tmp/file-checksums-restored.txt; then
echo "SUCCESS: All individual file checksums match!"
else
echo "ERROR: Individual file checksums differ!"
exit 1
fi
- name: Show ZeroFS S3 usage
run: |
# Show how much data was written to S3
./mc du myminio/zerofs-zfs-test
- name: Cleanup
if: always()
run: |
# Export and destroy ZFS pool
sudo zpool export testpool || true
# Disconnect NBD device
sudo nbd-client -d /dev/nbd0 || true
# Kill ZeroFS
pkill -f "zerofs run -c zerofs-ci.toml" || true
# Stop MinIO
docker stop minio || true