
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>
43 lines
1013 B
Go
43 lines
1013 B
Go
package metadata
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/boltdb/bolt"
|
|
"github.com/containerd/containerd/snapshot"
|
|
"github.com/containerd/containerd/snapshot/naive"
|
|
"github.com/containerd/containerd/snapshot/testsuite"
|
|
"github.com/containerd/containerd/testutil"
|
|
)
|
|
|
|
func newSnapshotter(ctx context.Context, root string) (snapshot.Snapshotter, func() error, error) {
|
|
naiveRoot := filepath.Join(root, "naive")
|
|
if err := os.Mkdir(naiveRoot, 0770); err != nil {
|
|
return nil, nil, err
|
|
}
|
|
snapshotter, err := naive.NewSnapshotter(naiveRoot)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
db, err := bolt.Open(filepath.Join(root, "metadata.db"), 0660, nil)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
sn := NewSnapshotter(db, "naive", snapshotter)
|
|
|
|
return sn, func() error {
|
|
return db.Close()
|
|
}, nil
|
|
}
|
|
|
|
func TestMetadata(t *testing.T) {
|
|
// Snapshot tests require mounting, still requires root
|
|
testutil.RequiresRoot(t)
|
|
testsuite.SnapshotterSuite(t, "Metadata", newSnapshotter)
|
|
}
|