blob: 704c0b5b3d580b65aa8385517a49d007778dafc8 [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
Neha Sharma3f221ae2020-04-29 19:02:12 +000051 KVStoreAddress string
cbabua9e04cc2019-10-03 12:35:45 +053052 KVStoreType string
53 exitChannel chan int
54 lockDeviceHandlersMap sync.RWMutex
55 ctx context.Context
56}
57
cbabubef89432019-10-18 11:47:27 +020058// mockOlt mocks OpenOLT struct.
cbabua9e04cc2019-10-03 12:35:45 +053059func mockOlt() *fields {
cbabua9e04cc2019-10-03 12:35:45 +053060 dh := newMockDeviceHandler()
61 newOlt := &fields{}
62 newOlt.deviceHandlers = map[string]*DeviceHandler{}
63 newOlt.deviceHandlers[dh.device.Id] = dh
64 return newOlt
65}
66
cbabubef89432019-10-18 11:47:27 +020067// testOltObject maps fields type to OpenOLt type.
cbabua9e04cc2019-10-03 12:35:45 +053068func testOltObject(testOlt *fields) *OpenOLT {
69 return &OpenOLT{
70 deviceHandlers: testOlt.deviceHandlers,
71 coreProxy: testOlt.coreProxy,
72 adapterProxy: testOlt.adapterProxy,
73 eventProxy: testOlt.eventProxy,
74 kafkaICProxy: testOlt.kafkaICProxy,
75 numOnus: testOlt.numOnus,
Neha Sharma3f221ae2020-04-29 19:02:12 +000076 KVStoreAddress: testOlt.KVStoreAddress,
cbabua9e04cc2019-10-03 12:35:45 +053077 KVStoreType: testOlt.KVStoreType,
78 exitChannel: testOlt.exitChannel,
79 }
80}
81
cbabubef89432019-10-18 11:47:27 +020082// mockDevice mocks Device.
cbabua9e04cc2019-10-03 12:35:45 +053083func mockDevice() *voltha.Device {
84 device := &voltha.Device{
85 Id: "olt",
86 Root: true,
87 ParentId: "logical_device",
88 Ports: []*voltha.Port{
89 {PortNo: 1, Label: "pon"},
90 {PortNo: 2, Label: "nni"},
91 },
92 ProxyAddress: &voltha.Device_ProxyAddress{
93 DeviceId: "olt",
94 DeviceType: "onu",
95 ChannelId: 1,
96 ChannelGroupId: 1,
97 },
98 ConnectStatus: 1,
99 }
100 return device
101}
102
103func TestNewOpenOLT(t *testing.T) {
104 tests := []struct {
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530105 name string
106 fields *fields
107 configFlags *config.AdapterFlags
108 want *OpenOLT
cbabua9e04cc2019-10-03 12:35:45 +0530109 }{
Neha Sharma3f221ae2020-04-29 19:02:12 +0000110 {"newopenolt-1", &fields{}, &config.AdapterFlags{OnuNumber: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "consul"},
111 &OpenOLT{numOnus: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "consul"}},
112 {"newopenolt-2", &fields{}, &config.AdapterFlags{OnuNumber: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"},
113 &OpenOLT{numOnus: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"}},
114 {"newopenolt-3", &fields{}, &config.AdapterFlags{OnuNumber: 3, KVStoreAddress: "3.3.3.3:3", KVStoreType: "consul"},
115 &OpenOLT{numOnus: 3, KVStoreAddress: "3.3.3.3:3", KVStoreType: "consul"}},
cbabua9e04cc2019-10-03 12:35:45 +0530116 }
117 for _, tt := range tests {
118 t.Run(tt.name, func(t *testing.T) {
119 if got := NewOpenOLT(tt.fields.ctx, tt.fields.kafkaICProxy, tt.fields.coreProxy, tt.fields.adapterProxy,
Abhilash Laxmeshwarf9942e92020-01-07 15:32:44 +0530120 tt.fields.eventProxy, tt.configFlags); reflect.TypeOf(got) != reflect.TypeOf(tt.want) && got != nil {
cbabua9e04cc2019-10-03 12:35:45 +0530121 t.Errorf("NewOpenOLT() error = %v, wantErr %v", got, tt.want)
122 }
123 })
124 }
125}
126
127func TestOpenOLT_Abandon_device(t *testing.T) {
128 type args struct {
129 device *voltha.Device
130 }
131 tests := []struct {
132 name string
133 fields *fields
134 args args
135 wantErr error
136 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530137 {"abandon_device-1", &fields{}, args{}, olterrors.ErrNotImplemented},
138 {"abandon_device-2", &fields{}, args{}, olterrors.ErrNotImplemented},
139 {"abandon_device-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530140 }
141 for _, tt := range tests {
142 t.Run(tt.name, func(t *testing.T) {
143 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800144 if err := oo.Abandon_device(tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530145 t.Errorf("Abandon_device() error = %v, wantErr %v", err, tt.wantErr)
146 }
147 })
148 }
149}
150
151func TestOpenOLT_Activate_image_update(t *testing.T) {
152 type args struct {
153 device *voltha.Device
154 request *voltha.ImageDownload
155 }
156 tests := []struct {
157 name string
158 fields *fields
159 args args
160 want *voltha.ImageDownload
161 wantErr error
162 }{
163 {"activate_image_upate-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530164 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530165 {"activate_image_upate-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123CDE"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530166 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530167 {"activate_image_upate-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123EFG"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530168 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530169 }
170 for _, tt := range tests {
171 t.Run(tt.name, func(t *testing.T) {
172 oo := testOltObject(tt.fields)
173 got, err := oo.Activate_image_update(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800174 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530175 t.Errorf("Activate_image_update() error = %v, wantErr %v", err, tt.wantErr)
176 }
177 })
178 }
179}
180
181func TestOpenOLT_Adapter_descriptor(t *testing.T) {
182 tests := []struct {
183 name string
184 fields *fields
185 wantErr error
186 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530187 {"adapter_descriptor-1", &fields{}, olterrors.ErrNotImplemented},
188 {"adapter_descriptor-2", &fields{}, olterrors.ErrNotImplemented},
189 {"adapter_descriptor-3", &fields{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530190 }
191 for _, tt := range tests {
192 t.Run(tt.name, func(t *testing.T) {
193 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800194 if err := oo.Adapter_descriptor(); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530195 t.Errorf("Adapter_descriptor() error = %v, wantErr %v", err, tt.wantErr)
196 }
197 })
198 }
199}
200
201func TestOpenOLT_Adopt_device(t *testing.T) {
202 type args struct {
203 device *voltha.Device
204 }
205 var device = mockDevice()
kesavand39e0aa32020-01-28 20:58:50 -0500206 device.Id = "olt"
Thomas Lee S94109f12020-03-03 16:39:29 +0530207 nilDevice := olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
cbabua9e04cc2019-10-03 12:35:45 +0530208 tests := []struct {
209 name string
210 fields *fields
211 args args
212 wantErr error
213 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800214 {"adopt_device-1", mockOlt(), args{}, nilDevice},
215 {"adopt_device-2", mockOlt(), args{device}, nilDevice},
216 {"adopt_device-3", mockOlt(), args{mockDevice()}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530217 }
218 for _, tt := range tests {
219 t.Run(tt.name, func(t *testing.T) {
220 oo := testOltObject(tt.fields)
221 err := oo.Adopt_device(tt.args.device)
222 if (err != nil) && (reflect.TypeOf(err) !=
223 reflect.TypeOf(tt.wantErr)) && (tt.args.device == nil) {
224 t.Errorf("Adopt_device() error = %v, wantErr %v", err, tt.wantErr)
225 }
226 if err == nil {
227 t.Log("return'd nil")
228 }
229 })
230 }
231}
232
233func TestOpenOLT_Cancel_image_download(t *testing.T) {
234 type args struct {
235 device *voltha.Device
236 request *voltha.ImageDownload
237 }
238 tests := []struct {
239 name string
240 fields *fields
241 args args
242 want *voltha.ImageDownload
243 wantErr error
244 }{
245 {"cancel_image_download-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530246 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530247 {"cancel_image_download-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123IJK"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530248 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530249 {"cancel_image_download-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123KLM"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530250 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530251 }
252 for _, tt := range tests {
253 t.Run(tt.name, func(t *testing.T) {
254 oo := testOltObject(tt.fields)
255 got, err := oo.Cancel_image_download(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800256 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530257 t.Errorf("Cancel_image_download() error = %v, wantErr %v", err, tt.wantErr)
258 }
259 })
260 }
261}
262
263func TestOpenOLT_Delete_device(t *testing.T) {
264 type args struct {
265 device *voltha.Device
266 }
267 tests := []struct {
268 name string
269 fields *fields
270 args args
271 wantErr error
272 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800273 {"delete_device-1", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530274 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530275 }
276 for _, tt := range tests {
277 t.Run(tt.name, func(t *testing.T) {
278 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800279 if err := oo.Delete_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530280 t.Errorf("Delete_device() error = %v, wantErr %v", err, tt.wantErr)
281 }
282 })
283 }
284}
285
286func TestOpenOLT_Device_types(t *testing.T) {
287 tests := []struct {
288 name string
289 fields *fields
290 want *voltha.DeviceTypes
291 wantErr error
292 }{
293 {"device_types-1", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530294 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530295 {"device_types-2", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530296 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530297 {"device_types-3", &fields{}, &voltha.DeviceTypes{},
Thomas Lee S94109f12020-03-03 16:39:29 +0530298 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530299 }
300 for _, tt := range tests {
301 t.Run(tt.name, func(t *testing.T) {
302 oo := testOltObject(tt.fields)
303 got, err := oo.Device_types()
David K. Bainbridge794735f2020-02-11 21:01:37 -0800304 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530305 t.Errorf("Device_types() error = %v, wantErr %v", err, tt.wantErr)
306 }
307 })
308 }
309}
310
311func TestOpenOLT_Disable_device(t *testing.T) {
312 type args struct {
313 device *voltha.Device
314 }
315 tests := []struct {
316 name string
317 fields *fields
318 args args
319 wantErr error
320 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800321 {"disable_device-1", mockOlt(), args{mockDevice()}, nil},
322 {"disable_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530323 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530324 }
325 for _, tt := range tests {
326 t.Run(tt.name, func(t *testing.T) {
327 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800328 if err := oo.Disable_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530329 t.Errorf("Disable_device() error = %v, wantErr %v", err, tt.wantErr)
330 }
331 })
332 }
333}
334
335func TestOpenOLT_Download_image(t *testing.T) {
336 type args struct {
337 device *voltha.Device
338 request *voltha.ImageDownload
339 }
340 tests := []struct {
341 name string
342 fields *fields
343 args args
344 want *voltha.ImageDownload
345 wantErr error
346 }{
347 {"download_image-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530348 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530349 {"download_image-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123LKJ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530350 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530351 {"download_image-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123RTY"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530352 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530353 }
354 for _, tt := range tests {
355 t.Run(tt.name, func(t *testing.T) {
356 oo := testOltObject(tt.fields)
357 got, err := oo.Download_image(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800358 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530359 t.Errorf("Download_image() error = %v, wantErr %v", err, tt.wantErr)
360 }
361 })
362 }
363}
364
365func TestOpenOLT_Get_device_details(t *testing.T) {
366 type args struct {
367 device *voltha.Device
368 }
369 tests := []struct {
370 name string
371 fields *fields
372 args args
373 wantErr error
374 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530375 {"get_device_details-1", &fields{}, args{}, olterrors.ErrNotImplemented},
376 {"get_device_details-2", &fields{}, args{}, olterrors.ErrNotImplemented},
377 {"get_device_details-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530378 }
379 for _, tt := range tests {
380 t.Run(tt.name, func(t *testing.T) {
381 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800382 if err := oo.Get_device_details(tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530383 t.Errorf("Get_device_details() error = %v, wantErr %v", err, tt.wantErr)
384 }
385 })
386 }
387}
388
389func TestOpenOLT_Get_image_download_status(t *testing.T) {
390 type args struct {
391 device *voltha.Device
392 request *voltha.ImageDownload
393 }
394 tests := []struct {
395 name string
396 fields *fields
397 args args
398 want *voltha.ImageDownload
399 wantErr error
400 }{
401 {"get_image_download_status-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530402 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530403 {"get_image_download_status-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123LKJ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530404 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530405 {"get_image_download_status-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123DFG"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530406 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530407 }
408 for _, tt := range tests {
409 t.Run(tt.name, func(t *testing.T) {
410 oo := testOltObject(tt.fields)
411 got, err := oo.Get_image_download_status(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800412 if err != tt.wantErr && got == nil {
413 t.Errorf("Get_image_download_status() got = %v want = %v error = %v, wantErr %v",
414 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530415 }
416 })
417 }
418}
419
420func TestOpenOLT_Get_ofp_device_info(t *testing.T) {
421 type args struct {
422 device *voltha.Device
423 }
424 tests := []struct {
425 name string
426 fields *fields
427 args args
428 want *ic.SwitchCapability
429 wantErr error
430 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800431 {"get_ofp_device_info-1", mockOlt(), args{mockDevice()}, &ic.SwitchCapability{
432 Desc: &openflow_13.OfpDesc{
433 MfrDesc: "VOLTHA Project",
434 HwDesc: "open_pon",
435 SwDesc: "open_pon",
436 },
437 SwitchFeatures: &openflow_13.OfpSwitchFeatures{
438 NBuffers: uint32(256),
439 NTables: uint32(2),
440 Capabilities: uint32(15),
441 },
442 }, nil},
443 {"get_ofp_device_info-2", &fields{}, args{mockDevice()}, nil,
Thomas Lee S94109f12020-03-03 16:39:29 +0530444 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530445 }
446 for _, tt := range tests {
447 t.Run(tt.name, func(t *testing.T) {
448 oo := testOltObject(tt.fields)
449 got, err := oo.Get_ofp_device_info(tt.args.device)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800450 if !reflect.DeepEqual(err, tt.wantErr) || !reflect.DeepEqual(got, tt.want) {
451 t.Errorf("Get_ofp_device_info() got = %v want = %v error = %v, wantErr = %v",
452 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530453 }
454 })
455 }
456}
457
458func TestOpenOLT_Get_ofp_port_info(t *testing.T) {
459 type args struct {
460 device *voltha.Device
461 portNo int64
462 }
463 tests := []struct {
464 name string
465 fields *fields
466 args args
467 want *ic.PortCapability
468 wantErr error
469 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800470 {"get_ofp_port_info-1", mockOlt(), args{mockDevice(), 1}, &ic.PortCapability{
471 Port: &voltha.LogicalPort{
472 DeviceId: "olt",
473 DevicePortNo: uint32(1),
474 OfpPort: &openflow_13.OfpPort{
475 HwAddr: []uint32{1, 2, 3, 4, 5, 6},
476 State: uint32(4),
477 Curr: uint32(4128),
478 Advertised: uint32(4128),
479 Peer: uint32(4128),
480 CurrSpeed: uint32(32),
481 MaxSpeed: uint32(32),
482 },
483 },
484 }, nil},
485 {"get_ofp_port_info-2", &fields{}, args{mockDevice(), 1}, nil,
Thomas Lee S94109f12020-03-03 16:39:29 +0530486 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530487 }
488 for _, tt := range tests {
489 t.Run(tt.name, func(t *testing.T) {
490 oo := testOltObject(tt.fields)
491 got, err := oo.Get_ofp_port_info(tt.args.device, tt.args.portNo)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800492 if !reflect.DeepEqual(err, tt.wantErr) || !reflect.DeepEqual(got, tt.want) {
493 t.Errorf("Get_ofp_port_info() got = %v want = %v error = %v, wantErr = %v",
494 got, tt.want, err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530495 }
496 })
497 }
498}
499
500func TestOpenOLT_Health(t *testing.T) {
501 tests := []struct {
502 name string
503 fields *fields
504 want *voltha.HealthStatus
505 wantErr error
506 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530507 {"health-1", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
508 {"health-2", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
509 {"health-3", &fields{}, &voltha.HealthStatus{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530510 }
511 for _, tt := range tests {
512 t.Run(tt.name, func(t *testing.T) {
513 oo := testOltObject(tt.fields)
514 got, err := oo.Health()
David K. Bainbridge794735f2020-02-11 21:01:37 -0800515 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530516 t.Errorf("Get_ofp_port_info() error = %v, wantErr %v", err, tt.wantErr)
517 }
518 })
519 }
520}
521
522func TestOpenOLT_Process_inter_adapter_message(t *testing.T) {
523 type args struct {
524 msg *ic.InterAdapterMessage
525 }
526 var message1 = args{
527 msg: &ic.InterAdapterMessage{
528 Header: &ic.InterAdapterHeader{
529 Id: "olt",
530 ProxyDeviceId: "",
531 ToDeviceId: "onu1",
532 },
533 },
534 }
535 var message2 = args{
536 msg: &ic.InterAdapterMessage{
537 Header: &ic.InterAdapterHeader{
538 Id: "olt",
539 ProxyDeviceId: "olt",
540 ToDeviceId: "olt",
David K. Bainbridge794735f2020-02-11 21:01:37 -0800541 Type: ic.InterAdapterMessageType_OMCI_REQUEST,
542 },
543 },
544 }
545 var message3 = args{
546 msg: &ic.InterAdapterMessage{
547 Header: &ic.InterAdapterHeader{
548 Id: "olt",
549 ProxyDeviceId: "olt",
550 ToDeviceId: "olt",
551 Type: ic.InterAdapterMessageType_FLOW_REQUEST,
cbabua9e04cc2019-10-03 12:35:45 +0530552 },
553 },
554 }
555 tests := []struct {
David K. Bainbridge794735f2020-02-11 21:01:37 -0800556 name string
557 fields *fields
558 args args
559 wantErrType reflect.Type
cbabua9e04cc2019-10-03 12:35:45 +0530560 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800561 {"process_inter_adaptor_messgae-1", mockOlt(), message1,
Thomas Lee S94109f12020-03-03 16:39:29 +0530562 reflect.TypeOf(&olterrors.ErrNotFound{})},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800563 {"process_inter_adaptor_messgae-2", mockOlt(), message2,
Girish Kumarf26e4882020-03-05 06:49:10 +0000564 reflect.TypeOf(&olterrors.ErrAdapter{})},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800565 {"process_inter_adaptor_messgae-3", mockOlt(), message3,
Thomas Lee S94109f12020-03-03 16:39:29 +0530566 reflect.TypeOf(&olterrors.ErrInvalidValue{})},
cbabua9e04cc2019-10-03 12:35:45 +0530567 }
568 for _, tt := range tests {
569 t.Run(tt.name, func(t *testing.T) {
570 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800571 if err := oo.Process_inter_adapter_message(tt.args.msg); reflect.TypeOf(err) != tt.wantErrType {
572 t.Errorf("Process_inter_adapter_message() error = %v, wantErr %v",
573 reflect.TypeOf(err), tt.wantErrType)
cbabua9e04cc2019-10-03 12:35:45 +0530574 }
575 })
576 }
577}
578
579func TestOpenOLT_Reboot_device(t *testing.T) {
580 type args struct {
581 device *voltha.Device
582 }
583 tests := []struct {
584 name string
585 fields *fields
586 args args
587 wantErr error
588 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800589 {"reboot_device-1", mockOlt(), args{mockDevice()}, nil},
590 {"reboot_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530591 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530592 }
593 for _, tt := range tests {
594 t.Run(tt.name, func(t *testing.T) {
595 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800596 if err := oo.Reboot_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530597 t.Errorf("Reboot_device() error = %v, wantErr %v", err, tt.wantErr)
598 }
599 })
600 }
601}
602
603func TestOpenOLT_Receive_packet_out(t *testing.T) {
604 acts := []*ofp.OfpAction{
605 fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA))),
606 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
607 fu.Output(1),
608 }
609 type args struct {
610 deviceID string
611 egressPortNo int
612 packet *openflow_13.OfpPacketOut
613 }
614 pktout := &ofp.OfpPacketOut{BufferId: 0, InPort: 1, Actions: acts, Data: []byte("AYDCAAAOAODsSE5TiMwCBwQA4OxITlIEBQUwLzUx" +
615 "BgIAFAgEMC81MQoJbG9jYWxob3N0EBwFAawbqqACAAAAoRAxLjMuNi4xLjQuMS40NDEz/gYAgMILAgD+GQCAwgkDAAAAAGQAAAAAAAAAAgICAgICAgL+" +
616 "GQCAwgoDAAAAAGQAAAAAAAAAAgICAgICAgIAAA==")}
617 tests := []struct {
618 name string
619 fields *fields
620 args args
621 wantErr error
622 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800623 {"receive_packet_out-1", mockOlt(), args{mockDevice().Id, 1, pktout}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530624 {"receive_packet_out-2", mockOlt(), args{"1234", 1, pktout},
Thomas Lee S94109f12020-03-03 16:39:29 +0530625 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "1234"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530626 }
627 for _, tt := range tests {
628 t.Run(tt.name, func(t *testing.T) {
629 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800630 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 +0530631 t.Errorf("Receive_packet_out() error = %v, wantErr %v", err, tt.wantErr)
632 }
633 })
634 }
635}
636
637func TestOpenOLT_Reconcile_device(t *testing.T) {
638 type args struct {
639 device *voltha.Device
640 }
Thomas Lee S94109f12020-03-03 16:39:29 +0530641 expectedError := olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil)
cbabua9e04cc2019-10-03 12:35:45 +0530642 tests := []struct {
643 name string
644 fields *fields
645 args args
646 wantErr error
647 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800648 {"reconcile_device-1", &fields{}, args{}, expectedError},
649 {"reconcile_device-2", &fields{}, args{}, expectedError},
650 {"reconcile_device-3", &fields{}, args{}, expectedError},
cbabua9e04cc2019-10-03 12:35:45 +0530651 }
652 for _, tt := range tests {
653 t.Run(tt.name, func(t *testing.T) {
654 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800655 if err := oo.Reconcile_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530656 t.Errorf("Reconcile_device() error = %v, wantErr %v", err, tt.wantErr)
657 }
658 })
659 }
660}
661
662func TestOpenOLT_Reenable_device(t *testing.T) {
663 type args struct {
664 device *voltha.Device
665 }
666 tests := []struct {
667 name string
668 fields *fields
669 args args
670 wantErr error
671 }{
David K. Bainbridge794735f2020-02-11 21:01:37 -0800672 {"reenable_device-1", mockOlt(), args{mockDevice()}, nil},
673 {"reenable_device-2", &fields{}, args{mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530674 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
cbabua9e04cc2019-10-03 12:35:45 +0530675 }
676 for _, tt := range tests {
677 t.Run(tt.name, func(t *testing.T) {
678 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800679 if err := oo.Reenable_device(tt.args.device); !reflect.DeepEqual(err, tt.wantErr) {
cbabua9e04cc2019-10-03 12:35:45 +0530680 t.Errorf("Reenable_device() error = %v, wantErr %v", err, tt.wantErr)
681 }
682 })
683 }
684}
685
686func TestOpenOLT_Revert_image_update(t *testing.T) {
687 type args struct {
688 device *voltha.Device
689 request *voltha.ImageDownload
690 }
691 tests := []struct {
692 name string
693 fields *fields
694 args args
695 want *voltha.ImageDownload
696 wantErr error
697 }{
698 {"revert_image_update-1", &fields{}, args{}, &voltha.ImageDownload{Id: "Image1-ABC123XYZ"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530699 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530700 {"revert_image_update-2", &fields{}, args{}, &voltha.ImageDownload{Id: "Image2-ABC123TYU"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530701 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530702 {"revert_image_update-3", &fields{}, args{}, &voltha.ImageDownload{Id: "Image3-ABC123GTH"},
Thomas Lee S94109f12020-03-03 16:39:29 +0530703 olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530704 }
705 for _, tt := range tests {
706 t.Run(tt.name, func(t *testing.T) {
707 oo := testOltObject(tt.fields)
708 got, err := oo.Revert_image_update(tt.args.device, tt.args.request)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800709 if err != tt.wantErr && got == nil {
cbabua9e04cc2019-10-03 12:35:45 +0530710 t.Log("error :", err)
711 }
712 })
713 }
714}
715
716func TestOpenOLT_Self_test_device(t *testing.T) {
717 type args struct {
718 device *voltha.Device
719 }
720 tests := []struct {
721 name string
722 fields *fields
723 args args
724 wantErr error
725 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530726 {"self_test_device-1", &fields{}, args{}, olterrors.ErrNotImplemented},
727 {"self_test_device-2", &fields{}, args{}, olterrors.ErrNotImplemented},
728 {"self_test_device-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530729 }
730 for _, tt := range tests {
731 t.Run(tt.name, func(t *testing.T) {
732 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800733 if err := oo.Self_test_device(tt.args.device); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530734 t.Errorf("Self_test_device() error = %v, wantErr %v", err, tt.wantErr)
735 }
736 })
737 }
738}
739
740func TestOpenOLT_Start(t *testing.T) {
741 type args struct {
742 ctx context.Context
743 }
744 tests := []struct {
745 name string
746 fields *fields
747 args args
748 wantErr error
749 }{
750 {"start-1", &fields{}, args{}, errors.New("start error")},
751 }
752 for _, tt := range tests {
753 t.Run(tt.name, func(t *testing.T) {
754 oo := testOltObject(tt.fields)
755 if err := oo.Start(tt.args.ctx); err != nil {
756 t.Errorf("Start() error = %v, wantErr %v", err, tt.wantErr)
757 }
758 })
759 }
760}
761
762func TestOpenOLT_Stop(t *testing.T) {
763 type args struct {
764 ctx context.Context
765 }
766 tests := []struct {
767 name string
768 fields *fields
769 args args
770 wantErr error
771 }{
772 {"stop-1", &fields{exitChannel: make(chan int, 1)}, args{}, errors.New("stop error")},
773 }
774 for _, tt := range tests {
775 t.Run(tt.name, func(t *testing.T) {
776 oo := testOltObject(tt.fields)
777 oo.Start(tt.args.ctx)
778 if err := oo.Stop(tt.args.ctx); err != nil {
779 t.Errorf("Stop() error = %v, wantErr %v", err, tt.wantErr)
780 }
781 })
782 }
783}
784
Devmalya Pauldd23a992019-11-14 07:06:31 +0000785func TestOpenOLT_Suppress_event(t *testing.T) {
cbabua9e04cc2019-10-03 12:35:45 +0530786 type args struct {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000787 filter *voltha.EventFilter
cbabua9e04cc2019-10-03 12:35:45 +0530788 }
789 tests := []struct {
790 name string
791 fields *fields
792 args args
793 wantErr error
794 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530795 {"suppress_event-1", &fields{}, args{}, olterrors.ErrNotImplemented},
796 {"suppress_event-2", &fields{}, args{}, olterrors.ErrNotImplemented},
797 {"suppress_event-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530798 }
799 for _, tt := range tests {
800 t.Run(tt.name, func(t *testing.T) {
801 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800802 if err := oo.Suppress_event(tt.args.filter); err != tt.wantErr {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000803 t.Errorf("Suppress_event() error = %v, wantErr %v", err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530804 }
805 })
806 }
807}
808
Devmalya Pauldd23a992019-11-14 07:06:31 +0000809func TestOpenOLT_Unsuppress_event(t *testing.T) {
cbabua9e04cc2019-10-03 12:35:45 +0530810 type args struct {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000811 filter *voltha.EventFilter
cbabua9e04cc2019-10-03 12:35:45 +0530812 }
813 tests := []struct {
814 name string
815 fields *fields
816 args args
817 wantErr error
818 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530819 {"unsupress_event-1", &fields{}, args{}, olterrors.ErrNotImplemented},
820 {"unsupress_event-2", &fields{}, args{}, olterrors.ErrNotImplemented},
821 {"unsupress_event-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530822 }
823 for _, tt := range tests {
824 t.Run(tt.name, func(t *testing.T) {
825 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800826 if err := oo.Unsuppress_event(tt.args.filter); err != tt.wantErr {
Devmalya Pauldd23a992019-11-14 07:06:31 +0000827 t.Errorf("Unsuppress_event() error = %v, wantErr %v", err, tt.wantErr)
cbabua9e04cc2019-10-03 12:35:45 +0530828 }
829 })
830 }
831}
832
833func TestOpenOLT_Update_flows_bulk(t *testing.T) {
834 type args struct {
835 device *voltha.Device
836 flows *voltha.Flows
837 groups *voltha.FlowGroups
838 flowMetadata *voltha.FlowMetadata
839 }
840 tests := []struct {
841 name string
842 fields *fields
843 args args
844 wantErr error
845 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530846 {"update_flows_bulk-1", &fields{}, args{}, olterrors.ErrNotImplemented},
847 {"update_flows_bulk-2", &fields{}, args{}, olterrors.ErrNotImplemented},
848 {"update_flows_bulk-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530849 }
850 for _, tt := range tests {
851 t.Run(tt.name, func(t *testing.T) {
852 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800853 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 +0530854 t.Errorf("Update_flows_bulk() error = %v, wantErr %v", err, tt.wantErr)
855 }
856 })
857 }
858}
859
860func TestOpenOLT_Update_flows_incrementally(t *testing.T) {
861 type args struct {
862 device *voltha.Device
863 flows *openflow_13.FlowChanges
864 groups *openflow_13.FlowGroupChanges
865 flowMetadata *voltha.FlowMetadata
866 }
867
868 tests := []struct {
869 name string
870 fields *fields
871 args args
872 wantErr error
873 }{
874 {"update_flows_incrementally-1", &fields{}, args{device: mockDevice()},
Thomas Lee S94109f12020-03-03 16:39:29 +0530875 olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": "olt"}, nil)},
David K. Bainbridge794735f2020-02-11 21:01:37 -0800876 {"update_flows_incrementally-2", mockOlt(), args{device: mockDevice()}, nil},
cbabua9e04cc2019-10-03 12:35:45 +0530877 }
878 for _, tt := range tests {
879 t.Run(tt.name, func(t *testing.T) {
880 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800881 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 +0530882 t.Errorf("Update_flows_incrementally() error = %v, wantErr %v", err, tt.wantErr)
883 }
884 })
885 }
886}
887
888func TestOpenOLT_Update_pm_config(t *testing.T) {
889 type args struct {
890 device *voltha.Device
891 pmConfigs *voltha.PmConfigs
892 }
893 tests := []struct {
894 name string
895 fields *fields
896 args args
897 wantErr error
898 }{
Thomas Lee S94109f12020-03-03 16:39:29 +0530899 {"update_pm_config-1", &fields{}, args{}, olterrors.ErrNotImplemented},
900 {"update_pm_config-2", &fields{}, args{}, olterrors.ErrNotImplemented},
901 {"update_pm_config-3", &fields{}, args{}, olterrors.ErrNotImplemented},
cbabua9e04cc2019-10-03 12:35:45 +0530902 }
903 for _, tt := range tests {
904 t.Run(tt.name, func(t *testing.T) {
905 oo := testOltObject(tt.fields)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800906 if err := oo.Update_pm_config(tt.args.device, tt.args.pmConfigs); err != tt.wantErr {
cbabua9e04cc2019-10-03 12:35:45 +0530907 t.Errorf("Update_pm_config() error = %v, wantErr %v", err, tt.wantErr)
908 }
909
910 })
911 }
912}
913
914func TestOpenOLT_deleteDeviceHandlerToMap(t *testing.T) {
915 type args struct {
916 agent *DeviceHandler
917 }
918 tests := []struct {
919 name string
920 fields *fields
921 args args
922 }{
923 {"delete_device_handler_map-1", mockOlt(), args{newMockDeviceHandler()}},
924 }
925 for _, tt := range tests {
926 t.Run(tt.name, func(t *testing.T) {
927 oo := testOltObject(tt.fields)
928 oo.deleteDeviceHandlerToMap(tt.args.agent)
929 if len(oo.deviceHandlers) > 0 {
930 t.Errorf("delete device manager failed")
931 }
932 })
933 }
934}
kesavand39e0aa32020-01-28 20:58:50 -0500935
936func TestOpenOLT_Enable_port(t *testing.T) {
937 type args struct {
938 deviceID string
939 port *voltha.Port
940 }
941 tests := []struct {
942 name string
943 fields *fields
944 args args
945 wantErr bool
946 }{
947 // TODO: Add test cases.
948 {"Enable_port-1", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_PON_OLT, PortNo: 1}}, false},
949 {"Enable_port-2", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_ETHERNET_NNI, PortNo: 1}}, true},
950 }
951 for _, tt := range tests {
952 t.Run(tt.name, func(t *testing.T) {
953 oo := testOltObject(tt.fields)
954 if err := oo.Enable_port(tt.args.deviceID, tt.args.port); (err != nil) != tt.wantErr {
955 t.Errorf("OpenOLT.Enable_port() error = %v, wantErr %v", err, tt.wantErr)
956 }
957 })
958 }
959}
960
961func TestOpenOLT_Disable_port(t *testing.T) {
962 type args struct {
963 deviceID string
964 port *voltha.Port
965 }
966 tests := []struct {
967 name string
968 fields *fields
969 args args
970 wantErr bool
971 }{
972 // TODO: Add test cases.
973 {"Disable_port-1", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_PON_OLT, PortNo: 1}}, false},
974 {"Disable_port-2", mockOlt(), args{deviceID: "olt", port: &voltha.Port{Type: voltha.Port_ETHERNET_NNI, PortNo: 1}}, true},
975 }
976 for _, tt := range tests {
977 t.Run(tt.name, func(t *testing.T) {
978 oo := testOltObject(tt.fields)
979 if err := oo.Disable_port(tt.args.deviceID, tt.args.port); (err != nil) != tt.wantErr {
980 t.Errorf("OpenOLT.Disable_port() error = %v, wantErr %v", err, tt.wantErr)
981 }
982 })
983 }
984}