diff --git a/api/go/gosdn/pnd/pnd.pb.go b/api/go/gosdn/pnd/pnd.pb.go index 3738f74a09fbca7fb2ffe3c9e2116e6e3606bf44..a622934a77fe515fadc1e6b9865bb0bce2965201 100644 --- a/api/go/gosdn/pnd/pnd.pb.go +++ b/api/go/gosdn/pnd/pnd.pb.go @@ -1866,7 +1866,8 @@ type SetResponse struct { unknownFields protoimpl.UnknownFields Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Timestamp in nanoseconds since Epoch. - Status Status `protobuf:"varint,2,opt,name=status,proto3,enum=gosdn.pnd.Status" json:"status,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + Status Status `protobuf:"varint,3,opt,name=status,proto3,enum=gosdn.pnd.Status" json:"status,omitempty"` } func (x *SetResponse) Reset() { @@ -1908,6 +1909,13 @@ func (x *SetResponse) GetTimestamp() int64 { return 0 } +func (x *SetResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + func (x *SetResponse) GetStatus() Status { if x != nil { return x.Status @@ -2543,10 +2551,11 @@ var file_gosdn_pnd_pnd_proto_rawDesc = []byte{ 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x75, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x02, 0x6f, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6e, 0x64, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x02, 0x6f, 0x70, 0x22, 0x56, 0x0a, 0x0b, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x52, 0x02, 0x6f, 0x70, 0x22, 0x66, 0x0a, 0x0b, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x12, 0x29, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x29, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x70, 0x6e, 0x64, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x93, 0x01, 0x0a, 0x12, 0x53, 0x65, 0x74, 0x4f, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, diff --git a/api/openapiv2/gosdn_northbound.swagger.json b/api/openapiv2/gosdn_northbound.swagger.json index d7787740e84767031e74059eb15666340add3b6c..d5c84271c8d4ef29c118f5ce8a97c14f5be21ea0 100644 --- a/api/openapiv2/gosdn_northbound.swagger.json +++ b/api/openapiv2/gosdn_northbound.swagger.json @@ -2215,6 +2215,9 @@ "type": "string", "format": "int64" }, + "id": { + "type": "string" + }, "status": { "$ref": "#/definitions/gosdnpndStatus" } diff --git a/api/proto/buf.lock b/api/proto/buf.lock index 18424600585920365ca34c2abca5d6ade0947705..d7d702045b0aafc544ded4b2a2ab0242b8ab5c84 100644 --- a/api/proto/buf.lock +++ b/api/proto/buf.lock @@ -4,8 +4,14 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 0f45818f23164927b753ca450a5ed5bf + branch: main + commit: 21bf7e5141ca4ab9a894d42c81ebc570 + digest: b1-1Tn2sIjZX6rkgifBoIByzQIxjjVVhOltFQVK1888mUw= + create_time: 2022-04-19T15:12:03.248152Z - remote: buf.build owner: grpc-ecosystem repository: grpc-gateway - commit: f85c60ac38544f2d8f346491c9d916e5 + branch: main + commit: febd9e8be39b4f4b878b9c64bcc203fd + digest: b1-K5jSHBrJ24jZXRgQgkmphZuP-cAL2b90ssKrgvDK2hU= + create_time: 2022-04-17T01:28:07.574665Z diff --git a/api/proto/gosdn/pnd/pnd.proto b/api/proto/gosdn/pnd/pnd.proto index 11bed8ef564785395463955b363ba372fcff4da8..826a9a43a5871c92d390e48fa6b37f5e26612756 100644 --- a/api/proto/gosdn/pnd/pnd.proto +++ b/api/proto/gosdn/pnd/pnd.proto @@ -310,7 +310,8 @@ message SetChange { message SetResponse{ int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. - Status status = 2; + string id = 2; + Status status = 3; } message SetOndListResponse{ diff --git a/controller/api/grpc.go b/controller/api/grpc.go index 71f08e6de0c6cf25d7ef1744bb02622ce9e26af9..86393e1b892c667db3ba73b78e2fe6bb4d8d3c6f 100644 --- a/controller/api/grpc.go +++ b/controller/api/grpc.go @@ -255,7 +255,6 @@ func AddDevice(addr, deviceName string, opt *tpb.TransportOption, sid, pid uuid. req.Ond[0].Sbi.Id = uuid.Nil.String() req.Ond[0].Sbi.Type = t req.Ond[0].TransportOption.Type = t - default: } ctx := context.Background() return pndClient.SetOndList(ctx, req) diff --git a/controller/interfaces/networkdomain/pnd.go b/controller/interfaces/networkdomain/pnd.go index 2c86f6260acc4da3d2eba8b84688fe659592c68e..fc9dec411c54ec8a1877445401bb801f37aec274 100644 --- a/controller/interfaces/networkdomain/pnd.go +++ b/controller/interfaces/networkdomain/pnd.go @@ -16,7 +16,7 @@ type NetworkDomain interface { Destroy() error AddSbi(s southbound.SouthboundInterface) error RemoveSbi(uuid.UUID) error - AddDevice(name string, opts *tpb.TransportOption, sid uuid.UUID) error + AddDevice(name string, opts *tpb.TransportOption, sid uuid.UUID) (uuid.UUID, error) GetDevice(identifier string) (device.Device, error) RemoveDevice(uuid.UUID) error Devices() []device.Device diff --git a/controller/mocks/Change.go b/controller/mocks/Change.go index 9c3e9b9f26cddfe94a04c0e0d1a68b8f248dfa3a..1679dd57a3bd422db75db6d286e2b610c36c72dc 100644 --- a/controller/mocks/Change.go +++ b/controller/mocks/Change.go @@ -1,13 +1,15 @@ -// Code generated by mockery v2.10.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package mocks import ( - time "time" + testing "testing" pnd "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" mock "github.com/stretchr/testify/mock" + time "time" + uuid "github.com/google/uuid" ) @@ -87,3 +89,12 @@ func (_m *Change) State() pnd.ChangeState { return r0 } + +// NewChange creates a new instance of Change. It also registers a cleanup function to assert the mocks expectations. +func NewChange(t testing.TB) *Change { + mock := &Change{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/Device.go b/controller/mocks/Device.go index 5004309d1d439424d96d31b581b3e5f915d7f3bb..4b42cddd742c8809f09c16d2911ddc6d05f80cd2 100644 --- a/controller/mocks/Device.go +++ b/controller/mocks/Device.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.10.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( mock "github.com/stretchr/testify/mock" protoreflect "google.golang.org/protobuf/reflect/protoreflect" + testing "testing" + transport "code.fbi.h-da.de/danet/gosdn/controller/interfaces/transport" uuid "github.com/google/uuid" @@ -19,32 +21,32 @@ type Device struct { mock.Mock } -// ID provides a mock function with given fields: -func (_m *Device) ID() uuid.UUID { +// GetModel provides a mock function with given fields: +func (_m *Device) GetModel() ygot.ValidatedGoStruct { ret := _m.Called() - var r0 uuid.UUID - if rf, ok := ret.Get(0).(func() uuid.UUID); ok { + var r0 ygot.ValidatedGoStruct + if rf, ok := ret.Get(0).(func() ygot.ValidatedGoStruct); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(uuid.UUID) + r0 = ret.Get(0).(ygot.ValidatedGoStruct) } } return r0 } -// Model provides a mock function with given fields: -func (_m *Device) Model() ygot.GoStruct { +// ID provides a mock function with given fields: +func (_m *Device) ID() uuid.UUID { ret := _m.Called() - var r0 ygot.GoStruct - if rf, ok := ret.Get(0).(func() ygot.GoStruct); ok { + var r0 uuid.UUID + if rf, ok := ret.Get(0).(func() uuid.UUID); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(ygot.GoStruct) + r0 = ret.Get(0).(uuid.UUID) } } @@ -110,3 +112,12 @@ func (_m *Device) Transport() transport.Transport { return r0 } + +// NewDevice creates a new instance of Device. It also registers a cleanup function to assert the mocks expectations. +func NewDevice(t testing.TB) *Device { + mock := &Device{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/NetworkDomain.go b/controller/mocks/NetworkDomain.go index 607db2834b1e53331278f1cc1ddcb153790f67a8..22e6e7bfc2f65a0316466d46598827dc31eb621c 100644 --- a/controller/mocks/NetworkDomain.go +++ b/controller/mocks/NetworkDomain.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.10.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package mocks @@ -14,6 +14,8 @@ import ( southbound "code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound" + testing "testing" + transport "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport" uuid "github.com/google/uuid" @@ -25,17 +27,26 @@ type NetworkDomain struct { } // AddDevice provides a mock function with given fields: name, opts, sid -func (_m *NetworkDomain) AddDevice(name string, opts *transport.TransportOption, sid uuid.UUID) error { +func (_m *NetworkDomain) AddDevice(name string, opts *transport.TransportOption, sid uuid.UUID) (uuid.UUID, error) { ret := _m.Called(name, opts, sid) - var r0 error - if rf, ok := ret.Get(0).(func(string, *transport.TransportOption, uuid.UUID) error); ok { + var r0 uuid.UUID + if rf, ok := ret.Get(0).(func(string, *transport.TransportOption, uuid.UUID) uuid.UUID); ok { r0 = rf(name, opts, sid) } else { - r0 = ret.Error(0) + if ret.Get(0) != nil { + r0 = ret.Get(0).(uuid.UUID) + } } - return r0 + var r1 error + if rf, ok := ret.Get(1).(func(string, *transport.TransportOption, uuid.UUID) error); ok { + r1 = rf(name, opts, sid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } // AddSbi provides a mock function with given fields: s @@ -393,3 +404,12 @@ func (_m *NetworkDomain) RequestAll(_a0 string) error { return r0 } + +// NewNetworkDomain creates a new instance of NetworkDomain. It also registers a cleanup function to assert the mocks expectations. +func NewNetworkDomain(t testing.TB) *NetworkDomain { + mock := &NetworkDomain{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/Plugin.go b/controller/mocks/Plugin.go index f69729e0c9536a06314fca0e65d3f9b56157af3c..b6d86b9165866a110766c87bbd51b7d8934f3108 100644 --- a/controller/mocks/Plugin.go +++ b/controller/mocks/Plugin.go @@ -1,11 +1,14 @@ -// Code generated by mockery v2.10.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package mocks import ( + testing "testing" + plugin "code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin" - uuid "github.com/google/uuid" mock "github.com/stretchr/testify/mock" + + uuid "github.com/google/uuid" ) // Plugin is an autogenerated mock type for the Plugin type @@ -86,3 +89,12 @@ func (_m *Plugin) Update() error { return r0 } + +// NewPlugin creates a new instance of Plugin. It also registers a cleanup function to assert the mocks expectations. +func NewPlugin(t testing.TB) *Plugin { + mock := &Plugin{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/SouthboundInterface.go b/controller/mocks/SouthboundInterface.go index abf903d86ecce202e3a6c11b27e4098220e0afc5..ca8fa0a15e5db5baad513f82c4b2398c26eb120c 100644 --- a/controller/mocks/SouthboundInterface.go +++ b/controller/mocks/SouthboundInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.10.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package mocks @@ -7,6 +7,8 @@ import ( gnmi "github.com/openconfig/gnmi/proto/gnmi" mock "github.com/stretchr/testify/mock" + testing "testing" + uuid "github.com/google/uuid" yang "github.com/openconfig/goyang/pkg/yang" @@ -143,3 +145,12 @@ func (_m *SouthboundInterface) Unmarshal(_a0 []byte, _a1 *gnmi.Path, _a2 ygot.Va return r0 } + +// NewSouthboundInterface creates a new instance of SouthboundInterface. It also registers a cleanup function to assert the mocks expectations. +func NewSouthboundInterface(t testing.TB) *SouthboundInterface { + mock := &SouthboundInterface{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/Storable.go b/controller/mocks/Storable.go index 2f37e9dc922e617f2b42e0a89903d1001c1042c8..9219bcfc00e0276434dcc8cb53dbaa8a0cfddb18 100644 --- a/controller/mocks/Storable.go +++ b/controller/mocks/Storable.go @@ -1,10 +1,12 @@ -// Code generated by mockery v2.10.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package mocks import ( mock "github.com/stretchr/testify/mock" + testing "testing" + uuid "github.com/google/uuid" ) @@ -28,3 +30,12 @@ func (_m *Storable) ID() uuid.UUID { return r0 } + +// NewStorable creates a new instance of Storable. It also registers a cleanup function to assert the mocks expectations. +func NewStorable(t testing.TB) *Storable { + mock := &Storable{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/mocks/Transport.go b/controller/mocks/Transport.go index b2c7aa34f6b2b4235d36f407c9ed7c24f1ffd940..ae80536a4f465db7af6e5d47ec8beebd7ee027c4 100644 --- a/controller/mocks/Transport.go +++ b/controller/mocks/Transport.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.10.0. DO NOT EDIT. +// Code generated by mockery v2.11.0. DO NOT EDIT. package mocks @@ -9,6 +9,8 @@ import ( mock "github.com/stretchr/testify/mock" + testing "testing" + ytypes "github.com/openconfig/ygot/ytypes" ) @@ -109,3 +111,12 @@ func (_m *Transport) Type() string { return r0 } + +// NewTransport creates a new instance of Transport. It also registers a cleanup function to assert the mocks expectations. +func NewTransport(t testing.TB) *Transport { + mock := &Transport{} + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/controller/northbound/server/pnd.go b/controller/northbound/server/pnd.go index 6d53008450b78c502f81a6bf5ace70a8c367d0c4..fc009d5e5afa65519d32993815297f63f0f1ff9e 100644 --- a/controller/northbound/server/pnd.go +++ b/controller/northbound/server/pnd.go @@ -492,22 +492,26 @@ func (p pndServer) SetOndList(ctx context.Context, request *ppb.SetOndListReques return nil, handleRPCError(labels, err) } + deviceIDs := make([]uuid.UUID, 0, len(request.Ond)) for _, r := range request.Ond { sid, err := uuid.Parse(r.Sbi.Id) if err != nil { log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) } - if err := pnd.AddDevice(r.DeviceName, r.TransportOption, sid); err != nil { + did, err := pnd.AddDevice(r.DeviceName, r.TransportOption, sid) + if err != nil { log.Error(err) return nil, status.Errorf(codes.Aborted, "%v", err) } + deviceIDs = append(deviceIDs, did) } return &ppb.SetOndListResponse{ Timestamp: time.Now().UnixNano(), Status: ppb.Status_STATUS_OK, Responses: []*ppb.SetResponse{ { + Id: "", Status: ppb.Status_STATUS_OK, }, }, diff --git a/controller/nucleus/principalNetworkDomain.go b/controller/nucleus/principalNetworkDomain.go index 54a04a44759e2c1450714f370ae08ff4065ee7e3..bd31ff962470ee34ce26996bc205429f2371cd23 100644 --- a/controller/nucleus/principalNetworkDomain.go +++ b/controller/nucleus/principalNetworkDomain.go @@ -197,32 +197,31 @@ func (pnd *pndImplementation) RemoveSbi(sid uuid.UUID) error { } // AddDevice adds a new device to the PND -func (pnd *pndImplementation) AddDevice(name string, opt *tpb.TransportOption, sid uuid.UUID) error { +func (pnd *pndImplementation) AddDevice(name string, opt *tpb.TransportOption, sid uuid.UUID) (uuid.UUID, error) { labels := prometheus.Labels{"type": opt.Type.String()} start := metrics.StartHook(labels, deviceCreationsTotal) defer metrics.FinishHook(labels, start, deviceCreationDurationSecondsTotal, deviceCreationDurationSeconds) var sbi southbound.SouthboundInterface + var err error switch t := opt.Type; t { case spb.Type_TYPE_CONTAINERISED: return pnd.handleCsbiEnrolment(name, opt) case spb.Type_TYPE_PLUGIN: - var err error sbi, err = pnd.requestPlugin(name, opt) if err != nil { - return err + return uuid.Nil, err } default: - var err error sbi, err = pnd.sbic.Get(store.Query{ID: sid}) if err != nil { - return err + return uuid.Nil, err } } d, err := NewDevice(name, uuid.Nil, opt, sbi) if err != nil { - return err + return uuid.Nil, err } return pnd.addDevice(d) } @@ -284,13 +283,13 @@ func (pnd *pndImplementation) removeSbi(id uuid.UUID) error { } // addDevice adds a device to the PND's device store. -func (pnd *pndImplementation) addDevice(device device.Device) error { +func (pnd *pndImplementation) addDevice(device device.Device) (uuid.UUID, error) { err := pnd.devices.Add(device) if err != nil { - return err + return uuid.Nil, err } - return nil + return device.ID(), nil } func (pnd *pndImplementation) removeDevice(id uuid.UUID) error { @@ -472,7 +471,7 @@ func (pnd *pndImplementation) handleCsbiDeletion(id uuid.UUID) error { return nil } -func (pnd *pndImplementation) handleCsbiEnrolment(name string, opt *tpb.TransportOption) error { +func (pnd *pndImplementation) handleCsbiEnrolment(name string, opt *tpb.TransportOption) (uuid.UUID, error) { g := new(errgroup.Group) ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5) defer cancel() @@ -482,20 +481,26 @@ func (pnd *pndImplementation) handleCsbiEnrolment(name string, opt *tpb.Transpor } resp, err := pnd.csbiClient.Create(ctx, req) if err != nil { - return err + return uuid.Nil, err } + // the slice only contains one deployment + var devID uuid.UUID for _, d := range resp.Deployments { dCopy := d g.Go(func() error { - return pnd.createCsbiDevice(ctx, name, dCopy, opt) + devID, err = pnd.createCsbiDevice(ctx, name, dCopy, opt) + if err != nil { + return err + } + return nil }) } err = g.Wait() if err != nil { - return err + return uuid.Nil, err } - return nil + return devID, nil } // createCsbiDevice is a helper method for cSBI device creation. The method @@ -506,10 +511,10 @@ func (pnd *pndImplementation) createCsbiDevice( name string, d *cpb.Deployment, opt *tpb.TransportOption, -) error { +) (uuid.UUID, error) { id, err := uuid.Parse(d.Id) if err != nil { - return err + return uuid.Nil, err } ch := make(chan device.Details, 1) pnd.callback(id, ch) @@ -527,7 +532,7 @@ func (pnd *pndImplementation) createCsbiDevice( log.Infof("syn from csbi %v", deviceDetails.ID) id, err := uuid.Parse(deviceDetails.ID) if err != nil { - return err + return uuid.Nil, err } csbiTransportOptions := &tpb.TransportOption{ Address: deviceDetails.Address, @@ -548,41 +553,42 @@ func (pnd *pndImplementation) createCsbiDevice( // here and in csbi. gClient, err := pnd.csbiClient.GetGoStruct(ctx, req) if err != nil { - return err + return uuid.Nil, err } csbiID, err := saveGenericClientStreamToFile(gClient, "gostructs.go", uuid.New()) if err != nil { - return err + return uuid.Nil, err } // TODO: this is currently just a workaround needs major adjustments // here and in csbi. mClient, err := pnd.csbiClient.GetManifest(ctx, req) if err != nil { - return err + return uuid.Nil, err } _, err = saveGenericClientStreamToFile(mClient, "plugin.yml", csbiID) if err != nil { - return err + return uuid.Nil, err } csbi, err := NewSBI(spb.Type_TYPE_CONTAINERISED, csbiID) if err != nil { - return err + return uuid.Nil, err } err = pnd.sbic.Add(csbi) if err != nil { - return err + return uuid.Nil, err } d, err := NewDevice(name, uuid.Nil, csbiTransportOptions, csbi) if err != nil { - return err + return uuid.Nil, err } d.(*CsbiDevice).UUID = id ch <- device.Details{TransportOption: opt} if err := pnd.devices.Add(d); err != nil { - return err + return uuid.Nil, err } + return id, nil } - return nil + return uuid.Nil, nil } // requestPlugin is a feature for cSBIs and sends a plugin request to the cSBI diff --git a/controller/nucleus/principalNetworkDomain_test.go b/controller/nucleus/principalNetworkDomain_test.go index f6d58d02dab9cb0ebeb4c3a547a75f03242bcd08..261c80d855d1038ab16aa6a32c66385df4ea73a6 100644 --- a/controller/nucleus/principalNetworkDomain_test.go +++ b/controller/nucleus/principalNetworkDomain_test.go @@ -115,7 +115,7 @@ func Test_pndImplementation_AddDevice(t *testing.T) { t.Error(err) } - err := pnd.AddDevice(tt.args.name, tt.args.opts, defaultSbiID) + _, err := pnd.AddDevice(tt.args.name, tt.args.opts, defaultSbiID) if (err != nil) != tt.wantErr { t.Errorf("AddDevice() error = %v, wantErr %v", err, tt.wantErr) } @@ -298,7 +298,8 @@ func Test_pndImplementation_MarshalDevice(t *testing.T) { sbi: nil, transport: nil, } - if err := pnd.addDevice(d); err != nil { + _, err := pnd.addDevice(d) + if err != nil { t.Error(err) } got, err := pnd.MarshalDevice(tt.args.uuid.String()) @@ -343,7 +344,8 @@ func Test_pndImplementation_RemoveDevice(t *testing.T) { UUID: did, sbi: sbi, } - if err := pnd.addDevice(d); err != nil { + _, err = pnd.addDevice(d) + if err != nil { t.Error(err) } } @@ -388,10 +390,12 @@ func Test_pndImplementation_RemoveSbi(t *testing.T) { if err := pnd.addSbi(&OpenConfig{id: defaultSbiID}); err != nil { t.Error(err) } - if err := pnd.AddDevice("associatedDevice", opts, tt.args.id); err != nil { + _, err := pnd.AddDevice("associatedDevice", opts, tt.args.id) + if err != nil { t.Error(err) } - if err := pnd.AddDevice("associatedDevice2", opts, tt.args.id); err != nil { + _, err = pnd.AddDevice("associatedDevice2", opts, tt.args.id) + if err != nil { t.Error(err) } if tt.name == "exclusively remove associated devices" { @@ -399,7 +403,8 @@ func Test_pndImplementation_RemoveSbi(t *testing.T) { if err := pnd.addSbi(&OpenConfig{id: newID}); err != nil { t.Error(err) } - if err := pnd.AddDevice("associatedDevice2", opts, newID); err != nil { + _, err := pnd.AddDevice("associatedDevice2", opts, newID) + if err != nil { t.Error(err) } } @@ -467,7 +472,7 @@ func Test_pndImplementation_Request(t *testing.T) { transport := deviceWithMockTransport.Transport().(*mocks.Transport) transport.On("Get", mockContext, mock.Anything).Return(&gpb.GetResponse{}, tt.args.rErr) transport.On("ProcessResponse", mock.Anything, mock.Anything, mock.Anything).Return(tt.args.rErr) - _ = pnd.addDevice(deviceWithMockTransport) + _, _ = pnd.addDevice(deviceWithMockTransport) _, err := pnd.Request(tt.args.uuid, tt.args.path) if (err != nil) != tt.wantErr { @@ -524,7 +529,7 @@ func Test_pndImplementation_RequestAll(t *testing.T) { tr.On("Get", mockContext, mock.Anything).Return(&gpb.GetResponse{}, tt.args.rErr) tr.On("ProcessResponse", mock.Anything, mock.Anything, mock.Anything).Return(tt.args.rErr) - _ = pnd.addDevice(deviceWithMockTransport) + _, _ = pnd.addDevice(deviceWithMockTransport) if err := pnd.RequestAll(tt.args.path); (err != nil) != tt.wantErr { t.Errorf("RequestAll() error = %v, wantErr %v", err, tt.wantErr) } @@ -639,7 +644,8 @@ func Test_pndImplementation_ChangeOND(t *testing.T) { if err := pnd.addSbi(&OpenConfig{id: defaultSbiID}); err != nil { t.Error(err) } - if err := pnd.AddDevice("testdevice", opts, defaultSbiID); err != nil { + _, err := pnd.AddDevice("testdevice", opts, defaultSbiID) + if err != nil { t.Error(err) return } @@ -677,7 +683,8 @@ func Test_pndImplementation_GetDevice(t *testing.T) { t.Error(err) return } - if err = pnd.addDevice(d); err != nil { + _, err = pnd.addDevice(d) + if err != nil { t.Error(err) return } @@ -731,7 +738,8 @@ func Test_pndImplementation_GetDeviceByName(t *testing.T) { t.Error(err) return } - if err = p.addDevice(d); err != nil { + _, err = p.addDevice(d) + if err != nil { t.Error(err) return } @@ -794,11 +802,12 @@ func Test_pndImplementation_Confirm(t *testing.T) { d := mockDevice() tr := d.Transport().(*mocks.Transport) tr.On("Set", mockContext, mock.Anything, mock.Anything).Return(nil) - if err := pnd.addDevice(d); err != nil { + _, err := pnd.addDevice(d) + if err != nil { t.Error(err) return } - _, err := pnd.ChangeOND(d.ID(), ppb.ApiOperation_API_OPERATION_UPDATE, "system/config/hostname", "ceos3000") + _, err = pnd.ChangeOND(d.ID(), ppb.ApiOperation_API_OPERATION_UPDATE, "system/config/hostname", "ceos3000") if err != nil { t.Error(err) return diff --git a/controller/test/integration/nucleusIntegration_test.go b/controller/test/integration/nucleusIntegration_test.go index c7d44567d667848102abb11e83d896f3d4c4724c..b325c85549e0185743f96f609a14788aa31562ac 100644 --- a/controller/test/integration/nucleusIntegration_test.go +++ b/controller/test/integration/nucleusIntegration_test.go @@ -177,7 +177,8 @@ func TestGnmi_SetValidIntegration(t *testing.T) { t.Error(err) return } - if err := pnd.AddDevice("test", opt, sbi.ID()); err != nil { + _, err = pnd.AddDevice("test", opt, sbi.ID()) + if err != nil { t.Error(err) return }