Skip to content

Commit

Permalink
test(nvme): check nqn, model and serial
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
  • Loading branch information
glimchb committed Sep 22, 2023
1 parent 81e7d51 commit 3981de4
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions pkg/frontend/nvme_subsystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package frontend
import (
"fmt"
"reflect"
"strings"
"testing"

"google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -151,6 +152,54 @@ func TestFrontEnd_CreateNvmeSubsystem(t *testing.T) {
"missing required field: nvme_subsystem",
false,
},
"too long nqn field": {
id: testControllerID,
in: &pb.NvmeSubsystem{
Name: testSubsystemName,
Spec: &pb.NvmeSubsystemSpec{
Nqn: strings.Repeat("a", 224),
SerialNumber: strings.Repeat("b", 20),
ModelNumber: strings.Repeat("c", 40),
},
},
out: nil,
spdk: []string{},
errCode: codes.InvalidArgument,
errMsg: fmt.Sprintf("Nqn value (%s) is too long, have to be between 1 and %d", strings.Repeat("a", 224), 223),
exist: false,
},
"too long model field": {
id: testControllerID,
in: &pb.NvmeSubsystem{
Name: testSubsystemName,
Spec: &pb.NvmeSubsystemSpec{
Nqn: strings.Repeat("a", 223),
SerialNumber: strings.Repeat("b", 20),
ModelNumber: strings.Repeat("c", 41),
},
},
out: nil,
spdk: []string{},
errCode: codes.InvalidArgument,
errMsg: fmt.Sprintf("ModelNumber value (%s) is too long, have to be between 1 and %d", strings.Repeat("c", 41), 40),
exist: false,
},
"too long serial field": {
id: testControllerID,
in: &pb.NvmeSubsystem{
Name: testSubsystemName,
Spec: &pb.NvmeSubsystemSpec{
Nqn: strings.Repeat("a", 223),
SerialNumber: strings.Repeat("b", 21),
ModelNumber: strings.Repeat("c", 40),
},
},
out: nil,
spdk: []string{},
errCode: codes.InvalidArgument,
errMsg: fmt.Sprintf("SerialNumber value (%s) is too long, have to be between 1 and %d", strings.Repeat("b", 21), 20),
exist: false,
},
}

// run tests
Expand Down

0 comments on commit 3981de4

Please sign in to comment.