Skip to content

Commit 00df69c

Browse files
committed
Run a full integration test with a ZFS filesystem during build
1 parent 75090b7 commit 00df69c

5 files changed

Lines changed: 115 additions & 10 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
run: |
2727
# Build on Ubuntu
2828
29+
set -e
30+
2931
# Add a new binfmt entry that matches APE's (Actually Portable Executable)'s
3032
# magic number to avoid execution by Ubuntu's built-in "MZ" binfmt
3133
# interpreter which "helpfully" tries to run the binary with Wine.
@@ -62,19 +64,29 @@ jobs:
6264
run: |
6365
# Test on Ubuntu
6466
65-
# Add a new binfmt entry that matches APE's (Actually Portable Executable)'s
66-
# magic number to avoid execution by Ubuntu's built-in "MZ" binfmt
67-
# interpreter which "helpfully" tries to run the binary with Wine.
68-
sudo apt install -y binfmt-support
69-
sudo update-binfmts --install APE /bin/sh --magic MZqFpD
67+
set -e
68+
69+
# Test the assimiate workaround here
70+
sudo chmod +x sanoid-portable
71+
sh ./sanoid-portable --assimilate
7072
71-
./test.sh
73+
./test-smoke.sh
7274
7375
- name: Test in FreeBSD
7476
uses: vmactions/freebsd-vm@v1
7577
with:
7678
usesh: true
7779
prepare: |
78-
pkg install -y jq
80+
pkg install -y bash jq wget
7981
run: |
80-
./test.sh
82+
set -e
83+
84+
echo 'Begin smoke tests...'
85+
./test-smoke.sh
86+
echo 'Completed smoke tests.'
87+
88+
echo ''
89+
90+
echo 'Begin integration tests...'
91+
./test-integration.sh
92+
echo 'Completed integration tests.'

‎.github/workflows/release.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
sudo update-binfmts --install APE /bin/sh --magic MZqFpD
4343
4444
sudo chmod +x sanoid-portable
45+
4546
sanoid_version=$(./sanoid-portable --version)
4647
release_version="${{ github.event.release.tag_name }}"
4748

‎build.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ echo ''
8080
echo 'Testing...'
8181
echo ''
8282

83-
"${repo_root}/test.sh"
83+
"${repo_root}/test-smoke.sh"
8484

8585
popd > /dev/null

‎test-integration.sh‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
output_dir=$(pwd)
6+
prod_disk="${output_dir}/disk-production.raw"
7+
backup_disk="${output_dir}/disk-backup.raw"
8+
9+
echo 'Create sparse files to use as disks for ZFS...'
10+
for disk_file in $prod_disk $backup_disk; do
11+
truncate -s 64M $disk_file
12+
ls -l $disk_file
13+
done
14+
15+
prod_pool='production-pool'
16+
backup_pool='backup-pool'
17+
18+
echo 'Create ZFS pools...'
19+
zpool create $prod_pool $prod_disk
20+
zpool create $backup_pool $backup_disk
21+
22+
zpool status
23+
24+
prod_dataset="${prod_pool}/test"
25+
backup_dataset="${backup_pool}/test"
26+
27+
echo "Create dataset \"${prod_dataset}\"..." # backup dataset created from syncoid replication
28+
zfs create $prod_dataset
29+
zfs list -rt all
30+
31+
echo 'Get sanoid.defaults.conf...'
32+
mkdir /etc/sanoid
33+
wget -O /etc/sanoid/sanoid.defaults.conf https://github.com/jimsalterjrs/sanoid/raw/refs/tags/v2.2.0/sanoid.defaults.conf
34+
35+
echo 'Create /etc/sanoid/sanoid.conf...'
36+
cat << EOF > /etc/sanoid/sanoid.conf
37+
[${prod_dataset}]
38+
use_template = default
39+
frequently = 60
40+
frequent_period = 1
41+
EOF
42+
43+
test_file_path="/${prod_dataset}/date.txt"
44+
45+
echo 'Create an initial test file in the dataset...'
46+
date > $test_file_path
47+
48+
echo 'Run sanoid to take snapshots of the dataset...'
49+
./sanoid --take-snapshots --verbose
50+
51+
echo 'Update test file with new data...'
52+
date > $test_file_path
53+
54+
echo 'Wait 1 minute to take another snapshot...'
55+
sleep 1m
56+
57+
echo 'Taking new snapshot with sanoid...'
58+
./sanoid --take-snapshots --verbose
59+
60+
echo 'List all snapshots...'
61+
zfs list -rt all
62+
63+
echo 'Execute findoid to locate snapshots containing a given file...'
64+
./findoid $test_file_path
65+
66+
echo 'Execute syncoid to replicate snapshots to backup pool...'
67+
./syncoid $prod_dataset $backup_dataset
68+
69+
echo 'List all snapshots on both pools...'
70+
zfs list -rt all
71+
72+
echo "Adjust sanoid config to prune minute-ly snapshots on ${prod_dataset}..."
73+
cat << EOF > /etc/sanoid/sanoid.conf
74+
[${prod_dataset}]
75+
use_template = default
76+
frequently = 0
77+
EOF
78+
79+
echo "Execute sanoid to prune snapshots on ${prod_dataset}..."
80+
./sanoid --prune-snapshots --verbose
81+
82+
echo "List all snapshots on ${prod_dataset}..."
83+
zfs list -rt all $prod_dataset
84+
85+
echo ''
86+
echo 'sanoid, findoid, and syncoid tested successfully!'
87+
echo ''
88+
89+
echo 'Destroying test pools...'
90+
for pool in $prod_pool $backup_pool; do
91+
zpool destroy -f $pool
92+
done

test.sh renamed to test-smoke.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -eu
66
output_dir=$(pwd)
77

88
# Optionally pass in the output directory
9-
# Usage: test.sh [output-directory]
9+
# Usage: test-smoke.sh [output-directory]
1010
if [ $# -gt 0 ] && [ -n "${1}" ]; then
1111
output_dir=$(realpath "${1}")
1212
fi

0 commit comments

Comments
 (0)