Skip to content

Commit

Permalink
Add checks for capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Vest committed Dec 14, 2023
1 parent ded8835 commit 9a395cb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/linode-bs/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"reflect"
"testing"
"time"

"github.com/container-storage-interface/spec/lib/go/csi"
linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client"
"github.com/linode/linode-blockstorage-csi-driver/pkg/metadata"
mountmanager "github.com/linode/linode-blockstorage-csi-driver/pkg/mount-manager"
Expand Down Expand Up @@ -74,6 +76,32 @@ func TestDriverSuite(t *testing.T) {
t.Fatalf("Failed to setup Linode Driver: %v", err)
}

// Validate Capabilities are as expected
wantControllerCaps := []*csi.ControllerServiceCapability{}
for _, cscap := range controllerCapabilities() {
wantControllerCaps = append(wantControllerCaps, NewControllerServiceCapability(cscap))
}

if !reflect.DeepEqual(linodeDriver.cscap, wantControllerCaps) {
t.Errorf("controller capabilities are not as expected, got:\n%v\nwant:%v", linodeDriver.cscap, wantControllerCaps)
}

wantNodeCaps := []*csi.NodeServiceCapability{}
for _, nscap := range nodeCapabilities() {
wantNodeCaps = append(wantNodeCaps, NewNodeServiceCapability(nscap))
}
if !reflect.DeepEqual(linodeDriver.nscap, wantNodeCaps) {
t.Errorf("node capabilities are not as expected, got:\n%v\nwant:%v", linodeDriver.nscap, wantNodeCaps)
}

wantVolumeCapAccessMode := []*csi.VolumeCapability_AccessMode{}
for _, vcap := range volumeCapabilitiesAccessMode() {
wantVolumeCapAccessMode = append(wantVolumeCapAccessMode, NewVolumeCapabilityAccessMode(vcap))
}
if !reflect.DeepEqual(linodeDriver.vcap, wantVolumeCapAccessMode) {
t.Errorf("volume capabilities are not as expected, got:\n%v\nwant:%v", linodeDriver.vcap, volumeCapabilitiesAccessMode())
}

go linodeDriver.Run(endpoint)

// TODO: fix sanity checks for e2e, disable for ci
Expand Down

0 comments on commit 9a395cb

Please sign in to comment.