72430a4e62
Following the new volumewatcher in #7794 and performance improvements to it that landed afterwards, there's no particular reason we should be threading claim releases through the GC eval rather than writing an empty `CSIVolumeClaimRequest` with the mode set to `CSIVolumeClaimRelease`, just as the GC evaluation would do. Also, by batching up these raft messages, we can reduce the amount of raft writes by 1 and cross-server RPCs by 1 per volume we release claims on.
35 lines
901 B
Go
35 lines
901 B
Go
package nomad
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCSI_Batcher(t *testing.T) {
|
|
t.Parallel()
|
|
srv, shutdown := TestServer(t, func(c *Config) {
|
|
c.NumSchedulers = 0 // Prevent automatic dequeue
|
|
})
|
|
defer shutdown()
|
|
|
|
batcher := newCSIBatchRelease(srv, nil, 5)
|
|
|
|
batcher.add("vol0", "global")
|
|
batcher.add("vol", "0global")
|
|
batcher.add("vol1", "global")
|
|
batcher.add("vol1", "global")
|
|
batcher.add("vol2", "global")
|
|
batcher.add("vol2", "other")
|
|
batcher.add("vol3", "global")
|
|
batcher.add("vol4", "global")
|
|
batcher.add("vol5", "global")
|
|
batcher.add("vol6", "global")
|
|
|
|
require.Len(t, batcher.batches, 2)
|
|
require.Len(t, batcher.batches[0].Claims, 5, "first batch")
|
|
require.Equal(t, batcher.batches[0].Claims[4].VolumeID, "vol2")
|
|
require.Equal(t, batcher.batches[0].Claims[4].Namespace, "other")
|
|
require.Len(t, batcher.batches[1].Claims, 4, "second batch")
|
|
}
|