2019-10-14 19:51:10 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCSIVolumeClaim(t *testing.T) {
|
2020-02-03 16:59:00 +00:00
|
|
|
vol := NewCSIVolume("", 0)
|
2020-01-08 22:27:43 +00:00
|
|
|
vol.AccessMode = CSIVolumeAccessModeMultiNodeSingleWriter
|
2020-03-03 15:59:58 +00:00
|
|
|
vol.Schedulable = true
|
2019-10-14 19:51:10 +00:00
|
|
|
|
|
|
|
alloc := &Allocation{ID: "al"}
|
|
|
|
|
|
|
|
vol.ClaimRead(alloc)
|
2020-01-08 22:27:43 +00:00
|
|
|
require.True(t, vol.CanReadOnly())
|
2019-10-14 19:51:10 +00:00
|
|
|
require.True(t, vol.CanWrite())
|
2020-01-08 22:27:43 +00:00
|
|
|
require.True(t, vol.ClaimRead(alloc))
|
2019-10-14 19:51:10 +00:00
|
|
|
|
|
|
|
vol.ClaimWrite(alloc)
|
|
|
|
require.True(t, vol.CanReadOnly())
|
|
|
|
require.False(t, vol.CanWrite())
|
|
|
|
require.False(t, vol.ClaimWrite(alloc))
|
|
|
|
|
|
|
|
vol.ClaimRelease(alloc)
|
|
|
|
require.True(t, vol.CanReadOnly())
|
|
|
|
require.True(t, vol.CanWrite())
|
|
|
|
}
|