Skip to content

Commit f7eff87

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

File tree

4 files changed

+109
-5
lines changed

4 files changed

+109
-5
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 3 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,31 @@ jobs:
6264
run: |
6365
# Test on Ubuntu
6466
67+
set -e
68+
6569
# Add a new binfmt entry that matches APE's (Actually Portable Executable)'s
6670
# magic number to avoid execution by Ubuntu's built-in "MZ" binfmt
6771
# interpreter which "helpfully" tries to run the binary with Wine.
6872
sudo apt install -y binfmt-support
6973
sudo update-binfmts --install APE /bin/sh --magic MZqFpD
7074
71-
./test.sh
75+
./test-smoke.sh
7276
7377
- name: Test in FreeBSD
7478
uses: vmactions/freebsd-vm@v1
7579
with:
7680
usesh: true
7781
prepare: |
78-
pkg install -y jq
82+
pkg install -y bash jq
7983
run: |
80-
./test.sh
84+
set -e
85+
86+
echo 'Begin smoke tests...'
87+
./test-smoke.sh
88+
echo 'Completed smoke tests.'
89+
90+
echo ''
91+
92+
echo 'Begin integration tests...'
93+
./test-integration.sh
94+
echo 'Completed integration tests.'

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 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+
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)