blob: d6c65eac9fcac338e368cf84fe944fee942c98f5 [file] [log] [blame]
kdarapub67f49c2019-07-31 18:23:16 +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
17//Package adaptercore provides the utility for olt devices, flows and statistics
18package adaptercore
19
20import (
kdarapu4cf5cc72019-09-16 12:33:49 +053021 "context"
kdarapub67f49c2019-07-31 18:23:16 +053022 "net"
kdarapu4cf5cc72019-09-16 12:33:49 +053023 "reflect"
kdarapub67f49c2019-07-31 18:23:16 +053024 "testing"
25
kdarapu4cf5cc72019-09-16 12:33:49 +053026 "github.com/golang/protobuf/ptypes"
27 "github.com/golang/protobuf/ptypes/any"
28 "github.com/opencord/voltha-go/common/log"
29 fu "github.com/opencord/voltha-go/rw_core/utils"
30 "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
kdarapub67f49c2019-07-31 18:23:16 +053031 "github.com/opencord/voltha-openolt-adapter/mocks"
kdarapu4cf5cc72019-09-16 12:33:49 +053032 ic "github.com/opencord/voltha-protos/go/inter_container"
33 of "github.com/opencord/voltha-protos/go/openflow_13"
34 ofp "github.com/opencord/voltha-protos/go/openflow_13"
35 oop "github.com/opencord/voltha-protos/go/openolt"
kdarapub67f49c2019-07-31 18:23:16 +053036 "github.com/opencord/voltha-protos/go/voltha"
37)
38
kdarapu4cf5cc72019-09-16 12:33:49 +053039func init() {
40 _, _ = log.AddPackage(log.JSON, log.DebugLevel, nil)
41}
42
43func newMockCoreProxy() *mocks.MockCoreProxy {
44 mcp := mocks.MockCoreProxy{}
45 mcp.Devices = make(map[string]*voltha.Device)
46 mcp.Devices["olt"] = &voltha.Device{
47
48 Id: "olt",
49 Root: true,
50 ParentId: "logical_device",
51 ParentPortNo: 1,
52
53 Ports: []*voltha.Port{
54 {PortNo: 1, Label: "pon"},
55 {PortNo: 2, Label: "nni"},
56 },
57 ProxyAddress: &voltha.Device_ProxyAddress{
58 DeviceId: "olt",
59 DeviceType: "onu",
60 ChannelId: 1,
61 ChannelGroupId: 1,
62 },
63 ConnectStatus: 1,
64 }
65 mcp.Devices["onu1"] = &voltha.Device{
66
67 Id: "1",
68 Root: false,
69 ParentId: "olt",
70 ParentPortNo: 1,
71
72 Ports: []*voltha.Port{
73 {PortNo: 1, Label: "pon"},
74 {PortNo: 2, Label: "uni"},
75 },
76 OperStatus: 4,
77 ProxyAddress: &voltha.Device_ProxyAddress{
78 OnuId: 1,
79 ChannelId: 1,
80 ChannelGroupId: 1,
81 },
82 ConnectStatus: 1,
83 }
84 mcp.Devices["onu2"] = &voltha.Device{
85 Id: "2",
86 Root: false,
87 ParentId: "olt",
88 OperStatus: 2,
89 Ports: []*voltha.Port{
90 {PortNo: 1, Label: "pon"},
91 {PortNo: 2, Label: "uni"},
92 },
93
94 ParentPortNo: 1,
95
96 ProxyAddress: &voltha.Device_ProxyAddress{
97 OnuId: 2,
98 ChannelId: 1,
99 ChannelGroupId: 1,
100 },
101 ConnectStatus: 1,
102 }
103 return &mcp
104}
105func newMockDeviceHandler() *DeviceHandler {
kdarapub67f49c2019-07-31 18:23:16 +0530106 device := &voltha.Device{
107 Id: "olt",
108 Root: true,
109 ParentId: "logical_device",
110 Ports: []*voltha.Port{
111 {PortNo: 1, Label: "pon"},
112 {PortNo: 2, Label: "nni"},
113 },
kdarapu4cf5cc72019-09-16 12:33:49 +0530114 ProxyAddress: &voltha.Device_ProxyAddress{
115 DeviceId: "olt",
116 DeviceType: "onu",
117 ChannelId: 1,
118 ChannelGroupId: 1,
119 },
120 ConnectStatus: 1,
kdarapub67f49c2019-07-31 18:23:16 +0530121 }
kdarapu4cf5cc72019-09-16 12:33:49 +0530122 cp := newMockCoreProxy()
123 ap := &mocks.MockAdapterProxy{}
124 ep := &mocks.MockEventProxy{}
125 openOLT := &OpenOLT{coreProxy: cp, adapterProxy: ap, eventProxy: ep}
126 dh := NewDeviceHandler(cp, ap, ep, device, openOLT)
127 deviceInf := &oop.DeviceInfo{Vendor: "openolt", Ranges: nil, Model: "openolt", DeviceId: dh.deviceID}
128 dh.resourceMgr = &resourcemanager.OpenOltResourceMgr{DeviceID: dh.deviceID, DeviceType: dh.deviceType, DevInfo: deviceInf}
129 dh.flowMgr = NewFlowManager(dh, dh.resourceMgr)
130 dh.Client = &mocks.MockOpenoltClient{}
131 dh.eventMgr = &OpenOltEventMgr{eventProxy: &mocks.MockEventProxy{}}
132 dh.transitionMap = &TransitionMap{}
133 return dh
kdarapub67f49c2019-07-31 18:23:16 +0530134}
135
kdarapu4cf5cc72019-09-16 12:33:49 +0530136func negativeDeviceHandler() *DeviceHandler {
137 dh := newMockDeviceHandler()
138 device := dh.device
139 device.Id = ""
140 dh.adminState = "down"
141 return dh
142}
kdarapub67f49c2019-07-31 18:23:16 +0530143func Test_generateMacFromHost(t *testing.T) {
144 type args struct {
145 host string
146 }
147 tests := []struct {
148 name string
149 args args
150 want string
151 wantErr bool
152 }{
kdarapu4cf5cc72019-09-16 12:33:49 +0530153 {"generateMacFromHost-1", args{host: "localhost"}, "00:00:7f:00:00:01", false},
154 {"generateMacFromHost-2", args{host: "10.10.10.10"}, "00:00:0a:0a:0a:0a", false},
155 //{"generateMacFromHost-3", args{host: "google.com"}, "00:00:d8:3a:c8:8e", false},
156 {"generateMacFromHost-4", args{host: "testing3"}, "", true},
kdarapub67f49c2019-07-31 18:23:16 +0530157 }
158 for _, tt := range tests {
159 t.Run(tt.name, func(t *testing.T) {
160 got, err := generateMacFromHost(tt.args.host)
161 if (err != nil) != tt.wantErr {
162 t.Errorf("generateMacFromHost() error = %v, wantErr %v", err, tt.wantErr)
163 return
164 }
165 if got != tt.want {
166 t.Errorf("generateMacFromHost() = %v, want %v", got, tt.want)
167 }
168 })
169 }
170}
171func Test_macifyIP(t *testing.T) {
172 type args struct {
173 ip net.IP
174 }
175 tests := []struct {
176 name string
177 args args
178 want string
179 }{{
kdarapu4cf5cc72019-09-16 12:33:49 +0530180 "macifyIP-1",
kdarapub67f49c2019-07-31 18:23:16 +0530181 args{ip: net.ParseIP("10.10.10.10")},
182 "00:00:0a:0a:0a:0a",
183 },
184 {
kdarapu4cf5cc72019-09-16 12:33:49 +0530185 "macifyIP-2",
kdarapub67f49c2019-07-31 18:23:16 +0530186 args{ip: net.ParseIP("127.0.0.1")},
187 "00:00:7f:00:00:01",
kdarapu4cf5cc72019-09-16 12:33:49 +0530188 },
189 {
190 "macifyIP-3",
191 args{ip: net.ParseIP("127.0.0.1/24")},
192 "",
193 },
194 }
kdarapub67f49c2019-07-31 18:23:16 +0530195 for _, tt := range tests {
196 t.Run(tt.name, func(t *testing.T) {
197 if got := macifyIP(tt.args.ip); got != tt.want {
198 t.Errorf("macifyIP() = %v, want %v", got, tt.want)
199 }
200 })
201 }
202}
203
kdarapub67f49c2019-07-31 18:23:16 +0530204func TestDeviceHandler_GetChildDevice(t *testing.T) {
kdarapu4cf5cc72019-09-16 12:33:49 +0530205 dh1 := newMockDeviceHandler()
206 dh2 := negativeDeviceHandler()
kdarapub67f49c2019-07-31 18:23:16 +0530207 type args struct {
208 parentPort uint32
209 onuID uint32
210 }
211 tests := []struct {
kdarapu4cf5cc72019-09-16 12:33:49 +0530212 name string
213 devicehandler *DeviceHandler
214 args args
215 want *voltha.Device
kdarapub67f49c2019-07-31 18:23:16 +0530216 }{
kdarapu4cf5cc72019-09-16 12:33:49 +0530217 {"GetChildDevice-1", dh1,
218 args{parentPort: 1,
219 onuID: 1},
220 &voltha.Device{},
221 },
222 {"GetChildDevice-2", dh2,
kdarapub67f49c2019-07-31 18:23:16 +0530223 args{parentPort: 1,
224 onuID: 1},
225 &voltha.Device{},
226 },
227 }
228 for _, tt := range tests {
229 t.Run(tt.name, func(t *testing.T) {
kdarapu4cf5cc72019-09-16 12:33:49 +0530230 got := tt.devicehandler.GetChildDevice(tt.args.parentPort, tt.args.onuID)
kdarapub67f49c2019-07-31 18:23:16 +0530231 t.Log("onu device id", got)
232 })
233 }
234}
kdarapu4cf5cc72019-09-16 12:33:49 +0530235
236func TestGetportLabel(t *testing.T) {
237 type args struct {
238 portNum uint32
239 portType voltha.Port_PortType
240 }
241 tests := []struct {
242 name string
243 args args
244 want string
245 }{
246 {"GetportLabel-1", args{portNum: 0, portType: 0}, ""},
247 {"GetportLabel-2", args{portNum: 1, portType: 1}, "nni-1"},
248 {"GetportLabel-3", args{portNum: 2, portType: 2}, ""},
249 {"GetportLabel-4", args{portNum: 3, portType: 3}, "pon-3"},
250 {"GetportLabel-5", args{portNum: 4, portType: 4}, ""},
251 {"GetportLabel-6", args{portNum: 5, portType: 5}, ""},
252 {"GetportLabel-7", args{portNum: 6, portType: 6}, ""},
253 }
254 for _, tt := range tests {
255 t.Run(tt.name, func(t *testing.T) {
256 if got := GetportLabel(tt.args.portNum, tt.args.portType); got != tt.want {
257 t.Errorf("GetportLabel() = %v, want %v", got, tt.want)
258 }
259 })
260 }
261}
262
263func TestDeviceHandler_ProcessInterAdapterMessage(t *testing.T) {
264 dh := newMockDeviceHandler()
265 proxyAddr := dh.device.ProxyAddress
266 body := &ic.InterAdapterOmciMessage{
267 Message: []byte("asdfasdfasdfasdfas"),
268 ProxyAddress: proxyAddr,
269 }
270 body2 := &ic.InterAdapterOmciMessage{
271 Message: []byte("asdfasdfasdfasdfas"),
272 //ProxyAddress: &voltha.Device_ProxyAddress{},
273 }
274 body3 := &ic.InterAdapterTechProfileDownloadMessage{}
275 var marshalledData *any.Any
276 var err error
277
278 if marshalledData, err = ptypes.MarshalAny(body); err != nil {
279 log.Errorw("cannot-marshal-request", log.Fields{"error": err})
280 }
281
282 var marshalledData1 *any.Any
283
284 if marshalledData1, err = ptypes.MarshalAny(body2); err != nil {
285 log.Errorw("cannot-marshal-request", log.Fields{"error": err})
286 }
287 var marshalledData2 *any.Any
288
289 if marshalledData2, err = ptypes.MarshalAny(body3); err != nil {
290 log.Errorw("cannot-marshal-request", log.Fields{"error": err})
291 }
292 type args struct {
293 msg *ic.InterAdapterMessage
294 }
295 tests := []struct {
296 name string
297 args args
298 wantErr bool
299 }{
300 {"ProcessInterAdapterMessage-1", args{msg: &ic.InterAdapterMessage{
301 Header: &ic.InterAdapterHeader{
302 Id: "012345",
303 Type: 0,
304 },
305 Body: marshalledData,
306 }}, false},
307 {"ProcessInterAdapterMessage-2", args{msg: &ic.InterAdapterMessage{
308 Header: &ic.InterAdapterHeader{
309 Id: "012345",
310 Type: 1,
311 },
312 Body: marshalledData1,
313 }}, false},
314 {"ProcessInterAdapterMessage-3", args{msg: &ic.InterAdapterMessage{
315 Header: &ic.InterAdapterHeader{
316 Id: "012345",
317 Type: 2,
318 },
319 Body: marshalledData,
320 }}, false},
321 {"ProcessInterAdapterMessage-4", args{msg: &ic.InterAdapterMessage{
322 Header: &ic.InterAdapterHeader{
323 Id: "012345",
324 Type: 3,
325 }, Body: marshalledData,
326 }}, false},
327 {"ProcessInterAdapterMessage-5", args{msg: &ic.InterAdapterMessage{
328 Header: &ic.InterAdapterHeader{
329 Id: "012345",
330 Type: 4,
331 }, Body: marshalledData1,
332 }}, false},
333 {"ProcessInterAdapterMessage-6", args{msg: &ic.InterAdapterMessage{
334 Header: &ic.InterAdapterHeader{
335 Id: "012345",
336 Type: 4,
337 }, Body: marshalledData,
338 }}, false},
339 {"ProcessInterAdapterMessage-7", args{msg: &ic.InterAdapterMessage{
340 Header: &ic.InterAdapterHeader{
341 Id: "012345",
342 Type: 5,
343 }, Body: marshalledData,
344 }}, false},
345 {"ProcessInterAdapterMessage-8", args{msg: &ic.InterAdapterMessage{
346 Header: &ic.InterAdapterHeader{
347 Id: "012345",
348 Type: 6,
349 }, Body: marshalledData,
350 }}, false},
351 {"ProcessInterAdapterMessage-9", args{msg: &ic.InterAdapterMessage{
352 Header: &ic.InterAdapterHeader{
353 Id: "012345",
354 Type: 7,
355 }, Body: marshalledData,
356 }}, false},
357 {"ProcessInterAdapterMessage-10", args{msg: &ic.InterAdapterMessage{
358 Header: &ic.InterAdapterHeader{
359 Id: "012345",
360 Type: 7,
361 }, Body: marshalledData2,
362 }}, false},
363 //marshalledData2
364 }
365 for _, tt := range tests {
366 t.Run(tt.name, func(t *testing.T) {
367
368 if err := dh.ProcessInterAdapterMessage(tt.args.msg); (err != nil) != tt.wantErr {
369 t.Errorf("DeviceHandler.ProcessInterAdapterMessage() error = %v, wantErr %v", err, tt.wantErr)
370 }
371 })
372 }
373}
374
375func TestDeviceHandler_sendProxiedMessage(t *testing.T) {
376 dh1 := newMockDeviceHandler()
377 dh2 := negativeDeviceHandler()
378 device1 := &voltha.Device{
379 Id: "onu1",
380 Root: false,
381 ParentId: "logical_device",
382 ProxyAddress: &voltha.Device_ProxyAddress{
383 DeviceId: "onu1",
384 DeviceType: "onu",
385 ChannelId: 1,
386 ChannelGroupId: 1,
387 },
388 ConnectStatus: 1,
389 }
390 device2 := device1
391 device2.ConnectStatus = 2
392 iaomciMsg1 := &ic.InterAdapterOmciMessage{
393 ProxyAddress: &voltha.Device_ProxyAddress{
394 DeviceId: "onu2",
395 DeviceType: "onu",
396 ChannelId: 1,
397 ChannelGroupId: 1,
398 //OnuId: 2,
399 },
400 ConnectStatus: 1,
401 }
402 iaomciMsg2 := &ic.InterAdapterOmciMessage{
403 ProxyAddress: &voltha.Device_ProxyAddress{
404 DeviceId: "onu3",
405 DeviceType: "onu",
406 ChannelId: 1,
407 ChannelGroupId: 1,
408 },
409 ConnectStatus: 1,
410 }
411 type args struct {
412 onuDevice *voltha.Device
413 omciMsg *ic.InterAdapterOmciMessage
414 }
415 tests := []struct {
416 name string
417 devicehandler *DeviceHandler
418 args args
419 }{
420 {"sendProxiedMessage-1", dh1, args{onuDevice: device1, omciMsg: &ic.InterAdapterOmciMessage{}}},
421 {"sendProxiedMessage-2", dh1, args{onuDevice: device2, omciMsg: &ic.InterAdapterOmciMessage{}}},
422 {"sendProxiedMessage-3", dh1, args{onuDevice: nil, omciMsg: iaomciMsg1}},
423 {"sendProxiedMessage-4", dh1, args{onuDevice: nil, omciMsg: iaomciMsg2}},
424 {"sendProxiedMessage-5", dh2, args{onuDevice: nil, omciMsg: iaomciMsg2}},
425 {"sendProxiedMessage-6", dh2, args{onuDevice: device1, omciMsg: &ic.InterAdapterOmciMessage{}}},
426 }
427 for _, tt := range tests {
428 t.Run(tt.name, func(t *testing.T) {
429 tt.devicehandler.sendProxiedMessage(tt.args.onuDevice, tt.args.omciMsg)
430 })
431 }
432}
433
434func TestDeviceHandler_SendPacketInToCore(t *testing.T) {
435 dh1 := newMockDeviceHandler()
436 dh2 := negativeDeviceHandler()
437
438 type args struct {
439 logicalPort uint32
440 packetPayload []byte
441 }
442 tests := []struct {
443 name string
444 devicehandler *DeviceHandler
445 args args
446 }{
447 {"SendPacketInToCore-1", dh1, args{logicalPort: 1, packetPayload: []byte("test1")}},
448 {"SendPacketInToCore-2", dh1, args{logicalPort: 1, packetPayload: []byte("")}},
449 {"SendPacketInToCore-3", dh2, args{logicalPort: 1, packetPayload: []byte("test1")}},
450 }
451 for _, tt := range tests {
452 t.Run(tt.name, func(t *testing.T) {
453 tt.devicehandler.SendPacketInToCore(tt.args.logicalPort, tt.args.packetPayload)
454 })
455 }
456}
457
458func TestDeviceHandler_DisableDevice(t *testing.T) {
459 dh1 := newMockDeviceHandler()
460 dh2 := negativeDeviceHandler()
461 type args struct {
462 device *voltha.Device
463 }
464 tests := []struct {
465 name string
466 devicehandler *DeviceHandler
467 args args
468 wantErr bool
469 }{
470 {"DisableDevice-1", dh1, args{device: dh1.device}, false},
471 {"DisableDevice-2", dh1, args{device: dh1.device}, true},
472 {"DisableDevice-3", dh2, args{device: dh2.device}, true},
473 }
474 for _, tt := range tests {
475 t.Run(tt.name, func(t *testing.T) {
476
477 if err := tt.devicehandler.DisableDevice(tt.args.device); (err != nil) != tt.wantErr {
478 t.Errorf("DeviceHandler.DisableDevice() error = %v, wantErr %v", err, tt.wantErr)
479 }
480 })
481 }
482}
483
484func TestDeviceHandler_ReenableDevice(t *testing.T) {
485 dh1 := newMockDeviceHandler()
486 dh2 := negativeDeviceHandler()
487 type args struct {
488 device *voltha.Device
489 }
490 tests := []struct {
491 name string
492 devicehandler *DeviceHandler
493 args args
494 wantErr bool
495 }{
496 {"ReenableDevice-1", dh1, args{device: dh1.device}, false},
497 {"ReenableDevice-2", dh1, args{device: &voltha.Device{}}, true},
498 {"ReenableDevice-3", dh2, args{device: dh1.device}, false},
499 }
500 for _, tt := range tests {
501 t.Run(tt.name, func(t *testing.T) {
502 dh := tt.devicehandler
503 if err := dh.ReenableDevice(tt.args.device); (err != nil) != tt.wantErr {
504 t.Errorf("DeviceHandler.ReenableDevice() error = %v, wantErr %v", err, tt.wantErr)
505 }
506 })
507 }
508}
509
510func TestDeviceHandler_RebootDevice(t *testing.T) {
511 dh1 := newMockDeviceHandler()
512 dh2 := newMockDeviceHandler()
513 type args struct {
514 device *voltha.Device
515 }
516 tests := []struct {
517 name string
518 devicehandler *DeviceHandler
519 args args
520 wantErr bool
521 }{
522 // TODO: Add test cases.
523 {"RebootDevice-1", dh1, args{device: dh1.device}, false},
524 {"RebootDevice-2", dh1, args{device: dh2.device}, true},
525 {"RebootDevice-3", dh2, args{device: dh2.device}, false},
526 }
527 for _, tt := range tests {
528 t.Run(tt.name, func(t *testing.T) {
529
530 if err := tt.devicehandler.RebootDevice(tt.args.device); (err != nil) != tt.wantErr {
531 t.Errorf("DeviceHandler.RebootDevice() error = %v, wantErr %v", err, tt.wantErr)
532 }
533 })
534 }
535}
536
537func TestDeviceHandler_handleIndication(t *testing.T) {
538 dh1 := newMockDeviceHandler()
539 dh2 := negativeDeviceHandler()
540 dh3 := newMockDeviceHandler()
541 dh3.onus = map[string]*OnuDevice{"onu1": NewOnuDevice("onu1", "onu1", "onu1", 1, 1, "onu1"),
542 "onu2": NewOnuDevice("onu2", "onu2", "onu2", 2, 2, "onu2")}
543 type args struct {
544 indication *oop.Indication
545 }
546 tests := []struct {
547 name string
548 deviceHandler *DeviceHandler
549 args args
550 }{
551 // TODO: Add test cases.
552 {"handleIndication-1", dh1, args{indication: &oop.Indication{Data: &oop.Indication_OltInd{OltInd: &oop.OltIndication{OperState: "up"}}}}},
553 {"handleIndication-2", dh1, args{indication: &oop.Indication{Data: &oop.Indication_OltInd{OltInd: &oop.OltIndication{OperState: "down"}}}}},
554 {"handleIndication-3", dh1, args{indication: &oop.Indication{Data: &oop.Indication_IntfInd{IntfInd: &oop.IntfIndication{IntfId: 1, OperState: "up"}}}}},
555 {"handleIndication-4", dh1, args{indication: &oop.Indication{Data: &oop.Indication_IntfInd{IntfInd: &oop.IntfIndication{IntfId: 1, OperState: "down"}}}}},
556 {"handleIndication-5", dh1, args{indication: &oop.Indication{Data: &oop.Indication_IntfOperInd{IntfOperInd: &oop.IntfOperIndication{Type: "nni", IntfId: 1, OperState: "up"}}}}},
557 {"handleIndication-6", dh1, args{indication: &oop.Indication{Data: &oop.Indication_IntfOperInd{IntfOperInd: &oop.IntfOperIndication{Type: "pon", IntfId: 1, OperState: "up"}}}}},
558 {"handleIndication-7", dh1, args{indication: &oop.Indication{Data: &oop.Indication_OnuDiscInd{OnuDiscInd: &oop.OnuDiscIndication{IntfId: 1, SerialNumber: &oop.SerialNumber{VendorId: []byte("TWSH"), VendorSpecific: []byte("1234")}}}}}},
559 {"handleIndication-8", dh1, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "up", AdminState: "up"}}}}},
560 {"handleIndication-9", dh1, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "up", AdminState: "down"}}}}},
561 {"handleIndication-10", dh1, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "down", AdminState: "up"}}}}},
562 {"handleIndication-11", dh1, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "down", AdminState: "down"}}}}},
563 {"handleIndication-12", dh1, args{indication: &oop.Indication{Data: &oop.Indication_OmciInd{OmciInd: &oop.OmciIndication{IntfId: 1, OnuId: 1, Pkt: []byte("onu123-random value")}}}}},
564 {"handleIndication-13", dh1, args{indication: &oop.Indication{Data: &oop.Indication_PktInd{PktInd: &oop.PacketIndication{IntfType: "nni", IntfId: 1, GemportId: 1, FlowId: 1234, PortNo: 1}}}}},
565 {"handleIndication-14", dh1, args{indication: &oop.Indication{Data: &oop.Indication_PortStats{PortStats: &oop.PortStatistics{IntfId: 1, RxBytes: 100, RxPackets: 100, RxUcastPackets: 100, RxMcastPackets: 100, RxBcastPackets: 100, RxErrorPackets: 100, TxBytes: 100, TxPackets: 100, TxUcastPackets: 100, TxMcastPackets: 100, TxBcastPackets: 100, TxErrorPackets: 100, RxCrcErrors: 100, BipErrors: 100, Timestamp: 1000}}}}},
566 {"handleIndication-15", dh1, args{indication: &oop.Indication{Data: &oop.Indication_FlowStats{FlowStats: &oop.FlowStatistics{RxBytes: 100, RxPackets: 100, TxBytes: 100, TxPackets: 100, Timestamp: 1000}}}}},
567 {"handleIndication-16", dh1, args{indication: &oop.Indication{Data: &oop.Indication_AlarmInd{AlarmInd: &oop.AlarmIndication{}}}}},
568 {"handleIndication-17", dh1, args{indication: &oop.Indication{Data: &oop.Indication_PktInd{PktInd: &oop.PacketIndication{IntfType: "nni", FlowId: 1234, PortNo: 1}}}}},
569 {"handleIndication-18", dh1, args{indication: &oop.Indication{Data: &oop.Indication_PktInd{PktInd: &oop.PacketIndication{}}}}},
570
571 // Negative testcases
572 {"handleIndication-19", dh2, args{indication: &oop.Indication{Data: &oop.Indication_OltInd{OltInd: &oop.OltIndication{OperState: "up"}}}}},
573 {"handleIndication-20", dh2, args{indication: &oop.Indication{Data: &oop.Indication_OltInd{OltInd: &oop.OltIndication{OperState: "down"}}}}},
574 {"handleIndication-21", dh2, args{indication: &oop.Indication{Data: &oop.Indication_IntfInd{IntfInd: &oop.IntfIndication{IntfId: 1, OperState: "up"}}}}},
575 {"handleIndication-22", dh2, args{indication: &oop.Indication{Data: &oop.Indication_IntfInd{IntfInd: &oop.IntfIndication{IntfId: 1, OperState: "down"}}}}},
576 {"handleIndication-23", dh2, args{indication: &oop.Indication{Data: &oop.Indication_IntfOperInd{IntfOperInd: &oop.IntfOperIndication{Type: "nni", IntfId: 1, OperState: "up"}}}}},
577 {"handleIndication-24", dh2, args{indication: &oop.Indication{Data: &oop.Indication_IntfOperInd{IntfOperInd: &oop.IntfOperIndication{Type: "pon", IntfId: 1, OperState: "up"}}}}},
578 {"handleIndication-25", dh2, args{indication: &oop.Indication{Data: &oop.Indication_OnuDiscInd{OnuDiscInd: &oop.OnuDiscIndication{IntfId: 1, SerialNumber: &oop.SerialNumber{VendorId: []byte("TWSH"), VendorSpecific: []byte("1234")}}}}}},
579 {"handleIndication-26", dh2, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "up", AdminState: "up"}}}}},
580 {"handleIndication-27", dh2, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "up", AdminState: "down"}}}}},
581 {"handleIndication-28", dh2, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "down", AdminState: "up"}}}}},
582 {"handleIndication-29", dh2, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "down", AdminState: "down"}}}}},
583 {"handleIndication-30", dh2, args{indication: &oop.Indication{Data: &oop.Indication_OmciInd{OmciInd: &oop.OmciIndication{IntfId: 1, OnuId: 1, Pkt: []byte("onu123-random value")}}}}},
584 {"handleIndication-31", dh2, args{indication: &oop.Indication{Data: &oop.Indication_PktInd{PktInd: &oop.PacketIndication{IntfType: "nni", IntfId: 1, GemportId: 1, FlowId: 1234, PortNo: 1}}}}},
585 {"handleIndication-32", dh2, args{indication: &oop.Indication{Data: &oop.Indication_PortStats{PortStats: &oop.PortStatistics{IntfId: 1, RxBytes: 100, RxPackets: 100, RxUcastPackets: 100, RxMcastPackets: 100, RxBcastPackets: 100, RxErrorPackets: 100, TxBytes: 100, TxPackets: 100, TxUcastPackets: 100, TxMcastPackets: 100, TxBcastPackets: 100, TxErrorPackets: 100, RxCrcErrors: 100, BipErrors: 100, Timestamp: 1000}}}}},
586 {"handleIndication-33", dh2, args{indication: &oop.Indication{Data: &oop.Indication_FlowStats{FlowStats: &oop.FlowStatistics{RxBytes: 100, RxPackets: 100, TxBytes: 100, TxPackets: 100, Timestamp: 1000}}}}},
587 {"handleIndication-34", dh2, args{indication: &oop.Indication{Data: &oop.Indication_AlarmInd{AlarmInd: &oop.AlarmIndication{}}}}},
588 //
589 {"handleIndication-35", dh3, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "up", AdminState: "up"}}}}},
590 {"handleIndication-36", dh3, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "down", AdminState: "up"}}}}},
591 {"handleIndication-37", dh3, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "up", AdminState: "down"}}}}},
592 {"handleIndication-38", dh3, args{indication: &oop.Indication{Data: &oop.Indication_OnuInd{OnuInd: &oop.OnuIndication{IntfId: 1, OnuId: 1, OperState: "down", AdminState: "down"}}}}},
593 {"handleIndication-30", dh1, args{indication: &oop.Indication{Data: &oop.Indication_OmciInd{OmciInd: &oop.OmciIndication{IntfId: 1, OnuId: 4, Pkt: []byte("onu123-random value")}}}}},
594 {"handleIndication-30", dh2, args{indication: &oop.Indication{Data: &oop.Indication_OmciInd{OmciInd: &oop.OmciIndication{IntfId: 1, OnuId: 4, Pkt: []byte("onu123-random value")}}}}},
595 }
596 for _, tt := range tests {
597 t.Run(tt.name, func(t *testing.T) {
598 dh := tt.deviceHandler
599 dh.handleIndication(tt.args.indication)
600 })
601 }
602}
603
604func TestDeviceHandler_addPort(t *testing.T) {
605 dh1 := newMockDeviceHandler()
606 dh2 := negativeDeviceHandler()
607 type args struct {
608 intfID uint32
609 portType voltha.Port_PortType
610 state string
611 }
612 tests := []struct {
613 name string
614 devicehandler *DeviceHandler
615 args args
616 }{
617 // State up
618 {"addPort.1", dh1, args{intfID: 1, portType: voltha.Port_UNKNOWN, state: "up"}},
619 {"addPort.2", dh1, args{intfID: 1, portType: voltha.Port_VENET_OLT, state: "up"}},
620 {"addPort.3", dh1, args{intfID: 1, portType: voltha.Port_VENET_ONU, state: "up"}},
621 {"addPort.4", dh1, args{intfID: 1, portType: voltha.Port_ETHERNET_NNI, state: "up"}},
622 {"addPort.5", dh1, args{intfID: 1, portType: voltha.Port_ETHERNET_UNI, state: "up"}},
623 {"addPort.6", dh1, args{intfID: 1, portType: voltha.Port_PON_OLT, state: "up"}},
624 {"addPort.7", dh1, args{intfID: 1, portType: voltha.Port_PON_ONU, state: "up"}},
625 {"addPort.8", dh1, args{intfID: 1, portType: 8, state: "up"}},
626 // state discovery
627 {"addPort.9", dh1, args{intfID: 1, portType: voltha.Port_UNKNOWN, state: "down"}},
628 {"addPort.10", dh1, args{intfID: 1, portType: voltha.Port_VENET_OLT, state: "down"}},
629 {"addPort.11", dh1, args{intfID: 1, portType: voltha.Port_VENET_ONU, state: "down"}},
630 {"addPort.12", dh1, args{intfID: 1, portType: voltha.Port_ETHERNET_NNI, state: "down"}},
631 {"addPort.13", dh1, args{intfID: 1, portType: voltha.Port_ETHERNET_UNI, state: "down"}},
632 {"addPort.14", dh1, args{intfID: 1, portType: voltha.Port_PON_OLT, state: "down"}},
633 {"addPort.15", dh1, args{intfID: 1, portType: voltha.Port_PON_ONU, state: "down"}},
634 {"addPort.16", dh1, args{intfID: 1, portType: 8, state: "down"}},
635
636 {"addPort.17", dh2, args{intfID: 1, portType: voltha.Port_ETHERNET_NNI, state: "up"}},
637 {"addPort.18", dh2, args{intfID: 1, portType: voltha.Port_ETHERNET_UNI, state: "up"}},
638 {"addPort.19", dh2, args{intfID: 1, portType: voltha.Port_ETHERNET_NNI, state: "down"}},
639 {"addPort.20", dh2, args{intfID: 1, portType: voltha.Port_ETHERNET_UNI, state: "down"}},
640 }
641 for _, tt := range tests {
642 t.Run(tt.name, func(t *testing.T) {
643 tt.devicehandler.addPort(tt.args.intfID, tt.args.portType, tt.args.state)
644 })
645 }
646}
647
648func Test_macAddressToUint32Array(t *testing.T) {
649 type args struct {
650 mac string
651 }
652 tests := []struct {
653 name string
654 args args
655 want []uint32
656 }{
657 // TODO: Add test cases.
658 {"macAddressToUint32Array-1", args{mac: "00:00:00:00:00:01"}, []uint32{0, 0, 0, 0, 0, 1}},
659 {"macAddressToUint32Array-2", args{mac: "0abcdef"}, []uint32{11259375}},
660 {"macAddressToUint32Array-3", args{mac: "testing"}, []uint32{1, 2, 3, 4, 5, 6}},
661 }
662 for _, tt := range tests {
663 t.Run(tt.name, func(t *testing.T) {
664 if got := macAddressToUint32Array(tt.args.mac); !reflect.DeepEqual(got, tt.want) {
665 t.Errorf("macAddressToUint32Array() = %v, want %v", got, tt.want)
666 }
667 })
668 }
669}
670
671func TestDeviceHandler_handleOltIndication(t *testing.T) {
672
673 type args struct {
674 oltIndication *oop.OltIndication
675 }
676 tests := []struct {
677 name string
678 args args
679 }{
680 {"handleOltIndication-1", args{oltIndication: &oop.OltIndication{OperState: "up"}}},
681 {"handleOltIndication-2", args{oltIndication: &oop.OltIndication{OperState: "down"}}},
682 }
683 for _, tt := range tests {
684 t.Run(tt.name, func(t *testing.T) {
685 dh := newMockDeviceHandler()
686 dh.handleOltIndication(tt.args.oltIndication)
687 })
688 }
689}
690
691func TestDeviceHandler_AdoptDevice(t *testing.T) {
692 dh1 := newMockDeviceHandler()
693 dh2 := negativeDeviceHandler()
694 type args struct {
695 device *voltha.Device
696 }
697 tests := []struct {
698 name string
699 devicehandler *DeviceHandler
700 args args
701 }{
702 // TODO: Add test cases.
703 {"AdoptDevice-1", dh1, args{device: dh1.device}},
704 {"AdoptDevice-1", dh2, args{device: dh2.device}},
705 }
706 for _, tt := range tests {
707 t.Run(tt.name, func(t *testing.T) {
708 //dh.doStateInit()
709 // context.
710 //dh.AdoptDevice(tt.args.device)
711 tt.devicehandler.postInit()
712 })
713 }
714}
715
716func TestDeviceHandler_activateONU(t *testing.T) {
717 dh := newMockDeviceHandler()
718 dh1 := negativeDeviceHandler()
719 type args struct {
720 intfID uint32
721 onuID int64
722 serialNum *oop.SerialNumber
723 serialNumber string
724 }
725 tests := []struct {
726 name string
727 devicehandler *DeviceHandler
728 args args
729 }{
730 {"activateONU-1", dh, args{intfID: 1, onuID: 1, serialNum: &oop.SerialNumber{VendorId: []byte("onu1")}}},
731 {"activateONU-2", dh, args{intfID: 2, onuID: 2, serialNum: &oop.SerialNumber{VendorId: []byte("onu2")}}},
732 {"activateONU-3", dh1, args{intfID: 1, onuID: 1, serialNum: &oop.SerialNumber{VendorId: []byte("onu1")}}},
733 {"activateONU-4", dh1, args{intfID: 2, onuID: 2, serialNum: &oop.SerialNumber{VendorId: []byte("onu2")}}},
734 }
735 for _, tt := range tests {
736 t.Run(tt.name, func(t *testing.T) {
737
738 tt.devicehandler.activateONU(tt.args.intfID, tt.args.onuID,
739 tt.args.serialNum, tt.args.serialNumber)
740 })
741 }
742}
743
744func TestDeviceHandler_start(t *testing.T) {
745 dh := newMockDeviceHandler()
746 dh1 := negativeDeviceHandler()
747 dh.start(context.Background())
748 dh.stop(context.Background())
749
750 dh1.start(context.Background())
751 dh1.stop(context.Background())
752
753}
754
755func TestDeviceHandler_PacketOut(t *testing.T) {
756 dh1 := newMockDeviceHandler()
757 dh2 := negativeDeviceHandler()
758 acts := []*ofp.OfpAction{
759 fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA))),
760 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
761 fu.Output(1),
762 }
763 pktout := &ofp.OfpPacketOut{BufferId: 0, InPort: 1, Actions: acts, Data: []byte("AYDCAAAOAODsSE5TiMwCBwQA4OxITlIEBQUwLzUxBgIAFAgEMC81MQoJbG9jYWxob3N0EBwFAawbqqACAAAAoRAxLjMuNi4xLjQuMS40NDEz/gYAgMILAgD+GQCAwgkDAAAAAGQAAAAAAAAAAgICAgICAgL+GQCAwgoDAAAAAGQAAAAAAAAAAgICAgICAgIAAA==")}
764 type args struct {
765 egressPortNo int
766 packet *of.OfpPacketOut
767 }
768 tests := []struct {
769 name string
770 devicehandler *DeviceHandler
771 args args
772 wantErr bool
773 }{
774 // TODO: Add test cases.
775 //{"test1", args{egressPortNo: 0, packet: &ofp.OfpPacketOut{}}, true},
776 {"PacketOut-1", dh1, args{egressPortNo: 0, packet: pktout}, false},
777 {"PacketOut-2", dh2, args{egressPortNo: 1, packet: pktout}, false},
778 {"PacketOut-2", dh2, args{egressPortNo: 115000, packet: pktout}, false},
779 {"PacketOut-3", dh1, args{egressPortNo: 65536, packet: pktout}, false},
780 {"PacketOut-4", dh2, args{egressPortNo: 65535, packet: pktout}, false},
781 }
782 for _, tt := range tests {
783 t.Run(tt.name, func(t *testing.T) {
784 dh := tt.devicehandler
785 if err := dh.PacketOut(tt.args.egressPortNo, tt.args.packet); (err != nil) != tt.wantErr {
786 t.Errorf("DeviceHandler.PacketOut() error = %v, wantErr %v", err, tt.wantErr)
787 }
788 })
789 }
790}
791
792//
793func TestDeviceHandler_doStateUp(t *testing.T) {
794 dh1 := newMockDeviceHandler()
795 dh2 := newMockDeviceHandler()
796
797 dh2.deviceID = ""
798 dh3 := negativeDeviceHandler()
799
800 tests := []struct {
801 name string
802 devicehandler *DeviceHandler
803 wantErr bool
804 }{
805 {"dostateup-1", dh1, false},
806 {"dostateup-2", dh2, false},
807 {"dostateup-3", dh3, true},
808 }
809 for _, tt := range tests {
810 t.Run(tt.name, func(t *testing.T) {
811 if err := tt.devicehandler.doStateUp(); (err != nil) != tt.wantErr {
812 t.Logf("DeviceHandler.doStateUp() error = %v, wantErr %v", err, tt.wantErr)
813 }
814 })
815 }
816}
817func TestDeviceHandler_doStateDown(t *testing.T) {
818 dh1 := newMockDeviceHandler()
819 dh2 := negativeDeviceHandler()
820 dh3 := newMockDeviceHandler()
821 dh3.device.OperStatus = voltha.OperStatus_UNKNOWN
822 tests := []struct {
823 name string
824 devicehandler *DeviceHandler
825 wantErr bool
826 }{
827 {"dostatedown-1", dh1, false},
828 {"dostatedown-2", dh2, true},
829 {"dostatedown-2", dh3, true},
830 }
831 for _, tt := range tests {
832 t.Run(tt.name, func(t *testing.T) {
833 if err := tt.devicehandler.doStateDown(); (err != nil) != tt.wantErr {
834 t.Logf("DeviceHandler.doStateDown() error = %v", err)
835 }
836 })
837 }
838}
839
840func TestDeviceHandler_GetOfpDeviceInfo(t *testing.T) {
841 dh1 := newMockDeviceHandler()
842 dh2 := negativeDeviceHandler()
843 type args struct {
844 device *voltha.Device
845 }
846 tests := []struct {
847 name string
848 devicehandler *DeviceHandler
849 args args
850 wantErr bool
851 }{
852 // TODO: Add test cases.
853 {"GetOfpDeviceInfo-1", dh1, args{dh1.device}, false},
854 {"GetOfpDeviceInfo-2", dh1, args{&voltha.Device{}}, false},
855 {"GetOfpDeviceInfo-3", dh2, args{dh1.device}, false},
856 }
857 for _, tt := range tests {
858 t.Run(tt.name, func(t *testing.T) {
859 dh := tt.devicehandler
860 _, err := dh.GetOfpDeviceInfo(tt.args.device)
861 if (err != nil) != tt.wantErr {
862 t.Errorf("DeviceHandler.GetOfpDeviceInfo() error = %v, wantErr %v", err, tt.wantErr)
863 return
864 }
865 })
866 }
867}
868
869func TestDeviceHandler_GetOfpPortInfo(t *testing.T) {
870 dh1 := newMockDeviceHandler()
871 dh2 := negativeDeviceHandler()
872 type args struct {
873 device *voltha.Device
874 portNo int64
875 }
876 tests := []struct {
877 name string
878 devicehandler *DeviceHandler
879 args args
880 wantErr bool
881 }{
882 {"GetOfpPortInfo-1", dh1, args{device: dh1.device, portNo: 1}, false},
883 {"GetOfpPortInfo-2", dh2, args{device: dh2.device, portNo: 1}, false},
884 {"GetOfpPortInfo-3", dh1, args{device: dh1.device, portNo: 0}, false},
885 {"GetOfpPortInfo-4", dh2, args{device: dh2.device, portNo: 0}, false},
886 {"GetOfpPortInfo-5", dh1, args{device: &voltha.Device{}, portNo: 1}, false},
887 {"GetOfpPortInfo-6", dh2, args{device: &voltha.Device{}, portNo: 0}, false},
888 // TODO: Add test cases.
889 }
890 for _, tt := range tests {
891 t.Run(tt.name, func(t *testing.T) {
892 dh := tt.devicehandler
893 _, err := dh.GetOfpPortInfo(tt.args.device, tt.args.portNo)
894 if (err != nil) != tt.wantErr {
895 t.Errorf("DeviceHandler.GetOfpPortInfo() error = %v, wantErr %v", err, tt.wantErr)
896 return
897 }
898 })
899 }
900}
901
902func TestDeviceHandler_onuDiscIndication(t *testing.T) {
903
904 dh1 := newMockDeviceHandler()
905 dh1.discOnus = map[string]bool{"onu1": true, "onu2": false}
906 dh2 := negativeDeviceHandler()
907 type args struct {
908 onuDiscInd *oop.OnuDiscIndication
909 sn string
910 }
911 tests := []struct {
912 name string
913 devicehandler *DeviceHandler
914 args args
915 }{
916 // TODO: Add test cases.
917 {"onuDiscIndication-1", dh1, args{onuDiscInd: &oop.OnuDiscIndication{IntfId: 1, SerialNumber: &oop.SerialNumber{VendorId: []byte("TWSH"), VendorSpecific: []byte("1234")}}}},
918 {"onuDiscIndication-2", dh1, args{onuDiscInd: &oop.OnuDiscIndication{IntfId: 1, SerialNumber: &oop.SerialNumber{}}}},
919 {"onuDiscIndication-3", dh1, args{onuDiscInd: &oop.OnuDiscIndication{SerialNumber: &oop.SerialNumber{}}}},
920 {"onuDiscIndication-4", dh1, args{onuDiscInd: &oop.OnuDiscIndication{}}},
921 {"onuDiscIndication-5", dh1, args{onuDiscInd: &oop.OnuDiscIndication{IntfId: 1, SerialNumber: &oop.SerialNumber{VendorId: []byte("TWSH"), VendorSpecific: []byte("1234")}}, sn: "onu1"}},
922 {"onuDiscIndication-6", dh1, args{onuDiscInd: &oop.OnuDiscIndication{IntfId: 1, SerialNumber: &oop.SerialNumber{VendorId: []byte("TWSH"), VendorSpecific: []byte("1234")}}, sn: "onu2"}},
923 {"onuDiscIndication-7", dh2, args{onuDiscInd: &oop.OnuDiscIndication{IntfId: 1, SerialNumber: &oop.SerialNumber{VendorId: []byte("TWSH"), VendorSpecific: []byte("1234")}}}},
924 }
925 for _, tt := range tests {
926 t.Run(tt.name, func(t *testing.T) {
927 tt.devicehandler.onuDiscIndication(tt.args.onuDiscInd, tt.args.sn)
928 })
929 }
930}
931
932func TestDeviceHandler_populateDeviceInfo(t *testing.T) {
933 dh1 := newMockDeviceHandler()
934 dh2 := negativeDeviceHandler()
935 tests := []struct {
936 name string
937 devicehandler *DeviceHandler
938
939 wantErr bool
940 }{
941 // TODO: Add test cases.
942 {"populateDeviceInfo-1", dh1, false},
943 {"populateDeviceInfo-2", dh1, true},
944 {"populateDeviceInfo-3", dh1, true},
945 {"populateDeviceInfo-4", dh1, true},
946 {"populateDeviceInfo-5", dh2, true},
947 }
948 for _, tt := range tests {
949 t.Run(tt.name, func(t *testing.T) {
950
951 _, err := tt.devicehandler.populateDeviceInfo()
952 if (err != nil) != tt.wantErr {
953 t.Errorf("DeviceHandler.populateDeviceInfo() error = %v, wantErr %v", err, tt.wantErr)
954 return
955 }
956
957 })
958 }
959}
960
961func TestDeviceHandler_readIndications(t *testing.T) {
962 dh1 := newMockDeviceHandler()
963 dh2 := newMockDeviceHandler()
964 dh2.adminState = "down"
965 dh3 := newMockDeviceHandler()
966 dh3.device.AdminState = voltha.AdminState_DISABLED
967 dh4 := negativeDeviceHandler()
968 tests := []struct {
969 name string
970 devicehandler *DeviceHandler
971 }{
972 // TODO: Add test cases.
973 {"readIndications-1", dh1},
974 {"readIndications-2", dh2},
975 {"readIndications-3", dh2},
976 {"readIndications-4", dh2},
977 {"readIndications-5", dh2},
978 {"readIndications-6", dh3},
979 {"readIndications-7", dh3},
980 {"readIndications-8", dh4},
981 }
982 for _, tt := range tests {
983 t.Run(tt.name, func(t *testing.T) {
984 tt.devicehandler.readIndications()
985 })
986 }
987}