open-nomad/nomad/structs/csi_test.go
Lang Martin 369b0e54b9 csi: volumes use Schedulable rather than Healthy (#7250)
* structs: add ControllerRequired, volume.Name, no plug.Type

* structs: Healthy -> Schedulable

* state_store: Healthy -> Schedulable

* api: add ControllerRequired to api data types

* api: copy csi structs changes

* nomad/structs/csi: include name and external id

* api/csi: include Name and ExternalID

* nomad/structs/csi: comments for the 3 ids
2020-03-23 13:58:30 -04:00

30 lines
627 B
Go

package structs
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCSIVolumeClaim(t *testing.T) {
vol := NewCSIVolume("", 0)
vol.AccessMode = CSIVolumeAccessModeMultiNodeSingleWriter
vol.Schedulable = true
alloc := &Allocation{ID: "al"}
vol.ClaimRead(alloc)
require.True(t, vol.CanReadOnly())
require.True(t, vol.CanWrite())
require.True(t, vol.ClaimRead(alloc))
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())
}