From 95d0bd160c1a344c7a69d8918f1156b8790de609 Mon Sep 17 00:00:00 2001 From: Boris Glimcher Date: Tue, 26 Sep 2023 19:58:47 +0300 Subject: [PATCH] refactor: fix go imports after rename Signed-off-by: Boris Glimcher --- cmd/main.go | 6 ++-- go.mod | 6 ++-- go.sum | 6 ++++ pkg/frontend/frontend_test.go | 14 ++++----- pkg/frontend/nvme_controller.go | 8 ++--- pkg/frontend/nvme_controller_test.go | 44 +++++++++++++------------- pkg/frontend/nvme_namespace.go | 8 ++--- pkg/frontend/nvme_namespace_test.go | 44 +++++++++++++------------- pkg/frontend/nvme_subsystem.go | 8 ++--- pkg/frontend/nvme_subsystem_test.go | 46 ++++++++++++++-------------- pkg/frontend/virtio.go | 14 ++++----- pkg/frontend/virtio_test.go | 30 +++++++++--------- 12 files changed, 120 insertions(+), 114 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index c4b296f2..53ad879f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -22,7 +22,7 @@ import ( "github.com/opiproject/opi-spdk-bridge/pkg/backend" "github.com/opiproject/opi-spdk-bridge/pkg/frontend" "github.com/opiproject/opi-spdk-bridge/pkg/middleend" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" "github.com/opiproject/opi-strongswan-bridge/pkg/ipsec" pc "github.com/opiproject/opi-api/common/v1/gen/go" @@ -72,13 +72,13 @@ func runGrpcServer(grpcPort int, spdkAddress string, tlsFiles string) { log.Println("TLS files are not specified. Use insecure connection.") } else { log.Println("Use TLS certificate files:", tlsFiles) - config, err := server.ParseTLSFiles(tlsFiles) + config, err := utils.ParseTLSFiles(tlsFiles) if err != nil { log.Fatal("Failed to parse string with tls paths:", err) } log.Println("TLS config:", config) var option grpc.ServerOption - if option, err = server.SetupTLSCredentials(config); err != nil { + if option, err = utils.SetupTLSCredentials(config); err != nil { log.Fatal("Failed to setup TLS:", err) } serverOptions = append(serverOptions, option) diff --git a/go.mod b/go.mod index 2a03a2b1..8b1878cf 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/opiproject/gospdk v0.0.0-20230924031820-4b65d0851cb9 github.com/opiproject/opi-api v0.0.0-20230924031502-67b3821b62cf github.com/opiproject/opi-smbios-bridge v0.1.3-0.20230924050511-ed2cf72c2fbf - github.com/opiproject/opi-spdk-bridge 4f881a4be44a + github.com/opiproject/opi-spdk-bridge v0.1.2-0.20230926113920-4f881a4be44a github.com/opiproject/opi-strongswan-bridge v0.1.1 github.com/vektra/mockery/v2 v2.34.0 go.einride.tech/aip v0.62.0 @@ -199,9 +199,9 @@ require ( golang.org/x/sys v0.12.0 // indirect golang.org/x/term v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect - google.golang.org/genproto v0.0.0-20230911183012-2d3300fd4832 // indirect + google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230911183012-2d3300fd4832 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 84451ef7..b4710e9c 100644 --- a/go.sum +++ b/go.sum @@ -449,6 +449,8 @@ github.com/opiproject/opi-spdk-bridge v0.1.2-0.20230924130629-b3c17968b054 h1:aF github.com/opiproject/opi-spdk-bridge v0.1.2-0.20230924130629-b3c17968b054/go.mod h1:7CvulWmvsdwEsOSZJlSR9M/RWQ14WAIYjItFMEvevQw= github.com/opiproject/opi-spdk-bridge v0.1.2-0.20230924154020-88fe0ef01402 h1:+T55+Jrsnr/nTRziqPWgpDDzBBT+wKIeIfCJyhpxv3E= github.com/opiproject/opi-spdk-bridge v0.1.2-0.20230924154020-88fe0ef01402/go.mod h1:xhcQBZJYAtYIV5/7tac3xpiPlF55fmOasi6LwsZL1J4= +github.com/opiproject/opi-spdk-bridge v0.1.2-0.20230926113920-4f881a4be44a h1:cHMlf3p1sZhYfLPLOT4G9ZwptQg5f+GZnSnC58pDg0w= +github.com/opiproject/opi-spdk-bridge v0.1.2-0.20230926113920-4f881a4be44a/go.mod h1:BvAKawBYOGpU+SHR1apoytsFS42I+co6X92+DWzJE3M= github.com/opiproject/opi-strongswan-bridge v0.1.1 h1:Mz/8AtA0DD8O/H9jCsDw7wuVoWNiqgXICLsD10XWJ+g= github.com/opiproject/opi-strongswan-bridge v0.1.1/go.mod h1:ek3r3zLa9nOfb2a7ybdMJvb5BSGU9I17Xo38UMXfE+k= github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= @@ -986,10 +988,14 @@ google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20230911183012-2d3300fd4832 h1:/30npZKtUjXqju7ZA2MsvpkGKD4mQFtf+zPnZasABjg= google.golang.org/genproto v0.0.0-20230911183012-2d3300fd4832/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= +google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb h1:XFBgcDwm7irdHTbz4Zk2h7Mh+eis4nfJEFQFYzJzuIA= +google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= google.golang.org/genproto/googleapis/api v0.0.0-20230911183012-2d3300fd4832 h1:4E7rZzBdR5LmiZx6n47Dg4AjH8JLhMQWywsYqvXNLcs= google.golang.org/genproto/googleapis/api v0.0.0-20230911183012-2d3300fd4832/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb h1:Isk1sSH7bovx8Rti2wZK0UZF6oraBDK74uoyLEEVFN0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/pkg/frontend/frontend_test.go b/pkg/frontend/frontend_test.go index e5d51660..f9d0740f 100644 --- a/pkg/frontend/frontend_test.go +++ b/pkg/frontend/frontend_test.go @@ -20,7 +20,7 @@ import ( "github.com/opiproject/gospdk/spdk" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-spdk-bridge/pkg/frontend" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" ) type frontendClient struct { @@ -39,8 +39,8 @@ type testEnv struct { } func (e *testEnv) Close() { - server.CloseListener(e.ln) - server.CloseGrpcConnection(e.conn) + utils.CloseListener(e.ln) + utils.CloseGrpcConnection(e.conn) if err := os.RemoveAll(e.testSocket); err != nil { log.Fatal(err) } @@ -48,8 +48,8 @@ func (e *testEnv) Close() { func createTestEnvironment(spdkResponses []string) *testEnv { env := &testEnv{} - env.testSocket = server.GenerateSocketName("frontend") - env.ln, env.jsonRPC = server.CreateTestSpdkServer(env.testSocket, spdkResponses) + env.testSocket = utils.GenerateSocketName("frontend") + env.ln, env.jsonRPC = utils.CreateTestSpdkServer(env.testSocket, spdkResponses) env.opiSpdkServer = NewServer(env.jsonRPC) ctx := context.Background() @@ -124,7 +124,7 @@ var ( }, } testVirtioCtrlID = "virtio-blk-42" - testVirtioCtrlName = server.ResourceIDToVolumeName(testVirtioCtrlID) + testVirtioCtrlName = utils.ResourceIDToVolumeName(testVirtioCtrlID) testVirtioCtrl = pb.VirtioBlk{ PcieId: &pb.PciEndpoint{ PhysicalFunction: wrapperspb.Int32(42), @@ -134,7 +134,7 @@ var ( VolumeNameRef: "Malloc42", MaxIoQps: 1, } - checkGlobalTestProtoObjectsNotChanged = server.CheckTestProtoObjectsNotChanged( + checkGlobalTestProtoObjectsNotChanged = utils.CheckTestProtoObjectsNotChanged( &testSubsystem, &testController, &testNamespace, diff --git a/pkg/frontend/nvme_controller.go b/pkg/frontend/nvme_controller.go index edbf22af..b4610d7b 100644 --- a/pkg/frontend/nvme_controller.go +++ b/pkg/frontend/nvme_controller.go @@ -16,7 +16,7 @@ import ( pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-nvidia-bridge/pkg/models" "github.com/opiproject/opi-spdk-bridge/pkg/frontend" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" "github.com/google/uuid" "go.einride.tech/aip/fieldbehavior" @@ -85,7 +85,7 @@ func (s *Server) CreateNvmeController(_ context.Context, in *pb.CreateNvmeContro log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - response := server.ProtoClone(in.NvmeController) + response := utils.ProtoClone(in.NvmeController) response.Spec.NvmeControllerId = proto.Int32(int32(result.Cntlid)) response.Status = &pb.NvmeControllerStatus{Active: true} s.Controllers[in.NvmeController.Name] = response @@ -175,7 +175,7 @@ func (s *Server) ListNvmeControllers(_ context.Context, in *pb.ListNvmeControlle return nil, err } // fetch object from the database - size, offset, perr := server.ExtractPagination(in.PageSize, in.PageToken, s.Pagination) + size, offset, perr := utils.ExtractPagination(in.PageSize, in.PageToken, s.Pagination) if perr != nil { log.Printf("error: %v", perr) return nil, perr @@ -195,7 +195,7 @@ func (s *Server) ListNvmeControllers(_ context.Context, in *pb.ListNvmeControlle log.Printf("Received from SPDK: %v", result) token, hasMoreElements := "", false log.Printf("Limiting result len(%d) to [%d:%d]", len(result), offset, size) - result, hasMoreElements = server.LimitPagination(result, offset, size) + result, hasMoreElements = utils.LimitPagination(result, offset, size) if hasMoreElements { token = uuid.New().String() s.Pagination[token] = offset + size diff --git a/pkg/frontend/nvme_controller_test.go b/pkg/frontend/nvme_controller_test.go index 85b5c2e3..c9e72f55 100644 --- a/pkg/frontend/nvme_controller_test.go +++ b/pkg/frontend/nvme_controller_test.go @@ -20,7 +20,7 @@ import ( pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-spdk-bridge/pkg/frontend" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" ) func TestFrontEnd_CreateNvmeController(t *testing.T) { @@ -41,7 +41,7 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) { NvmeControllerId: proto.Int32(17), } t.Cleanup(checkGlobalTestProtoObjectsNotChanged(t, t.Name())) - t.Cleanup(server.CheckTestProtoObjectsNotChanged(spec, controllerSpec)(t, t.Name())) + t.Cleanup(utils.CheckTestProtoObjectsNotChanged(spec, controllerSpec)(t, t.Name())) tests := map[string]struct { id string @@ -197,16 +197,16 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName if tt.exist { - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName } if tt.out != nil { - tt.out = server.ProtoClone(tt.out) + tt.out = utils.ProtoClone(tt.out) tt.out.Name = testControllerName } @@ -321,11 +321,11 @@ func TestFrontEnd_DeleteNvmeController(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.DeleteNvmeControllerRequest{Name: tt.in, AllowMissing: tt.missing} @@ -411,11 +411,11 @@ func TestFrontEnd_UpdateNvmeController(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.UpdateNvmeControllerRequest{NvmeController: tt.in, UpdateMask: tt.mask} @@ -610,18 +610,18 @@ func TestFrontEnd_ListNvmeControllers(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName testEnv.opiSpdkServer.Pagination["existing-pagination-token"] = 1 request := &pb.ListNvmeControllersRequest{Parent: tt.in, PageSize: tt.size, PageToken: tt.token} response, err := testEnv.client.ListNvmeControllers(testEnv.ctx, request) - if !server.EqualProtoSlices(response.GetNvmeControllers(), tt.out) { + if !utils.EqualProtoSlices(response.GetNvmeControllers(), tt.out) { t.Error("response: expected", tt.out, "received", response.GetNvmeControllers()) } @@ -724,11 +724,11 @@ func TestFrontEnd_GetNvmeController(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.GetNvmeControllerRequest{Name: tt.in} @@ -783,11 +783,11 @@ func TestFrontEnd_StatsNvmeController(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.StatsNvmeControllerRequest{Name: tt.in} diff --git a/pkg/frontend/nvme_namespace.go b/pkg/frontend/nvme_namespace.go index 02dc4927..49f98b21 100644 --- a/pkg/frontend/nvme_namespace.go +++ b/pkg/frontend/nvme_namespace.go @@ -17,7 +17,7 @@ import ( pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-nvidia-bridge/pkg/models" "github.com/opiproject/opi-spdk-bridge/pkg/frontend" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" "github.com/google/uuid" "go.einride.tech/aip/fieldbehavior" @@ -87,7 +87,7 @@ func (s *Server) CreateNvmeNamespace(_ context.Context, in *pb.CreateNvmeNamespa log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - response := server.ProtoClone(in.NvmeNamespace) + response := utils.ProtoClone(in.NvmeNamespace) response.Status = &pb.NvmeNamespaceStatus{PciState: 2, PciOperState: 1} s.Namespaces[in.NvmeNamespace.Name] = response return response, nil @@ -180,7 +180,7 @@ func (s *Server) ListNvmeNamespaces(_ context.Context, in *pb.ListNvmeNamespaces return nil, err } // fetch object from the database - size, offset, perr := server.ExtractPagination(in.PageSize, in.PageToken, s.Pagination) + size, offset, perr := utils.ExtractPagination(in.PageSize, in.PageToken, s.Pagination) if perr != nil { log.Printf("error: %v", perr) return nil, perr @@ -205,7 +205,7 @@ func (s *Server) ListNvmeNamespaces(_ context.Context, in *pb.ListNvmeNamespaces log.Printf("Received from SPDK: %v", result) token, hasMoreElements := "", false log.Printf("Limiting result len(%d) to [%d:%d]", len(result.Namespaces), offset, size) - result.Namespaces, hasMoreElements = server.LimitPagination(result.Namespaces, offset, size) + result.Namespaces, hasMoreElements = utils.LimitPagination(result.Namespaces, offset, size) if hasMoreElements { token = uuid.New().String() s.Pagination[token] = offset + size diff --git a/pkg/frontend/nvme_namespace_test.go b/pkg/frontend/nvme_namespace_test.go index da2f6eca..cd6dd08e 100644 --- a/pkg/frontend/nvme_namespace_test.go +++ b/pkg/frontend/nvme_namespace_test.go @@ -20,7 +20,7 @@ import ( pc "github.com/opiproject/opi-api/common/v1/gen/go" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-spdk-bridge/pkg/frontend" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" ) func TestFrontEnd_CreateNvmeNamespace(t *testing.T) { @@ -38,7 +38,7 @@ func TestFrontEnd_CreateNvmeNamespace(t *testing.T) { Nguid: "1b4e28ba-2fa1-11d2-883f-b9a761bde3fb", Eui64: 1967554867335598546, } - t.Cleanup(server.CheckTestProtoObjectsNotChanged(spec, namespaceSpec)(t, t.Name())) + t.Cleanup(utils.CheckTestProtoObjectsNotChanged(spec, namespaceSpec)(t, t.Name())) t.Cleanup(checkGlobalTestProtoObjectsNotChanged(t, t.Name())) tests := map[string]struct { @@ -206,16 +206,16 @@ func TestFrontEnd_CreateNvmeNamespace(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName if tt.exist { - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName } if tt.out != nil { - tt.out = server.ProtoClone(tt.out) + tt.out = utils.ProtoClone(tt.out) tt.out.Name = testNamespaceName } @@ -330,11 +330,11 @@ func TestFrontEnd_DeleteNvmeNamespace(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.DeleteNvmeNamespaceRequest{Name: tt.in, AllowMissing: tt.missing} @@ -420,11 +420,11 @@ func TestFrontEnd_UpdateNvmeNamespace(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.UpdateNvmeNamespaceRequest{NvmeNamespace: tt.in, UpdateMask: tt.mask} @@ -628,18 +628,18 @@ func TestFrontEnd_ListNvmeNamespaces(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName testEnv.opiSpdkServer.Pagination["existing-pagination-token"] = 1 request := &pb.ListNvmeNamespacesRequest{Parent: tt.in, PageSize: tt.size, PageToken: tt.token} response, err := testEnv.client.ListNvmeNamespaces(testEnv.ctx, request) - if !server.EqualProtoSlices(response.GetNvmeNamespaces(), tt.out) { + if !utils.EqualProtoSlices(response.GetNvmeNamespaces(), tt.out) { t.Error("response: expected", tt.out, "received", response.GetNvmeNamespaces()) } @@ -750,11 +750,11 @@ func TestFrontEnd_GetNvmeNamespace(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.GetNvmeNamespaceRequest{Name: tt.in} @@ -854,11 +854,11 @@ func TestFrontEnd_StatsNvmeNamespace(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.StatsNvmeNamespaceRequest{Name: tt.in} diff --git a/pkg/frontend/nvme_subsystem.go b/pkg/frontend/nvme_subsystem.go index 276c7eb8..0f396614 100644 --- a/pkg/frontend/nvme_subsystem.go +++ b/pkg/frontend/nvme_subsystem.go @@ -18,7 +18,7 @@ import ( pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-nvidia-bridge/pkg/models" "github.com/opiproject/opi-spdk-bridge/pkg/frontend" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" "github.com/google/uuid" "go.einride.tech/aip/fieldbehavior" @@ -89,7 +89,7 @@ func (s *Server) CreateNvmeSubsystem(_ context.Context, in *pb.CreateNvmeSubsyst return nil, err } log.Printf("Received from SPDK: %v", ver) - response := server.ProtoClone(in.NvmeSubsystem) + response := utils.ProtoClone(in.NvmeSubsystem) response.Status = &pb.NvmeSubsystemStatus{FirmwareRevision: ver.Version} s.Subsystems[in.NvmeSubsystem.Name] = response return response, nil @@ -169,7 +169,7 @@ func (s *Server) ListNvmeSubsystems(_ context.Context, in *pb.ListNvmeSubsystems return nil, err } // fetch object from the database - size, offset, perr := server.ExtractPagination(in.PageSize, in.PageToken, s.Pagination) + size, offset, perr := utils.ExtractPagination(in.PageSize, in.PageToken, s.Pagination) if perr != nil { log.Printf("error: %v", perr) return nil, perr @@ -183,7 +183,7 @@ func (s *Server) ListNvmeSubsystems(_ context.Context, in *pb.ListNvmeSubsystems log.Printf("Received from SPDK: %v", result) token, hasMoreElements := "", false log.Printf("Limiting result len(%d) to [%d:%d]", len(result), offset, size) - result, hasMoreElements = server.LimitPagination(result, offset, size) + result, hasMoreElements = utils.LimitPagination(result, offset, size) if hasMoreElements { token = uuid.New().String() s.Pagination[token] = offset + size diff --git a/pkg/frontend/nvme_subsystem_test.go b/pkg/frontend/nvme_subsystem_test.go index a1e73004..711933bf 100644 --- a/pkg/frontend/nvme_subsystem_test.go +++ b/pkg/frontend/nvme_subsystem_test.go @@ -20,7 +20,7 @@ import ( pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-spdk-bridge/pkg/frontend" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" ) func TestFrontEnd_CreateNvmeSubsystem(t *testing.T) { @@ -29,7 +29,7 @@ func TestFrontEnd_CreateNvmeSubsystem(t *testing.T) { SerialNumber: "OpiSerialNumber", ModelNumber: "OpiModelNumber", } - t.Cleanup(server.CheckTestProtoObjectsNotChanged(spec)(t, t.Name())) + t.Cleanup(utils.CheckTestProtoObjectsNotChanged(spec)(t, t.Name())) t.Cleanup(checkGlobalTestProtoObjectsNotChanged(t, t.Name())) tests := map[string]struct { @@ -205,16 +205,16 @@ func TestFrontEnd_CreateNvmeSubsystem(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName if tt.exist { - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName } if tt.out != nil { - tt.out = server.ProtoClone(tt.out) + tt.out = utils.ProtoClone(tt.out) tt.out.Name = testSubsystemName } @@ -330,11 +330,11 @@ func TestFrontEnd_DeleteNvmeSubsystem(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.DeleteNvmeSubsystemRequest{Name: tt.in, AllowMissing: tt.missing} @@ -422,13 +422,13 @@ func TestFrontEnd_UpdateNvmeSubsystem(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) request := &pb.UpdateNvmeSubsystemRequest{NvmeSubsystem: tt.in, UpdateMask: tt.mask} response, err := testEnv.client.UpdateNvmeSubsystem(testEnv.ctx, request) @@ -611,18 +611,18 @@ func TestFrontEnd_ListNvmeSubsystem(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName testEnv.opiSpdkServer.Pagination["existing-pagination-token"] = 1 request := &pb.ListNvmeSubsystemsRequest{PageSize: tt.size, PageToken: tt.token} response, err := testEnv.client.ListNvmeSubsystems(testEnv.ctx, request) - if !server.EqualProtoSlices(response.GetNvmeSubsystems(), tt.out) { + if !utils.EqualProtoSlices(response.GetNvmeSubsystems(), tt.out) { t.Error("response: expected", tt.out, "received", response.GetNvmeSubsystems()) } @@ -728,11 +728,11 @@ func TestFrontEnd_GetNvmeSubsystem(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.GetNvmeSubsystemRequest{Name: tt.in} @@ -787,11 +787,11 @@ func TestFrontEnd_StatsNvmeSubsystem(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.Subsystems[testSubsystemName] = server.ProtoClone(&testSubsystem) + testEnv.opiSpdkServer.Subsystems[testSubsystemName] = utils.ProtoClone(&testSubsystem) testEnv.opiSpdkServer.Subsystems[testSubsystemName].Name = testSubsystemName - testEnv.opiSpdkServer.Controllers[testControllerName] = server.ProtoClone(&testController) + testEnv.opiSpdkServer.Controllers[testControllerName] = utils.ProtoClone(&testController) testEnv.opiSpdkServer.Controllers[testControllerName].Name = testControllerName - testEnv.opiSpdkServer.Namespaces[testNamespaceName] = server.ProtoClone(&testNamespace) + testEnv.opiSpdkServer.Namespaces[testNamespaceName] = utils.ProtoClone(&testNamespace) testEnv.opiSpdkServer.Namespaces[testNamespaceName].Name = testNamespaceName request := &pb.StatsNvmeSubsystemRequest{Name: tt.in} diff --git a/pkg/frontend/virtio.go b/pkg/frontend/virtio.go index eb226547..061bd8b0 100644 --- a/pkg/frontend/virtio.go +++ b/pkg/frontend/virtio.go @@ -14,7 +14,7 @@ import ( pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-nvidia-bridge/pkg/models" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" "github.com/google/uuid" "go.einride.tech/aip/fieldbehavior" @@ -46,7 +46,7 @@ func (s *Server) CreateVirtioBlk(_ context.Context, in *pb.CreateVirtioBlkReques log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.VirtioBlkId, in.VirtioBlk.Name) resourceID = in.VirtioBlkId } - in.VirtioBlk.Name = server.ResourceIDToVolumeName(resourceID) + in.VirtioBlk.Name = utils.ResourceIDToVolumeName(resourceID) // idempotent API when called with same key, should return same object controller, ok := s.VirtioCtrls[in.VirtioBlk.Name] if ok { @@ -75,7 +75,7 @@ func (s *Server) CreateVirtioBlk(_ context.Context, in *pb.CreateVirtioBlkReques log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - response := server.ProtoClone(in.VirtioBlk) + response := utils.ProtoClone(in.VirtioBlk) // response.Status = &pb.NvmeControllerStatus{Active: true} s.VirtioCtrls[in.VirtioBlk.Name] = response return response, nil @@ -152,7 +152,7 @@ func (s *Server) ListVirtioBlks(_ context.Context, in *pb.ListVirtioBlksRequest) return nil, err } - size, offset, perr := server.ExtractPagination(in.PageSize, in.PageToken, s.Pagination) + size, offset, perr := utils.ExtractPagination(in.PageSize, in.PageToken, s.Pagination) if perr != nil { log.Printf("error: %v", perr) return nil, perr @@ -166,7 +166,7 @@ func (s *Server) ListVirtioBlks(_ context.Context, in *pb.ListVirtioBlksRequest) log.Printf("Received from SPDK: %v", result) token, hasMoreElements := "", false log.Printf("Limiting result len(%d) to [%d:%d]", len(result), offset, size) - result, hasMoreElements = server.LimitPagination(result, offset, size) + result, hasMoreElements = utils.LimitPagination(result, offset, size) if hasMoreElements { token = uuid.New().String() s.Pagination[token] = offset + size @@ -176,7 +176,7 @@ func (s *Server) ListVirtioBlks(_ context.Context, in *pb.ListVirtioBlksRequest) r := &result[i] if r.Type == "virtio_blk" { ctrl := &pb.VirtioBlk{ - Name: server.ResourceIDToVolumeName(r.Name), + Name: utils.ResourceIDToVolumeName(r.Name), PcieId: &pb.PciEndpoint{ PhysicalFunction: wrapperspb.Int32(int32(r.PciIndex)), VirtualFunction: wrapperspb.Int32(0), @@ -217,7 +217,7 @@ func (s *Server) GetVirtioBlk(_ context.Context, in *pb.GetVirtioBlkRequest) (*p r := &result[i] if r.Name == resourceID && r.Type == "virtio_blk" { return &pb.VirtioBlk{ - Name: server.ResourceIDToVolumeName(r.Name), + Name: utils.ResourceIDToVolumeName(r.Name), PcieId: &pb.PciEndpoint{ PhysicalFunction: wrapperspb.Int32(int32(r.PciIndex)), VirtualFunction: wrapperspb.Int32(0), diff --git a/pkg/frontend/virtio_test.go b/pkg/frontend/virtio_test.go index 427717d6..ebad8876 100644 --- a/pkg/frontend/virtio_test.go +++ b/pkg/frontend/virtio_test.go @@ -19,7 +19,7 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" - "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/opiproject/opi-spdk-bridge/pkg/utils" ) func TestFrontEnd_CreateVirtioBlk(t *testing.T) { @@ -68,7 +68,7 @@ func TestFrontEnd_CreateVirtioBlk(t *testing.T) { defer testEnv.Close() if tt.out != nil { - tt.out = server.ProtoClone(tt.out) + tt.out = utils.ProtoClone(tt.out) tt.out.Name = testVirtioCtrlName } @@ -159,7 +159,7 @@ func TestFrontEnd_UpdateVirtioBlk(t *testing.T) { "valid request with unknown key": { mask: nil, in: &pb.VirtioBlk{ - Name: server.ResourceIDToVolumeName("unknown-id"), + Name: utils.ResourceIDToVolumeName("unknown-id"), PcieId: &pb.PciEndpoint{ PhysicalFunction: wrapperspb.Int32(42), VirtualFunction: wrapperspb.Int32(0), @@ -171,7 +171,7 @@ func TestFrontEnd_UpdateVirtioBlk(t *testing.T) { out: nil, spdk: []string{}, errCode: codes.NotFound, - errMsg: fmt.Sprintf("unable to find key %v", server.ResourceIDToVolumeName("unknown-id")), + errMsg: fmt.Sprintf("unable to find key %v", utils.ResourceIDToVolumeName("unknown-id")), }, "malformed name": { mask: nil, @@ -193,7 +193,7 @@ func TestFrontEnd_UpdateVirtioBlk(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.VirtioCtrls[testVirtioCtrlName] = server.ProtoClone(&testVirtioCtrl) + testEnv.opiSpdkServer.VirtioCtrls[testVirtioCtrlName] = utils.ProtoClone(&testVirtioCtrl) testEnv.opiSpdkServer.VirtioCtrls[testVirtioCtrlName].Name = testVirtioCtrlName request := &pb.UpdateVirtioBlkRequest{VirtioBlk: tt.in, UpdateMask: tt.mask} @@ -286,7 +286,7 @@ func TestFrontEnd_ListVirtioBlks(t *testing.T) { in: "subsystem-test", out: []*pb.VirtioBlk{ { - Name: server.ResourceIDToVolumeName("VblkEmu0pf0"), + Name: utils.ResourceIDToVolumeName("VblkEmu0pf0"), PcieId: &pb.PciEndpoint{ PhysicalFunction: wrapperspb.Int32(0), VirtualFunction: wrapperspb.Int32(0), @@ -305,7 +305,7 @@ func TestFrontEnd_ListVirtioBlks(t *testing.T) { in: "subsystem-test", out: []*pb.VirtioBlk{ { - Name: server.ResourceIDToVolumeName("VblkEmu0pf0"), + Name: utils.ResourceIDToVolumeName("VblkEmu0pf0"), PcieId: &pb.PciEndpoint{ PhysicalFunction: wrapperspb.Int32(0), VirtualFunction: wrapperspb.Int32(0), @@ -314,7 +314,7 @@ func TestFrontEnd_ListVirtioBlks(t *testing.T) { VolumeNameRef: "TBD", }, { - Name: server.ResourceIDToVolumeName("VblkEmu0pf2"), + Name: utils.ResourceIDToVolumeName("VblkEmu0pf2"), PcieId: &pb.PciEndpoint{ PhysicalFunction: wrapperspb.Int32(0), VirtualFunction: wrapperspb.Int32(0), @@ -361,7 +361,7 @@ func TestFrontEnd_ListVirtioBlks(t *testing.T) { in: "subsystem-test", out: []*pb.VirtioBlk{ { - Name: server.ResourceIDToVolumeName("VblkEmu0pf0"), + Name: utils.ResourceIDToVolumeName("VblkEmu0pf0"), PcieId: &pb.PciEndpoint{ PhysicalFunction: wrapperspb.Int32(0), VirtualFunction: wrapperspb.Int32(0), @@ -370,7 +370,7 @@ func TestFrontEnd_ListVirtioBlks(t *testing.T) { VolumeNameRef: "TBD", }, { - Name: server.ResourceIDToVolumeName("VblkEmu0pf2"), + Name: utils.ResourceIDToVolumeName("VblkEmu0pf2"), PcieId: &pb.PciEndpoint{ PhysicalFunction: wrapperspb.Int32(0), VirtualFunction: wrapperspb.Int32(0), @@ -416,7 +416,7 @@ func TestFrontEnd_ListVirtioBlks(t *testing.T) { request := &pb.ListVirtioBlksRequest{Parent: tt.in, PageSize: tt.size, PageToken: tt.token} response, err := testEnv.client.ListVirtioBlks(testEnv.ctx, request) - if !server.EqualProtoSlices(response.GetVirtioBlks(), tt.out) { + if !utils.EqualProtoSlices(response.GetVirtioBlks(), tt.out) { t.Error("response: expected", tt.out, "received", response.GetVirtioBlks()) } @@ -513,7 +513,7 @@ func TestFrontEnd_GetVirtioBlk(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.VirtioCtrls[testVirtioCtrlName] = server.ProtoClone(&testVirtioCtrl) + testEnv.opiSpdkServer.VirtioCtrls[testVirtioCtrlName] = utils.ProtoClone(&testVirtioCtrl) request := &pb.GetVirtioBlkRequest{Name: tt.in} response, err := testEnv.client.GetVirtioBlk(testEnv.ctx, request) @@ -605,7 +605,7 @@ func TestFrontEnd_VirtioBlkStats(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.VirtioCtrls[testVirtioCtrl.Name] = server.ProtoClone(&testVirtioCtrl) + testEnv.opiSpdkServer.VirtioCtrls[testVirtioCtrl.Name] = utils.ProtoClone(&testVirtioCtrl) request := &pb.StatsVirtioBlkRequest{Name: tt.in} response, err := testEnv.client.StatsVirtioBlk(testEnv.ctx, request) @@ -679,7 +679,7 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) { missing: false, }, "unknown key with missing allowed": { - in: server.ResourceIDToVolumeName("unknown-id"), + in: utils.ResourceIDToVolumeName("unknown-id"), out: &emptypb.Empty{}, spdk: []string{}, errCode: codes.OK, @@ -710,7 +710,7 @@ func TestFrontEnd_DeleteVirtioBlk(t *testing.T) { testEnv := createTestEnvironment(tt.spdk) defer testEnv.Close() - testEnv.opiSpdkServer.VirtioCtrls[testVirtioCtrlName] = server.ProtoClone(&testVirtioCtrl) + testEnv.opiSpdkServer.VirtioCtrls[testVirtioCtrlName] = utils.ProtoClone(&testVirtioCtrl) request := &pb.DeleteVirtioBlkRequest{Name: tt.in, AllowMissing: tt.missing} response, err := testEnv.client.DeleteVirtioBlk(testEnv.ctx, request)