diff --git a/README.md b/README.md index 36f53dd8..88bec59c 100644 --- a/README.md +++ b/README.md @@ -118,14 +118,14 @@ See services ```bash $ grpc_cli ls opi-spdk-server:50051 grpc.reflection.v1alpha.ServerReflection -opi_api.storage.v1.AioControllerService +opi_api.storage.v1.AioVolumeService opi_api.storage.v1.FrontendNvmeService opi_api.storage.v1.FrontendVirtioBlkService opi_api.storage.v1.FrontendVirtioScsiService opi_api.storage.v1.MiddleendEncryptionService opi_api.storage.v1.MiddleendQosVolumeService opi_api.storage.v1.NvmeRemoteControllerService -opi_api.storage.v1.NullDebugService +opi_api.storage.v1.NullVolumeService ``` See commands diff --git a/cmd/main.go b/cmd/main.go index a2e67c6f..8b9603df 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -82,8 +82,8 @@ func main() { } pb.RegisterNvmeRemoteControllerServiceServer(s, backendServer) - pb.RegisterNullDebugServiceServer(s, backendServer) - pb.RegisterAioControllerServiceServer(s, backendServer) + pb.RegisterNullVolumeServiceServer(s, backendServer) + pb.RegisterAioVolumeServiceServer(s, backendServer) pb.RegisterMiddleendEncryptionServiceServer(s, middleendServer) pb.RegisterMiddleendQosVolumeServiceServer(s, middleendServer) diff --git a/docker-compose.yml b/docker-compose.yml index 42480261..9501c51c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -68,7 +68,7 @@ services: test: grpcurl -plaintext localhost:50051 list || exit 1 opi-spdk-client: - image: ghcr.io/opiproject/godpu:main@sha256:02cc40862881a1e3bf16b13b42afc94f7f3c91568a2cf23735164de2770770f3 + image: ghcr.io/opiproject/godpu:main@sha256:eb81222ec10ed279869b407e1a5f74933fd872e6c1bbe551d7b7e96882e080aa networks: - opi depends_on: diff --git a/go.mod b/go.mod index 1c077e4c..46da346a 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/digitalocean/go-qemu v0.0.0-20230711162256-2e3d0186973e github.com/google/uuid v1.3.0 github.com/opiproject/gospdk v0.0.0-20230721162442-5187c4c6663b - github.com/opiproject/opi-api v0.0.0-20230721161716-ea8314a63ccb + github.com/opiproject/opi-api v0.0.0-20230726170919-691a90a13429 go.einride.tech/aip v0.60.0 google.golang.org/grpc v1.56.2 google.golang.org/protobuf v1.31.0 @@ -18,7 +18,7 @@ require ( golang.org/x/net v0.12.0 // indirect golang.org/x/sys v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect - google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e // indirect ) diff --git a/go.sum b/go.sum index bcb24cf3..f9c3bec0 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/digitalocean/go-libvirt v0.0.0-20220804181439-8648fbde413e h1:SCnqm8SjSa0QqRxXbo5YY//S+OryeJioe17nK+iDZpg= github.com/digitalocean/go-libvirt v0.0.0-20220804181439-8648fbde413e/go.mod h1:o129ljs6alsIQTc8d6eweihqpmmrbxZ2g1jhgjhPykI= -github.com/digitalocean/go-qemu v0.0.0-20221209210016-f035778c97f7 h1:3OVJAbR131SnAXao7c9w8bFlAGH0oa29DCwsa88MJGk= -github.com/digitalocean/go-qemu v0.0.0-20221209210016-f035778c97f7/go.mod h1:K4+o74YGNjOb9N6yyG+LPj1NjHtk+Qz0IYQPvirbaLs= github.com/digitalocean/go-qemu v0.0.0-20230711162256-2e3d0186973e h1:x5PInTuXLddHWHlePCNAcM8QtUfOGx44f3UmYPMtDcI= github.com/digitalocean/go-qemu v0.0.0-20230711162256-2e3d0186973e/go.mod h1:K4+o74YGNjOb9N6yyG+LPj1NjHtk+Qz0IYQPvirbaLs= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= @@ -13,20 +11,10 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/opiproject/gospdk v0.0.0-20230706153333-46d1efd3dfde h1:F34T5Kq7GzFSlnycskJ/LXfBDwhsN061ADzhARHO+Lg= -github.com/opiproject/gospdk v0.0.0-20230706153333-46d1efd3dfde/go.mod h1:UzRy421kjqvDVi1awOCLaFpyMLAGKMR3G5tXgqLsiq8= -github.com/opiproject/gospdk v0.0.0-20230714152149-de73bd1ee87d h1:H+E4ITds+AW3j7PHLbhAz3C+OPGJGREJUdmTo9YOviE= -github.com/opiproject/gospdk v0.0.0-20230714152149-de73bd1ee87d/go.mod h1:RqA5Ix7+x0Is8UckJE+6Ji5kCfk6yujWWaTMoRlZv3w= github.com/opiproject/gospdk v0.0.0-20230721162442-5187c4c6663b h1:MYk4lS7uUpJwT89WJgjqg9RCXywslytpBDmZcWy626I= github.com/opiproject/gospdk v0.0.0-20230721162442-5187c4c6663b/go.mod h1:RqA5Ix7+x0Is8UckJE+6Ji5kCfk6yujWWaTMoRlZv3w= -github.com/opiproject/opi-api v0.0.0-20230712141241-3ccebf87270b h1:/t1mBhxyV8Obu2zeVhAjyXaLfy4dwCrS1A8/MJ71KFA= -github.com/opiproject/opi-api v0.0.0-20230712141241-3ccebf87270b/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= -github.com/opiproject/opi-api v0.0.0-20230713203751-f1f72eaaee0e h1:dFlwXYeXuRPKe5w40eDYMpc3+1zCQDXS+9W/5LWCnbU= -github.com/opiproject/opi-api v0.0.0-20230713203751-f1f72eaaee0e/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= -github.com/opiproject/opi-api v0.0.0-20230717064243-520b62d2f155 h1:I35TX9YBVrl6PlYe1Eima79mA6VS0qohETDUoB6W+Pk= -github.com/opiproject/opi-api v0.0.0-20230717064243-520b62d2f155/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= -github.com/opiproject/opi-api v0.0.0-20230721161716-ea8314a63ccb h1:N8wK6C6A7Y4fr9SECSvTTUMhcD2xZ6t2W+/NO9vy768= -github.com/opiproject/opi-api v0.0.0-20230721161716-ea8314a63ccb/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= +github.com/opiproject/opi-api v0.0.0-20230726170919-691a90a13429 h1:bvctyHEk77amCzqlP2Q40C7uTzgYCX/IEdpmAkvFw0Y= +github.com/opiproject/opi-api v0.0.0-20230726170919-691a90a13429/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -64,12 +52,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= -google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98/go.mod h1:S7mY02OqCJTD0E1OiQy1F72PWFB4bZJ87cAtLPYgDR0= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e h1:xIXmWJ303kJCuogpj0bHq+dcjcZHU+XFyc1I0Yl9cRg= +google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:0ggbjUrZYpy1q+ANUS30SEoGZ53cdfwtbuG7Ptgy108= +google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1:z3vDksarJxsAKM5dmEGv0GHwE2hKJ096wZra71Vs4sw= +google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/pkg/backend/aio.go b/pkg/backend/aio.go index e19ee975..0e045bb9 100644 --- a/pkg/backend/aio.go +++ b/pkg/backend/aio.go @@ -26,15 +26,15 @@ import ( "google.golang.org/protobuf/types/known/emptypb" ) -func sortAioControllers(controllers []*pb.AioController) { - sort.Slice(controllers, func(i int, j int) bool { - return controllers[i].Name < controllers[j].Name +func sortAioVolumes(volumes []*pb.AioVolume) { + sort.Slice(volumes, func(i int, j int) bool { + return volumes[i].Name < volumes[j].Name }) } -// CreateAioController creates an Aio controller -func (s *Server) CreateAioController(_ context.Context, in *pb.CreateAioControllerRequest) (*pb.AioController, error) { - log.Printf("CreateAioController: Received from client: %v", in) +// CreateAioVolume creates an Aio volume +func (s *Server) CreateAioVolume(_ context.Context, in *pb.CreateAioVolumeRequest) (*pb.AioVolume, error) { + log.Printf("CreateAioVolume: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -42,27 +42,27 @@ func (s *Server) CreateAioController(_ context.Context, in *pb.CreateAioControll } // see https://google.aip.dev/133#user-specified-ids resourceID := resourceid.NewSystemGenerated() - if in.AioControllerId != "" { - err := resourceid.ValidateUserSettable(in.AioControllerId) + if in.AioVolumeId != "" { + err := resourceid.ValidateUserSettable(in.AioVolumeId) if err != nil { log.Printf("error: %v", err) return nil, err } - log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.AioControllerId, in.AioController.Name) - resourceID = in.AioControllerId + log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.AioVolumeId, in.AioVolume.Name) + resourceID = in.AioVolumeId } - in.AioController.Name = server.ResourceIDToVolumeName(resourceID) + in.AioVolume.Name = server.ResourceIDToVolumeName(resourceID) // idempotent API when called with same key, should return same object - volume, ok := s.Volumes.AioVolumes[in.AioController.Name] + volume, ok := s.Volumes.AioVolumes[in.AioVolume.Name] if ok { - log.Printf("Already existing AioController with id %v", in.AioController.Name) + log.Printf("Already existing AioVolume with id %v", in.AioVolume.Name) return volume, nil } // not found, so create a new one params := spdk.BdevAioCreateParams{ Name: resourceID, BlockSize: 512, - Filename: in.AioController.Filename, + Filename: in.AioVolume.Filename, } var result spdk.BdevAioCreateResult err := s.rpc.Call("bdev_aio_create", ¶ms, &result) @@ -76,15 +76,15 @@ func (s *Server) CreateAioController(_ context.Context, in *pb.CreateAioControll log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - response := server.ProtoClone(in.AioController) - s.Volumes.AioVolumes[in.AioController.Name] = response - log.Printf("CreateAioController: Sending to client: %v", response) + response := server.ProtoClone(in.AioVolume) + s.Volumes.AioVolumes[in.AioVolume.Name] = response + log.Printf("CreateAioVolume: Sending to client: %v", response) return response, nil } -// DeleteAioController deletes an Aio controller -func (s *Server) DeleteAioController(_ context.Context, in *pb.DeleteAioControllerRequest) (*emptypb.Empty, error) { - log.Printf("DeleteAioController: Received from client: %v", in) +// DeleteAioVolume deletes an Aio volume +func (s *Server) DeleteAioVolume(_ context.Context, in *pb.DeleteAioVolumeRequest) (*emptypb.Empty, error) { + log.Printf("DeleteAioVolume: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -125,28 +125,28 @@ func (s *Server) DeleteAioController(_ context.Context, in *pb.DeleteAioControll return &emptypb.Empty{}, nil } -// UpdateAioController updates an Aio controller -func (s *Server) UpdateAioController(_ context.Context, in *pb.UpdateAioControllerRequest) (*pb.AioController, error) { - log.Printf("UpdateAioController: Received from client: %v", in) +// UpdateAioVolume updates an Aio volume +func (s *Server) UpdateAioVolume(_ context.Context, in *pb.UpdateAioVolumeRequest) (*pb.AioVolume, error) { + log.Printf("UpdateAioVolume: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { 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.AioController.Name); err != nil { + if err := resourcename.Validate(in.AioVolume.Name); err != nil { log.Printf("error: %v", err) return nil, err } // fetch object from the database - volume, ok := s.Volumes.AioVolumes[in.AioController.Name] + volume, ok := s.Volumes.AioVolumes[in.AioVolume.Name] if !ok { if in.AllowMissing { log.Printf("Got AllowMissing, create a new resource, don't return error when resource not found") params := spdk.BdevAioCreateParams{ - Name: path.Base(in.AioController.Name), + Name: path.Base(in.AioVolume.Name), BlockSize: 512, - Filename: in.AioController.Filename, + Filename: in.AioVolume.Filename, } var result spdk.BdevAioCreateResult err := s.rpc.Call("bdev_aio_create", ¶ms, &result) @@ -160,18 +160,18 @@ func (s *Server) UpdateAioController(_ context.Context, in *pb.UpdateAioControll log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - response := server.ProtoClone(in.AioController) - s.Volumes.AioVolumes[in.AioController.Name] = response - log.Printf("CreateAioController: Sending to client: %v", response) + response := server.ProtoClone(in.AioVolume) + s.Volumes.AioVolumes[in.AioVolume.Name] = response + log.Printf("CreateAioVolume: Sending to client: %v", response) return response, nil } - err := status.Errorf(codes.NotFound, "unable to find key %s", in.AioController.Name) + err := status.Errorf(codes.NotFound, "unable to find key %s", in.AioVolume.Name) log.Printf("error: %v", err) return nil, err } resourceID := path.Base(volume.Name) // update_mask = 2 - if err := fieldmask.Validate(in.UpdateMask, in.AioController); err != nil { + if err := fieldmask.Validate(in.UpdateMask, in.AioVolume); err != nil { log.Printf("error: %v", err) return nil, err } @@ -193,7 +193,7 @@ func (s *Server) UpdateAioController(_ context.Context, in *pb.UpdateAioControll params2 := spdk.BdevAioCreateParams{ Name: resourceID, BlockSize: 512, - Filename: in.AioController.Filename, + Filename: in.AioVolume.Filename, } var result2 spdk.BdevAioCreateResult err2 := s.rpc.Call("bdev_aio_create", ¶ms2, &result2) @@ -207,14 +207,14 @@ func (s *Server) UpdateAioController(_ context.Context, in *pb.UpdateAioControll log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - response := server.ProtoClone(in.AioController) - s.Volumes.AioVolumes[in.AioController.Name] = response + response := server.ProtoClone(in.AioVolume) + s.Volumes.AioVolumes[in.AioVolume.Name] = response return response, nil } -// ListAioControllers lists Aio controllers -func (s *Server) ListAioControllers(_ context.Context, in *pb.ListAioControllersRequest) (*pb.ListAioControllersResponse, error) { - log.Printf("ListAioControllers: Received from client: %v", in) +// ListAioVolumes lists Aio volumes +func (s *Server) ListAioVolumes(_ context.Context, in *pb.ListAioVolumesRequest) (*pb.ListAioVolumesResponse, error) { + log.Printf("ListAioVolumes: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -240,18 +240,18 @@ func (s *Server) ListAioControllers(_ context.Context, in *pb.ListAioControllers token = uuid.New().String() s.Pagination[token] = offset + size } - Blobarray := make([]*pb.AioController, len(result)) + Blobarray := make([]*pb.AioVolume, len(result)) for i := range result { r := &result[i] - Blobarray[i] = &pb.AioController{Name: r.Name, BlockSize: r.BlockSize, BlocksCount: r.NumBlocks} + Blobarray[i] = &pb.AioVolume{Name: r.Name, BlockSize: r.BlockSize, BlocksCount: r.NumBlocks} } - sortAioControllers(Blobarray) - return &pb.ListAioControllersResponse{AioControllers: Blobarray, NextPageToken: token}, nil + sortAioVolumes(Blobarray) + return &pb.ListAioVolumesResponse{AioVolumes: Blobarray, NextPageToken: token}, nil } -// GetAioController gets an Aio controller -func (s *Server) GetAioController(_ context.Context, in *pb.GetAioControllerRequest) (*pb.AioController, error) { - log.Printf("GetAioController: Received from client: %v", in) +// GetAioVolume gets an Aio volume +func (s *Server) GetAioVolume(_ context.Context, in *pb.GetAioVolumeRequest) (*pb.AioVolume, error) { + log.Printf("GetAioVolume: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -285,12 +285,12 @@ func (s *Server) GetAioController(_ context.Context, in *pb.GetAioControllerRequ log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - return &pb.AioController{Name: result[0].Name, BlockSize: result[0].BlockSize, BlocksCount: result[0].NumBlocks}, nil + return &pb.AioVolume{Name: result[0].Name, BlockSize: result[0].BlockSize, BlocksCount: result[0].NumBlocks}, nil } -// AioControllerStats gets an Aio controller stats -func (s *Server) AioControllerStats(_ context.Context, in *pb.AioControllerStatsRequest) (*pb.AioControllerStatsResponse, error) { - log.Printf("AioControllerStats: Received from client: %v", in) +// AioVolumeStats gets an Aio volume stats +func (s *Server) AioVolumeStats(_ context.Context, in *pb.AioVolumeStatsRequest) (*pb.AioVolumeStatsResponse, error) { + log.Printf("AioVolumeStats: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -325,7 +325,7 @@ func (s *Server) AioControllerStats(_ context.Context, in *pb.AioControllerStats log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - return &pb.AioControllerStatsResponse{Stats: &pb.VolumeStats{ + return &pb.AioVolumeStatsResponse{Stats: &pb.VolumeStats{ ReadBytesCount: int32(result.Bdevs[0].BytesRead), ReadOpsCount: int32(result.Bdevs[0].NumReadOps), WriteBytesCount: int32(result.Bdevs[0].BytesWritten), diff --git a/pkg/backend/aio_test.go b/pkg/backend/aio_test.go index c54221cb..dec0510c 100644 --- a/pkg/backend/aio_test.go +++ b/pkg/backend/aio_test.go @@ -25,18 +25,18 @@ import ( var ( testAioVolumeID = "mytest" testAioVolumeName = server.ResourceIDToVolumeName(testAioVolumeID) - testAioVolume = pb.AioController{ + testAioVolume = pb.AioVolume{ BlockSize: 512, BlocksCount: 12, Filename: "/tmp/aio_bdev_file", } ) -func TestBackEnd_CreateAioController(t *testing.T) { +func TestBackEnd_CreateAioVolume(t *testing.T) { tests := map[string]struct { id string - in *pb.AioController - out *pb.AioController + in *pb.AioVolume + out *pb.AioVolume spdk []string errCode codes.Code errMsg string @@ -120,8 +120,8 @@ func TestBackEnd_CreateAioController(t *testing.T) { tt.out.Name = testAioVolumeName } - request := &pb.CreateAioControllerRequest{AioController: tt.in, AioControllerId: tt.id} - response, err := testEnv.client.CreateAioController(testEnv.ctx, request) + request := &pb.CreateAioVolumeRequest{AioVolume: tt.in, AioVolumeId: tt.id} + response, err := testEnv.client.CreateAioVolume(testEnv.ctx, request) if !proto.Equal(response, tt.out) { t.Error("response: expected", tt.out, "received", response) @@ -141,11 +141,11 @@ func TestBackEnd_CreateAioController(t *testing.T) { } } -func TestBackEnd_UpdateAioController(t *testing.T) { +func TestBackEnd_UpdateAioVolume(t *testing.T) { tests := map[string]struct { mask *fieldmaskpb.FieldMask - in *pb.AioController - out *pb.AioController + in *pb.AioVolume + out *pb.AioVolume spdk []string errCode codes.Code errMsg string @@ -243,7 +243,7 @@ func TestBackEnd_UpdateAioController(t *testing.T) { }, "valid request with unknown key": { nil, - &pb.AioController{ + &pb.AioVolume{ Name: server.ResourceIDToVolumeName("unknown-id"), BlockSize: 512, BlocksCount: 12, @@ -257,13 +257,13 @@ func TestBackEnd_UpdateAioController(t *testing.T) { }, "unknown key with missing allowed": { nil, - &pb.AioController{ + &pb.AioVolume{ Name: server.ResourceIDToVolumeName("unknown-id"), BlockSize: 512, BlocksCount: 12, Filename: "/tmp/aio_bdev_file", }, - &pb.AioController{ + &pb.AioVolume{ Name: server.ResourceIDToVolumeName("unknown-id"), BlockSize: 512, BlocksCount: 12, @@ -276,7 +276,7 @@ func TestBackEnd_UpdateAioController(t *testing.T) { }, "malformed name": { nil, - &pb.AioController{Name: "-ABC-DEF"}, + &pb.AioVolume{Name: "-ABC-DEF"}, nil, []string{}, codes.Unknown, @@ -294,8 +294,8 @@ func TestBackEnd_UpdateAioController(t *testing.T) { testAioVolume.Name = testAioVolumeName testEnv.opiSpdkServer.Volumes.AioVolumes[testAioVolumeName] = &testAioVolume - request := &pb.UpdateAioControllerRequest{AioController: tt.in, UpdateMask: tt.mask, AllowMissing: tt.missing} - response, err := testEnv.client.UpdateAioController(testEnv.ctx, request) + request := &pb.UpdateAioVolumeRequest{AioVolume: tt.in, UpdateMask: tt.mask, AllowMissing: tt.missing} + response, err := testEnv.client.UpdateAioVolume(testEnv.ctx, request) if !proto.Equal(response, tt.out) { t.Error("response: expected", tt.out, "received", response) @@ -315,10 +315,10 @@ func TestBackEnd_UpdateAioController(t *testing.T) { } } -func TestBackEnd_ListAioControllers(t *testing.T) { +func TestBackEnd_ListAioVolumes(t *testing.T) { tests := map[string]struct { in string - out []*pb.AioController + out []*pb.AioVolume spdk []string errCode codes.Code errMsg string @@ -372,7 +372,7 @@ func TestBackEnd_ListAioControllers(t *testing.T) { }, "valid request with valid SPDK response": { testAioVolumeID, - []*pb.AioController{ + []*pb.AioVolume{ { Name: "Malloc0", BlockSize: 512, @@ -395,7 +395,7 @@ func TestBackEnd_ListAioControllers(t *testing.T) { }, "pagination overflow": { testAioVolumeID, - []*pb.AioController{ + []*pb.AioVolume{ { Name: "Malloc0", BlockSize: 512, @@ -433,7 +433,7 @@ func TestBackEnd_ListAioControllers(t *testing.T) { }, "pagination": { testAioVolumeID, - []*pb.AioController{ + []*pb.AioVolume{ { Name: "Malloc0", BlockSize: 512, @@ -448,7 +448,7 @@ func TestBackEnd_ListAioControllers(t *testing.T) { }, "pagination offset": { testAioVolumeID, - []*pb.AioController{ + []*pb.AioVolume{ { Name: "Malloc1", BlockSize: 512, @@ -471,11 +471,11 @@ func TestBackEnd_ListAioControllers(t *testing.T) { testEnv.opiSpdkServer.Pagination["existing-pagination-token"] = 1 - request := &pb.ListAioControllersRequest{Parent: tt.in, PageSize: tt.size, PageToken: tt.token} - response, err := testEnv.client.ListAioControllers(testEnv.ctx, request) + request := &pb.ListAioVolumesRequest{Parent: tt.in, PageSize: tt.size, PageToken: tt.token} + response, err := testEnv.client.ListAioVolumes(testEnv.ctx, request) - if !server.EqualProtoSlices(response.GetAioControllers(), tt.out) { - t.Error("response: expected", tt.out, "received", response.GetAioControllers()) + if !server.EqualProtoSlices(response.GetAioVolumes(), tt.out) { + t.Error("response: expected", tt.out, "received", response.GetAioVolumes()) } // Empty NextPageToken indicates end of results list @@ -497,10 +497,10 @@ func TestBackEnd_ListAioControllers(t *testing.T) { } } -func TestBackEnd_GetAioController(t *testing.T) { +func TestBackEnd_GetAioVolume(t *testing.T) { tests := map[string]struct { in string - out *pb.AioController + out *pb.AioVolume spdk []string errCode codes.Code errMsg string @@ -542,7 +542,7 @@ func TestBackEnd_GetAioController(t *testing.T) { }, "valid request with valid SPDK response": { testAioVolumeID, - &pb.AioController{Name: "Malloc1", BlockSize: 512, BlocksCount: 131072}, + &pb.AioVolume{Name: "Malloc1", BlockSize: 512, BlocksCount: 131072}, []string{`{"jsonrpc":"2.0","id":%d,"result":[{"name":"Malloc1","aliases":["88112c76-8c49-4395-955a-0d695b1d2099"],"product_name":"Malloc disk","block_size":512,"num_blocks":131072,"uuid":"88112c76-8c49-4395-955a-0d695b1d2099","assigned_rate_limits":{"rw_ios_per_sec":0,"rw_mbytes_per_sec":0,"r_mbytes_per_sec":0,"w_mbytes_per_sec":0},"claimed":false,"zoned":false,"supported_io_types":{"read":true,"write":true,"unmap":true,"write_zeroes":true,"flush":true,"reset":true,"compare":false,"compare_and_write":false,"abort":true,"nvme_admin":false,"nvme_io":false},"driver_specific":{}}]}`}, codes.OK, "", @@ -571,8 +571,8 @@ func TestBackEnd_GetAioController(t *testing.T) { testEnv.opiSpdkServer.Volumes.AioVolumes[testAioVolumeID] = &testAioVolume - request := &pb.GetAioControllerRequest{Name: tt.in} - response, err := testEnv.client.GetAioController(testEnv.ctx, request) + request := &pb.GetAioVolumeRequest{Name: tt.in} + response, err := testEnv.client.GetAioVolume(testEnv.ctx, request) if !proto.Equal(response, tt.out) { t.Error("response: expected", tt.out, "received", response) @@ -592,7 +592,7 @@ func TestBackEnd_GetAioController(t *testing.T) { } } -func TestBackEnd_AioControllerStats(t *testing.T) { +func TestBackEnd_AioVolumeStats(t *testing.T) { tests := map[string]struct { in string out *pb.VolumeStats @@ -673,8 +673,8 @@ func TestBackEnd_AioControllerStats(t *testing.T) { testEnv.opiSpdkServer.Volumes.AioVolumes[testAioVolumeID] = &testAioVolume - request := &pb.AioControllerStatsRequest{Handle: &pc.ObjectKey{Value: tt.in}} - response, err := testEnv.client.AioControllerStats(testEnv.ctx, request) + request := &pb.AioVolumeStatsRequest{Handle: &pc.ObjectKey{Value: tt.in}} + response, err := testEnv.client.AioVolumeStats(testEnv.ctx, request) if !proto.Equal(tt.out, response.GetStats()) { t.Error("response: expected", tt.out, "received", response.GetStats()) @@ -694,7 +694,7 @@ func TestBackEnd_AioControllerStats(t *testing.T) { } } -func TestBackEnd_DeleteAioController(t *testing.T) { +func TestBackEnd_DeleteAioVolume(t *testing.T) { tests := map[string]struct { in string out *emptypb.Empty @@ -778,8 +778,8 @@ func TestBackEnd_DeleteAioController(t *testing.T) { fname1 := server.ResourceIDToVolumeName(tt.in) testEnv.opiSpdkServer.Volumes.AioVolumes[testAioVolumeName] = &testAioVolume - request := &pb.DeleteAioControllerRequest{Name: fname1, AllowMissing: tt.missing} - response, err := testEnv.client.DeleteAioController(testEnv.ctx, request) + request := &pb.DeleteAioVolumeRequest{Name: fname1, AllowMissing: tt.missing} + response, err := testEnv.client.DeleteAioVolume(testEnv.ctx, request) if er, ok := status.FromError(err); ok { if er.Code() != tt.errCode { diff --git a/pkg/backend/backend.go b/pkg/backend/backend.go index 9c3a06f7..0183d59a 100644 --- a/pkg/backend/backend.go +++ b/pkg/backend/backend.go @@ -15,8 +15,8 @@ import ( // VolumeParameters contains all BackEnd volume related structures type VolumeParameters struct { - AioVolumes map[string]*pb.AioController - NullVolumes map[string]*pb.NullDebug + AioVolumes map[string]*pb.AioVolume + NullVolumes map[string]*pb.NullVolume NvmeControllers map[string]*pb.NvmeRemoteController NvmePaths map[string]*pb.NvmePath @@ -25,8 +25,8 @@ type VolumeParameters struct { // Server contains backend related OPI services type Server struct { pb.UnimplementedNvmeRemoteControllerServiceServer - pb.UnimplementedNullDebugServiceServer - pb.UnimplementedAioControllerServiceServer + pb.UnimplementedNullVolumeServiceServer + pb.UnimplementedAioVolumeServiceServer rpc spdk.JSONRPC Volumes VolumeParameters @@ -39,8 +39,8 @@ func NewServer(jsonRPC spdk.JSONRPC) *Server { return &Server{ rpc: jsonRPC, Volumes: VolumeParameters{ - AioVolumes: make(map[string]*pb.AioController), - NullVolumes: make(map[string]*pb.NullDebug), + AioVolumes: make(map[string]*pb.AioVolume), + NullVolumes: make(map[string]*pb.NullVolume), NvmeControllers: make(map[string]*pb.NvmeRemoteController), NvmePaths: make(map[string]*pb.NvmePath), }, diff --git a/pkg/backend/backend_test.go b/pkg/backend/backend_test.go index 67c74c4d..94749320 100644 --- a/pkg/backend/backend_test.go +++ b/pkg/backend/backend_test.go @@ -24,8 +24,8 @@ import ( type backendClient struct { pb.NvmeRemoteControllerServiceClient - pb.NullDebugServiceClient - pb.AioControllerServiceClient + pb.NullVolumeServiceClient + pb.AioVolumeServiceClient } type testEnv struct { @@ -66,8 +66,8 @@ func createTestEnvironment(spdkResponses []string) *testEnv { env.client = &backendClient{ pb.NewNvmeRemoteControllerServiceClient(env.conn), - pb.NewNullDebugServiceClient(env.conn), - pb.NewAioControllerServiceClient(env.conn), + pb.NewNullVolumeServiceClient(env.conn), + pb.NewAioVolumeServiceClient(env.conn), } return env @@ -77,8 +77,8 @@ func dialer(opiSpdkServer *Server) func(context.Context, string) (net.Conn, erro listener := bufconn.Listen(1024 * 1024) server := grpc.NewServer() pb.RegisterNvmeRemoteControllerServiceServer(server, opiSpdkServer) - pb.RegisterNullDebugServiceServer(server, opiSpdkServer) - pb.RegisterAioControllerServiceServer(server, opiSpdkServer) + pb.RegisterNullVolumeServiceServer(server, opiSpdkServer) + pb.RegisterAioVolumeServiceServer(server, opiSpdkServer) go func() { if err := server.Serve(listener); err != nil { diff --git a/pkg/backend/null.go b/pkg/backend/null.go index 81d37023..7132e189 100644 --- a/pkg/backend/null.go +++ b/pkg/backend/null.go @@ -27,15 +27,15 @@ import ( "google.golang.org/protobuf/types/known/emptypb" ) -func sortNullDebugs(nullDebugs []*pb.NullDebug) { - sort.Slice(nullDebugs, func(i int, j int) bool { - return nullDebugs[i].Name < nullDebugs[j].Name +func sortNullVolumes(volumes []*pb.NullVolume) { + sort.Slice(volumes, func(i int, j int) bool { + return volumes[i].Name < volumes[j].Name }) } -// CreateNullDebug creates a Null Debug instance -func (s *Server) CreateNullDebug(_ context.Context, in *pb.CreateNullDebugRequest) (*pb.NullDebug, error) { - log.Printf("CreateNullDebug: Received from client: %v", in) +// CreateNullVolume creates a Null volume instance +func (s *Server) CreateNullVolume(_ context.Context, in *pb.CreateNullVolumeRequest) (*pb.NullVolume, error) { + log.Printf("CreateNullVolume: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -43,20 +43,20 @@ func (s *Server) CreateNullDebug(_ context.Context, in *pb.CreateNullDebugReques } // see https://google.aip.dev/133#user-specified-ids resourceID := resourceid.NewSystemGenerated() - if in.NullDebugId != "" { - err := resourceid.ValidateUserSettable(in.NullDebugId) + if in.NullVolumeId != "" { + err := resourceid.ValidateUserSettable(in.NullVolumeId) if err != nil { log.Printf("error: %v", err) return nil, err } - log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.NullDebugId, in.NullDebug.Name) - resourceID = in.NullDebugId + log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.NullVolumeId, in.NullVolume.Name) + resourceID = in.NullVolumeId } - in.NullDebug.Name = server.ResourceIDToVolumeName(resourceID) + in.NullVolume.Name = server.ResourceIDToVolumeName(resourceID) // idempotent API when called with same key, should return same object - volume, ok := s.Volumes.NullVolumes[in.NullDebug.Name] + volume, ok := s.Volumes.NullVolumes[in.NullVolume.Name] if ok { - log.Printf("Already existing NullDebug with id %v", in.NullDebug.Name) + log.Printf("Already existing NullVolume with id %v", in.NullVolume.Name) return volume, nil } // not found, so create a new one @@ -77,15 +77,15 @@ func (s *Server) CreateNullDebug(_ context.Context, in *pb.CreateNullDebugReques log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - response := server.ProtoClone(in.NullDebug) - s.Volumes.NullVolumes[in.NullDebug.Name] = response - log.Printf("CreateNullDebug: Sending to client: %v", response) + response := server.ProtoClone(in.NullVolume) + s.Volumes.NullVolumes[in.NullVolume.Name] = response + log.Printf("CreateNullVolume: Sending to client: %v", response) return response, nil } -// DeleteNullDebug deletes a Null Debug instance -func (s *Server) DeleteNullDebug(_ context.Context, in *pb.DeleteNullDebugRequest) (*emptypb.Empty, error) { - log.Printf("DeleteNullDebug: Received from client: %v", in) +// DeleteNullVolume deletes a Null volume instance +func (s *Server) DeleteNullVolume(_ context.Context, in *pb.DeleteNullVolumeRequest) (*emptypb.Empty, error) { + log.Printf("DeleteNullVolume: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -126,26 +126,26 @@ func (s *Server) DeleteNullDebug(_ context.Context, in *pb.DeleteNullDebugReques return &emptypb.Empty{}, nil } -// UpdateNullDebug updates a Null Debug instance -func (s *Server) UpdateNullDebug(_ context.Context, in *pb.UpdateNullDebugRequest) (*pb.NullDebug, error) { - log.Printf("UpdateNullDebug: Received from client: %v", in) +// UpdateNullVolume updates a Null volume instance +func (s *Server) UpdateNullVolume(_ context.Context, in *pb.UpdateNullVolumeRequest) (*pb.NullVolume, error) { + log.Printf("UpdateNullVolume: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { 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.NullDebug.Name); err != nil { + if err := resourcename.Validate(in.NullVolume.Name); err != nil { log.Printf("error: %v", err) return nil, err } // fetch object from the database - volume, ok := s.Volumes.NullVolumes[in.NullDebug.Name] + volume, ok := s.Volumes.NullVolumes[in.NullVolume.Name] if !ok { if in.AllowMissing { log.Printf("Got AllowMissing, create a new resource, don't return error when resource not found") params := spdk.BdevNullCreateParams{ - Name: path.Base(in.NullDebug.Name), + Name: path.Base(in.NullVolume.Name), BlockSize: 512, NumBlocks: 64, } @@ -161,18 +161,18 @@ func (s *Server) UpdateNullDebug(_ context.Context, in *pb.UpdateNullDebugReques log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - response := server.ProtoClone(in.NullDebug) - s.Volumes.NullVolumes[in.NullDebug.Name] = response - log.Printf("CreateNullDebug: Sending to client: %v", response) + response := server.ProtoClone(in.NullVolume) + s.Volumes.NullVolumes[in.NullVolume.Name] = response + log.Printf("CreateNullVolume: Sending to client: %v", response) return response, nil } - err := status.Errorf(codes.NotFound, "unable to find key %s", in.NullDebug.Name) + err := status.Errorf(codes.NotFound, "unable to find key %s", in.NullVolume.Name) log.Printf("error: %v", err) return nil, err } resourceID := path.Base(volume.Name) // update_mask = 2 - if err := fieldmask.Validate(in.UpdateMask, in.NullDebug); err != nil { + if err := fieldmask.Validate(in.UpdateMask, in.NullVolume); err != nil { log.Printf("error: %v", err) return nil, err } @@ -208,14 +208,14 @@ func (s *Server) UpdateNullDebug(_ context.Context, in *pb.UpdateNullDebugReques log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - response := server.ProtoClone(in.NullDebug) - s.Volumes.NullVolumes[in.NullDebug.Name] = response + response := server.ProtoClone(in.NullVolume) + s.Volumes.NullVolumes[in.NullVolume.Name] = response return response, nil } -// ListNullDebugs lists Null Debug instances -func (s *Server) ListNullDebugs(_ context.Context, in *pb.ListNullDebugsRequest) (*pb.ListNullDebugsResponse, error) { - log.Printf("ListNullDebugs: Received from client: %v", in) +// ListNullVolumes lists Null volume instances +func (s *Server) ListNullVolumes(_ context.Context, in *pb.ListNullVolumesRequest) (*pb.ListNullVolumesResponse, error) { + log.Printf("ListNullVolumes: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -241,18 +241,18 @@ func (s *Server) ListNullDebugs(_ context.Context, in *pb.ListNullDebugsRequest) token = uuid.New().String() s.Pagination[token] = offset + size } - Blobarray := make([]*pb.NullDebug, len(result)) + Blobarray := make([]*pb.NullVolume, len(result)) for i := range result { r := &result[i] - Blobarray[i] = &pb.NullDebug{Name: r.Name, Uuid: &pc.Uuid{Value: r.UUID}, BlockSize: r.BlockSize, BlocksCount: r.NumBlocks} + Blobarray[i] = &pb.NullVolume{Name: r.Name, Uuid: &pc.Uuid{Value: r.UUID}, BlockSize: r.BlockSize, BlocksCount: r.NumBlocks} } - sortNullDebugs(Blobarray) - return &pb.ListNullDebugsResponse{NullDebugs: Blobarray, NextPageToken: token}, nil + sortNullVolumes(Blobarray) + return &pb.ListNullVolumesResponse{NullVolumes: Blobarray, NextPageToken: token}, nil } -// GetNullDebug gets a a Null Debug instance -func (s *Server) GetNullDebug(_ context.Context, in *pb.GetNullDebugRequest) (*pb.NullDebug, error) { - log.Printf("GetNullDebug: Received from client: %v", in) +// GetNullVolume gets a a Null volume instance +func (s *Server) GetNullVolume(_ context.Context, in *pb.GetNullVolumeRequest) (*pb.NullVolume, error) { + log.Printf("GetNullVolume: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -286,12 +286,12 @@ func (s *Server) GetNullDebug(_ context.Context, in *pb.GetNullDebugRequest) (*p log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - return &pb.NullDebug{Name: result[0].Name, Uuid: &pc.Uuid{Value: result[0].UUID}, BlockSize: result[0].BlockSize, BlocksCount: result[0].NumBlocks}, nil + return &pb.NullVolume{Name: result[0].Name, Uuid: &pc.Uuid{Value: result[0].UUID}, BlockSize: result[0].BlockSize, BlocksCount: result[0].NumBlocks}, nil } -// NullDebugStats gets a Null Debug instance stats -func (s *Server) NullDebugStats(_ context.Context, in *pb.NullDebugStatsRequest) (*pb.NullDebugStatsResponse, error) { - log.Printf("NullDebugStats: Received from client: %v", in) +// NullVolumeStats gets a Null volume instance stats +func (s *Server) NullVolumeStats(_ context.Context, in *pb.NullVolumeStatsRequest) (*pb.NullVolumeStatsResponse, error) { + log.Printf("NullVolumeStats: Received from client: %v", in) // check required fields if err := fieldbehavior.ValidateRequiredFields(in); err != nil { log.Printf("error: %v", err) @@ -326,7 +326,7 @@ func (s *Server) NullDebugStats(_ context.Context, in *pb.NullDebugStatsRequest) log.Print(msg) return nil, status.Errorf(codes.InvalidArgument, msg) } - return &pb.NullDebugStatsResponse{Stats: &pb.VolumeStats{ + return &pb.NullVolumeStatsResponse{Stats: &pb.VolumeStats{ ReadBytesCount: int32(result.Bdevs[0].BytesRead), ReadOpsCount: int32(result.Bdevs[0].NumReadOps), WriteBytesCount: int32(result.Bdevs[0].BytesWritten), diff --git a/pkg/backend/null_test.go b/pkg/backend/null_test.go index 7bede808..d421c34f 100644 --- a/pkg/backend/null_test.go +++ b/pkg/backend/null_test.go @@ -25,17 +25,17 @@ import ( var ( testNullVolumeID = "mytest" testNullVolumeName = server.ResourceIDToVolumeName(testNullVolumeID) - testNullVolume = pb.NullDebug{ + testNullVolume = pb.NullVolume{ BlockSize: 512, BlocksCount: 64, } ) -func TestBackEnd_CreateNullDebug(t *testing.T) { +func TestBackEnd_CreateNullVolume(t *testing.T) { tests := map[string]struct { id string - in *pb.NullDebug - out *pb.NullDebug + in *pb.NullVolume + out *pb.NullVolume spdk []string errCode codes.Code errMsg string @@ -119,8 +119,8 @@ func TestBackEnd_CreateNullDebug(t *testing.T) { tt.out.Name = testNullVolumeName } - request := &pb.CreateNullDebugRequest{NullDebug: tt.in, NullDebugId: tt.id} - response, err := testEnv.client.CreateNullDebug(testEnv.ctx, request) + request := &pb.CreateNullVolumeRequest{NullVolume: tt.in, NullVolumeId: tt.id} + response, err := testEnv.client.CreateNullVolume(testEnv.ctx, request) if !proto.Equal(response, tt.out) { t.Error("response: expected", tt.out, "received", response) @@ -140,11 +140,11 @@ func TestBackEnd_CreateNullDebug(t *testing.T) { } } -func TestBackEnd_UpdateNullDebug(t *testing.T) { +func TestBackEnd_UpdateNullVolume(t *testing.T) { tests := map[string]struct { mask *fieldmaskpb.FieldMask - in *pb.NullDebug - out *pb.NullDebug + in *pb.NullVolume + out *pb.NullVolume spdk []string errCode codes.Code errMsg string @@ -242,7 +242,7 @@ func TestBackEnd_UpdateNullDebug(t *testing.T) { }, "valid request with unknown key": { nil, - &pb.NullDebug{ + &pb.NullVolume{ Name: server.ResourceIDToVolumeName("unknown-id"), BlockSize: 512, BlocksCount: 64, @@ -255,12 +255,12 @@ func TestBackEnd_UpdateNullDebug(t *testing.T) { }, "unknown key with missing allowed": { nil, - &pb.NullDebug{ + &pb.NullVolume{ Name: server.ResourceIDToVolumeName("unknown-id"), BlockSize: 512, BlocksCount: 64, }, - &pb.NullDebug{ + &pb.NullVolume{ Name: server.ResourceIDToVolumeName("unknown-id"), BlockSize: 512, BlocksCount: 64, @@ -272,7 +272,7 @@ func TestBackEnd_UpdateNullDebug(t *testing.T) { }, "malformed name": { nil, - &pb.NullDebug{Name: "-ABC-DEF"}, + &pb.NullVolume{Name: "-ABC-DEF"}, nil, []string{}, codes.Unknown, @@ -290,8 +290,8 @@ func TestBackEnd_UpdateNullDebug(t *testing.T) { testNullVolume.Name = testNullVolumeName testEnv.opiSpdkServer.Volumes.NullVolumes[testNullVolumeName] = &testNullVolume - request := &pb.UpdateNullDebugRequest{NullDebug: tt.in, UpdateMask: tt.mask, AllowMissing: tt.missing} - response, err := testEnv.client.UpdateNullDebug(testEnv.ctx, request) + request := &pb.UpdateNullVolumeRequest{NullVolume: tt.in, UpdateMask: tt.mask, AllowMissing: tt.missing} + response, err := testEnv.client.UpdateNullVolume(testEnv.ctx, request) if !proto.Equal(response, tt.out) { t.Error("response: expected", tt.out, "received", response) @@ -311,10 +311,10 @@ func TestBackEnd_UpdateNullDebug(t *testing.T) { } } -func TestBackEnd_ListNullDebugs(t *testing.T) { +func TestBackEnd_ListNullVolumes(t *testing.T) { tests := map[string]struct { in string - out []*pb.NullDebug + out []*pb.NullVolume spdk []string errCode codes.Code errMsg string @@ -368,7 +368,7 @@ func TestBackEnd_ListNullDebugs(t *testing.T) { }, "valid request with valid SPDK response": { testNullVolumeID, - []*pb.NullDebug{ + []*pb.NullVolume{ { Name: "Malloc0", Uuid: &pc.Uuid{Value: "11d3902e-d9bb-49a7-bb27-cd7261ef3217"}, @@ -393,7 +393,7 @@ func TestBackEnd_ListNullDebugs(t *testing.T) { }, "pagination overflow": { testNullVolumeID, - []*pb.NullDebug{ + []*pb.NullVolume{ { Name: "Malloc0", Uuid: &pc.Uuid{Value: "11d3902e-d9bb-49a7-bb27-cd7261ef3217"}, @@ -433,7 +433,7 @@ func TestBackEnd_ListNullDebugs(t *testing.T) { }, "pagination": { testNullVolumeID, - []*pb.NullDebug{ + []*pb.NullVolume{ { Name: "Malloc0", Uuid: &pc.Uuid{Value: "11d3902e-d9bb-49a7-bb27-cd7261ef3217"}, @@ -449,7 +449,7 @@ func TestBackEnd_ListNullDebugs(t *testing.T) { }, "pagination offset": { testNullVolumeID, - []*pb.NullDebug{ + []*pb.NullVolume{ { Name: "Malloc1", Uuid: &pc.Uuid{Value: "88112c76-8c49-4395-955a-0d695b1d2099"}, @@ -473,11 +473,11 @@ func TestBackEnd_ListNullDebugs(t *testing.T) { testEnv.opiSpdkServer.Pagination["existing-pagination-token"] = 1 - request := &pb.ListNullDebugsRequest{Parent: tt.in, PageSize: tt.size, PageToken: tt.token} - response, err := testEnv.client.ListNullDebugs(testEnv.ctx, request) + request := &pb.ListNullVolumesRequest{Parent: tt.in, PageSize: tt.size, PageToken: tt.token} + response, err := testEnv.client.ListNullVolumes(testEnv.ctx, request) - if !server.EqualProtoSlices(response.GetNullDebugs(), tt.out) { - t.Error("response: expected", tt.out, "received", response.GetNullDebugs()) + if !server.EqualProtoSlices(response.GetNullVolumes(), tt.out) { + t.Error("response: expected", tt.out, "received", response.GetNullVolumes()) } if tt.size != 1 && response.GetNextPageToken() != "" { @@ -498,10 +498,10 @@ func TestBackEnd_ListNullDebugs(t *testing.T) { } } -func TestBackEnd_GetNullDebug(t *testing.T) { +func TestBackEnd_GetNullVolume(t *testing.T) { tests := map[string]struct { in string - out *pb.NullDebug + out *pb.NullVolume spdk []string errCode codes.Code errMsg string @@ -543,7 +543,7 @@ func TestBackEnd_GetNullDebug(t *testing.T) { }, "valid request with valid SPDK response": { testNullVolumeID, - &pb.NullDebug{ + &pb.NullVolume{ Name: "Malloc1", Uuid: &pc.Uuid{Value: "88112c76-8c49-4395-955a-0d695b1d2099"}, BlockSize: 512, @@ -577,8 +577,8 @@ func TestBackEnd_GetNullDebug(t *testing.T) { testEnv.opiSpdkServer.Volumes.NullVolumes[testNullVolumeID] = &testNullVolume - request := &pb.GetNullDebugRequest{Name: tt.in} - response, err := testEnv.client.GetNullDebug(testEnv.ctx, request) + request := &pb.GetNullVolumeRequest{Name: tt.in} + response, err := testEnv.client.GetNullVolume(testEnv.ctx, request) if !proto.Equal(response, tt.out) { t.Error("response: expected", tt.out, "received", response) @@ -598,7 +598,7 @@ func TestBackEnd_GetNullDebug(t *testing.T) { } } -func TestBackEnd_NullDebugStats(t *testing.T) { +func TestBackEnd_NullVolumeStats(t *testing.T) { tests := map[string]struct { in string out *pb.VolumeStats @@ -679,8 +679,8 @@ func TestBackEnd_NullDebugStats(t *testing.T) { testEnv.opiSpdkServer.Volumes.NullVolumes[testNullVolumeID] = &testNullVolume - request := &pb.NullDebugStatsRequest{Handle: &pc.ObjectKey{Value: tt.in}} - response, err := testEnv.client.NullDebugStats(testEnv.ctx, request) + request := &pb.NullVolumeStatsRequest{Handle: &pc.ObjectKey{Value: tt.in}} + response, err := testEnv.client.NullVolumeStats(testEnv.ctx, request) if !proto.Equal(response.GetStats(), tt.out) { t.Error("response: expected", tt.out, "received", response.GetStats()) @@ -700,7 +700,7 @@ func TestBackEnd_NullDebugStats(t *testing.T) { } } -func TestBackEnd_DeleteNullDebug(t *testing.T) { +func TestBackEnd_DeleteNullVolume(t *testing.T) { tests := map[string]struct { in string out *emptypb.Empty @@ -784,8 +784,8 @@ func TestBackEnd_DeleteNullDebug(t *testing.T) { fname1 := server.ResourceIDToVolumeName(tt.in) testEnv.opiSpdkServer.Volumes.NullVolumes[testNullVolumeName] = &testNullVolume - request := &pb.DeleteNullDebugRequest{Name: fname1, AllowMissing: tt.missing} - response, err := testEnv.client.DeleteNullDebug(testEnv.ctx, request) + request := &pb.DeleteNullVolumeRequest{Name: fname1, AllowMissing: tt.missing} + response, err := testEnv.client.DeleteNullVolume(testEnv.ctx, request) if er, ok := status.FromError(err); ok { if er.Code() != tt.errCode { diff --git a/scripts/tests.sh b/scripts/tests.sh index a3c891b4..2187ae15 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -35,14 +35,14 @@ docker run --network=host --rm docker.io/namely/grpc-cli ls 127.0.0.1:50051 # check reflection grpc_cli=(docker run --network=opi-spdk-bridge_opi --rm docker.io/namely/grpc-cli) "${grpc_cli[@]}" ls opi-spdk-server:50051 -"${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.AioControllerService -l +"${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.AioVolumeService -l "${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.FrontendNvmeService -l "${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.FrontendVirtioBlkService -l "${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.FrontendVirtioScsiService -l "${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.MiddleendEncryptionService -l "${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.MiddleendQosVolumeService -l "${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.NvmeRemoteControllerService -l -"${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.NullDebugService -l +"${grpc_cli[@]}" ls opi-spdk-server:50051 opi_api.storage.v1.NullVolumeService -l # check spdk sanity docker run --rm --network=host --privileged -v /dev/hugepages:/dev/hugepages ghcr.io/opiproject/spdk:main spdk_nvme_perf -r 'traddr:127.0.0.1 trtype:TCP adrfam:IPv4 trsvcid:4444 subnqn:nqn.2016-06.io.spdk:cnode1 hostnqn:nqn.2014-08.org.nvmexpress:uuid:feb98abe-d51f-40c8-b348-2753f3571d3c' -c 0x1 -q 1 -o 4096 -w randread -t 10 | tee log.txt