blob: 20cb38d6ed9e5fb909fd1201454064f655ef0e51 [file] [log] [blame]
cbabua9e04cc2019-10-03 12:35:45 +05301/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
cbabubef89432019-10-18 11:47:27 +020017/*
18This file contains unit test cases for functions in the file openolt.go.
19This file also implements the fields struct to mock the Openolt and few utility functions.
20*/
21
Scott Bakerdbd960e2020-02-28 08:57:51 -080022//Package core provides the utility for olt devices, flows and statistics
23package core
cbabua9e04cc2019-10-03 12:35:45 +053024
25import (
26 "context"
27 "errors"
Esin Karamanccb714b2019-11-29 15:02:06 +000028 com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
29 fu "github.com/opencord/voltha-lib-go/v3/pkg/flows"
30 "github.com/opencord/voltha-lib-go/v3/pkg/kafka"
David K. Bainbridge794735f2020-02-11 21:01:37 -080031 "github.com/opencord/voltha-lib-go/v3/pkg/log"
Scott Bakerdbd960e2020-02-28 08:57:51 -080032 "github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
Thomas Lee S94109f12020-03-03 16:39:29 +053033 "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
Esin Karamanccb714b2019-11-29 15:02:06 +000034 ic "github.com/opencord/voltha-protos/v3/go/inter_container"
35 "github.com/opencord/voltha-protos/v3/go/openflow_13"
36 ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
37 "github.com/opencord/voltha-protos/v3/go/voltha"
kesavand39e0aa32020-01-28 20:58:50 -050038 "reflect"
39 "sync"
40 "testing"
cbabua9e04cc2019-10-03 12:35:45 +053041)
42
cbabubef89432019-10-18 11:47:27 +020043// mocks the OpenOLT struct.
cbabua9e04cc2019-10-03 12:35:45 +053044type fields struct {
45 deviceHandlers map[string]*DeviceHandler
46 coreProxy *com.CoreProxy
47 adapterProxy *com.AdapterProxy
48 eventProxy *com.EventProxy
npujarec5762e2020-01-01 14:08:48 +053049 kafkaICProxy kafka.InterContainerProxy
cbabua9e04cc2019-10-03 12:35:45 +053050 numOnus int
51 KVStoreHost string
52 KVStorePort int
53 KVStoreType string
54 exitChannel chan int
55 lockDeviceHandlersMap sync.RWMutex
56 ctx context.Context
57}
58
cbabubef89432019-10-18 11:47:27 +020059// mockOlt mocks OpenOLT struct.
cbabua9e04cc2019-10-03 12:35:45 +053060func mockOlt() *fields {
cbabua9e04cc2019-10-03 12:35:45 +053061 dh := newMockDeviceHandler()
62 newOlt := &fields{}
63 newOlt.deviceHandlers = map[string]*DeviceHandler{}
64 newOlt.deviceHandlers[dh.device.Id] = dh
65 return newOlt
66}
67
cbabubef89432019-10-18 11:47:27 +020068// testOltObject maps fields type to OpenOLt type.
cbabua9e04cc2019-10-03 12:35:45 +053069func testOltObject(testOlt *fields) *OpenOLT {
70 return &OpenOLT{
71 deviceHandlers: testOlt.deviceHandlers,
72 coreProxy: testOlt.coreProxy,
73 adapterProxy: testOlt.adapterProxy,
74 eventProxy: testOlt.eventProxy,
75 kafkaICProxy: testOlt.kafkaICProxy,
76 numOnus: testOlt.numOnus,
77 KVStoreHost: testOlt.KVStoreHost,
78 KVStorePort: testOlt.KVStorePort,
79 KVStoreType: testOlt.KVStoreType,
80 exitChannel: testOlt.exitChannel,
81 }
82}
83
cbabubef89432019-10-18 11:47:27 +020084// mockDevice mocks Device.
cbabua9e04cc2019-10-03 12:35:45 +053085func mockDevice() *voltha.Device {
86 device := &voltha.Device{
87 Id: "olt",
88 Root: true,
89 ParentId: "logical_device",
90 Ports: []*voltha.Port{
91 {PortNo: 1, Label: "pon"},
92 {PortNo: 2, Label: "nni"},
93 },
94 ProxyAddress: &voltha.Device_ProxyAddress{
95 DeviceId: "olt",
96 DeviceType: "onu",
97 ChannelId: 1,
98 ChannelGroupId: 1,
99 },
100 ConnectStatus: 1,
101 }
102 return device
103}
104
105func TestNewOpenOLT(t *testing.T) {
106 tests := []struct {
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530107 name string
108 fields *fields
109 configFlags *config.AdapterFlags
110 want *OpenOLT
cbabua9e04cc2019-10-03 12:35:45 +0530111 }{
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530112 {"newopenolt-1", &fields{}, &config.AdapterFlags{OnuNumber: 1, KVStorePort: 1, KVStoreType: "consul", KVStoreHost: "1.1.1.1"},
cbabua9e04cc2019-10-03 12:35:45 +0530113 &OpenOLT{numOnus: 1, KVStorePort: 1, KVStoreType: "consul", KVStoreHost: "1.1.1.1"}},
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530114 {"newopenolt-2", &fields{}, &config.AdapterFlags{OnuNumber: 2, KVStorePort: 2, KVStoreType: "etcd", KVStoreHost: "2.2.2.2"},
cbabua9e04cc2019-10-03 12:35:45 +0530115 &OpenOLT{numOnus: 2, KVStorePort: 2, KVStoreType: "etcd", KVStoreHost: "2.2.2.2"}},
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530116 {"newopenolt-3", &fields{}, &config.AdapterFlags{OnuNumber: 3, KVStorePort: 3, KVStoreType: "consul", KVStoreHost: "3.3.3.3"},
cbabua9e04cc2019-10-03 12:35:45 +0530117 &OpenOLT{numOnus: 3, KVStorePort: 3, KVStoreType: "consul", KVStoreHost: "3.3.3.3"}},
118 }
119 for _, tt := range tests {
120 t.Run(tt.name, func(t *testing.T) {
121 if got := NewOpenOLT(tt.fields.ctx, tt.fields.kafkaICProxy, tt.fields.coreProxy, tt.fields.adapterProxy,
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530122 tt.fields.eventProxy, tt.configFlags); reflect.TypeOf(got) != reflect.TypeOf(tt.want) && got != nil {
cbabua9e04cc2019-10-03 12:35:45 +0530123 t.Errorf("NewOpenOLT() error = %v, wantErr %v", got, tt.want)
124 }
125 })
126 }
127}
128
129func TestOpenOLT_Abandon_device(t *testing.T) {
130 type args struct {
131 device *voltha.Device
132 }
133 tests := []struct {
134 name string
135 fields *fields
136 args args
137 wantErr error
138 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530139 {"abandon_device-1", &fields{}, args{}, olterrors.ErrNotImplemented},
140 {"abandon_device-2", &fields{}, args{}, olterrors.ErrNotImplemented},
141 {"abandon_device-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530142 }
143 for _, tt := range tests {
144 t.Run(tt.name, func(t *testing.T) {
145 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800146 if err := oo.Abandon_device(tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530147 t.Errorf("Abandon_device() error = %v, wantErr %v", err, tt.wantErr)
148 }
149 })
150 }
151}
152
153func TestOpenOLT_Activate_image_update(t *testing.T) {
154 type args struct {
155 device *voltha.Device
156 request *voltha.ImageDownload
157 }
158 tests := []struct {
159 name string
160 fields *fields
161 args args
162 want *voltha.ImageDownload
163 wantErr error
164 }{
165 {"activate_image_upate-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530166 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530167 {"activate_image_upate-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123CDE"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530168 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530169 {"activate_image_upate-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123EFG"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530170 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530171 }
172 for _, tt := range tests {
173 t.Run(tt.name, func(t *testing.T) {
174 oo := testOltObject(tt.fields)
175 got, err := oo.Activate_image_update(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800176 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530177 t.Errorf("Activate_image_update() error = %v, wantErr %v", err, tt.wantErr)
178 }
179 })
180 }
181}
182
183func TestOpenOLT_Adapter_descriptor(t *testing.T) {
184 tests := []struct {
185 name string
186 fields *fields
187 wantErr error
188 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530189 {"adapter_descriptor-1", &fields{}, olterrors.ErrNotImplemented},
190 {"adapter_descriptor-2", &fields{}, olterrors.ErrNotImplemented},
191 {"adapter_descriptor-3", &fields{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530192 }
193 for _, tt := range tests {
194 t.Run(tt.name, func(t *testing.T) {
195 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800196 if err := oo.Adapter_descriptor(); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530197 t.Errorf("Adapter_descriptor() error = %v, wantErr %v", err, tt.wantErr)
198 }
199 })
200 }
201}
202
203func TestOpenOLT_Adopt_device(t *testing.T) {
204 type args struct {
205 device *voltha.Device
206 }
207 var device = mockDevice()
kesavand39e0aa32020-01-28 20:58:50 -0500208 device.Id = "olt"
Thomas Lee S94109f12020-03-03 16:39:29 +0530209 nilDevice := olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
cbabua9e04cc2019-10-03 12:35:45 +0530210 tests := []struct {
211 name string
212 fields *fields
213 args args
214 wantErr error
215 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800216 {"adopt_device-1", mockOlt(), args{}, nilDevice},
217 {"adopt_device-2", mockOlt(), args{device}, nilDevice},
218 {"adopt_device-3", mockOlt(), args{mockDevice()}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530219 }
220 for _, tt := range tests {
221 t.Run(tt.name, func(t *testing.T) {
222 oo := testOltObject(tt.fields)
223 err := oo.Adopt_device(tt.args.device)
224 if (err != nil) && (reflect.TypeOf(err) !=
225 reflect.TypeOf(tt.wantErr)) && (tt.args.device == nil) {
226 t.Errorf("Adopt_device() error = %v, wantErr %v", err, tt.wantErr)
227 }
228 if err == nil {
229 t.Log("return'd nil")
230 }
231 })
232 }
233}
234
235func TestOpenOLT_Cancel_image_download(t *testing.T) {
236 type args struct {
237 device *voltha.Device
238 request *voltha.ImageDownload
239 }
240 tests := []struct {
241 name string
242 fields *fields
243 args args
244 want *voltha.ImageDownload
245 wantErr error
246 }{
247 {"cancel_image_download-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530248 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530249 {"cancel_image_download-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123IJK"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530250 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530251 {"cancel_image_download-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123KLM"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530252 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530253 }
254 for _, tt := range tests {
255 t.Run(tt.name, func(t *testing.T) {
256 oo := testOltObject(tt.fields)
257 got, err := oo.Cancel_image_download(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800258 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530259 t.Errorf("Cancel_image_download() error = %v, wantErr %v", err, tt.wantErr)
260 }
261 })
262 }
263}
264
265func TestOpenOLT_Delete_device(t *testing.T) {
266 type args struct {
267 device *voltha.Device
268 }
269 tests := []struct {
270 name string
271 fields *fields
272 args args
273 wantErr error
274 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800275 {"delete_device-1", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530276 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530277 }
278 for _, tt := range tests {
279 t.Run(tt.name, func(t *testing.T) {
280 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800281 if err := oo.Delete_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530282 t.Errorf("Delete_device() error = %v, wantErr %v", err, tt.wantErr)
283 }
284 })
285 }
286}
287
288func TestOpenOLT_Device_types(t *testing.T) {
289 tests := []struct {
290 name string
291 fields *fields
292 want *voltha.DeviceTypes
293 wantErr error
294 }{
295 {"device_types-1", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530296 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530297 {"device_types-2", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530298 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530299 {"device_types-3", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530300 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530301 }
302 for _, tt := range tests {
303 t.Run(tt.name, func(t *testing.T) {
304 oo := testOltObject(tt.fields)
305 got, err := oo.Device_types()
David K. Bainbridge794735f2020-02-11 21:01:37 -0800306 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530307 t.Errorf("Device_types() error = %v, wantErr %v", err, tt.wantErr)
308 }
309 })
310 }
311}
312
313func TestOpenOLT_Disable_device(t *testing.T) {
314 type args struct {
315 device *voltha.Device
316 }
317 tests := []struct {
318 name string
319 fields *fields
320 args args
321 wantErr error
322 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800323 {"disable_device-1", mockOlt(), args{mockDevice()}, nil},
324 {"disable_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530325 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530326 }
327 for _, tt := range tests {
328 t.Run(tt.name, func(t *testing.T) {
329 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800330 if err := oo.Disable_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530331 t.Errorf("Disable_device() error = %v, wantErr %v", err, tt.wantErr)
332 }
333 })
334 }
335}
336
337func TestOpenOLT_Download_image(t *testing.T) {
338 type args struct {
339 device *voltha.Device
340 request *voltha.ImageDownload
341 }
342 tests := []struct {
343 name string
344 fields *fields
345 args args
346 want *voltha.ImageDownload
347 wantErr error
348 }{
349 {"download_image-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530350 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530351 {"download_image-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123LKJ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530352 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530353 {"download_image-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123RTY"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530354 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530355 }
356 for _, tt := range tests {
357 t.Run(tt.name, func(t *testing.T) {
358 oo := testOltObject(tt.fields)
359 got, err := oo.Download_image(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800360 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530361 t.Errorf("Download_image() error = %v, wantErr %v", err, tt.wantErr)
362 }
363 })
364 }
365}
366
367func TestOpenOLT_Get_device_details(t *testing.T) {
368 type args struct {
369 device *voltha.Device
370 }
371 tests := []struct {
372 name string
373 fields *fields
374 args args
375 wantErr error
376 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530377 {"get_device_details-1", &fields{}, args{}, olterrors.ErrNotImplemented},
378 {"get_device_details-2", &fields{}, args{}, olterrors.ErrNotImplemented},
379 {"get_device_details-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530380 }
381 for _, tt := range tests {
382 t.Run(tt.name, func(t *testing.T) {
383 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800384 if err := oo.Get_device_details(tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530385 t.Errorf("Get_device_details() error = %v, wantErr %v", err, tt.wantErr)
386 }
387 })
388 }
389}
390
391func TestOpenOLT_Get_image_download_status(t *testing.T) {
392 type args struct {
393 device *voltha.Device
394 request *voltha.ImageDownload
395 }
396 tests := []struct {
397 name string
398 fields *fields
399 args args
400 want *voltha.ImageDownload
401 wantErr error
402 }{
403 {"get_image_download_status-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530404 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530405 {"get_image_download_status-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123LKJ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530406 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530407 {"get_image_download_status-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123DFG"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530408 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530409 }
410 for _, tt := range tests {
411 t.Run(tt.name, func(t *testing.T) {
412 oo := testOltObject(tt.fields)
413 got, err := oo.Get_image_download_status(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800414 if err != tt.wantErr && got == nil {
415 t.Errorf("Get_image_download_status() got = %v want = %v error = %v, wantErr %v",
416 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530417 }
418 })
419 }
420}
421
422func TestOpenOLT_Get_ofp_device_info(t *testing.T) {
423 type args struct {
424 device *voltha.Device
425 }
426 tests := []struct {
427 name string
428 fields *fields
429 args args
430 want *ic.SwitchCapability
431 wantErr error
432 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800433 {"get_ofp_device_info-1", mockOlt(), args{mockDevice()}, &ic.SwitchCapability{
434 Desc: &openflow_13.OfpDesc{
435 MfrDesc: "VOLTHA Project",
436 HwDesc: "open_pon",
437 SwDesc: "open_pon",
438 },
439 SwitchFeatures: &openflow_13.OfpSwitchFeatures{
440 NBuffers: uint32(256),
441 NTables: uint32(2),
442 Capabilities: uint32(15),
443 },
444 }, nil},
445 {"get_ofp_device_info-2", &fields{}, args{mockDevice()}, nil,
Thomas Lee S94109f12020-03-03 16:39:29 +0530446 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530447 }
448 for _, tt := range tests {
449 t.Run(tt.name, func(t *testing.T) {
450 oo := testOltObject(tt.fields)
451 got, err := oo.Get_ofp_device_info(tt.args.device)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800452 if !reflect.DeepEqual(err, tt.wantErr) || !reflect.DeepEqual(got, tt.want) {
453 t.Errorf("Get_ofp_device_info() got = %v want = %v error = %v, wantErr = %v",
454 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530455 }
456 })
457 }
458}
459
460func TestOpenOLT_Get_ofp_port_info(t *testing.T) {
461 type args struct {
462 device *voltha.Device
463 portNo int64
464 }
465 tests := []struct {
466 name string
467 fields *fields
468 args args
469 want *ic.PortCapability
470 wantErr error
471 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800472 {"get_ofp_port_info-1", mockOlt(), args{mockDevice(), 1}, &ic.PortCapability{
473 Port: &voltha.LogicalPort{
474 DeviceId: "olt",
475 DevicePortNo: uint32(1),
476 OfpPort: &openflow_13.OfpPort{
477 HwAddr: []uint32{1, 2, 3, 4, 5, 6},
478 State: uint32(4),
479 Curr: uint32(4128),
480 Advertised: uint32(4128),
481 Peer: uint32(4128),
482 CurrSpeed: uint32(32),
483 MaxSpeed: uint32(32),
484 },
485 },
486 }, nil},
487 {"get_ofp_port_info-2", &fields{}, args{mockDevice(), 1}, nil,
Thomas Lee S94109f12020-03-03 16:39:29 +0530488 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530489 }
490 for _, tt := range tests {
491 t.Run(tt.name, func(t *testing.T) {
492 oo := testOltObject(tt.fields)
493 got, err := oo.Get_ofp_port_info(tt.args.device, tt.args.portNo)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800494 if !reflect.DeepEqual(err, tt.wantErr) || !reflect.DeepEqual(got, tt.want) {
495 t.Errorf("Get_ofp_port_info() got = %v want = %v error = %v, wantErr = %v",
496 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530497 }
498 })
499 }
500}
501
502func TestOpenOLT_Health(t *testing.T) {
503 tests := []struct {
504 name string
505 fields *fields
506 want *voltha.HealthStatus
507 wantErr error
508 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530509 {"health-1", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
510 {"health-2", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
511 {"health-3", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530512 }
513 for _, tt := range tests {
514 t.Run(tt.name, func(t *testing.T) {
515 oo := testOltObject(tt.fields)
516 got, err := oo.Health()
David K. Bainbridge794735f2020-02-11 21:01:37 -0800517 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530518 t.Errorf("Get_ofp_port_info() error = %v, wantErr %v", err, tt.wantErr)
519 }
520 })
521 }
522}
523
524func TestOpenOLT_Process_inter_adapter_message(t *testing.T) {
525 type args struct {
526 msg *ic.InterAdapterMessage
527 }
528 var message1 = args{
529 msg: &ic.InterAdapterMessage{
530 Header: &ic.InterAdapterHeader{
531 Id: "olt",
532 ProxyDeviceId: "",
533 ToDeviceId: "onu1",
534 },
535 },
536 }
537 var message2 = args{
538 msg: &ic.InterAdapterMessage{
539 Header: &ic.InterAdapterHeader{
540 Id: "olt",
541 ProxyDeviceId: "olt",
542 ToDeviceId: "olt",
David K. Bainbridge794735f2020-02-11 21:01:37 -0800543 Type: ic.InterAdapterMessageType_OMCI_REQUEST,
544 },
545 },
546 }
547 var message3 = args{
548 msg: &ic.InterAdapterMessage{
549 Header: &ic.InterAdapterHeader{
550 Id: "olt",
551 ProxyDeviceId: "olt",
552 ToDeviceId: "olt",
553 Type: ic.InterAdapterMessageType_FLOW_REQUEST,
cbabua9e04cc2019-10-03 12:35:45 +0530554 },
555 },
556 }
557 tests := []struct {
David K. Bainbridge794735f2020-02-11 21:01:37 -0800558 name string
559 fields *fields
560 args args
561 wantErrType reflect.Type
cbabua9e04cc2019-10-03 12:35:45 +0530562 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800563 {"process_inter_adaptor_messgae-1", mockOlt(), message1,
Thomas Lee S94109f12020-03-03 16:39:29 +0530564 reflect.TypeOf(&olterrors.ErrNotFound{})},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800565 {"process_inter_adaptor_messgae-2", mockOlt(), message2,
566 reflect.TypeOf(errors.New("message is nil"))},
567 {"process_inter_adaptor_messgae-3", mockOlt(), message3,
Thomas Lee S94109f12020-03-03 16:39:29 +0530568 reflect.TypeOf(&olterrors.ErrInvalidValue{})},
cbabua9e04cc2019-10-03 12:35:45 +0530569 }
570 for _, tt := range tests {
571 t.Run(tt.name, func(t *testing.T) {
572 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800573 if err := oo.Process_inter_adapter_message(tt.args.msg); reflect.TypeOf(err) != tt.wantErrType {
574 t.Errorf("Process_inter_adapter_message() error = %v, wantErr %v",
575 reflect.TypeOf(err), tt.wantErrType)
cbabua9e04cc2019-10-03 12:35:45 +0530576 }
577 })
578 }
579}
580
581func TestOpenOLT_Reboot_device(t *testing.T) {
582 type args struct {
583 device *voltha.Device
584 }
585 tests := []struct {
586 name string
587 fields *fields
588 args args
589 wantErr error
590 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800591 {"reboot_device-1", mockOlt(), args{mockDevice()}, nil},
592 {"reboot_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530593 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530594 }
595 for _, tt := range tests {
596 t.Run(tt.name, func(t *testing.T) {
597 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800598 if err := oo.Reboot_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530599 t.Errorf("Reboot_device() error = %v, wantErr %v", err, tt.wantErr)
600 }
601 })
602 }
603}
604
605func TestOpenOLT_Receive_packet_out(t *testing.T) {
606 acts := []*ofp.OfpAction{
607 fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA))),
608 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
609 fu.Output(1),
610 }
611 type args struct {
612 deviceID string
613 egressPortNo int
614 packet *openflow_13.OfpPacketOut
615 }
616 pktout := &ofp.OfpPacketOut{BufferId: 0, InPort: 1, Actions: acts, Data: []byte("AYDCAAAOAODsSE5TiMwCBwQA4OxITlIEBQUwLzUx" +
617 "BgIAFAgEMC81MQoJbG9jYWxob3N0EBwFAawbqqACAAAAoRAxLjMuNi4xLjQuMS40NDEz/gYAgMILAgD+GQCAwgkDAAAAAGQAAAAAAAAAAgICAgICAgL+" +
618 "GQCAwgoDAAAAAGQAAAAAAAAAAgICAgICAgIAAA==")}
619 tests := []struct {
620 name string
621 fields *fields
622 args args
623 wantErr error
624 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800625 {"receive_packet_out-1", mockOlt(), args{mockDevice().Id, 1, pktout}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530626 {"receive_packet_out-2", mockOlt(), args{"1234", 1, pktout},
Thomas Lee S94109f12020-03-03 16:39:29 +0530627 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "1234"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530628 }
629 for _, tt := range tests {
630 t.Run(tt.name, func(t *testing.T) {
631 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800632 if err := oo.Receive_packet_out(tt.args.deviceID, tt.args.egressPortNo, tt.args.packet); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530633 t.Errorf("Receive_packet_out() error = %v, wantErr %v", err, tt.wantErr)
634 }
635 })
636 }
637}
638
639func TestOpenOLT_Reconcile_device(t *testing.T) {
640 type args struct {
641 device *voltha.Device
642 }
Thomas Lee S94109f12020-03-03 16:39:29 +0530643 expectedError := olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
cbabua9e04cc2019-10-03 12:35:45 +0530644 tests := []struct {
645 name string
646 fields *fields
647 args args
648 wantErr error
649 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800650 {"reconcile_device-1", &fields{}, args{}, expectedError},
651 {"reconcile_device-2", &fields{}, args{}, expectedError},
652 {"reconcile_device-3", &fields{}, args{}, expectedError},
cbabua9e04cc2019-10-03 12:35:45 +0530653 }
654 for _, tt := range tests {
655 t.Run(tt.name, func(t *testing.T) {
656 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800657 if err := oo.Reconcile_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530658 t.Errorf("Reconcile_device() error = %v, wantErr %v", err, tt.wantErr)
659 }
660 })
661 }
662}
663
664func TestOpenOLT_Reenable_device(t *testing.T) {
665 type args struct {
666 device *voltha.Device
667 }
668 tests := []struct {
669 name string
670 fields *fields
671 args args
672 wantErr error
673 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800674 {"reenable_device-1", mockOlt(), args{mockDevice()}, nil},
675 {"reenable_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530676 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530677 }
678 for _, tt := range tests {
679 t.Run(tt.name, func(t *testing.T) {
680 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800681 if err := oo.Reenable_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530682 t.Errorf("Reenable_device() error = %v, wantErr %v", err, tt.wantErr)
683 }
684 })
685 }
686}
687
688func TestOpenOLT_Revert_image_update(t *testing.T) {
689 type args struct {
690 device *voltha.Device
691 request *voltha.ImageDownload
692 }
693 tests := []struct {
694 name string
695 fields *fields
696 args args
697 want *voltha.ImageDownload
698 wantErr error
699 }{
700 {"revert_image_update-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530701 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530702 {"revert_image_update-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123TYU"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530703 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530704 {"revert_image_update-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123GTH"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530705 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530706 }
707 for _, tt := range tests {
708 t.Run(tt.name, func(t *testing.T) {
709 oo := testOltObject(tt.fields)
710 got, err := oo.Revert_image_update(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800711 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530712 t.Log("error :", err)
713 }
714 })
715 }
716}
717
718func TestOpenOLT_Self_test_device(t *testing.T) {
719 type args struct {
720 device *voltha.Device
721 }
722 tests := []struct {
723 name string
724 fields *fields
725 args args
726 wantErr error
727 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530728 {"self_test_device-1", &fields{}, args{}, olterrors.ErrNotImplemented},
729 {"self_test_device-2", &fields{}, args{}, olterrors.ErrNotImplemented},
730 {"self_test_device-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530731 }
732 for _, tt := range tests {
733 t.Run(tt.name, func(t *testing.T) {
734 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800735 if err := oo.Self_test_device(tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530736 t.Errorf("Self_test_device() error = %v, wantErr %v", err, tt.wantErr)
737 }
738 })
739 }
740}
741
742func TestOpenOLT_Start(t *testing.T) {
743 type args struct {
744 ctx context.Context
745 }
746 tests := []struct {
747 name string
748 fields *fields
749 args args
750 wantErr error
751 }{
752 {"start-1", &fields{}, args{}, errors.New("start error")},
753 }
754 for _, tt := range tests {
755 t.Run(tt.name, func(t *testing.T) {
756 oo := testOltObject(tt.fields)
757 if err := oo.Start(tt.args.ctx); err != nil {
758 t.Errorf("Start() error = %v, wantErr %v", err, tt.wantErr)
759 }
760 })
761 }
762}
763
764func TestOpenOLT_Stop(t *testing.T) {
765 type args struct {
766 ctx context.Context
767 }
768 tests := []struct {
769 name string
770 fields *fields
771 args args
772 wantErr error
773 }{
774 {"stop-1", &fields{exitChannel: make(chan int, 1)}, args{}, errors.New("stop error")},
775 }
776 for _, tt := range tests {
777 t.Run(tt.name, func(t *testing.T) {
778 oo := testOltObject(tt.fields)
779 oo.Start(tt.args.ctx)
780 if err := oo.Stop(tt.args.ctx); err != nil {
781 t.Errorf("Stop() error = %v, wantErr %v", err, tt.wantErr)
782 }
783 })
784 }
785}
786
Devmalya Pauldd23a992019-11-14 07:06:31 +0000787func TestOpenOLT_Suppress_event(t *testing.T) {
cbabua9e04cc2019-10-03 12:35:45 +0530788 type args struct {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000789 filter *voltha.EventFilter
cbabua9e04cc2019-10-03 12:35:45 +0530790 }
791 tests := []struct {
792 name string
793 fields *fields
794 args args
795 wantErr error
796 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530797 {"suppress_event-1", &fields{}, args{}, olterrors.ErrNotImplemented},
798 {"suppress_event-2", &fields{}, args{}, olterrors.ErrNotImplemented},
799 {"suppress_event-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530800 }
801 for _, tt := range tests {
802 t.Run(tt.name, func(t *testing.T) {
803 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800804 if err := oo.Suppress_event(tt.args.filter); err != tt.wantErr {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000805 t.Errorf("Suppress_event() error = %v, wantErr %v", err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530806 }
807 })
808 }
809}
810
Devmalya Pauldd23a992019-11-14 07:06:31 +0000811func TestOpenOLT_Unsuppress_event(t *testing.T) {
cbabua9e04cc2019-10-03 12:35:45 +0530812 type args struct {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000813 filter *voltha.EventFilter
cbabua9e04cc2019-10-03 12:35:45 +0530814 }
815 tests := []struct {
816 name string
817 fields *fields
818 args args
819 wantErr error
820 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530821 {"unsupress_event-1", &fields{}, args{}, olterrors.ErrNotImplemented},
822 {"unsupress_event-2", &fields{}, args{}, olterrors.ErrNotImplemented},
823 {"unsupress_event-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530824 }
825 for _, tt := range tests {
826 t.Run(tt.name, func(t *testing.T) {
827 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800828 if err := oo.Unsuppress_event(tt.args.filter); err != tt.wantErr {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000829 t.Errorf("Unsuppress_event() error = %v, wantErr %v", err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530830 }
831 })
832 }
833}
834
835func TestOpenOLT_Update_flows_bulk(t *testing.T) {
836 type args struct {
837 device *voltha.Device
838 flows *voltha.Flows
839 groups *voltha.FlowGroups
840 flowMetadata *voltha.FlowMetadata
841 }
842 tests := []struct {
843 name string
844 fields *fields
845 args args
846 wantErr error
847 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530848 {"update_flows_bulk-1", &fields{}, args{}, olterrors.ErrNotImplemented},
849 {"update_flows_bulk-2", &fields{}, args{}, olterrors.ErrNotImplemented},
850 {"update_flows_bulk-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530851 }
852 for _, tt := range tests {
853 t.Run(tt.name, func(t *testing.T) {
854 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800855 if err := oo.Update_flows_bulk(tt.args.device, tt.args.flows, tt.args.groups, tt.args.flowMetadata); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530856 t.Errorf("Update_flows_bulk() error = %v, wantErr %v", err, tt.wantErr)
857 }
858 })
859 }
860}
861
862func TestOpenOLT_Update_flows_incrementally(t *testing.T) {
863 type args struct {
864 device *voltha.Device
865 flows *openflow_13.FlowChanges
866 groups *openflow_13.FlowGroupChanges
867 flowMetadata *voltha.FlowMetadata
868 }
869
870 tests := []struct {
871 name string
872 fields *fields
873 args args
874 wantErr error
875 }{
876 {"update_flows_incrementally-1", &fields{}, args{device: mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530877 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800878 {"update_flows_incrementally-2", mockOlt(), args{device: mockDevice()}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530879 }
880 for _, tt := range tests {
881 t.Run(tt.name, func(t *testing.T) {
882 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800883 if err := oo.Update_flows_incrementally(tt.args.device, tt.args.flows, tt.args.groups, tt.args.flowMetadata); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530884 t.Errorf("Update_flows_incrementally() error = %v, wantErr %v", err, tt.wantErr)
885 }
886 })
887 }
888}
889
890func TestOpenOLT_Update_pm_config(t *testing.T) {
891 type args struct {
892 device *voltha.Device
893 pmConfigs *voltha.PmConfigs
894 }
895 tests := []struct {
896 name string
897 fields *fields
898 args args
899 wantErr error
900 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530901 {"update_pm_config-1", &fields{}, args{}, olterrors.ErrNotImplemented},
902 {"update_pm_config-2", &fields{}, args{}, olterrors.ErrNotImplemented},
903 {"update_pm_config-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530904 }
905 for _, tt := range tests {
906 t.Run(tt.name, func(t *testing.T) {
907 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800908 if err := oo.Update_pm_config(tt.args.device, tt.args.pmConfigs); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530909 t.Errorf("Update_pm_config() error = %v, wantErr %v", err, tt.wantErr)
910 }
911
912 })
913 }
914}
915
916func TestOpenOLT_deleteDeviceHandlerToMap(t *testing.T) {
917 type args struct {
918 agent *DeviceHandler
919 }
920 tests := []struct {
921 name string
922 fields *fields
923 args args
924 }{
925 {"delete_device_handler_map-1", mockOlt(), args{newMockDeviceHandler()}},
926 }
927 for _, tt := range tests {
928 t.Run(tt.name, func(t *testing.T) {
929 oo := testOltObject(tt.fields)
930 oo.deleteDeviceHandlerToMap(tt.args.agent)
931 if len(oo.deviceHandlers) > 0 {
932 t.Errorf("delete device manager failed")
933 }
934 })
935 }
936}
kesavand39e0aa32020-01-28 20:58:50 -0500937
938func TestOpenOLT_Enable_port(t *testing.T) {
939 type args struct {
940 deviceID string
941 port *voltha.Port
942 }
943 tests := []struct {
944 name string
945 fields *fields
946 args args
947 wantErr bool
948 }{
949 // TODO: Add test cases.
950 {"Enable_port-1", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_PON_OLT, PortNo: 1}}, false},
951 {"Enable_port-2", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_ETHERNET_NNI, PortNo: 1}}, true},
952 }
953 for _, tt := range tests {
954 t.Run(tt.name, func(t *testing.T) {
955 oo := testOltObject(tt.fields)
956 if err := oo.Enable_port(tt.args.deviceID, tt.args.port); (err != nil) != tt.wantErr {
957 t.Errorf("OpenOLT.Enable_port() error = %v, wantErr %v", err, tt.wantErr)
958 }
959 })
960 }
961}
962
963func TestOpenOLT_Disable_port(t *testing.T) {
964 type args struct {
965 deviceID string
966 port *voltha.Port
967 }
968 tests := []struct {
969 name string
970 fields *fields
971 args args
972 wantErr bool
973 }{
974 // TODO: Add test cases.
975 {"Disable_port-1", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_PON_OLT, PortNo: 1}}, false},
976 {"Disable_port-2", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_ETHERNET_NNI, PortNo: 1}}, true},
977 }
978 for _, tt := range tests {
979 t.Run(tt.name, func(t *testing.T) {
980 oo := testOltObject(tt.fields)
981 if err := oo.Disable_port(tt.args.deviceID, tt.args.port); (err != nil) != tt.wantErr {
982 t.Errorf("OpenOLT.Disable_port() error = %v, wantErr %v", err, tt.wantErr)
983 }
984 })
985 }
986}