Skip to content

Commit 3eb77a4

Browse files
committed
Run a full integration test with a ZFS filesystem during build
1 parent 376ccd3 commit 3eb77a4

File tree

4 files changed

+95
-4
lines changed

4 files changed

+95
-4
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
sudo apt install -y binfmt-support
6969
sudo update-binfmts --install APE /bin/sh --magic MZqFpD
7070
71-
./test.sh
71+
./test-smoke.sh
7272
7373
- name: Test in FreeBSD
7474
uses: vmactions/freebsd-vm@v1
@@ -77,4 +77,5 @@ jobs:
7777
prepare: |
7878
pkg install -y jq
7979
run: |
80-
./test.sh
80+
./test-smoke.sh
81+
./test-integration.sh

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: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env sh
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 10M $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+
for pool in $prod_pool $backup_pool; do
20+
zpool create $pool
21+
zpool status $pool
22+
done
23+
24+
prod_dataset="${prod_pool}\test"
25+
backup_dataset="${backup_pool}\test"
26+
echo "Create dataset \"${prod_dataset}\"..." # backup dataset created from syncoid replication
27+
zfs create $prod_pool
28+
zfs list -rt all $prod_pool
29+
30+
echo 'Create sanoid config...'
31+
mkdir /etc/sanoid
32+
wget -O /etc/sanoid/sanoid.defaults.conf https://github.com/jimsalterjrs/sanoid/raw/refs/tags/v2.2.0/sanoid.defaults.conf
33+
34+
cat < EOF > /etc/sanoid/sanoid.conf
35+
[${prod_dataset}]
36+
use_template = default
37+
frequently = 60
38+
frequent_period = 1
39+
EOF
40+
41+
test_file_path="/${prod_dataset}/date.txt"
42+
43+
echo 'Create an initial test file with data...'
44+
echo date > $test_file_path
45+
46+
echo 'Run sanoid to take snapshots...'
47+
./sanoid --take-snapshots --verbose
48+
49+
echo 'Update test file with new data...'
50+
echo date > $test_file_path
51+
52+
echo 'Wait 1 minute to take another snapshot...'
53+
sleep 1m
54+
55+
echo 'Taking new snapshot with sanoid...'
56+
./sanoid --take-snapshots --verbose
57+
58+
echo 'List all snapshots...'
59+
zfs list -rt $prod_pool
60+
61+
echo 'Execute findoid to test locating snapshots containing a given file...'
62+
./findoid $test_file_path
63+
64+
echo 'Execute syncoid to replicate snapshots to backup pool...'
65+
./syncoid $prod_dataset $backup_pool
66+
67+
echo 'List all snapshots on backup pool...'
68+
zfs list -rt all $backup_pool
69+
70+
echo 'Adjust sanoid config to prune minute-ly snapshots...'
71+
cat < EOF > /etc/sanoid/sanoid.conf
72+
[${prod_dataset}]
73+
use_template = default
74+
frequently = 0
75+
EOF
76+
77+
echo 'Execute sanoid to prune snapshots...'
78+
./sanoid --prune-snapshots --verbose
79+
80+
echo 'List all snapshots...'
81+
zfs list -rt $prod_pool
82+
83+
echo ''
84+
echo 'sanoid, findoid, and syncoid tested successfully!'
85+
echo ''
86+
87+
echo 'Destroying test pools...'
88+
for pool in $prod_pool $backup_pool; do
89+
zfs destroy $pool
90+
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)