Files
zrepl_patched/internal/platformtest/tests/undestroyableSnapshotParsing.go
Christian Schwarz 1dfae6829b zfs: fix platformtest compat with ZFS 2.3 & 2.4 (#922)
The error message when destroying a held snapshot no longer is `dataset
is busy` but `it's being held. Run 'zfs holds -r <snapshot>' to see
holders.`

The existing `destroySnapshotsErrorRegexp` parses both formats
correctly, but downstream test assertions in platformtest were checking
for the literal `dataset is busy` string.

refs
- the PR that adds ZFS 2.3 & 2.4 to CI:
https://github.com/zrepl/zrepl/pull/921

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 22:39:07 +01:00

38 lines
1006 B
Go

package tests
import (
"fmt"
"github.com/stretchr/testify/require"
"github.com/zrepl/zrepl/internal/platformtest"
"github.com/zrepl/zrepl/internal/zfs"
)
func UndestroyableSnapshotParsing(t *platformtest.Context) {
platformtest.Run(t, platformtest.PanicErr, t.RootDataset, `
DESTROYROOT
CREATEROOT
+ "foo bar"
+ "foo bar@1 2 3"
+ "foo bar@4 5 6"
+ "foo bar@7 8 9"
R zfs hold zrepl_platformtest "${ROOTDS}/foo bar@4 5 6"
`)
err := zfs.ZFSDestroy(t, fmt.Sprintf("%s/foo bar@1 2 3,4 5 6,7 8 9", t.RootDataset))
if err == nil {
panic("expecting destroy error due to hold")
}
if dse, ok := err.(*zfs.DestroySnapshotsError); !ok {
panic(fmt.Sprintf("expecting *zfs.DestroySnapshotsError, got %T\n%v\n%s", err, err, err))
} else {
if dse.Filesystem != fmt.Sprintf("%s/foo bar", t.RootDataset) {
panic(dse.Filesystem)
}
require.Equal(t, []string{"4 5 6"}, dse.Undestroyable)
require.True(t, dse.AllReasonIsHold(), "expected hold reason, got %v", dse.Reason)
}
}