Remove snapshot test suite as a parallel test runner
The testsuite alters global state by setting the umask, avoid running the testsuite in parallel and move umask manipulation to the test suite level to individual tests may run in parallel. Added better error messaging and handling. Removed reliance on testing object for handling cleanup failure. When a cleanup error occurred, it would fail the test but the log would get skipped. With this change the failure will show up for the running test. Update test unmounting to set the detach flag, avoiding races with btrfs which may see the device as busy when attempting to unmount. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -21,11 +21,11 @@ func applyToMounts(m []mount.Mount, work string, a fstest.Applier) (err error) {
|
||||
defer os.RemoveAll(td)
|
||||
|
||||
if err := mount.MountAll(m, td); err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "failed to mount")
|
||||
}
|
||||
defer func() {
|
||||
if err1 := mount.UnmountAll(td, 0); err == nil {
|
||||
err = err1
|
||||
if err1 := mount.UnmountAll(td, umountflags); err == nil {
|
||||
err = errors.Wrap(err1, "failed to unmount")
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -40,26 +40,30 @@ func createSnapshot(ctx context.Context, sn snapshot.Snapshotter, parent, work s
|
||||
|
||||
m, err := sn.Prepare(ctx, prepare, parent)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", errors.Wrap(err, "failed to prepare snapshot")
|
||||
}
|
||||
|
||||
if err := applyToMounts(m, work, a); err != nil {
|
||||
return "", err
|
||||
return "", errors.Wrap(err, "failed to apply")
|
||||
}
|
||||
|
||||
if err := sn.Commit(ctx, n, prepare); err != nil {
|
||||
return "", err
|
||||
return "", errors.Wrap(err, "failed to commit")
|
||||
}
|
||||
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func checkSnapshot(ctx context.Context, sn snapshot.Snapshotter, work, name, check string) error {
|
||||
func checkSnapshot(ctx context.Context, sn snapshot.Snapshotter, work, name, check string) (err error) {
|
||||
td, err := ioutil.TempDir(work, "check")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create temp dir")
|
||||
}
|
||||
defer os.RemoveAll(td)
|
||||
defer func() {
|
||||
if err1 := os.RemoveAll(td); err == nil {
|
||||
err = errors.Wrapf(err1, "failed to remove temporary directory %s", td)
|
||||
}
|
||||
}()
|
||||
|
||||
view := fmt.Sprintf("%s-view", name)
|
||||
m, err := sn.View(ctx, view, name)
|
||||
@@ -73,10 +77,10 @@ func checkSnapshot(ctx context.Context, sn snapshot.Snapshotter, work, name, che
|
||||
}()
|
||||
|
||||
if err := mount.MountAll(m, td); err != nil {
|
||||
return errors.Wrap(err, "failed to unmount")
|
||||
return errors.Wrap(err, "failed to mount")
|
||||
}
|
||||
defer func() {
|
||||
if err1 := mount.UnmountAll(td, 0); err == nil {
|
||||
if err1 := mount.UnmountAll(td, umountflags); err == nil {
|
||||
err = errors.Wrap(err1, "failed to unmount view")
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user