new features: {resumable,encrypted,hold-protected} send-recv, last-received-hold
- **Resumable Send & Recv Support**
No knobs required, automatically used where supported.
- **Hold-Protected Send & Recv**
Automatic ZFS holds to ensure that we can always resume a replication step.
- **Encrypted Send & Recv Support** for OpenZFS native encryption.
Configurable at the job level, i.e., for all filesystems a job is responsible for.
- **Receive-side hold on last received dataset**
The counterpart to the replication cursor bookmark on the send-side.
Ensures that incremental replication will always be possible between a sender and receiver.
Design Doc
----------
`replication/design.md` doc describes how we use ZFS holds and bookmarks to ensure that a single replication step is always resumable.
The replication algorithm described in the design doc introduces the notion of job IDs (please read the details on this design doc).
We reuse the job names for job IDs and use `JobID` type to ensure that a job name can be embedded into hold tags, bookmark names, etc.
This might BREAK CONFIG on upgrade.
Protocol Version Bump
---------------------
This commit makes backwards-incompatible changes to the replication/pdu protobufs.
Thus, bump the version number used in the protocol handshake.
Replication Cursor Format Change
--------------------------------
The new replication cursor bookmark format is: `#zrepl_CURSOR_G_${this.GUID}_J_${jobid}`
Including the GUID enables transaction-safe moving-forward of the cursor.
Including the job id enables that multiple sending jobs can send the same filesystem without interfering.
The `zrepl migrate replication-cursor:v1-v2` subcommand can be used to safely destroy old-format cursors once zrepl has created new-format cursors.
Changes in This Commit
----------------------
- package zfs
- infrastructure for holds
- infrastructure for resume token decoding
- implement a variant of OpenZFS's `entity_namecheck` and use it for validation in new code
- ZFSSendArgs to specify a ZFS send operation
- validation code protects against malicious resume tokens by checking that the token encodes the same send parameters that the send-side would use if no resume token were available (i.e. same filesystem, `fromguid`, `toguid`)
- RecvOptions support for `recv -s` flag
- convert a bunch of ZFS operations to be idempotent
- achieved through more differentiated error message scraping / additional pre-/post-checks
- package replication/pdu
- add field for encryption to send request messages
- add fields for resume handling to send & recv request messages
- receive requests now contain `FilesystemVersion To` in addition to the filesystem into which the stream should be `recv`d into
- can use `zfs recv $root_fs/$client_id/path/to/dataset@${To.Name}`, which enables additional validation after recv (i.e. whether `To.Guid` matched what we received in the stream)
- used to set `last-received-hold`
- package replication/logic
- introduce `PlannerPolicy` struct, currently only used to configure whether encrypted sends should be requested from the sender
- integrate encryption and resume token support into `Step` struct
- package endpoint
- move the concepts that endpoint builds on top of ZFS to a single file `endpoint/endpoint_zfs.go`
- step-holds + step-bookmarks
- last-received-hold
- new replication cursor + old replication cursor compat code
- adjust `endpoint/endpoint.go` handlers for
- encryption
- resumability
- new replication cursor
- last-received-hold
- client subcommand `zrepl holds list`: list all holds and hold-like bookmarks that zrepl thinks belong to it
- client subcommand `zrepl migrate replication-cursor:v1-v2`
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/zrepl/zrepl/platformtest"
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
type rollupReleaseExpectTags struct {
|
||||
Snap string
|
||||
Holds map[string]bool
|
||||
}
|
||||
|
||||
func rollupReleaseTest(ctx *platformtest.Context, cb func(fs string) []rollupReleaseExpectTags) {
|
||||
|
||||
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
||||
DESTROYROOT
|
||||
CREATEROOT
|
||||
+ "foo bar"
|
||||
+ "foo bar@1"
|
||||
+ "foo bar@2"
|
||||
+ "foo bar@3"
|
||||
+ "foo bar@4"
|
||||
+ "foo bar@5"
|
||||
+ "foo bar@6"
|
||||
R zfs hold zrepl_platformtest "${ROOTDS}/foo bar@1"
|
||||
R zfs hold zrepl_platformtest_2 "${ROOTDS}/foo bar@2"
|
||||
R zfs hold zrepl_platformtest "${ROOTDS}/foo bar@3"
|
||||
R zfs hold zrepl_platformtest "${ROOTDS}/foo bar@5"
|
||||
R zfs hold zrepl_platformtest "${ROOTDS}/foo bar@6"
|
||||
R zfs bookmark "${ROOTDS}/foo bar@5" "${ROOTDS}/foo bar#5"
|
||||
`)
|
||||
|
||||
fs := fmt.Sprintf("%s/foo bar", ctx.RootDataset)
|
||||
|
||||
expTags := cb(fs)
|
||||
|
||||
for _, exp := range expTags {
|
||||
holds, err := zfs.ZFSHolds(ctx, fs, exp.Snap)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, h := range holds {
|
||||
if e, ok := exp.Holds[h]; !ok || !e {
|
||||
panic(fmt.Sprintf("tag %q on snap %q not expected", h, exp.Snap))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func RollupReleaseIncluding(ctx *platformtest.Context) {
|
||||
rollupReleaseTest(ctx, func(fs string) []rollupReleaseExpectTags {
|
||||
guid5, err := zfs.ZFSGetGUID(fs, "@5")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
err = zfs.ZFSReleaseAllOlderAndIncludingGUID(ctx, fs, guid5, "zrepl_platformtest")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
return []rollupReleaseExpectTags{
|
||||
{"1", map[string]bool{}},
|
||||
{"2", map[string]bool{"zrepl_platformtest_2": true}},
|
||||
{"3", map[string]bool{}},
|
||||
{"4", map[string]bool{}},
|
||||
{"5", map[string]bool{}},
|
||||
{"6", map[string]bool{"zrepl_platformtest": true}},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func RollupReleaseExcluding(ctx *platformtest.Context) {
|
||||
rollupReleaseTest(ctx, func(fs string) []rollupReleaseExpectTags {
|
||||
guid5, err := zfs.ZFSGetGUID(fs, "@5")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
err = zfs.ZFSReleaseAllOlderThanGUID(ctx, fs, guid5, "zrepl_platformtest")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
return []rollupReleaseExpectTags{
|
||||
{"1", map[string]bool{}},
|
||||
{"2", map[string]bool{"zrepl_platformtest_2": true}},
|
||||
{"3", map[string]bool{}},
|
||||
{"4", map[string]bool{}},
|
||||
{"5", map[string]bool{"zrepl_platformtest": true}},
|
||||
{"6", map[string]bool{"zrepl_platformtest": true}},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func RollupReleaseMostRecentIsBookmarkWithoutSnapshot(ctx *platformtest.Context) {
|
||||
rollupReleaseTest(ctx, func(fs string) []rollupReleaseExpectTags {
|
||||
guid5, err := zfs.ZFSGetGUID(fs, "#5")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
err = zfs.ZFSRelease(ctx, "zrepl_platformtest", fs+"@5")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
err = zfs.ZFSDestroy(fs + "@5")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
err = zfs.ZFSReleaseAllOlderAndIncludingGUID(ctx, fs, guid5, "zrepl_platformtest")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
return []rollupReleaseExpectTags{
|
||||
{"1", map[string]bool{}},
|
||||
{"2", map[string]bool{"zrepl_platformtest_2": true}},
|
||||
{"3", map[string]bool{}},
|
||||
{"4", map[string]bool{}},
|
||||
// {"5", map[string]bool{}}, doesn't exist
|
||||
{"6", map[string]bool{"zrepl_platformtest": true}},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func RollupReleaseMostRecentIsBookmarkAndSnapshotStillExists(ctx *platformtest.Context) {
|
||||
rollupReleaseTest(ctx, func(fs string) []rollupReleaseExpectTags {
|
||||
guid5, err := zfs.ZFSGetGUID(fs, "#5")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
err = zfs.ZFSReleaseAllOlderAndIncludingGUID(ctx, fs, guid5, "zrepl_platformtest")
|
||||
require.NoError(ctx, err)
|
||||
|
||||
return []rollupReleaseExpectTags{
|
||||
{"1", map[string]bool{}},
|
||||
{"2", map[string]bool{"zrepl_platformtest_2": true}},
|
||||
{"3", map[string]bool{}},
|
||||
{"4", map[string]bool{}},
|
||||
{"5", map[string]bool{}},
|
||||
{"6", map[string]bool{"zrepl_platformtest": true}},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func RollupReleaseMostRecentDoesntExist(ctx *platformtest.Context) {
|
||||
rollupReleaseTest(ctx, func(fs string) []rollupReleaseExpectTags {
|
||||
|
||||
const nonexistentGuid = 0 // let's take our chances...
|
||||
err := zfs.ZFSReleaseAllOlderAndIncludingGUID(ctx, fs, nonexistentGuid, "zrepl_platformtest")
|
||||
require.Error(ctx, err)
|
||||
require.Contains(ctx, err.Error(), "cannot find snapshot or bookmark with guid 0")
|
||||
|
||||
return []rollupReleaseExpectTags{
|
||||
{"1", map[string]bool{"zrepl_platformtest": true}},
|
||||
{"2", map[string]bool{"zrepl_platformtest_2": true}},
|
||||
{"3", map[string]bool{"zrepl_platformtest": true}},
|
||||
{"4", map[string]bool{"zrepl_platformtest": true}},
|
||||
{"5", map[string]bool{"zrepl_platformtest": true}},
|
||||
{"6", map[string]bool{"zrepl_platformtest": true}},
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"io"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/zrepl/zrepl/platformtest"
|
||||
"github.com/zrepl/zrepl/util/limitio"
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
func sendArgVersion(fs, relName string) zfs.ZFSSendArgVersion {
|
||||
guid, err := zfs.ZFSGetGUID(fs, relName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return zfs.ZFSSendArgVersion{
|
||||
RelName: relName,
|
||||
GUID: guid,
|
||||
}
|
||||
}
|
||||
|
||||
func mustDatasetPath(fs string) *zfs.DatasetPath {
|
||||
p, err := zfs.NewDatasetPath(fs)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func mustSnapshot(snap string) {
|
||||
if err := zfs.EntityNamecheck(snap, zfs.EntityTypeSnapshot); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
comps := strings.Split(snap, "@")
|
||||
if len(comps) != 2 {
|
||||
panic(comps)
|
||||
}
|
||||
err := zfs.ZFSSnapshot(mustDatasetPath(comps[0]), comps[1], false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func mustGetProps(entity string) zfs.ZFSPropCreateTxgAndGuidProps {
|
||||
props, err := zfs.ZFSGetCreateTXGAndGuid(entity)
|
||||
check(err)
|
||||
return props
|
||||
}
|
||||
|
||||
func check(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
var dummyDataRand = rand.New(rand.NewSource(99))
|
||||
|
||||
func writeDummyData(path string, numBytes int64) {
|
||||
r := io.LimitReader(dummyDataRand, numBytes)
|
||||
d, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
|
||||
check(err)
|
||||
defer d.Close()
|
||||
_, err = io.Copy(d, r)
|
||||
check(err)
|
||||
}
|
||||
|
||||
type dummySnapshotSituation struct {
|
||||
sendFS string
|
||||
dummyDataLen int64
|
||||
snapA *zfs.ZFSSendArgVersion
|
||||
snapB *zfs.ZFSSendArgVersion
|
||||
}
|
||||
|
||||
type resumeSituation struct {
|
||||
sendArgs zfs.ZFSSendArgs
|
||||
recvOpts zfs.RecvOptions
|
||||
sendErr, recvErr error
|
||||
recvErrDecoded *zfs.RecvFailedWithResumeTokenErr
|
||||
}
|
||||
|
||||
func makeDummyDataSnapshots(ctx *platformtest.Context, sendFS string) (situation dummySnapshotSituation) {
|
||||
|
||||
situation.sendFS = sendFS
|
||||
sendFSMount, err := zfs.ZFSGetMountpoint(sendFS)
|
||||
require.NoError(ctx, err)
|
||||
require.True(ctx, sendFSMount.Mounted)
|
||||
|
||||
const dummyLen = int64(10 * (1 << 20))
|
||||
situation.dummyDataLen = dummyLen
|
||||
|
||||
writeDummyData(path.Join(sendFSMount.Mountpoint, "dummy_data"), dummyLen)
|
||||
mustSnapshot(sendFS + "@a snapshot")
|
||||
snapA := sendArgVersion(sendFS, "@a snapshot")
|
||||
situation.snapA = &snapA
|
||||
|
||||
writeDummyData(path.Join(sendFSMount.Mountpoint, "dummy_data"), dummyLen)
|
||||
mustSnapshot(sendFS + "@b snapshot")
|
||||
snapB := sendArgVersion(sendFS, "@b snapshot")
|
||||
situation.snapB = &snapB
|
||||
|
||||
return situation
|
||||
}
|
||||
|
||||
func makeResumeSituation(ctx *platformtest.Context, src dummySnapshotSituation, recvFS string, sendArgs zfs.ZFSSendArgs, recvOptions zfs.RecvOptions) *resumeSituation {
|
||||
|
||||
situation := &resumeSituation{}
|
||||
|
||||
situation.sendArgs = sendArgs
|
||||
situation.recvOpts = recvOptions
|
||||
require.True(ctx, recvOptions.SavePartialRecvState, "this method would be pointeless otherwise")
|
||||
require.Equal(ctx, sendArgs.FS, src.sendFS)
|
||||
|
||||
copier, err := zfs.ZFSSend(ctx, sendArgs)
|
||||
situation.sendErr = err
|
||||
if err != nil {
|
||||
return situation
|
||||
}
|
||||
|
||||
limitedCopier := zfs.NewReadCloserCopier(limitio.ReadCloser(copier, src.dummyDataLen/2))
|
||||
defer limitedCopier.Close()
|
||||
|
||||
require.NotNil(ctx, sendArgs.To)
|
||||
err = zfs.ZFSRecv(ctx, recvFS, sendArgs.To, limitedCopier, recvOptions)
|
||||
situation.recvErr = err
|
||||
ctx.Logf("zfs recv exit with %T %s", err, err)
|
||||
|
||||
require.NotNil(ctx, err)
|
||||
resumeErr, ok := err.(*zfs.RecvFailedWithResumeTokenErr)
|
||||
require.True(ctx, ok)
|
||||
situation.recvErrDecoded = resumeErr
|
||||
|
||||
return situation
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/zrepl/zrepl/platformtest"
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
func IdempotentBookmark(ctx *platformtest.Context) {
|
||||
|
||||
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
||||
DESTROYROOT
|
||||
CREATEROOT
|
||||
+ "foo bar"
|
||||
+ "foo bar@a snap"
|
||||
+ "foo bar@another snap"
|
||||
`)
|
||||
|
||||
fs := fmt.Sprintf("%s/foo bar", ctx.RootDataset)
|
||||
|
||||
asnap := sendArgVersion(fs, "@a snap")
|
||||
anotherSnap := sendArgVersion(fs, "@another snap")
|
||||
|
||||
err := zfs.ZFSBookmark(fs, asnap, "a bookmark")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// do it again, should be idempotent
|
||||
err = zfs.ZFSBookmark(fs, asnap, "a bookmark")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// should fail for another snapshot
|
||||
err = zfs.ZFSBookmark(fs, anotherSnap, "a bookmark")
|
||||
if err == nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, ok := err.(*zfs.BookmarkExists); !ok {
|
||||
panic(fmt.Sprintf("has type %T", err))
|
||||
}
|
||||
|
||||
// destroy the snapshot
|
||||
if err := zfs.ZFSDestroy(fmt.Sprintf("%s@a snap", fs)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// do it again, should fail with special error type
|
||||
err = zfs.ZFSBookmark(fs, asnap, "a bookmark")
|
||||
if err == nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, ok := err.(*zfs.DatasetDoesNotExist); !ok {
|
||||
panic(fmt.Sprintf("has type %T", err))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/zrepl/zrepl/platformtest"
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
func IdempotentDestroy(ctx *platformtest.Context) {
|
||||
|
||||
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
||||
DESTROYROOT
|
||||
CREATEROOT
|
||||
+ "foo bar"
|
||||
+ "foo bar@a snap"
|
||||
`)
|
||||
|
||||
fs := fmt.Sprintf("%s/foo bar", ctx.RootDataset)
|
||||
asnap := sendArgVersion(fs, "@a snap")
|
||||
err := zfs.ZFSBookmark(fs, asnap, "a bookmark")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
type testCase struct {
|
||||
description, path string
|
||||
}
|
||||
|
||||
cases := []testCase{
|
||||
{"snapshot", fmt.Sprintf("%s@a snap", fs)},
|
||||
{"bookmark", fmt.Sprintf("%s#a bookmark", fs)},
|
||||
{"filesystem", fs},
|
||||
}
|
||||
|
||||
for i := range cases {
|
||||
func() {
|
||||
c := cases[i]
|
||||
|
||||
log.Printf("SUBBEGIN testing idempotent destroy %q for path %q", c.description, c.path)
|
||||
|
||||
log.Println("destroy existing")
|
||||
err = zfs.ZFSDestroy(c.path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Println("destroy again, non-idempotently, must error")
|
||||
err = zfs.ZFSDestroy(c.path)
|
||||
if _, ok := err.(*zfs.DatasetDoesNotExist); !ok {
|
||||
panic(fmt.Sprintf("%T: %s", err, err))
|
||||
}
|
||||
log.Println("destroy again, idempotently, must not error")
|
||||
err = zfs.ZFSDestroyIdempotent(c.path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
log.Println("SUBEND")
|
||||
|
||||
}()
|
||||
}
|
||||
|
||||
// also test idempotent destroy for cases where the parent dataset does not exist
|
||||
err = zfs.ZFSDestroyIdempotent(fmt.Sprintf("%s/not foo bar@nonexistent snapshot", ctx.RootDataset))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = zfs.ZFSDestroyIdempotent(fmt.Sprintf("%s/not foo bar#nonexistent bookmark", ctx.RootDataset))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/zrepl/zrepl/platformtest"
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
func IdempotentHold(ctx *platformtest.Context) {
|
||||
|
||||
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
||||
DESTROYROOT
|
||||
CREATEROOT
|
||||
+ "foo bar"
|
||||
+ "foo bar@1"
|
||||
`)
|
||||
defer platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
||||
R zfs release zrepl_platformtest "${ROOTDS}/foo bar@1"
|
||||
- "foo bar@1"
|
||||
- "foo bar"
|
||||
`)
|
||||
|
||||
fs := fmt.Sprintf("%s/foo bar", ctx.RootDataset)
|
||||
v1 := sendArgVersion(fs, "@1")
|
||||
|
||||
tag := "zrepl_platformtest"
|
||||
err := zfs.ZFSHold(ctx, fs, v1, tag)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = zfs.ZFSHold(ctx, fs, v1, tag)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
vnonexistent := zfs.ZFSSendArgVersion{
|
||||
RelName: "@nonexistent",
|
||||
GUID: 0xbadf00d,
|
||||
}
|
||||
err = zfs.ZFSHold(ctx, fs, vnonexistent, tag)
|
||||
if err == nil {
|
||||
panic("still expecting error for nonexistent snapshot")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package tests
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/zrepl/zrepl/endpoint"
|
||||
"github.com/zrepl/zrepl/platformtest"
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
@@ -13,25 +16,35 @@ func ReplicationCursor(ctx *platformtest.Context) {
|
||||
CREATEROOT
|
||||
+ "foo bar"
|
||||
+ "foo bar@1 with space"
|
||||
R zfs bookmark "${ROOTDS}/foo bar@1 with space" "${ROOTDS}/foo bar#1 with space"
|
||||
+ "foo bar@2 with space"
|
||||
R zfs bookmark "${ROOTDS}/foo bar@1 with space" "${ROOTDS}/foo bar#2 with space"
|
||||
+ "foo bar@3 with space"
|
||||
R zfs bookmark "${ROOTDS}/foo bar@1 with space" "${ROOTDS}/foo bar#3 with space"
|
||||
`)
|
||||
|
||||
jobid := endpoint.MustMakeJobID("zreplplatformtest")
|
||||
|
||||
ds, err := zfs.NewDatasetPath(ctx.RootDataset + "/foo bar")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
guid, err := zfs.ZFSSetReplicationCursor(ds, "1 with space")
|
||||
|
||||
fs := ds.ToString()
|
||||
snap := sendArgVersion(fs, "@1 with space")
|
||||
|
||||
destroyed, err := endpoint.MoveReplicationCursor(ctx, fs, &snap, jobid)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
snapProps, err := zfs.ZFSGetCreateTXGAndGuid(ds.ToString() + "@1 with space")
|
||||
assert.Empty(ctx, destroyed)
|
||||
|
||||
snapProps, err := zfs.ZFSGetCreateTXGAndGuid(snap.FullPath(fs))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if guid != snapProps.Guid {
|
||||
panic(fmt.Sprintf("guids to not match: %v != %v", guid, snapProps.Guid))
|
||||
}
|
||||
|
||||
bm, err := zfs.ZFSGetReplicationCursor(ds)
|
||||
bm, err := endpoint.GetMostRecentReplicationCursorOfJob(ctx, fs, jobid)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -41,22 +54,15 @@ func ReplicationCursor(ctx *platformtest.Context) {
|
||||
if bm.Guid != snapProps.Guid {
|
||||
panic(fmt.Sprintf("guids do not match: %v != %v", bm.Guid, snapProps.Guid))
|
||||
}
|
||||
if bm.Guid != guid {
|
||||
panic(fmt.Sprintf("guids do not match: %v != %v", bm.Guid, guid))
|
||||
}
|
||||
|
||||
// test nonexistent
|
||||
err = zfs.ZFSDestroyFilesystemVersion(ds, bm)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
bm2, err := zfs.ZFSGetReplicationCursor(ds)
|
||||
if bm2 != nil {
|
||||
panic(fmt.Sprintf("expecting no replication cursor after deleting it, got %v", bm))
|
||||
}
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("expecting no error for getting nonexistent replication cursor, bot %v", err))
|
||||
}
|
||||
// try moving
|
||||
cursor1BookmarkName, err := endpoint.ReplicationCursorBookmarkName(fs, snap.GUID, jobid)
|
||||
require.NoError(ctx, err)
|
||||
|
||||
// TODO test moving the replication cursor
|
||||
snap2 := sendArgVersion(fs, "@2 with space")
|
||||
destroyed, err = endpoint.MoveReplicationCursor(ctx, fs, &snap2, jobid)
|
||||
require.NoError(ctx, err)
|
||||
require.Equal(ctx, 1, len(destroyed))
|
||||
require.Equal(ctx, zfs.Bookmark, destroyed[0].Type)
|
||||
require.Equal(ctx, cursor1BookmarkName, destroyed[0].Name)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/zrepl/zrepl/platformtest"
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
func ResumableRecvAndTokenHandling(ctx *platformtest.Context) {
|
||||
|
||||
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
||||
DESTROYROOT
|
||||
CREATEROOT
|
||||
+ "send er"
|
||||
`)
|
||||
|
||||
sendFS := fmt.Sprintf("%s/send er", ctx.RootDataset)
|
||||
recvFS := fmt.Sprintf("%s/recv er", ctx.RootDataset)
|
||||
|
||||
supported, err := zfs.ResumeRecvSupported(ctx, mustDatasetPath(sendFS))
|
||||
check(err)
|
||||
|
||||
src := makeDummyDataSnapshots(ctx, sendFS)
|
||||
|
||||
s := makeResumeSituation(ctx, src, recvFS, zfs.ZFSSendArgs{
|
||||
FS: sendFS,
|
||||
To: src.snapA,
|
||||
Encrypted: &zfs.NilBool{B: false},
|
||||
ResumeToken: "",
|
||||
}, zfs.RecvOptions{
|
||||
RollbackAndForceRecv: false, // doesnt' exist yet
|
||||
SavePartialRecvState: true,
|
||||
})
|
||||
|
||||
if !supported {
|
||||
_, ok := s.recvErr.(*zfs.ErrRecvResumeNotSupported)
|
||||
require.True(ctx, ok)
|
||||
|
||||
// we know that support on sendFS implies support on recvFS
|
||||
// => asser that if we don't support resumed recv, the method returns ""
|
||||
tok, err := zfs.ZFSGetReceiveResumeTokenOrEmptyStringIfNotSupported(ctx, mustDatasetPath(recvFS))
|
||||
check(err)
|
||||
require.Equal(ctx, "", tok)
|
||||
|
||||
return // nothing more to test for recv that doesn't support -s
|
||||
}
|
||||
|
||||
getTokenRaw, err := zfs.ZFSGetReceiveResumeTokenOrEmptyStringIfNotSupported(ctx, mustDatasetPath(recvFS))
|
||||
check(err)
|
||||
|
||||
require.NotEmpty(ctx, getTokenRaw)
|
||||
decodedToken, err := zfs.ParseResumeToken(ctx, getTokenRaw)
|
||||
check(err)
|
||||
|
||||
require.True(ctx, decodedToken.HasToGUID)
|
||||
require.Equal(ctx, s.sendArgs.To.GUID, decodedToken.ToGUID)
|
||||
|
||||
recvErr := s.recvErr.(*zfs.RecvFailedWithResumeTokenErr)
|
||||
require.Equal(ctx, recvErr.ResumeTokenRaw, getTokenRaw)
|
||||
require.Equal(ctx, recvErr.ResumeTokenParsed, decodedToken)
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/zrepl/zrepl/platformtest"
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
type resumeTokenTest struct {
|
||||
Msg string
|
||||
Token string
|
||||
ExpectToken *zfs.ResumeToken
|
||||
ExpectError error
|
||||
}
|
||||
|
||||
func (rtt *resumeTokenTest) Test(t *platformtest.Context) {
|
||||
|
||||
resumeSendSupported, err := zfs.ResumeSendSupported()
|
||||
if err != nil {
|
||||
t.Errorf("cannot determine whether resume supported: %T %s", err, err)
|
||||
t.FailNow()
|
||||
return
|
||||
}
|
||||
|
||||
res, err := zfs.ParseResumeToken(t, rtt.Token)
|
||||
|
||||
// if decoding is not supported, don't bother with the expectations
|
||||
if !resumeSendSupported {
|
||||
require.Error(t, err)
|
||||
require.Equal(t, zfs.ResumeTokenDecodingNotSupported, err)
|
||||
return
|
||||
}
|
||||
|
||||
if rtt.ExpectError != nil {
|
||||
require.EqualValues(t, rtt.ExpectError, err)
|
||||
return
|
||||
}
|
||||
if rtt.ExpectToken != nil {
|
||||
require.Nil(t, err)
|
||||
require.EqualValues(t, rtt.ExpectToken, res)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func ResumeTokenParsing(ctx *platformtest.Context) {
|
||||
|
||||
// cases generated using resumeTokensGenerate.bash on ZoL 0.8.1
|
||||
cases := []resumeTokenTest{
|
||||
{
|
||||
Msg: "zreplplatformtest/dst/full",
|
||||
Token: "1-b338b54f3-c0-789c636064000310a500c4ec50360710e72765a52697303030419460caa7a515a796806474e0f26c48f2499525a9c540ba42430fabfe92fcf4d2cc140686c88a76d578ae45530c90e439c1f27989b9a90c0c5545a905390539892569f945b940234bf48b8b921d12c1660200c61a1aba",
|
||||
ExpectToken: &zfs.ResumeToken{
|
||||
HasToGUID: true,
|
||||
ToGUID: 0x94a20a5f25877859,
|
||||
ToName: "zreplplatformtest/src@a",
|
||||
},
|
||||
},
|
||||
{
|
||||
Msg: "zreplplatformtest/dst/full_raw",
|
||||
Token: "1-e3f40c323-f8-789c636064000310a500c4ec50360710e72765a52697303030419460caa7a515a796806474e0f26c48f2499525a9c540da454f0fabfe92fcf4d2cc140686c88a76d578ae45530c90e439c1f27989b9a90c0c5545a905390539892569f945b940234bf48b8b921d12c1e6713320dc9f9c9f5b50945a5c9c9f0d119380ba07265f94580e936200004ff12141",
|
||||
ExpectToken: &zfs.ResumeToken{
|
||||
HasToGUID: true,
|
||||
ToGUID: 0x94a20a5f25877859,
|
||||
ToName: "zreplplatformtest/src@a",
|
||||
HasCompressOK: true, CompressOK: true,
|
||||
HasRawOk: true, RawOK: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
Msg: "zreplplatformtest/dst/inc",
|
||||
Token: "1-eadabb296-e8-789c636064000310a501c49c50360710a715e5e7a69766a63040416445bb6a3cd7a2290a40363b92bafca4acd4e412060626a83a0cf9b4b4e2d412908c0e5c9e0d493ea9b224b518483ba8ea61d55f920f714515bf9b3fc3c396ef0648f29c60f9bcc4dc54a07c516a414e414e62495a7e512ed0c812fde2a2648724b09900d43e2191",
|
||||
ExpectToken: &zfs.ResumeToken{
|
||||
HasFromGUID: true, FromGUID: 0x94a20a5f25877859,
|
||||
HasToGUID: true, ToGUID: 0xf784e1004f460f7a,
|
||||
ToName: "zreplplatformtest/src@b",
|
||||
},
|
||||
},
|
||||
{
|
||||
Msg: "zreplplatformtest/dst/inc_raw",
|
||||
Token: "1-1164f8d409-120-789c636064000310a501c49c50360710a715e5e7a69766a63040416445bb6a3cd7a2290a40363b92bafca4acd4e412060626a83a0cf9b4b4e2d412908c0e5c9e0d493ea9b224b51848f368eb61d55f920f714515bf9b3fc3c396ef0648f29c60f9bcc4dc54a07c516a414e414e62495a7e512ed0c812fde2a2648724b079dc0c087f26e7e71614a51617e76743c424a0ee81c9172596c3a41800dd2c2818",
|
||||
ExpectToken: &zfs.ResumeToken{
|
||||
HasFromGUID: true, FromGUID: 0x94a20a5f25877859,
|
||||
HasToGUID: true, ToGUID: 0xf784e1004f460f7a,
|
||||
ToName: "zreplplatformtest/src@b",
|
||||
HasCompressOK: true, CompressOK: true,
|
||||
HasRawOk: true, RawOK: true,
|
||||
},
|
||||
},
|
||||
|
||||
// manual test csaes
|
||||
{
|
||||
Msg: "corrupted",
|
||||
Token: "1-1164f8d409-120-badf00d064000310a501c49c50360710a715e5e7a69766a63040416445bb6a3cd7a2290a40363b92bafca4acd4e412060626a83a0cf9b4b4e2d412908c0e5c9e0d493ea9b224b51848f368eb61d55f920f714515bf9b3fc3c396ef0648f29c60f9bcc4dc54a07c516a414e414e62495a7e512ed0c812fde2a2648724b079dc0c087f26e7e71614a51617e76743c424a0ee81c9172596c3a41800dd2c2818",
|
||||
ExpectError: zfs.ResumeTokenCorruptError,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range cases {
|
||||
ctx.Logf("BEGIN SUBTEST: %s", test.Msg)
|
||||
test.Test(ctx)
|
||||
ctx.Logf("COMPLETE SUBTEST: %s", test.Msg)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set -x
|
||||
|
||||
POOLNAME="zreplplatformtest"
|
||||
POOLIMG="$1"
|
||||
|
||||
if zpool status "$POOLNAME"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e "$POOLIMG" ]; then
|
||||
exit 1
|
||||
fi
|
||||
fallocate -l 500M "$POOLIMG"
|
||||
zpool create "$POOLNAME" "$POOLIMG"
|
||||
|
||||
SRC_DATASET="$POOLNAME/src"
|
||||
DST_ROOT="$POOLNAME/dst"
|
||||
|
||||
keylocation="$(mktemp /tmp/ZREPL_PLATFORMTEST_GENERATE_TOKENS_KEYFILE_XXX)"
|
||||
echo "foobar123" > "$keylocation"
|
||||
zfs create -o encryption=on -o keylocation="file:///$keylocation" -o keyformat=passphrase "$SRC_DATASET"
|
||||
rm "$keylocation"
|
||||
|
||||
SRC_MOUNT="$(zfs get -H -o value mountpoint "$SRC_DATASET")"
|
||||
test -d "$SRC_MOUNT"
|
||||
|
||||
A="$SRC_DATASET"@a
|
||||
B="$SRC_DATASET"@b
|
||||
dd if=/dev/urandom of="$SRC_MOUNT"/dummy_data bs=1M count=5
|
||||
zfs snapshot "$A"
|
||||
dd if=/dev/urandom of="$SRC_MOUNT"/dummy_data bs=1M count=5
|
||||
zfs snapshot "$B"
|
||||
|
||||
zfs create "$DST_ROOT"
|
||||
|
||||
cutoff="dd bs=1024 count=3K"
|
||||
|
||||
set +e
|
||||
zfs send "$A" | $cutoff | zfs recv -s "$DST_ROOT"/full
|
||||
|
||||
zfs send "$A" | zfs recv "$DST_ROOT"/inc
|
||||
zfs send -i "$A" "$B" | $cutoff | zfs recv -s "$DST_ROOT"/inc
|
||||
|
||||
zfs send -w "$A" | $cutoff | zfs recv -s "$DST_ROOT"/full_raw
|
||||
|
||||
zfs send -w "$A" | zfs recv "$DST_ROOT"/inc_raw
|
||||
zfs send -w -i "$A" "$B" | $cutoff | zfs recv -s "$DST_ROOT"/inc_raw
|
||||
set -e
|
||||
|
||||
TOKENS="$(zfs list -H -o name,receive_resume_token -r "$DST_ROOT")"
|
||||
|
||||
echo "$TOKENS" | awk -e '//{ if ($2 == "-") { } else { system("zfs send -nvt " + $2);} }'
|
||||
|
||||
zpool destroy "$POOLNAME"
|
||||
rm "$POOLIMG"
|
||||
@@ -0,0 +1,208 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/zrepl/zrepl/platformtest"
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
func SendArgsValidationEncryptedSendOfUnencryptedDatasetForbidden(ctx *platformtest.Context) {
|
||||
|
||||
supported, err := zfs.EncryptionCLISupported(ctx)
|
||||
check(err)
|
||||
expectNotSupportedErr := !supported
|
||||
|
||||
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
||||
DESTROYROOT
|
||||
CREATEROOT
|
||||
+ "send er"
|
||||
+ "send er@a snap"
|
||||
`)
|
||||
|
||||
fs := fmt.Sprintf("%s/send er", ctx.RootDataset)
|
||||
props := mustGetProps(fs + "@a snap")
|
||||
|
||||
sendArgs := zfs.ZFSSendArgs{
|
||||
FS: fs,
|
||||
To: &zfs.ZFSSendArgVersion{
|
||||
RelName: "@a snap",
|
||||
GUID: props.Guid,
|
||||
},
|
||||
Encrypted: &zfs.NilBool{B: true},
|
||||
ResumeToken: "",
|
||||
}
|
||||
stream, err := zfs.ZFSSend(ctx, sendArgs)
|
||||
if err == nil {
|
||||
defer stream.Close()
|
||||
}
|
||||
|
||||
if expectNotSupportedErr {
|
||||
require.Error(ctx, err)
|
||||
require.Equal(ctx, zfs.ErrEncryptedSendNotSupported, err)
|
||||
return
|
||||
}
|
||||
require.Error(ctx, err)
|
||||
ctx.Logf("send err: %T %s", err, err)
|
||||
validationErr, ok := err.(*zfs.ZFSSendArgsValidationError)
|
||||
require.True(ctx, ok)
|
||||
require.True(ctx, validationErr.What == zfs.ZFSSendArgsEncryptedSendRequestedButFSUnencrypted)
|
||||
}
|
||||
|
||||
func SendArgsValidationResumeTokenEncryptionMismatchForbidden(ctx *platformtest.Context) {
|
||||
|
||||
supported, err := zfs.EncryptionCLISupported(ctx)
|
||||
check(err)
|
||||
if !supported {
|
||||
ctx.SkipNow()
|
||||
}
|
||||
supported, err = zfs.ResumeSendSupported()
|
||||
check(err)
|
||||
if !supported {
|
||||
ctx.SkipNow()
|
||||
}
|
||||
|
||||
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
||||
DESTROYROOT
|
||||
CREATEROOT
|
||||
+ "send er" encrypted
|
||||
`)
|
||||
|
||||
sendFS := fmt.Sprintf("%s/send er", ctx.RootDataset)
|
||||
unencRecvFS := fmt.Sprintf("%s/unenc recv", ctx.RootDataset)
|
||||
encRecvFS := fmt.Sprintf("%s/enc recv", ctx.RootDataset)
|
||||
|
||||
src := makeDummyDataSnapshots(ctx, sendFS)
|
||||
|
||||
unencS := makeResumeSituation(ctx, src, unencRecvFS, zfs.ZFSSendArgs{
|
||||
FS: sendFS,
|
||||
To: src.snapA,
|
||||
Encrypted: &zfs.NilBool{B: false}, // !
|
||||
}, zfs.RecvOptions{
|
||||
RollbackAndForceRecv: false,
|
||||
SavePartialRecvState: true,
|
||||
})
|
||||
|
||||
encS := makeResumeSituation(ctx, src, encRecvFS, zfs.ZFSSendArgs{
|
||||
FS: sendFS,
|
||||
To: src.snapA,
|
||||
Encrypted: &zfs.NilBool{B: true}, // !
|
||||
}, zfs.RecvOptions{
|
||||
RollbackAndForceRecv: false,
|
||||
SavePartialRecvState: true,
|
||||
})
|
||||
|
||||
// threat model: use of a crafted resume token that requests an unencrypted send
|
||||
// but send args require encrypted send
|
||||
{
|
||||
var maliciousSend zfs.ZFSSendArgs = encS.sendArgs
|
||||
maliciousSend.ResumeToken = unencS.recvErrDecoded.ResumeTokenRaw
|
||||
|
||||
stream, err := zfs.ZFSSend(ctx, maliciousSend)
|
||||
if err == nil {
|
||||
defer stream.Close()
|
||||
}
|
||||
require.Nil(ctx, stream)
|
||||
require.Error(ctx, err)
|
||||
ctx.Logf("send err: %T %s", err, err)
|
||||
validationErr, ok := err.(*zfs.ZFSSendArgsValidationError)
|
||||
require.True(ctx, ok)
|
||||
require.Equal(ctx, validationErr.What, zfs.ZFSSendArgsResumeTokenMismatch)
|
||||
ctx.Logf("%s", validationErr)
|
||||
|
||||
mismatchError, ok := validationErr.Msg.(*zfs.ZFSSendArgsResumeTokenMismatchError)
|
||||
require.True(ctx, ok)
|
||||
require.Equal(ctx, mismatchError.What, zfs.ZFSSendArgsResumeTokenMismatchEncryptionNotSet)
|
||||
}
|
||||
|
||||
// threat model: use of a crafted resume token that requests an encryped send
|
||||
// but send args require unencrypted send
|
||||
{
|
||||
var maliciousSend zfs.ZFSSendArgs = unencS.sendArgs
|
||||
maliciousSend.ResumeToken = encS.recvErrDecoded.ResumeTokenRaw
|
||||
|
||||
stream, err := zfs.ZFSSend(ctx, maliciousSend)
|
||||
if err == nil {
|
||||
defer stream.Close()
|
||||
}
|
||||
require.Nil(ctx, stream)
|
||||
require.Error(ctx, err)
|
||||
ctx.Logf("send err: %T %s", err, err)
|
||||
validationErr, ok := err.(*zfs.ZFSSendArgsValidationError)
|
||||
require.True(ctx, ok)
|
||||
require.Equal(ctx, validationErr.What, zfs.ZFSSendArgsResumeTokenMismatch)
|
||||
ctx.Logf("%s", validationErr)
|
||||
|
||||
mismatchError, ok := validationErr.Msg.(*zfs.ZFSSendArgsResumeTokenMismatchError)
|
||||
require.True(ctx, ok)
|
||||
require.Equal(ctx, mismatchError.What, zfs.ZFSSendArgsResumeTokenMismatchEncryptionSet)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func SendArgsValidationResumeTokenDifferentFilesystemForbidden(ctx *platformtest.Context) {
|
||||
|
||||
supported, err := zfs.EncryptionCLISupported(ctx)
|
||||
check(err)
|
||||
if !supported {
|
||||
ctx.SkipNow()
|
||||
}
|
||||
supported, err = zfs.ResumeSendSupported()
|
||||
check(err)
|
||||
if !supported {
|
||||
ctx.SkipNow()
|
||||
}
|
||||
|
||||
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
||||
DESTROYROOT
|
||||
CREATEROOT
|
||||
+ "send er1"
|
||||
+ "send er2"
|
||||
`)
|
||||
|
||||
sendFS1 := fmt.Sprintf("%s/send er1", ctx.RootDataset)
|
||||
sendFS2 := fmt.Sprintf("%s/send er2", ctx.RootDataset)
|
||||
recvFS := fmt.Sprintf("%s/unenc recv", ctx.RootDataset)
|
||||
|
||||
src1 := makeDummyDataSnapshots(ctx, sendFS1)
|
||||
src2 := makeDummyDataSnapshots(ctx, sendFS2)
|
||||
|
||||
rs := makeResumeSituation(ctx, src1, recvFS, zfs.ZFSSendArgs{
|
||||
FS: sendFS1,
|
||||
To: src1.snapA,
|
||||
Encrypted: &zfs.NilBool{B: false},
|
||||
}, zfs.RecvOptions{
|
||||
RollbackAndForceRecv: false,
|
||||
SavePartialRecvState: true,
|
||||
})
|
||||
|
||||
// threat model: forged resume token tries to steal a full send of snapA on fs2 by
|
||||
// presenting a resume token for full send of snapA on fs1
|
||||
var maliciousSend zfs.ZFSSendArgs = zfs.ZFSSendArgs{
|
||||
FS: sendFS2,
|
||||
To: &zfs.ZFSSendArgVersion{
|
||||
RelName: src2.snapA.RelName,
|
||||
GUID: src2.snapA.GUID,
|
||||
},
|
||||
Encrypted: &zfs.NilBool{B: false},
|
||||
ResumeToken: rs.recvErrDecoded.ResumeTokenRaw,
|
||||
}
|
||||
|
||||
stream, err := zfs.ZFSSend(ctx, maliciousSend)
|
||||
if err == nil {
|
||||
defer stream.Close()
|
||||
}
|
||||
require.Nil(ctx, stream)
|
||||
require.Error(ctx, err)
|
||||
ctx.Logf("send err: %T %s", err, err)
|
||||
validationErr, ok := err.(*zfs.ZFSSendArgsValidationError)
|
||||
require.True(ctx, ok)
|
||||
require.Equal(ctx, validationErr.What, zfs.ZFSSendArgsResumeTokenMismatch)
|
||||
ctx.Logf("%s", validationErr)
|
||||
|
||||
mismatchError, ok := validationErr.Msg.(*zfs.ZFSSendArgsResumeTokenMismatchError)
|
||||
require.True(ctx, ok)
|
||||
require.Equal(ctx, mismatchError.What, zfs.ZFSSendArgsResumeTokenMismatchFilesystem)
|
||||
}
|
||||
@@ -18,4 +18,17 @@ var Cases = []Case{
|
||||
UndestroyableSnapshotParsing,
|
||||
GetNonexistent,
|
||||
ReplicationCursor,
|
||||
RollupReleaseIncluding,
|
||||
RollupReleaseExcluding,
|
||||
RollupReleaseMostRecentIsBookmarkWithoutSnapshot,
|
||||
RollupReleaseMostRecentIsBookmarkAndSnapshotStillExists,
|
||||
RollupReleaseMostRecentDoesntExist,
|
||||
IdempotentHold,
|
||||
IdempotentBookmark,
|
||||
IdempotentDestroy,
|
||||
ResumeTokenParsing,
|
||||
ResumableRecvAndTokenHandling,
|
||||
SendArgsValidationEncryptedSendOfUnencryptedDatasetForbidden,
|
||||
SendArgsValidationResumeTokenEncryptionMismatchForbidden,
|
||||
SendArgsValidationResumeTokenDifferentFilesystemForbidden,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user