Skip to content

Commit

Permalink
Test QoS on virtio-blk deletion.
Browse files Browse the repository at this point in the history
Signed-off-by: Artsiom Koltun <[email protected]>
  • Loading branch information
artek-koltun committed Jun 2, 2023
1 parent 9ce2048 commit a08e719
Showing 1 changed file with 51 additions and 9 deletions.
60 changes: 51 additions & 9 deletions pkg/frontend/blk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,15 @@ func TestFrontEnd_VirtioBlkStats(t *testing.T) {

func TestFrontEnd_DeleteVirtioBlk(t *testing.T) {
tests := map[string]struct {
in string
out *emptypb.Empty
spdk []string
errCode codes.Code
errMsg string
start bool
missing bool
in string
out *emptypb.Empty
spdk []string
errCode codes.Code
errMsg string
start bool
missing bool
existingController *pb.VirtioBlk
qosDeleteErr error
}{
"valid request with invalid SPDK response": {
testVirtioCtrlID,
Expand All @@ -547,6 +549,8 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) {
status.Convert(spdk.ErrUnexpectedSpdkCallResult).Message(),
true,
false,
&testVirtioCtrl,
nil,
},
"valid request with empty SPDK response": {
testVirtioCtrlID,
Expand All @@ -556,6 +560,8 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) {
fmt.Sprintf("vhost_delete_controller: %v", "EOF"),
true,
false,
&testVirtioCtrl,
nil,
},
"valid request with ID mismatch SPDK response": {
testVirtioCtrlID,
Expand All @@ -565,6 +571,8 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) {
fmt.Sprintf("vhost_delete_controller: %v", "json response ID mismatch"),
true,
false,
&testVirtioCtrl,
nil,
},
"valid request with error code from SPDK response": {
testVirtioCtrlID,
Expand All @@ -574,6 +582,8 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) {
fmt.Sprintf("vhost_delete_controller: %v", "json response error: myopierr"),
true,
false,
&testVirtioCtrl,
nil,
},
"valid request with valid SPDK response": {
testVirtioCtrlID,
Expand All @@ -583,6 +593,8 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) {
"",
true,
false,
&testVirtioCtrl,
nil,
},
"valid request with unknown key": {
"unknown-id",
Expand All @@ -592,6 +604,8 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) {
fmt.Sprintf("unable to find key %v", "unknown-id"),
false,
false,
&testVirtioCtrl,
nil,
},
"unknown key with missing allowed": {
"unknown-id",
Expand All @@ -601,16 +615,44 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) {
"",
false,
true,
&testVirtioCtrl,
nil,
},
"valid request with valid SPDK response and max QoS limit virtio-blk": {
testVirtioCtrlID,
&emptypb.Empty{},
[]string{`{"id":%d,"error":{"code":0,"message":""},"result":true}`},
codes.OK,
"",
true,
false,
&testVirtioCtrlWithQos,
nil,
},
"valid request with valid SPDK response and max QoS limit error": {
testVirtioCtrlID,
&emptypb.Empty{},
[]string{`{"id":%d,"error":{"code":0,"message":""},"result":true}`},
status.Convert(spdk.ErrFailedSpdkCall).Code(),
status.Convert(spdk.ErrFailedSpdkCall).Message(),
true,
false,
&testVirtioCtrlWithQos,
spdk.ErrFailedSpdkCall,
},
}

// run tests
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
testEnv := createTestEnvironment(tt.start, tt.spdk)
tt.existingController = server.ProtoClone(tt.existingController)

testEnv := createTestEnvironmentWithVirtioBlkQosProvider(
tt.start, tt.spdk, stubQosProvider{tt.qosDeleteErr},
)
defer testEnv.Close()

testEnv.opiSpdkServer.Virt.BlkCtrls[testVirtioCtrlID] = &testVirtioCtrl
testEnv.opiSpdkServer.Virt.BlkCtrls[testVirtioCtrlID] = tt.existingController

request := &pb.DeleteVirtioBlkRequest{Name: tt.in, AllowMissing: tt.missing}
response, err := testEnv.client.DeleteVirtioBlk(testEnv.ctx, request)
Expand Down

0 comments on commit a08e719

Please sign in to comment.