aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/driver/controllerserver.go27
-rw-r--r--pkg/driver/nodeserver.go14
-rw-r--r--test/sanity/params.yaml0
-rw-r--r--test/test.sh22
4 files changed, 60 insertions, 3 deletions
diff --git a/pkg/driver/controllerserver.go b/pkg/driver/controllerserver.go
index 0533f07..b032542 100644
--- a/pkg/driver/controllerserver.go
+++ b/pkg/driver/controllerserver.go
@@ -13,7 +13,6 @@ import (
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"google.golang.org/grpc/codes"
- _ "google.golang.org/grpc/resolver/passthrough"
"google.golang.org/grpc/status"
)
@@ -71,7 +70,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
volumeId := req.VolumeId
// Check arguments
- if volumeId == "" {
+ if len(volumeId) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request")
}
@@ -89,10 +88,34 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
}
func (cs *ControllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) {
+
+ // Check arguments
+ volumeId := req.VolumeId
+ if len(volumeId) == 0 {
+ return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request")
+ }
+
+ volumePath := req.GetVolumeContext()["volumePath"]
+ if len(volumePath) == 0 {
+ return nil, status.Error(codes.InvalidArgument, "Volume path missing in request")
+ }
+
+ nodeId := req.NodeId
+ if len(nodeId) == 0 {
+ return nil, status.Error(codes.InvalidArgument, "Node ID missing in request")
+ }
+
return &csi.ControllerPublishVolumeResponse{}, nil
}
func (cs *ControllerServer) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) {
+
+ // Check arguments
+ volumeId := req.VolumeId
+ if len(volumeId) == 0 {
+ return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request")
+ }
+
return &csi.ControllerUnpublishVolumeResponse{}, nil
}
diff --git a/pkg/driver/nodeserver.go b/pkg/driver/nodeserver.go
index 3f18202..87fe6c5 100644
--- a/pkg/driver/nodeserver.go
+++ b/pkg/driver/nodeserver.go
@@ -9,7 +9,6 @@ import (
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/seaweedfs/seaweedfs/weed/glog"
"google.golang.org/grpc/codes"
- _ "google.golang.org/grpc/resolver/passthrough"
"google.golang.org/grpc/status"
"k8s.io/utils/mount"
)
@@ -238,7 +237,20 @@ func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
}
func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) {
+
volumeID := req.GetVolumeId()
+ if len(volumeID) == 0 {
+ return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request")
+ }
+
+ volumePath := req.GetVolumePath()
+ if len(volumePath) == 0 {
+ return nil, status.Error(codes.InvalidArgument, "Volume path missing in request")
+ }
+
+ // TODO Check if volume exists
+ // TODO Check if node exists
+
requiredBytes := req.GetCapacityRange().GetRequiredBytes()
glog.V(0).Infof("Node expand volume %s to %d bytes", volumeID, requiredBytes)
diff --git a/test/sanity/params.yaml b/test/sanity/params.yaml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/sanity/params.yaml
diff --git a/test/test.sh b/test/test.sh
new file mode 100644
index 0000000..c96e99b
--- /dev/null
+++ b/test/test.sh
@@ -0,0 +1,22 @@
+endpoint='unix:///tmp/csi.sock'
+
+# Install csi-sanity
+cd ..
+git clone https://github.com/kubernetes-csi/csi-test.git -b v5.0.0
+cd csi-test
+make install
+
+## Start Local weed server with filer
+weed server -dir=/tmp/seaweedfs/data -s3 -volume.max=100 -volume.port=8090
+
+## Run CSI Driver
+cd ../seaweedfs-csi-driver
+make build
+./_output/seaweedfs-csi-driver -endpoint="$endpoint" -alsologtostderr -v=5 -filer=localhost:8888
+
+# Run CSI Sanity Tests
+../csi-test/cmd/csi-sanity/csi-sanity\
+ --ginkgo.v\
+ --csi.testvolumeparameters="$(pwd)/test/sanity/params.yaml"\
+ --csi.endpoint="$endpoint"\
+ --ginkgo.skip="should not fail when requesting to create a volume with already existing name and same capacity|should fail when requesting to create a volume with already existing name and different capacity|should work|should fail when the requested volume does not exist|should return appropriate capabilities" \ No newline at end of file