Skip to content

Commit

Permalink
Test middleend Stats with non-AIP compliant names.
Browse files Browse the repository at this point in the history
Signed-off-by: Artsiom Koltun <[email protected]>
  • Loading branch information
artek-koltun authored and glimchb committed Jul 4, 2023
1 parent ce315c4 commit c2247af
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
8 changes: 8 additions & 0 deletions pkg/middleend/encryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,14 @@ func TestMiddleEnd_EncryptedVolumeStats(t *testing.T) {
fmt.Sprintf("unable to find key %v", server.ResourceIDToVolumeName("unknown-id")),
false,
},
"malformed name": {
"-ABC-DEF",
nil,
[]string{""},
codes.Unknown,
fmt.Sprintf("segment '%s': not a valid DNS name", "-ABC-DEF"),
false,
},
}

// run tests
Expand Down
12 changes: 6 additions & 6 deletions pkg/middleend/qos.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ func (s *Server) QosVolumeStats(_ context.Context, in *pb.QosVolumeStatsRequest)
log.Printf("error: %v", err)
return nil, err
}
// Validate that a resource name conforms to the restrictions outlined in AIP-122.
// if err := resourcename.Validate(in.VolumeId.Value); err != nil {
// log.Printf("error: %v", err)
// return nil, err
// }
// fetch object from the database
if in.VolumeId == nil || in.VolumeId.Value == "" {
return nil, status.Error(codes.InvalidArgument, "volume_id cannot be empty")
}
// Validate that a resource name conforms to the restrictions outlined in AIP-122.
if err := resourcename.Validate(in.VolumeId.Value); err != nil {
log.Printf("error: %v", err)
return nil, err
}
// fetch object from the database
volume, ok := s.volumes.qosVolumes[in.VolumeId.Value]
if !ok {
err := status.Errorf(codes.NotFound, "unable to find key %s", in.VolumeId.Value)
Expand Down
8 changes: 8 additions & 0 deletions pkg/middleend/qos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,14 @@ func TestMiddleEnd_QosVolumeStats(t *testing.T) {
errMsg: "",
start: true,
},
"malformed name": {
in: &_go.ObjectKey{Value: "-ABC-DEF"},
out: nil,
spdk: []string{""},
errCode: codes.Unknown,
errMsg: fmt.Sprintf("segment '%s': not a valid DNS name", "-ABC-DEF"),
start: false,
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
Expand Down

0 comments on commit c2247af

Please sign in to comment.