Skip to content

Commit

Permalink
feat(storage): renaming Aio and Null to Volume
Browse files Browse the repository at this point in the history
This brings more consistency to the naming of backend

See opiproject/opi-api#304

Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Jul 26, 2023
1 parent 87faa85 commit 6586529
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 66 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/lithammer/fuzzysearch v1.1.8
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.9
github.com/opiproject/opi-api v0.0.0-20230721161716-ea8314a63ccb
github.com/opiproject/opi-api v0.0.0-20230726170919-691a90a13429
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
golang.org/x/net v0.12.0
Expand All @@ -32,8 +32,8 @@ require (
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/tools v0.9.3 // 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
gopkg.in/yaml.v3 v3.0.1 // indirect
)
22 changes: 8 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,10 @@ github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU=
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc=
github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ=
github.com/onsi/gomega v1.27.9 h1:qIyVWbOsvQEye2QCqLsNSeH/5L1RS9vS382erEWfT3o=
github.com/onsi/gomega v1.27.9/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
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-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/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down Expand Up @@ -104,12 +98,12 @@ golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM=
golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/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=
Expand Down
54 changes: 27 additions & 27 deletions storage/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
// DoBackend executes the back end code
func DoBackend(ctx context.Context, conn grpc.ClientConnInterface) error {
nvme := pb.NewNvmeRemoteControllerServiceClient(conn)
null := pb.NewNullDebugServiceClient(conn)
aio := pb.NewAioControllerServiceClient(conn)
null := pb.NewNullVolumeServiceClient(conn)
aio := pb.NewAioVolumeServiceClient(conn)

err := executeNvmeRemoteController(ctx, nvme)
if err != nil {
Expand All @@ -35,11 +35,11 @@ func DoBackend(ctx context.Context, conn grpc.ClientConnInterface) error {
if err != nil {
return err
}
err = executeNullDebug(ctx, null)
err = executeNullVolume(ctx, null)
if err != nil {
return err
}
err = executeAioController(ctx, aio)
err = executeAioVolume(ctx, aio)
if err != nil {
return err
}
Expand Down Expand Up @@ -214,16 +214,16 @@ func executeNvmePath(ctx context.Context, c5 pb.NvmeRemoteControllerServiceClien
return nil
}

func executeNullDebug(ctx context.Context, c1 pb.NullDebugServiceClient) error {
func executeNullVolume(ctx context.Context, c1 pb.NullVolumeServiceClient) error {
log.Printf("=======================================")
log.Printf("Testing NewNullDebugServiceClient")
log.Printf("Testing NewNullVolumeServiceClient")
log.Printf("=======================================")

// testing with and without {resource}_id field
for _, resourceID := range []string{"opi-null9", ""} {
rs1, err := c1.CreateNullDebug(ctx, &pb.CreateNullDebugRequest{
NullDebugId: resourceID,
NullDebug: &pb.NullDebug{BlockSize: 512, BlocksCount: 64}})
rs1, err := c1.CreateNullVolume(ctx, &pb.CreateNullVolumeRequest{
NullVolumeId: resourceID,
NullVolume: &pb.NullVolume{BlockSize: 512, BlocksCount: 64}})
if err != nil {
return err
}
Expand All @@ -242,29 +242,29 @@ func executeNullDebug(ctx context.Context, c1 pb.NullDebugServiceClient) error {
}
log.Printf("Added Null: %v", rs1)
// continue
rs3, err := c1.UpdateNullDebug(ctx, &pb.UpdateNullDebugRequest{
rs3, err := c1.UpdateNullVolume(ctx, &pb.UpdateNullVolumeRequest{
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"*"}},
NullDebug: &pb.NullDebug{Name: rs1.Name}})
NullVolume: &pb.NullVolume{Name: rs1.Name}})
if err != nil {
return err
}
log.Printf("Updated Null: %v", rs3)
rs4, err := c1.ListNullDebugs(ctx, &pb.ListNullDebugsRequest{Parent: "todo"})
rs4, err := c1.ListNullVolumes(ctx, &pb.ListNullVolumesRequest{Parent: "todo"})
if err != nil {
return err
}
log.Printf("Listed Null: %v", rs4)
rs5, err := c1.GetNullDebug(ctx, &pb.GetNullDebugRequest{Name: rs1.Name})
rs5, err := c1.GetNullVolume(ctx, &pb.GetNullVolumeRequest{Name: rs1.Name})
if err != nil {
return err
}
log.Printf("Got Null: %s", rs5.Name)
rs6, err := c1.NullDebugStats(ctx, &pb.NullDebugStatsRequest{Handle: &pc.ObjectKey{Value: rs1.Name}})
rs6, err := c1.NullVolumeStats(ctx, &pb.NullVolumeStatsRequest{Handle: &pc.ObjectKey{Value: rs1.Name}})
if err != nil {
return err
}
log.Printf("Stats Null: %s", rs6.Stats)
rs2, err := c1.DeleteNullDebug(ctx, &pb.DeleteNullDebugRequest{Name: rs1.Name})
rs2, err := c1.DeleteNullVolume(ctx, &pb.DeleteNullVolumeRequest{Name: rs1.Name})
if err != nil {
return err
}
Expand All @@ -273,16 +273,16 @@ func executeNullDebug(ctx context.Context, c1 pb.NullDebugServiceClient) error {
return nil
}

func executeAioController(ctx context.Context, c2 pb.AioControllerServiceClient) error {
func executeAioVolume(ctx context.Context, c2 pb.AioVolumeServiceClient) error {
log.Printf("=======================================")
log.Printf("Testing NewAioControllerServiceClient")
log.Printf("Testing NewAioVolumeServiceClient")
log.Printf("=======================================")

// testing with and without {resource}_id field
for _, resourceID := range []string{"opi-aio4", ""} {
ra1, err := c2.CreateAioController(ctx, &pb.CreateAioControllerRequest{
AioControllerId: resourceID,
AioController: &pb.AioController{BlockSize: 512, BlocksCount: 12, Filename: "/tmp/aio_bdev_file"}})
ra1, err := c2.CreateAioVolume(ctx, &pb.CreateAioVolumeRequest{
AioVolumeId: resourceID,
AioVolume: &pb.AioVolume{BlockSize: 512, BlocksCount: 12, Filename: "/tmp/aio_bdev_file"}})
if err != nil {
return err
}
Expand All @@ -301,29 +301,29 @@ func executeAioController(ctx context.Context, c2 pb.AioControllerServiceClient)
}
log.Printf("Added Aio: %v", ra1)
// continue
ra3, err := c2.UpdateAioController(ctx, &pb.UpdateAioControllerRequest{
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"*"}},
AioController: &pb.AioController{Name: ra1.Name, Filename: "/tmp/aio_bdev_file"}})
ra3, err := c2.UpdateAioVolume(ctx, &pb.UpdateAioVolumeRequest{
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"*"}},
AioVolume: &pb.AioVolume{Name: ra1.Name, Filename: "/tmp/aio_bdev_file"}})
if err != nil {
return err
}
log.Printf("Updated Aio: %v", ra3)
ra4, err := c2.ListAioControllers(ctx, &pb.ListAioControllersRequest{Parent: "todo"})
ra4, err := c2.ListAioVolumes(ctx, &pb.ListAioVolumesRequest{Parent: "todo"})
if err != nil {
return err
}
log.Printf("Listed Aio: %v", ra4)
ra5, err := c2.GetAioController(ctx, &pb.GetAioControllerRequest{Name: ra1.Name})
ra5, err := c2.GetAioVolume(ctx, &pb.GetAioVolumeRequest{Name: ra1.Name})
if err != nil {
return err
}
log.Printf("Got Aio: %s", ra5.Name)
ra6, err := c2.AioControllerStats(ctx, &pb.AioControllerStatsRequest{Handle: &pc.ObjectKey{Value: ra1.Name}})
ra6, err := c2.AioVolumeStats(ctx, &pb.AioVolumeStatsRequest{Handle: &pc.ObjectKey{Value: ra1.Name}})
if err != nil {
return err
}
log.Printf("Stats Aio: %s", ra6.Stats)
ra2, err := c2.DeleteAioController(ctx, &pb.DeleteAioControllerRequest{Name: ra1.Name})
ra2, err := c2.DeleteAioVolume(ctx, &pb.DeleteAioVolumeRequest{Name: ra1.Name})
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions storage/goopicsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ func CreateNvmeNamespace(id string, subSystemID string, nguid string, hostID int
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

client1 := pb.NewNullDebugServiceClient(conn)
response, err := client1.ListNullDebugs(ctx, &pb.ListNullDebugsRequest{Parent: "todo"})
client1 := pb.NewNullVolumeServiceClient(conn)
response, err := client1.ListNullVolumes(ctx, &pb.ListNullVolumesRequest{Parent: "todo"})

if err != nil {
log.Println(err)
return "", err
}

volumeData := response.NullDebugs
volumeData := response.NullVolumes
volumeID := ""
for _, data := range volumeData {
uuid := strings.ReplaceAll(data.Uuid.Value, "-", "")
Expand Down
2 changes: 1 addition & 1 deletion storage/goopicsi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func RunServer() {

pb.RegisterFrontendNvmeServiceServer(MockServer, &server.GoopCSI{})
pb.RegisterNvmeRemoteControllerServiceServer(MockServer, &server.GoopCSI{})
pb.RegisterNullDebugServiceServer(MockServer, &server.GoopCSI{})
pb.RegisterNullVolumeServiceServer(MockServer, &server.GoopCSI{})

fmt.Printf("Serving gRPC on %s\n", csiAddress)
errChan := make(chan error)
Expand Down
28 changes: 14 additions & 14 deletions testing/mock-server/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,39 @@ import (
// GoopCSI mock gRPC server to implement mock service calls
type GoopCSI struct{}

// CreateNullDebug creates a mock NullDebug
func (s *GoopCSI) CreateNullDebug(_ context2.Context, _ *pb.CreateNullDebugRequest) (*pb.NullDebug, error) {
// CreateNullVolume creates a mock NullVolume
func (s *GoopCSI) CreateNullVolume(_ context2.Context, _ *pb.CreateNullVolumeRequest) (*pb.NullVolume, error) {
// TODO implement me
panic("implement me")
}

// DeleteNullDebug Deletes a mock NullDebug
func (s *GoopCSI) DeleteNullDebug(_ context2.Context, _ *pb.DeleteNullDebugRequest) (*emptypb.Empty, error) {
// DeleteNullVolume Deletes a mock NullVolume
func (s *GoopCSI) DeleteNullVolume(_ context2.Context, _ *pb.DeleteNullVolumeRequest) (*emptypb.Empty, error) {
// TODO implement me
panic("implement me")
}

// UpdateNullDebug Updated mock NullDebug
func (s *GoopCSI) UpdateNullDebug(_ context2.Context, _ *pb.UpdateNullDebugRequest) (*pb.NullDebug, error) {
// UpdateNullVolume Updated mock NullVolume
func (s *GoopCSI) UpdateNullVolume(_ context2.Context, _ *pb.UpdateNullVolumeRequest) (*pb.NullVolume, error) {
// TODO implement me
panic("implement me")
}

// ListNullDebugs Lists mock nullDebugs
func (s *GoopCSI) ListNullDebugs(_ context2.Context, request *pb.ListNullDebugsRequest) (*pb.ListNullDebugsResponse, error) {
out := &pb.ListNullDebugsResponse{}
err := FindStub("NullDebugServiceServer", "ListNullDebugs", request, out)
// ListNullVolumes Lists mock nullDebugs
func (s *GoopCSI) ListNullVolumes(_ context2.Context, request *pb.ListNullVolumesRequest) (*pb.ListNullVolumesResponse, error) {
out := &pb.ListNullVolumesResponse{}
err := FindStub("NullVolumeServiceServer", "ListNullVolumes", request, out)
return out, err
}

// GetNullDebug Gets mock NullDebug
func (s *GoopCSI) GetNullDebug(_ context2.Context, _ *pb.GetNullDebugRequest) (*pb.NullDebug, error) {
// GetNullVolume Gets mock NullVolume
func (s *GoopCSI) GetNullVolume(_ context2.Context, _ *pb.GetNullVolumeRequest) (*pb.NullVolume, error) {
// TODO implement me
panic("implement me")
}

// NullDebugStats gets mock NullDebugStats
func (s *GoopCSI) NullDebugStats(_ context2.Context, _ *pb.NullDebugStatsRequest) (*pb.NullDebugStatsResponse, error) {
// NullVolumeStats gets mock NullVolumeStats
func (s *GoopCSI) NullVolumeStats(_ context2.Context, _ *pb.NullVolumeStatsRequest) (*pb.NullVolumeStatsResponse, error) {
// TODO implement me
panic("implement me")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"service": "NullDebugServiceServer",
"method": "ListNullDebugs",
"service": "NullVolumeServiceServer",
"method": "ListNullVolumes",
"input": {
"contains": {
}
},
"output": {
"data": {
"NullDebugs": [{
"NullVolumes": [{
"Handle": {"Value":"12"},
"Uuid": {"Value": "12"}
}]
Expand Down

0 comments on commit 6586529

Please sign in to comment.