Skip to content

Commit

Permalink
fix small bug in cleanup and test cases (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronhurt authored Aug 30, 2024
1 parent 4b348f4 commit 42f5bfe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
36 changes: 24 additions & 12 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ _testSimpleSetNoConfig() {
local configOut snapOut exitOut line idx match

## source script and run test
. ./zfs-replicate.sh || true
# shellcheck source=/dev/null
. zfs-replicate.sh || true

## test loadConfig
printf "_testSimpleSetNoConfig/loadConfig\n"
Expand All @@ -62,13 +63,20 @@ _testSimpleSetNoConfig() {
match="loading configuration from defaults"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"

## init test environment
loadConfig > /dev/null 2>&1

## test snapCreate
printf "_testSimpleSetNoConfig/snapCreate\n"
mapfile -t snapOut < <(snapCreate)
for idx in "${!snapOut[@]}"; do
line="${snapOut[idx]}"
printf "%d %s\n" "$idx" "$line"
case $idx in
0)
match="creating lockfile ${TMPDIR}/.replicate.snapshot.lock"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
;;
1)
match="cmd=_fakeZFS list -H -o name srcPool/srcFS"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
Expand All @@ -85,17 +93,25 @@ _testSimpleSetNoConfig() {
match="cmd=_fakeZFS destroy srcPool/srcFS@autorep-test2"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
;;
14)
match="cmd=_fakeZFS destroy srcPool/srcFS@autorep-test3"
13)
match="cmd=_fakeZFS snapshot srcPool/srcFS@autorep-"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
;;
15)
match="cmd=_fakeZFS snapshot srcPool/srcFS@autorep-"
match="cmd=_fakeZFS send -Rs -I srcPool/srcFS@autorep-test3 srcPool/srcFS@autorep-${TAG} | "
match+="echo receive -vFd dstPool/dstFS"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
;;
16)
match="receive -vFd dstPool/dstFS"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
;;
17)
match="cmd=_fakeZFS send -Rs -I srcPool/srcFS@autorep-test3 srcPool/srcFS@autorep- | "
match+="echo receive -vFd dstPool/dstFS"
match="deleting lockfile ${TMPDIR}/.replicate.send.lock"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
;;
18)
match="deleting lockfile ${TMPDIR}/.replicate.snapshot.lock"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
;;
esac
Expand All @@ -108,12 +124,8 @@ _testSimpleSetNoConfig() {
line="${exitOut[idx]}"
printf "%d %s\n" "$idx" "$line"
case $idx in
0)
match="deleting lockfile "
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
;;
1)
match="success total sets 0 skipped 0: test message" ## bug in test
10)
match="success total sets 0 skipped 0: test message"
[[ ! "$line" == *"$match"* ]] && _fail "$line" "$match"
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion zfs-replicate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ snapCreate() {
snapSend "$base" "$name" "$src" "$srcHost" "$dst" "$dstHost"
done
## clear our lockfile
clearLock "${TMPDIR}/.snapshot.lock"
clearLock "${TMPDIR}/.replicate.snapshot.lock"
}

## handle logging to file or syslog
Expand Down

0 comments on commit 42f5bfe

Please sign in to comment.