From d367bc1cdfb73d571ef064290eea96a0b4d97cc0 Mon Sep 17 00:00:00 2001 From: SK Date: Thu, 26 Nov 2026 00:29:21 +0000 Subject: [PATCH] Test that deleting a volume releases its storage DeleteVolume subtracts the volume's size from the cached total that TotalVolumeBytes reports to disk capacity tracking, but no test checked that the total goes back down after a delete. --- lib/volumes/manager_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/volumes/manager_test.go b/lib/volumes/manager_test.go index cc3baac49..15f77949a 100644 --- a/lib/volumes/manager_test.go +++ b/lib/volumes/manager_test.go @@ -314,6 +314,30 @@ func TestDeleteVolume_RejectIfAttached(t *testing.T) { assert.ErrorIs(t, err, ErrInUse) } +func TestDeleteVolume_ReleasesStorage(t *testing.T) { + manager, _, cleanup := setupTestManager(t) + defer cleanup() + ctx := context.Background() + + vol, err := manager.CreateVolume(ctx, CreateVolumeRequest{ + Name: "test-vol", + SizeGb: 1, + }) + require.NoError(t, err) + + total, err := manager.TotalVolumeBytes(ctx) + require.NoError(t, err) + require.Equal(t, int64(1024*1024*1024), total) + + require.NoError(t, manager.DeleteVolume(ctx, vol.Id)) + + // The running total feeds disk capacity tracking, so a deleted + // volume must stop counting against it. + total, err = manager.TotalVolumeBytes(ctx) + require.NoError(t, err) + assert.Equal(t, int64(0), total) +} + func TestMultiAttach_ConcurrentAttachments(t *testing.T) { manager, _, cleanup := setupTestManager(t) defer cleanup()