Skip to content

Commit

Permalink
fix: TestCLeanUpQgroupsCI test
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabil-Salah committed Dec 4, 2024
1 parent ebe8ea7 commit 59eaa08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions pkg/storage/filesystem/btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ func (p *btrfsPool) Usage() (usage Usage, err error) {

usage.Size = p.device.Size

fmt.Println("we here")
for _, volume := range volumes {
fmt.Printf("%v\n", volume)
vol, err := volume.Usage()
if err != nil {
return Usage{}, errors.Wrapf(err, "failed to calculate volume '%s' usage", volume.Path())
Expand Down
13 changes: 6 additions & 7 deletions pkg/storage/filesystem/btrfs_ci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ func basePoolTest(t *testing.T, pool Pool) {

assert.Equal(t, path.Join("/mnt", pool.Name(), "subvol1"), volume.Path())
})
defer func() {
err := pool.RemoveVolume("subvol1")
require.NoError(t, err)
}()


t.Run("test list volumes", func(t *testing.T) {
volumes, err := pool.Volumes()
Expand Down Expand Up @@ -190,7 +187,7 @@ func basePoolTest(t *testing.T, pool Pool) {
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) {
Expand Down Expand Up @@ -259,7 +256,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)]
Expand All @@ -272,5 +271,5 @@ func TestCLeanUpQgroupsCI(t *testing.T) {
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")
}

0 comments on commit 59eaa08

Please sign in to comment.