Skip to content

Commit 91cc3f4

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

File tree

4 files changed

+110
-5
lines changed

4 files changed

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