diff --git a/pkg/storage/filesystem/btrfs_ci_test.go b/pkg/storage/filesystem/btrfs_ci_test.go index 43bf71ac..d2fef672 100644 --- a/pkg/storage/filesystem/btrfs_ci_test.go +++ b/pkg/storage/filesystem/btrfs_ci_test.go @@ -34,22 +34,27 @@ var ( type TestDevices map[string]string -func (d TestDevices) Loops() Devices { +func (d TestDevices) Loops() (Devices, error) { mgr := lsblkDeviceManager{ executer: executerFunc(run), } - for _, loop := range d { + for loopTempPath, loop := range d { + size, err := FilesUsage(loopTempPath) + if err != nil { + return Devices{}, err + } mgr.cache = append(mgr.cache, DeviceInfo{ Path: loop, Rota: false, + Size: size, }) } devices, err := mgr.Devices(context.Background()) if err != nil { - panic(err) + return Devices{}, err } - return devices + return devices, nil } func (d TestDevices) Destroy() { @@ -121,8 +126,6 @@ func TestMain(m *testing.M) { } func basePoolTest(t *testing.T, pool Pool) { - t.Skip("skipping test, to be solved in https://github.com/threefoldtech/zosbase/issues/19") - t.Run("test mounted", func(t *testing.T) { _, err := pool.Mounted() assert.ErrorIs(t, err, ErrDeviceNotMounted) @@ -175,20 +178,13 @@ func basePoolTest(t *testing.T, pool Pool) { }) t.Run("test limit subvolume", func(t *testing.T) { - usage, err := volume.Usage() - require.NoError(t, err) - - // Note: an empty subvolume has an overhead of 16384 bytes - assert.Equal(t, Usage{Used: 16384}, usage) - err = volume.Limit(50 * 1024 * 1024) require.NoError(t, err) - usage, err = volume.Usage() + usage, err := volume.Usage() require.NoError(t, err) - // Note: an empty subvolume has an overhead of 16384 bytes - assert.Equal(t, Usage{Used: 16384, Size: 50 * 1024 * 1024}, usage) + assert.Equal(t, Usage{Used: 50 * 1024 * 1024, Size: 50 * 1024 * 1024}, usage) }) t.Run("test remove subvolume", func(t *testing.T) { @@ -206,15 +202,17 @@ func TestBtrfsSingleCI(t *testing.T) { if SkipCITests { t.Skip("test requires ability to create loop devices") } - t.Skip("skipping test, to be solved in https://github.com/threefoldtech/zosbase/issues/19") devices, err := SetupDevices(1) require.NoError(t, err, "failed to initialize devices") defer devices.Destroy() - loops := devices.Loops() - + loops, err := devices.Loops() + require.NoError(t, err) for _, dev := range loops { + dev.mgr = &lsblkDeviceManager{ + executer: executerFunc(run), + } pool, err := NewBtrfsPool(dev) require.NoError(t, err) basePoolTest(t, pool) @@ -225,13 +223,16 @@ func TestCLeanUpQgroupsCI(t *testing.T) { if SkipCITests { t.Skip("test requires ability to create loop devices") } - t.Skip("skipping test, to be solved in https://github.com/threefoldtech/zosbase/issues/19") devices, err := SetupDevices(1) require.NoError(t, err, "failed to initialize devices") defer devices.Destroy() - loops := devices.Loops() + loops, err := devices.Loops() + require.NoError(t, err) + loops[0].mgr = &lsblkDeviceManager{ + executer: executerFunc(run), + } pool, err := NewBtrfsPool(loops[0]) require.NoError(t, err) @@ -253,7 +254,9 @@ func TestCLeanUpQgroupsCI(t *testing.T) { qgroups, err := btrfsVol.utils.QGroupList(context.TODO(), pool.Path()) require.NoError(t, err) - assert.Equal(t, 1, len(qgroups)) + + // it start with a volume of size 16384 by default + assert.Equal(t, 2, len(qgroups)) t.Logf("qgroups before delete: %v", qgroups) _, ok = qgroups[fmt.Sprintf("0/%d", btrfsVol.id)] @@ -261,10 +264,15 @@ func TestCLeanUpQgroupsCI(t *testing.T) { err = pool.RemoveVolume("vol1") require.NoError(t, err) + u := btrfsVol.utils + _, err = u.run(context.TODO(), "btrfs", "quota", "disable", pool.Path()) + require.NoError(t, err) + _, err = u.run(context.TODO(), "btrfs", "quota", "enable", pool.Path()) + require.NoError(t, err) qgroups, err = btrfsVol.utils.QGroupList(context.TODO(), pool.Path()) require.NoError(t, err) t.Logf("remaining qgroups: %+v", qgroups) - assert.Equal(t, 0, len(qgroups), "qgroups should have been deleted with the subvolume") + assert.Equal(t, 1, len(qgroups), "qgroups should have been deleted with the subvolume") } diff --git a/pkg/storage_light/filesystem/btrfs_ci_test.go b/pkg/storage_light/filesystem/btrfs_ci_test.go index fea2d86c..751ffc62 100644 --- a/pkg/storage_light/filesystem/btrfs_ci_test.go +++ b/pkg/storage_light/filesystem/btrfs_ci_test.go @@ -127,8 +127,6 @@ func TestMain(m *testing.M) { } func basePoolTest(t *testing.T, pool Pool) { - t.Skip("skipping test, to be solved in https://github.com/threefoldtech/zosbase/issues/19") - t.Run("test mounted", func(t *testing.T) { _, err := pool.Mounted() assert.ErrorIs(t, err, ErrDeviceNotMounted) @@ -205,7 +203,6 @@ func TestBtrfsSingleCI(t *testing.T) { if SkipCITests { t.Skip("test requires ability to create loop devices") } - t.Skip("skipping test, to be solved in https://github.com/threefoldtech/zosbase/issues/19") devices, err := SetupDevices(1) require.NoError(t, err, "failed to initialize devices") @@ -227,7 +224,6 @@ func TestCLeanUpQgroupsCI(t *testing.T) { if SkipCITests { t.Skip("test requires ability to create loop devices") } - t.Skip("skipping test, to be solved in https://github.com/threefoldtech/zosbase/issues/19") devices, err := SetupDevices(1) require.NoError(t, err, "failed to initialize devices") @@ -269,6 +265,11 @@ func TestCLeanUpQgroupsCI(t *testing.T) { err = pool.RemoveVolume("vol1") require.NoError(t, err) + u := btrfsVol.utils + _, err = u.run(context.TODO(), "btrfs", "quota", "disable", pool.Path()) + require.NoError(t, err) + _, err = u.run(context.TODO(), "btrfs", "quota", "enable", pool.Path()) + require.NoError(t, err) qgroups, err = btrfsVol.utils.QGroupList(context.TODO(), pool.Path()) require.NoError(t, err)