blob: 0fe877e0e2da34fdc7a29b6bb36a206a40009c99 [file] [log] [blame]
khenaidoob64fc8a2019-11-27 15:08:19 -05001/*
Kent Hagerman45a13e42020-04-13 12:23:50 -04002 * Copyright 2019-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.
khenaidoob64fc8a2019-11-27 15:08:19 -050015 */
Kent Hagerman45a13e42020-04-13 12:23:50 -040016
Kent Hagerman2b216042020-04-03 18:28:56 -040017package api
khenaidoob64fc8a2019-11-27 15:08:19 -050018
19import (
20 "context"
21 "errors"
22 "fmt"
khenaidoo67b22152020-03-02 16:01:25 -050023 "math/rand"
24 "os"
25 "runtime"
26 "runtime/pprof"
serkant.uluderya2ae470f2020-01-21 11:13:09 -080027 "strings"
khenaidoo67b22152020-03-02 16:01:25 -050028 "sync"
serkant.uluderya2ae470f2020-01-21 11:13:09 -080029 "testing"
30 "time"
31
khenaidoob64fc8a2019-11-27 15:08:19 -050032 "github.com/golang/protobuf/ptypes/empty"
Kent Hagerman2b216042020-04-03 18:28:56 -040033 "github.com/opencord/voltha-go/db/model"
khenaidoob64fc8a2019-11-27 15:08:19 -050034 "github.com/opencord/voltha-go/rw_core/config"
Kent Hagerman2b216042020-04-03 18:28:56 -040035 "github.com/opencord/voltha-go/rw_core/core/adapter"
36 "github.com/opencord/voltha-go/rw_core/core/device"
khenaidoob64fc8a2019-11-27 15:08:19 -050037 cm "github.com/opencord/voltha-go/rw_core/mocks"
Mahir Gunyel03de0d32020-06-03 01:36:59 -070038 tst "github.com/opencord/voltha-go/rw_core/test"
Kent Hagerman2b216042020-04-03 18:28:56 -040039 "github.com/opencord/voltha-lib-go/v3/pkg/db"
40 "github.com/opencord/voltha-lib-go/v3/pkg/flows"
serkant.uluderya2ae470f2020-01-21 11:13:09 -080041 "github.com/opencord/voltha-lib-go/v3/pkg/kafka"
Matteo Scandolod525ae32020-04-02 17:27:29 -070042 mock_etcd "github.com/opencord/voltha-lib-go/v3/pkg/mocks/etcd"
43 mock_kafka "github.com/opencord/voltha-lib-go/v3/pkg/mocks/kafka"
serkant.uluderya2ae470f2020-01-21 11:13:09 -080044 ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
45 "github.com/opencord/voltha-protos/v3/go/voltha"
khenaidoob64fc8a2019-11-27 15:08:19 -050046 "github.com/phayes/freeport"
47 "github.com/stretchr/testify/assert"
48 "google.golang.org/grpc/codes"
49 "google.golang.org/grpc/status"
khenaidoob64fc8a2019-11-27 15:08:19 -050050)
51
52type NBTest struct {
Matteo Scandolod525ae32020-04-02 17:27:29 -070053 etcdServer *mock_etcd.EtcdServer
Kent Hagerman2b216042020-04-03 18:28:56 -040054 deviceMgr *device.Manager
55 logicalDeviceMgr *device.LogicalManager
56 adapterMgr *adapter.Manager
57 kmp kafka.InterContainerProxy
khenaidoo67b22152020-03-02 16:01:25 -050058 kClient kafka.Client
59 kvClientPort int
60 numONUPerOLT int
61 startingUNIPortNo int
62 oltAdapter *cm.OLTAdapter
63 onuAdapter *cm.ONUAdapter
64 oltAdapterName string
65 onuAdapterName string
66 coreInstanceID string
67 defaultTimeout time.Duration
68 maxTimeout time.Duration
khenaidoob64fc8a2019-11-27 15:08:19 -050069}
70
71func newNBTest() *NBTest {
72 test := &NBTest{}
73 // Start the embedded etcd server
74 var err error
Mahir Gunyel03de0d32020-06-03 01:36:59 -070075 test.etcdServer, test.kvClientPort, err = tst.StartEmbeddedEtcdServer("voltha.rwcore.nb.test", "voltha.rwcore.nb.etcd", "error")
khenaidoob64fc8a2019-11-27 15:08:19 -050076 if err != nil {
Girish Kumarf56a4682020-03-20 20:07:46 +000077 logger.Fatal(err)
khenaidoob64fc8a2019-11-27 15:08:19 -050078 }
79 // Create the kafka client
Matteo Scandolod525ae32020-04-02 17:27:29 -070080 test.kClient = mock_kafka.NewKafkaClient()
khenaidoob64fc8a2019-11-27 15:08:19 -050081 test.oltAdapterName = "olt_adapter_mock"
82 test.onuAdapterName = "onu_adapter_mock"
83 test.coreInstanceID = "rw-nbi-test"
khenaidoo32836732020-03-05 16:10:44 -050084 test.defaultTimeout = 10 * time.Second
85 test.maxTimeout = 20 * time.Second
khenaidoob64fc8a2019-11-27 15:08:19 -050086 return test
87}
88
89func (nb *NBTest) startCore(inCompeteMode bool) {
Thomas Lee Se5a44012019-11-07 20:32:24 +053090 ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
91 defer cancel()
khenaidoob64fc8a2019-11-27 15:08:19 -050092 cfg := config.NewRWCoreFlags()
serkant.uluderya8ff291d2020-05-20 00:58:00 -070093 cfg.CoreTopic = "rw_core"
khenaidoo442e7c72020-03-10 16:13:48 -040094 cfg.DefaultRequestTimeout = nb.defaultTimeout
95 cfg.DefaultCoreTimeout = nb.defaultTimeout
khenaidoob64fc8a2019-11-27 15:08:19 -050096 cfg.KVStorePort = nb.kvClientPort
97 cfg.InCompetingMode = inCompeteMode
98 grpcPort, err := freeport.GetFreePort()
99 if err != nil {
Girish Kumarf56a4682020-03-20 20:07:46 +0000100 logger.Fatal("Cannot get a freeport for grpc")
khenaidoob64fc8a2019-11-27 15:08:19 -0500101 }
102 cfg.GrpcPort = grpcPort
103 cfg.GrpcHost = "127.0.0.1"
104 setCoreCompeteMode(inCompeteMode)
Mahir Gunyel03de0d32020-06-03 01:36:59 -0700105 client := tst.SetupKVClient(cfg, nb.coreInstanceID)
Kent Hagerman2b216042020-04-03 18:28:56 -0400106 backend := &db.Backend{
107 Client: client,
108 StoreType: cfg.KVStoreType,
109 Host: cfg.KVStoreHost,
110 Port: cfg.KVStorePort,
111 Timeout: cfg.KVStoreTimeout,
serkant.uluderya8ff291d2020-05-20 00:58:00 -0700112 LivenessChannelInterval: cfg.LiveProbeInterval / 2}
Kent Hagerman2b216042020-04-03 18:28:56 -0400113 nb.kmp = kafka.NewInterContainerProxy(
114 kafka.InterContainerHost(cfg.KafkaAdapterHost),
115 kafka.InterContainerPort(cfg.KafkaAdapterPort),
116 kafka.MsgClient(nb.kClient),
117 kafka.DefaultTopic(&kafka.Topic{Name: cfg.CoreTopic}),
118 kafka.DeviceDiscoveryTopic(&kafka.Topic{Name: cfg.AffinityRouterTopic}))
119
120 endpointMgr := kafka.NewEndpointManager(backend)
Kent Hagermanf5a67352020-04-30 15:15:26 -0400121 proxy := model.NewDBPath(backend)
Kent Hagerman2b216042020-04-03 18:28:56 -0400122 nb.adapterMgr = adapter.NewAdapterManager(proxy, nb.coreInstanceID, nb.kClient)
serkant.uluderya8ff291d2020-05-20 00:58:00 -0700123 nb.deviceMgr, nb.logicalDeviceMgr = device.NewManagers(proxy, nb.adapterMgr, nb.kmp, endpointMgr, cfg.CoreTopic, nb.coreInstanceID, cfg.DefaultCoreTimeout)
Kent Hagerman2f0d0552020-04-23 17:28:52 -0400124 nb.adapterMgr.Start(ctx)
Kent Hagerman2b216042020-04-03 18:28:56 -0400125
Kent Hagerman2f0d0552020-04-23 17:28:52 -0400126 if err := nb.kmp.Start(); err != nil {
Kent Hagerman2b216042020-04-03 18:28:56 -0400127 logger.Fatalf("Cannot start InterContainerProxy: %s", err)
128 }
Kent Hagerman2f0d0552020-04-23 17:28:52 -0400129 requestProxy := NewAdapterRequestHandlerProxy(nb.deviceMgr, nb.adapterMgr)
Kent Hagerman2b216042020-04-03 18:28:56 -0400130 if err := nb.kmp.SubscribeWithRequestHandlerInterface(kafka.Topic{Name: cfg.CoreTopic}, requestProxy); err != nil {
131 logger.Fatalf("Cannot add request handler: %s", err)
132 }
khenaidoob64fc8a2019-11-27 15:08:19 -0500133}
134
khenaidoob64fc8a2019-11-27 15:08:19 -0500135func (nb *NBTest) stopAll() {
136 if nb.kClient != nil {
137 nb.kClient.Stop()
138 }
Kent Hagerman2b216042020-04-03 18:28:56 -0400139 if nb.kmp != nil {
140 nb.kmp.Stop()
khenaidoob64fc8a2019-11-27 15:08:19 -0500141 }
142 if nb.etcdServer != nil {
Mahir Gunyel03de0d32020-06-03 01:36:59 -0700143 tst.StopEmbeddedEtcdServer(nb.etcdServer)
khenaidoob64fc8a2019-11-27 15:08:19 -0500144 }
145}
146
Kent Hagerman2b216042020-04-03 18:28:56 -0400147func (nb *NBTest) verifyLogicalDevices(t *testing.T, oltDevice *voltha.Device, nbi *NBIHandler) {
khenaidoob64fc8a2019-11-27 15:08:19 -0500148 // Get the latest set of logical devices
149 logicalDevices, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{})
150 assert.Nil(t, err)
151 assert.NotNil(t, logicalDevices)
152 assert.Equal(t, 1, len(logicalDevices.Items))
153
154 ld := logicalDevices.Items[0]
155 assert.NotEqual(t, "", ld.Id)
156 assert.NotEqual(t, uint64(0), ld.DatapathId)
157 assert.Equal(t, "olt_adapter_mock", ld.Desc.HwDesc)
158 assert.Equal(t, "olt_adapter_mock", ld.Desc.SwDesc)
159 assert.NotEqual(t, "", ld.RootDeviceId)
160 assert.NotEqual(t, "", ld.Desc.SerialNum)
161 assert.Equal(t, uint32(256), ld.SwitchFeatures.NBuffers)
162 assert.Equal(t, uint32(2), ld.SwitchFeatures.NTables)
163 assert.Equal(t, uint32(15), ld.SwitchFeatures.Capabilities)
164 assert.Equal(t, 1+nb.numONUPerOLT, len(ld.Ports))
165 assert.Equal(t, oltDevice.ParentId, ld.Id)
166 //Expected port no
167 expectedPortNo := make(map[uint32]bool)
168 expectedPortNo[uint32(2)] = false
169 for i := 0; i < nb.numONUPerOLT; i++ {
170 expectedPortNo[uint32(i+100)] = false
171 }
172 for _, p := range ld.Ports {
173 assert.Equal(t, p.OfpPort.PortNo, p.DevicePortNo)
174 assert.Equal(t, uint32(4), p.OfpPort.State)
175 expectedPortNo[p.OfpPort.PortNo] = true
176 if strings.HasPrefix(p.Id, "nni") {
177 assert.Equal(t, true, p.RootPort)
178 //assert.Equal(t, uint32(2), p.OfpPort.PortNo)
179 assert.Equal(t, p.Id, fmt.Sprintf("nni-%d", p.DevicePortNo))
180 } else {
181 assert.Equal(t, p.Id, fmt.Sprintf("uni-%d", p.DevicePortNo))
182 assert.Equal(t, false, p.RootPort)
183 }
184 }
185}
186
Kent Hagerman2b216042020-04-03 18:28:56 -0400187func (nb *NBTest) verifyDevices(t *testing.T, nbi *NBIHandler) {
khenaidoob64fc8a2019-11-27 15:08:19 -0500188 // Get the latest set of devices
189 devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
190 assert.Nil(t, err)
191 assert.NotNil(t, devices)
192
khenaidoo67b22152020-03-02 16:01:25 -0500193 // A device is ready to be examined when its ADMIN state is ENABLED and OPERATIONAL state is ACTIVE
khenaidoob64fc8a2019-11-27 15:08:19 -0500194 var vFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool {
195 return device.AdminState == voltha.AdminState_ENABLED && device.OperStatus == voltha.OperStatus_ACTIVE
196 }
khenaidoob64fc8a2019-11-27 15:08:19 -0500197
khenaidoo67b22152020-03-02 16:01:25 -0500198 var wg sync.WaitGroup
199 for _, device := range devices.Items {
200 wg.Add(1)
201 go func(wg *sync.WaitGroup, device *voltha.Device) {
202 // Wait until the device is in the right state
203 err := waitUntilDeviceReadiness(device.Id, nb.maxTimeout, vFunction, nbi)
204 assert.Nil(t, err)
205
206 // Now, verify the details of the device. First get the latest update
207 d, err := nbi.GetDevice(getContext(), &voltha.ID{Id: device.Id})
208 assert.Nil(t, err)
209 assert.Equal(t, voltha.AdminState_ENABLED, d.AdminState)
210 assert.Equal(t, voltha.ConnectStatus_REACHABLE, d.ConnectStatus)
211 assert.Equal(t, voltha.OperStatus_ACTIVE, d.OperStatus)
212 assert.Equal(t, d.Type, d.Adapter)
213 assert.NotEqual(t, "", d.MacAddress)
214 assert.NotEqual(t, "", d.SerialNumber)
215
216 if d.Type == "olt_adapter_mock" {
217 assert.Equal(t, true, d.Root)
218 assert.NotEqual(t, "", d.Id)
219 assert.NotEqual(t, "", d.ParentId)
220 assert.Nil(t, d.ProxyAddress)
221 } else if d.Type == "onu_adapter_mock" {
222 assert.Equal(t, false, d.Root)
223 assert.NotEqual(t, uint32(0), d.Vlan)
224 assert.NotEqual(t, "", d.Id)
225 assert.NotEqual(t, "", d.ParentId)
226 assert.NotEqual(t, "", d.ProxyAddress.DeviceId)
227 assert.Equal(t, "olt_adapter_mock", d.ProxyAddress.DeviceType)
khenaidoob64fc8a2019-11-27 15:08:19 -0500228 } else {
khenaidoo67b22152020-03-02 16:01:25 -0500229 assert.Error(t, errors.New("invalid-device-type"))
khenaidoob64fc8a2019-11-27 15:08:19 -0500230 }
khenaidoo67b22152020-03-02 16:01:25 -0500231 assert.Equal(t, 2, len(d.Ports))
232 for _, p := range d.Ports {
233 assert.Equal(t, voltha.AdminState_ENABLED, p.AdminState)
234 assert.Equal(t, voltha.OperStatus_ACTIVE, p.OperStatus)
235 if p.Type == voltha.Port_ETHERNET_NNI || p.Type == voltha.Port_ETHERNET_UNI {
236 assert.Equal(t, 0, len(p.Peers))
237 } else if p.Type == voltha.Port_PON_OLT {
238 assert.Equal(t, nb.numONUPerOLT, len(p.Peers))
239 assert.Equal(t, uint32(1), p.PortNo)
240 } else if p.Type == voltha.Port_PON_ONU {
241 assert.Equal(t, 1, len(p.Peers))
242 assert.Equal(t, uint32(1), p.PortNo)
243 } else {
244 assert.Error(t, errors.New("invalid-port"))
245 }
246 }
247 wg.Done()
248 }(&wg, device)
khenaidoob64fc8a2019-11-27 15:08:19 -0500249 }
khenaidoo67b22152020-03-02 16:01:25 -0500250 wg.Wait()
khenaidoob64fc8a2019-11-27 15:08:19 -0500251}
252
Kent Hagerman2b216042020-04-03 18:28:56 -0400253func (nb *NBTest) getADevice(rootDevice bool, nbi *NBIHandler) (*voltha.Device, error) {
khenaidoob64fc8a2019-11-27 15:08:19 -0500254 devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
255 if err != nil {
256 return nil, err
257 }
258 for _, d := range devices.Items {
259 if d.Root == rootDevice {
260 return d, nil
261 }
262 }
263 return nil, status.Errorf(codes.NotFound, "%v device not found", rootDevice)
264}
265
Kent Hagerman2b216042020-04-03 18:28:56 -0400266func (nb *NBTest) testCoreWithoutData(t *testing.T, nbi *NBIHandler) {
khenaidoob64fc8a2019-11-27 15:08:19 -0500267 lds, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{})
268 assert.Nil(t, err)
269 assert.NotNil(t, lds)
270 assert.Equal(t, 0, len(lds.Items))
271 devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
272 assert.Nil(t, err)
273 assert.NotNil(t, devices)
274 assert.Equal(t, 0, len(devices.Items))
275 adapters, err := nbi.ListAdapters(getContext(), &empty.Empty{})
khenaidoo442e7c72020-03-10 16:13:48 -0400276 assert.Equal(t, 0, len(adapters.Items))
khenaidoob64fc8a2019-11-27 15:08:19 -0500277 assert.Nil(t, err)
278 assert.NotNil(t, adapters)
khenaidoob64fc8a2019-11-27 15:08:19 -0500279}
280
Kent Hagerman2b216042020-04-03 18:28:56 -0400281func (nb *NBTest) testAdapterRegistration(t *testing.T, nbi *NBIHandler) {
khenaidoob64fc8a2019-11-27 15:08:19 -0500282 adapters, err := nbi.ListAdapters(getContext(), &empty.Empty{})
283 assert.Nil(t, err)
284 assert.NotNil(t, adapters)
285 assert.Equal(t, 2, len(adapters.Items))
286 for _, a := range adapters.Items {
287 switch a.Id {
288 case nb.oltAdapterName:
289 assert.Equal(t, "Voltha-olt", a.Vendor)
290 case nb.onuAdapterName:
291 assert.Equal(t, "Voltha-onu", a.Vendor)
292 default:
Girish Kumarf56a4682020-03-20 20:07:46 +0000293 logger.Fatal("unregistered-adapter", a.Id)
khenaidoob64fc8a2019-11-27 15:08:19 -0500294 }
295 }
296 deviceTypes, err := nbi.ListDeviceTypes(getContext(), &empty.Empty{})
297 assert.Nil(t, err)
298 assert.NotNil(t, deviceTypes)
299 assert.Equal(t, 2, len(deviceTypes.Items))
300 for _, dt := range deviceTypes.Items {
301 switch dt.Id {
302 case nb.oltAdapterName:
303 assert.Equal(t, nb.oltAdapterName, dt.Adapter)
304 assert.Equal(t, false, dt.AcceptsBulkFlowUpdate)
305 assert.Equal(t, true, dt.AcceptsAddRemoveFlowUpdates)
306 case nb.onuAdapterName:
307 assert.Equal(t, nb.onuAdapterName, dt.Adapter)
308 assert.Equal(t, false, dt.AcceptsBulkFlowUpdate)
309 assert.Equal(t, true, dt.AcceptsAddRemoveFlowUpdates)
310 default:
Girish Kumarf56a4682020-03-20 20:07:46 +0000311 logger.Fatal("invalid-device-type", dt.Id)
khenaidoob64fc8a2019-11-27 15:08:19 -0500312 }
313 }
314}
315
Kent Hagerman2b216042020-04-03 18:28:56 -0400316func (nb *NBTest) testCreateDevice(t *testing.T, nbi *NBIHandler) {
khenaidoob64fc8a2019-11-27 15:08:19 -0500317 // Create a valid device
318 oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"})
319 assert.Nil(t, err)
320 assert.NotNil(t, oltDevice)
321 device, err := nbi.GetDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
322 assert.Nil(t, err)
323 assert.NotNil(t, device)
324 assert.Equal(t, oltDevice.String(), device.String())
325
326 // Try to create the same device
327 _, err = nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"})
328 assert.NotNil(t, err)
Kent Hagerman45a13e42020-04-13 12:23:50 -0400329 assert.Equal(t, "device is already pre-provisioned", err.Error())
khenaidoob64fc8a2019-11-27 15:08:19 -0500330
331 // Try to create a device with invalid data
332 _, err = nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName})
333 assert.NotNil(t, err)
Thomas Lee Se5a44012019-11-07 20:32:24 +0530334 assert.Equal(t, "no-device-info-present; MAC or HOSTIP&PORT", err.Error())
khenaidoob64fc8a2019-11-27 15:08:19 -0500335
336 // Ensure we only have 1 device in the Core
337 devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
338 assert.Nil(t, err)
339 assert.NotNil(t, devices)
340 assert.Equal(t, 1, len(devices.Items))
341 assert.Equal(t, oltDevice.String(), devices.Items[0].String())
342
343 //Remove the device
344 _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
345 assert.Nil(t, err)
346
347 //Ensure there are no devices in the Core now - wait until condition satisfied or timeout
348 var vFunction isDevicesConditionSatisfied = func(devices *voltha.Devices) bool {
349 return devices != nil && len(devices.Items) == 0
350 }
khenaidoo442e7c72020-03-10 16:13:48 -0400351 err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction)
khenaidoob64fc8a2019-11-27 15:08:19 -0500352 assert.Nil(t, err)
353}
354
Kent Hagerman2b216042020-04-03 18:28:56 -0400355func (nb *NBTest) testEnableDevice(t *testing.T, nbi *NBIHandler) {
khenaidoob64fc8a2019-11-27 15:08:19 -0500356 // Create a device that has no adapter registered
357 oltDeviceNoAdapter, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: "noAdapterRegistered", MacAddress: "aa:bb:cc:cc:ee:ff"})
358 assert.Nil(t, err)
359 assert.NotNil(t, oltDeviceNoAdapter)
360
361 // Try to enable the oltDevice and check the error message
362 _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDeviceNoAdapter.Id})
363 assert.NotNil(t, err)
Kent Hagerman45a13e42020-04-13 12:23:50 -0400364 assert.Equal(t, "adapter-not-registered-for-device-type noAdapterRegistered", err.Error())
khenaidoob64fc8a2019-11-27 15:08:19 -0500365
366 //Remove the device
367 _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDeviceNoAdapter.Id})
368 assert.Nil(t, err)
369
370 //Ensure there are no devices in the Core now - wait until condition satisfied or timeout
371 var vdFunction isDevicesConditionSatisfied = func(devices *voltha.Devices) bool {
372 return devices != nil && len(devices.Items) == 0
373 }
khenaidoo442e7c72020-03-10 16:13:48 -0400374 err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vdFunction)
khenaidoob64fc8a2019-11-27 15:08:19 -0500375 assert.Nil(t, err)
376
khenaidoo67b22152020-03-02 16:01:25 -0500377 // Create a logical device monitor will automatically send trap and eapol flows to the devices being enables
378 var wg sync.WaitGroup
379 wg.Add(1)
khenaidoo8b4abbf2020-04-24 17:04:30 -0400380 go nb.monitorLogicalDevice(t, nbi, 1, nb.numONUPerOLT, &wg, false, false)
khenaidoo67b22152020-03-02 16:01:25 -0500381
khenaidoob64fc8a2019-11-27 15:08:19 -0500382 // Create the device with valid data
383 oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"})
384 assert.Nil(t, err)
385 assert.NotNil(t, oltDevice)
386
387 // Verify oltDevice exist in the core
388 devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
389 assert.Nil(t, err)
390 assert.Equal(t, 1, len(devices.Items))
391 assert.Equal(t, oltDevice.Id, devices.Items[0].Id)
392
393 // Enable the oltDevice
394 _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
395 assert.Nil(t, err)
396
397 // Wait for the logical device to be in the ready state
398 var vldFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool {
399 return ld != nil && len(ld.Ports) == nb.numONUPerOLT+1
400 }
401 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vldFunction)
402 assert.Nil(t, err)
403
404 // Verify that the devices have been setup correctly
405 nb.verifyDevices(t, nbi)
406
407 // Get latest oltDevice data
408 oltDevice, err = nbi.GetDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
409 assert.Nil(t, err)
410
411 // Verify that the logical device has been setup correctly
412 nb.verifyLogicalDevices(t, oltDevice, nbi)
khenaidoo67b22152020-03-02 16:01:25 -0500413
414 // Wait until all flows has been sent to the devices successfully
415 wg.Wait()
khenaidoob64fc8a2019-11-27 15:08:19 -0500416}
417
Kent Hagerman2b216042020-04-03 18:28:56 -0400418func (nb *NBTest) testDisableAndReEnableRootDevice(t *testing.T, nbi *NBIHandler) {
khenaidoob64fc8a2019-11-27 15:08:19 -0500419 //Get an OLT device
420 oltDevice, err := nb.getADevice(true, nbi)
421 assert.Nil(t, err)
422 assert.NotNil(t, oltDevice)
423
424 // Disable the oltDevice
425 _, err = nbi.DisableDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
426 assert.Nil(t, err)
427
428 // Wait for the old device to be disabled
429 var vdFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool {
430 return device.AdminState == voltha.AdminState_DISABLED && device.OperStatus == voltha.OperStatus_UNKNOWN
431 }
432 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
433 assert.Nil(t, err)
434
435 // Verify that all onu devices are disabled as well
Kent Hagerman2b216042020-04-03 18:28:56 -0400436 onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id)
khenaidoob64fc8a2019-11-27 15:08:19 -0500437 assert.Nil(t, err)
438 for _, onu := range onuDevices.Items {
439 err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunction, nbi)
440 assert.Nil(t, err)
441 }
442
443 // Wait for the logical device to satisfy the expected condition
444 var vlFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool {
khenaidoo67b22152020-03-02 16:01:25 -0500445 if ld == nil {
446 return false
447 }
khenaidoob64fc8a2019-11-27 15:08:19 -0500448 for _, lp := range ld.Ports {
449 if (lp.OfpPort.Config&uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN) != lp.OfpPort.Config) ||
450 lp.OfpPort.State != uint32(ofp.OfpPortState_OFPPS_LINK_DOWN) {
451 return false
452 }
453 }
454 return true
455 }
456 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction)
457 assert.Nil(t, err)
458
459 // Reenable the oltDevice
460 _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
461 assert.Nil(t, err)
462
463 // Wait for the old device to be enabled
464 vdFunction = func(device *voltha.Device) bool {
465 return device.AdminState == voltha.AdminState_ENABLED && device.OperStatus == voltha.OperStatus_ACTIVE
466 }
467 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
468 assert.Nil(t, err)
469
470 // Verify that all onu devices are enabled as well
Kent Hagerman2b216042020-04-03 18:28:56 -0400471 onuDevices, err = nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id)
khenaidoob64fc8a2019-11-27 15:08:19 -0500472 assert.Nil(t, err)
473 for _, onu := range onuDevices.Items {
474 err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunction, nbi)
475 assert.Nil(t, err)
476 }
477
478 // Wait for the logical device to satisfy the expected condition
479 vlFunction = func(ld *voltha.LogicalDevice) bool {
khenaidoo67b22152020-03-02 16:01:25 -0500480 if ld == nil {
481 return false
482 }
khenaidoob64fc8a2019-11-27 15:08:19 -0500483 for _, lp := range ld.Ports {
484 if (lp.OfpPort.Config&^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN) != lp.OfpPort.Config) ||
485 lp.OfpPort.State != uint32(ofp.OfpPortState_OFPPS_LIVE) {
486 return false
487 }
488 }
489 return true
490 }
491 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction)
492 assert.Nil(t, err)
493}
494
Kent Hagerman2b216042020-04-03 18:28:56 -0400495func (nb *NBTest) testDisableAndDeleteAllDevice(t *testing.T, nbi *NBIHandler) {
khenaidoo93d5a3d2020-01-15 12:37:05 -0500496 //Get an OLT device
497 oltDevice, err := nb.getADevice(true, nbi)
498 assert.Nil(t, err)
499 assert.NotNil(t, oltDevice)
500
501 // Disable the oltDevice
502 _, err = nbi.DisableDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
503 assert.Nil(t, err)
504
505 // Wait for the olt device to be disabled
506 var vdFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool {
507 return device.AdminState == voltha.AdminState_DISABLED && device.OperStatus == voltha.OperStatus_UNKNOWN
508 }
509 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
510 assert.Nil(t, err)
511
512 // Verify that all onu devices are disabled as well
Kent Hagerman2b216042020-04-03 18:28:56 -0400513 onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id)
khenaidoo93d5a3d2020-01-15 12:37:05 -0500514 assert.Nil(t, err)
515 for _, onu := range onuDevices.Items {
516 err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunction, nbi)
517 assert.Nil(t, err)
518 }
519
520 // Delete the oltDevice
521 _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
522 assert.Nil(t, err)
523
524 var vFunction isDevicesConditionSatisfied = func(devices *voltha.Devices) bool {
525 return devices != nil && len(devices.Items) == 0
526 }
527 err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction)
528 assert.Nil(t, err)
529
530 // Wait for absence of logical device
531 var vlFunction isLogicalDevicesConditionSatisfied = func(lds *voltha.LogicalDevices) bool {
532 return lds != nil && len(lds.Items) == 0
533 }
534
535 err = waitUntilConditionForLogicalDevices(nb.maxTimeout, nbi, vlFunction)
536 assert.Nil(t, err)
537}
khenaidoo8b4abbf2020-04-24 17:04:30 -0400538
539func (nb *NBTest) deleteAllDevices(t *testing.T, nbi *NBIHandler) {
khenaidoo0db4c812020-05-27 15:27:30 -0400540 devices, _ := nbi.ListDevices(getContext(), &empty.Empty{})
541 if len(devices.Items) == 0 {
542 // Nothing to do
543 return
544 }
khenaidoo8b4abbf2020-04-24 17:04:30 -0400545 //Get an OLT device
546 oltDevice, err := nb.getADevice(true, nbi)
547 assert.Nil(t, err)
548 assert.NotNil(t, oltDevice)
549
550 // Delete the oltDevice
551 _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
552 assert.Nil(t, err)
553
554 // Wait for all devices to be deleted
555 vFunction := func(devices *voltha.Devices) bool {
556 return devices != nil && len(devices.Items) == 0
557 }
558 err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction)
559 assert.Nil(t, err)
560
561 // Wait for absence of logical device
562 vlFunction := func(lds *voltha.LogicalDevices) bool {
563 return lds != nil && len(lds.Items) == 0
564 }
565
566 err = waitUntilConditionForLogicalDevices(nb.maxTimeout, nbi, vlFunction)
567 assert.Nil(t, err)
568}
569
Kent Hagerman2b216042020-04-03 18:28:56 -0400570func (nb *NBTest) testEnableAndDeleteAllDevice(t *testing.T, nbi *NBIHandler) {
Chaitrashree G S543df3e2020-02-24 22:36:54 -0500571 //Create the device with valid data
572 oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"})
573 assert.Nil(t, err)
574 assert.NotNil(t, oltDevice)
575
576 //Get an OLT device
577 oltDevice, err = nb.getADevice(true, nbi)
578 assert.Nil(t, err)
579 assert.NotNil(t, oltDevice)
580
581 // Enable the oltDevice
582 _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
583 assert.Nil(t, err)
584
585 // Wait for the logical device to be in the ready state
586 var vldFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool {
587 return ld != nil && len(ld.Ports) == nb.numONUPerOLT+1
588 }
589 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vldFunction)
590 assert.Nil(t, err)
591
592 //Get all child devices
Kent Hagerman2b216042020-04-03 18:28:56 -0400593 onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id)
Chaitrashree G S543df3e2020-02-24 22:36:54 -0500594 assert.Nil(t, err)
595
596 // Wait for the all onu devices to be enabled
597 var vdFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool {
598 return device.AdminState == voltha.AdminState_ENABLED
599 }
600 for _, onu := range onuDevices.Items {
601 err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunction, nbi)
602 assert.Nil(t, err)
603 }
Chaitrashree G Se8ad0202020-02-27 18:48:00 -0500604 // Wait for each onu device to get deleted
605 var vdFunc isDeviceConditionSatisfied = func(device *voltha.Device) bool {
606 return device == nil
607 }
608
Chaitrashree G S543df3e2020-02-24 22:36:54 -0500609 // Delete the onuDevice
610 for _, onu := range onuDevices.Items {
611 _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: onu.Id})
612 assert.Nil(t, err)
Chaitrashree G Se8ad0202020-02-27 18:48:00 -0500613 err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunc, nbi)
614 assert.Nil(t, err)
Chaitrashree G S543df3e2020-02-24 22:36:54 -0500615 }
Chaitrashree G Se8ad0202020-02-27 18:48:00 -0500616
Chaitrashree G S543df3e2020-02-24 22:36:54 -0500617 // Disable the oltDevice
618 _, err = nbi.DisableDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
619 assert.Nil(t, err)
620
621 // Wait for the olt device to be disabled
622 var vFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool {
623 return device.AdminState == voltha.AdminState_DISABLED && device.OperStatus == voltha.OperStatus_UNKNOWN
624 }
625 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vFunction, nbi)
626 assert.Nil(t, err)
627
628 // Delete the oltDevice
629 _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
630 assert.Nil(t, err)
631
632 var vFunc isDevicesConditionSatisfied = func(devices *voltha.Devices) bool {
633 return devices != nil && len(devices.Items) == 0
634 }
635 err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunc)
636 assert.Nil(t, err)
637}
Kent Hagerman2b216042020-04-03 18:28:56 -0400638func (nb *NBTest) testDisableAndEnablePort(t *testing.T, nbi *NBIHandler) {
kesavandbc2d1622020-01-21 00:42:01 -0500639 //Get an OLT device
640 var cp *voltha.Port
641 oltDevice, err := nb.getADevice(true, nbi)
642 assert.Nil(t, err)
643 assert.NotNil(t, oltDevice)
644
645 for _, cp = range oltDevice.Ports {
646 if cp.Type == voltha.Port_PON_OLT {
647 break
648 }
649
650 }
651 assert.NotNil(t, cp)
652 cp.DeviceId = oltDevice.Id
653
654 // Disable the NW Port of oltDevice
655 _, err = nbi.DisablePort(getContext(), cp)
656 assert.Nil(t, err)
657 // Wait for the olt device Port to be disabled
658 var vdFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool {
659 for _, port := range device.Ports {
660 if port.PortNo == cp.PortNo {
661 return port.AdminState == voltha.AdminState_DISABLED
662 }
663 }
664 return false
665 }
666 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
667 assert.Nil(t, err)
668 // Wait for the logical device to satisfy the expected condition
669 var vlFunction = func(ld *voltha.LogicalDevice) bool {
khenaidoo67b22152020-03-02 16:01:25 -0500670 if ld == nil {
671 return false
672 }
kesavandbc2d1622020-01-21 00:42:01 -0500673 for _, lp := range ld.Ports {
674 if (lp.OfpPort.Config&^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN) != lp.OfpPort.Config) ||
675 lp.OfpPort.State != uint32(ofp.OfpPortState_OFPPS_LIVE) {
676 return false
677 }
678 }
679 return true
680 }
681 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction)
682 assert.Nil(t, err)
683
684 // Enable the NW Port of oltDevice
685 _, err = nbi.EnablePort(getContext(), cp)
686 assert.Nil(t, err)
687
688 // Wait for the olt device Port to be enabled
689 vdFunction = func(device *voltha.Device) bool {
690 for _, port := range device.Ports {
691 if port.PortNo == cp.PortNo {
692 return port.AdminState == voltha.AdminState_ENABLED
693 }
694 }
695 return false
696 }
697 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
698 assert.Nil(t, err)
699 // Wait for the logical device to satisfy the expected condition
700 vlFunction = func(ld *voltha.LogicalDevice) bool {
khenaidoo67b22152020-03-02 16:01:25 -0500701 if ld == nil {
702 return false
703 }
kesavandbc2d1622020-01-21 00:42:01 -0500704 for _, lp := range ld.Ports {
705 if (lp.OfpPort.Config&^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN) != lp.OfpPort.Config) ||
706 lp.OfpPort.State != uint32(ofp.OfpPortState_OFPPS_LIVE) {
707 return false
708 }
709 }
710 return true
711 }
712 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction)
713 assert.Nil(t, err)
714
715 // Disable a non-PON port
716 for _, cp = range oltDevice.Ports {
717 if cp.Type != voltha.Port_PON_OLT {
718 break
719 }
720
721 }
722 assert.NotNil(t, cp)
723 cp.DeviceId = oltDevice.Id
724
725 // Disable the NW Port of oltDevice
726 _, err = nbi.DisablePort(getContext(), cp)
727 assert.NotNil(t, err)
728
729}
khenaidoo93d5a3d2020-01-15 12:37:05 -0500730
Kent Hagerman2b216042020-04-03 18:28:56 -0400731func (nb *NBTest) testDeviceRebootWhenOltIsEnabled(t *testing.T, nbi *NBIHandler) {
Girish Gowdra408cd962020-03-11 14:31:31 -0700732 //Get an OLT device
733 oltDevice, err := nb.getADevice(true, nbi)
734 assert.Nil(t, err)
735 assert.NotNil(t, oltDevice)
736 assert.Equal(t, oltDevice.ConnectStatus, voltha.ConnectStatus_REACHABLE)
737 assert.Equal(t, oltDevice.AdminState, voltha.AdminState_ENABLED)
738
739 // Verify that we have one or more ONUs to start with
Kent Hagerman2b216042020-04-03 18:28:56 -0400740 onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id)
Girish Gowdra408cd962020-03-11 14:31:31 -0700741 assert.Nil(t, err)
742 assert.NotNil(t, onuDevices)
743 assert.Greater(t, len(onuDevices.Items), 0)
744
745 // Reboot the OLT and very that Connection Status goes to UNREACHABLE and operation status to UNKNOWN
746 _, err = nbi.RebootDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
747 assert.Nil(t, err)
748
749 var vlFunction0 = func(d *voltha.Device) bool {
750 return d.ConnectStatus == voltha.ConnectStatus_UNREACHABLE && d.OperStatus == voltha.OperStatus_UNKNOWN
751 }
752
753 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vlFunction0, nbi)
754 assert.Nil(t, err)
755
756 // Wait for the logical device to satisfy the expected condition
757 var vlFunction1 = func(ld *voltha.LogicalDevice) bool {
758 return ld == nil
759 }
760
761 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction1)
762 assert.Nil(t, err)
763
764 // Wait for the device to satisfy the expected condition (device does not have flows)
765 var vlFunction2 = func(d *voltha.Device) bool {
766 var deviceFlows *ofp.Flows
767 var err error
768 if deviceFlows, err = nbi.ListDeviceFlows(getContext(), &voltha.ID{Id: d.Id}); err != nil {
769 return false
770 }
771 return len(deviceFlows.Items) == 0
772 }
773
774 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vlFunction2, nbi)
775 assert.Nil(t, err)
776
777 // Wait for the device to satisfy the expected condition (there are no child devices)
778 var vlFunction3 = func(d *voltha.Device) bool {
779 var devices *voltha.Devices
780 var err error
781 if devices, err = nbi.ListDevices(getContext(), nil); err != nil {
782 return false
783 }
784 for _, device := range devices.Items {
785 if device.ParentId == d.Id {
786 // We have a child device still left
787 return false
788 }
789 }
790 return true
791 }
792
793 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vlFunction3, nbi)
794 assert.Nil(t, err)
795
796 // Update the OLT Connection Status to REACHABLE and operation status to ACTIVE
797 // Normally, in a real adapter this happens after connection regain via a heartbeat mechanism with real hardware
Kent Hagerman45a13e42020-04-13 12:23:50 -0400798 err = nbi.UpdateDeviceStatus(getContext(), oltDevice.Id, voltha.OperStatus_ACTIVE, voltha.ConnectStatus_REACHABLE)
Girish Gowdra408cd962020-03-11 14:31:31 -0700799 assert.Nil(t, err)
800
801 // Verify the device connection and operation states
802 oltDevice, err = nb.getADevice(true, nbi)
803 assert.Nil(t, err)
804 assert.NotNil(t, oltDevice)
805 assert.Equal(t, oltDevice.ConnectStatus, voltha.ConnectStatus_REACHABLE)
806 assert.Equal(t, oltDevice.AdminState, voltha.AdminState_ENABLED)
807
808 // Wait for the logical device to satisfy the expected condition
809 var vlFunction4 = func(ld *voltha.LogicalDevice) bool {
810 return ld != nil
811 }
812 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction4)
813 assert.Nil(t, err)
814
815 // Verify that logical device is created again
816 logicalDevices, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{})
817 assert.Nil(t, err)
818 assert.NotNil(t, logicalDevices)
819 assert.Equal(t, 1, len(logicalDevices.Items))
820
821 // Verify that we have no ONUs left
Kent Hagerman2b216042020-04-03 18:28:56 -0400822 onuDevices, err = nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id)
Girish Gowdra408cd962020-03-11 14:31:31 -0700823 assert.Nil(t, err)
824 assert.NotNil(t, onuDevices)
825 assert.Equal(t, 0, len(onuDevices.Items))
826}
827
Kent Hagerman2b216042020-04-03 18:28:56 -0400828func (nb *NBTest) testStartOmciTestAction(t *testing.T, nbi *NBIHandler) {
Scott Baker432f9be2020-03-26 11:56:30 -0700829 // -----------------------------------------------------------------------
830 // SubTest 1: Omci test action should fail due to nonexistent device id
831
832 request := &voltha.OmciTestRequest{Id: "123", Uuid: "456"}
833 _, err := nbi.StartOmciTestAction(getContext(), request)
834 assert.NotNil(t, err)
835 assert.Equal(t, "rpc error: code = NotFound desc = 123", err.Error())
836
837 // -----------------------------------------------------------------------
838 // SubTest 2: Error should be returned for device with no adapter registered
839
840 // Create a device that has no adapter registered
841 deviceNoAdapter, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: "noAdapterRegisteredOmciTest", MacAddress: "aa:bb:cc:cc:ee:01"})
842 assert.Nil(t, err)
843 assert.NotNil(t, deviceNoAdapter)
844
845 // Omci test action should fail due to nonexistent adapter
846 request = &voltha.OmciTestRequest{Id: deviceNoAdapter.Id, Uuid: "456"}
847 _, err = nbi.StartOmciTestAction(getContext(), request)
848 assert.NotNil(t, err)
Kent Hagerman45a13e42020-04-13 12:23:50 -0400849 assert.Equal(t, "adapter-not-registered-for-device-type noAdapterRegisteredOmciTest", err.Error())
Scott Baker432f9be2020-03-26 11:56:30 -0700850
851 //Remove the device
852 _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: deviceNoAdapter.Id})
853 assert.Nil(t, err)
854
855 //Ensure there are no devices in the Core now - wait until condition satisfied or timeout
856 var vFunction isDevicesConditionSatisfied = func(devices *voltha.Devices) bool {
857 return devices != nil && len(devices.Items) == 0
858 }
859 err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction)
860 assert.Nil(t, err)
861
862 // -----------------------------------------------------------------------
863 // SubTest 3: Omci test action should succeed on valid ONU
864
865 // Create the device with valid data
866 oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"})
867 assert.Nil(t, err)
868 assert.NotNil(t, oltDevice)
869
870 // Verify oltDevice exist in the core
871 devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
872 assert.Nil(t, err)
873 assert.Equal(t, 1, len(devices.Items))
874 assert.Equal(t, oltDevice.Id, devices.Items[0].Id)
875
876 // Enable the oltDevice
877 _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
878 assert.Nil(t, err)
879
880 // Wait for the logical device to be in the ready state
881 var vldFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool {
882 return ld != nil && len(ld.Ports) == nb.numONUPerOLT+1
883 }
884 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vldFunction)
885 assert.Nil(t, err)
886
887 // Wait for the olt device to be enabled
888 vdFunction := func(device *voltha.Device) bool {
889 return device.AdminState == voltha.AdminState_ENABLED && device.OperStatus == voltha.OperStatus_ACTIVE
890 }
891 err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
892 assert.Nil(t, err)
893
Kent Hagerman2b216042020-04-03 18:28:56 -0400894 onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id)
Scott Baker432f9be2020-03-26 11:56:30 -0700895 assert.Nil(t, err)
896 assert.Greater(t, len(onuDevices.Items), 0)
897
898 onuDevice := onuDevices.Items[0]
899
900 // Omci test action should succeed
901 request = &voltha.OmciTestRequest{Id: onuDevice.Id, Uuid: "456"}
902 resp, err := nbi.StartOmciTestAction(getContext(), request)
903 assert.Nil(t, err)
904 assert.Equal(t, resp.Result, voltha.TestResponse_SUCCESS)
905
906 //Remove the device
907 _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
908 assert.Nil(t, err)
909 //Ensure there are no devices in the Core now - wait until condition satisfied or timeout
910 err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction)
911 assert.Nil(t, err)
912}
913
khenaidoo67b22152020-03-02 16:01:25 -0500914func makeSimpleFlowMod(fa *flows.FlowArgs) *ofp.OfpFlowMod {
915 matchFields := make([]*ofp.OfpOxmField, 0)
916 for _, val := range fa.MatchFields {
917 matchFields = append(matchFields, &ofp.OfpOxmField{Field: &ofp.OfpOxmField_OfbField{OfbField: val}})
918 }
919 return flows.MkSimpleFlowMod(matchFields, fa.Actions, fa.Command, fa.KV)
920}
921
922func createMetadata(cTag int, techProfile int, port int) uint64 {
923 md := 0
924 md = (md | (cTag & 0xFFFF)) << 16
925 md = (md | (techProfile & 0xFFFF)) << 32
926 return uint64(md | (port & 0xFFFFFFFF))
927}
928
khenaidoo8b4abbf2020-04-24 17:04:30 -0400929func (nb *NBTest) verifyLogicalDeviceFlowCount(t *testing.T, nbi *NBIHandler, numNNIPorts int, numUNIPorts int, flowAddFail bool) {
khenaidoo67b22152020-03-02 16:01:25 -0500930 expectedNumFlows := numNNIPorts*3 + numNNIPorts*numUNIPorts
khenaidoo8b4abbf2020-04-24 17:04:30 -0400931 if flowAddFail {
932 expectedNumFlows = 0
933 }
934 // Wait for logical device to have the flows (or none
khenaidoo67b22152020-03-02 16:01:25 -0500935 var vlFunction isLogicalDevicesConditionSatisfied = func(lds *voltha.LogicalDevices) bool {
Mahir Gunyeladdb66a2020-04-29 18:08:50 -0700936 flows, _ := nbi.ListLogicalDeviceFlows(getContext(), &voltha.ID{Id: lds.Items[0].Id})
937 return lds != nil && len(lds.Items) == 1 && len(flows.Items) == expectedNumFlows
khenaidoo67b22152020-03-02 16:01:25 -0500938 }
939 // No timeout implies a success
940 err := waitUntilConditionForLogicalDevices(nb.maxTimeout, nbi, vlFunction)
941 assert.Nil(t, err)
942}
943
Kent Hagerman2b216042020-04-03 18:28:56 -0400944func (nb *NBTest) sendTrapFlows(t *testing.T, nbi *NBIHandler, logicalDevice *voltha.LogicalDevice, meterID uint64, startingVlan int) (numNNIPorts, numUNIPorts int) {
khenaidoo67b22152020-03-02 16:01:25 -0500945 // Send flows for the parent device
946 var nniPorts []*voltha.LogicalPort
947 var uniPorts []*voltha.LogicalPort
948 for _, p := range logicalDevice.Ports {
949 if p.RootPort {
950 nniPorts = append(nniPorts, p)
951 } else {
952 uniPorts = append(uniPorts, p)
953 }
954 }
955 assert.Equal(t, 1, len(nniPorts))
956 //assert.Greater(t, len(uniPorts), 1 )
957 nniPort := nniPorts[0].OfpPort.PortNo
958 maxInt32 := uint64(0xFFFFFFFF)
959 controllerPortMask := uint32(4294967293) // will result in 4294967293&0x7fffffff => 2147483645 which is the actual controller port
960 var fa *flows.FlowArgs
961 fa = &flows.FlowArgs{
962 KV: flows.OfpFlowModArgs{"priority": 10000, "buffer_id": maxInt32, "out_port": maxInt32, "out_group": maxInt32, "flags": 1},
963 MatchFields: []*ofp.OfpOxmOfbField{
964 flows.InPort(nniPort),
965 flows.EthType(35020),
966 },
967 Actions: []*ofp.OfpAction{
968 flows.Output(controllerPortMask),
969 },
970 }
971 flowLLDP := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: logicalDevice.Id}
972 _, err := nbi.UpdateLogicalDeviceFlowTable(getContext(), &flowLLDP)
973 assert.Nil(t, err)
974
975 fa = &flows.FlowArgs{
976 KV: flows.OfpFlowModArgs{"priority": 10000, "buffer_id": maxInt32, "out_port": maxInt32, "out_group": maxInt32, "flags": 1},
977 MatchFields: []*ofp.OfpOxmOfbField{
978 flows.InPort(nniPort),
979 flows.EthType(2048),
980 flows.IpProto(17),
981 flows.UdpSrc(67),
982 flows.UdpDst(68),
983 },
984 Actions: []*ofp.OfpAction{
985 flows.Output(controllerPortMask),
986 },
987 }
988 flowIPV4 := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: logicalDevice.Id}
989 _, err = nbi.UpdateLogicalDeviceFlowTable(getContext(), &flowIPV4)
990 assert.Nil(t, err)
991
992 fa = &flows.FlowArgs{
993 KV: flows.OfpFlowModArgs{"priority": 10000, "buffer_id": maxInt32, "out_port": maxInt32, "out_group": maxInt32, "flags": 1},
994 MatchFields: []*ofp.OfpOxmOfbField{
995 flows.InPort(nniPort),
996 flows.EthType(34525),
997 flows.IpProto(17),
998 flows.UdpSrc(546),
999 flows.UdpDst(547),
1000 },
1001 Actions: []*ofp.OfpAction{
1002 flows.Output(controllerPortMask),
1003 },
1004 }
1005 flowIPV6 := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: logicalDevice.Id}
1006 _, err = nbi.UpdateLogicalDeviceFlowTable(getContext(), &flowIPV6)
1007 assert.Nil(t, err)
1008
1009 return len(nniPorts), len(uniPorts)
1010}
1011
Kent Hagerman2b216042020-04-03 18:28:56 -04001012func (nb *NBTest) sendEAPFlows(t *testing.T, nbi *NBIHandler, logicalDeviceID string, port *ofp.OfpPort, vlan int, meterID uint64) {
khenaidoo67b22152020-03-02 16:01:25 -05001013 maxInt32 := uint64(0xFFFFFFFF)
1014 controllerPortMask := uint32(4294967293) // will result in 4294967293&0x7fffffff => 2147483645 which is the actual controller port
1015 fa := &flows.FlowArgs{
1016 KV: flows.OfpFlowModArgs{"priority": 10000, "buffer_id": maxInt32, "out_port": maxInt32, "out_group": maxInt32, "flags": 1, "write_metadata": createMetadata(vlan, 64, 0), "meter_id": meterID},
1017 MatchFields: []*ofp.OfpOxmOfbField{
1018 flows.InPort(port.PortNo),
1019 flows.EthType(34958),
1020 flows.VlanVid(8187),
1021 },
1022 Actions: []*ofp.OfpAction{
1023 flows.Output(controllerPortMask),
1024 },
1025 }
1026 flowEAP := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: logicalDeviceID}
khenaidoo0db4c812020-05-27 15:27:30 -04001027 maxTries := 3
1028 var err error
1029 for {
1030 if _, err = nbi.UpdateLogicalDeviceFlowTable(getContext(), &flowEAP); err == nil {
1031 if maxTries < 3 {
1032 t.Log("Re-sending EAPOL flow succeeded for port:", port)
1033 }
1034 break
1035 }
1036 t.Log("Sending EAPOL flows fail:", err)
1037 time.Sleep(50 * time.Millisecond)
1038 maxTries--
1039 if maxTries == 0 {
1040 break
1041 }
1042 }
khenaidoo67b22152020-03-02 16:01:25 -05001043 assert.Nil(t, err)
1044}
1045
khenaidoo0db4c812020-05-27 15:27:30 -04001046func (nb *NBTest) monitorLogicalDevice(t *testing.T, nbi *NBIHandler, numNNIPorts int, numUNIPorts int, wg *sync.WaitGroup, flowAddFail bool, flowDeleteFail bool) {
khenaidoo67b22152020-03-02 16:01:25 -05001047 defer wg.Done()
khenaidoo67b22152020-03-02 16:01:25 -05001048
1049 // Clear any existing flows on the adapters
1050 nb.oltAdapter.ClearFlows()
1051 nb.onuAdapter.ClearFlows()
1052
khenaidoo8b4abbf2020-04-24 17:04:30 -04001053 // Set the adapter actions on flow addition/deletion
khenaidoo0db4c812020-05-27 15:27:30 -04001054 nb.oltAdapter.SetFlowAction(flowAddFail, flowDeleteFail)
1055 nb.onuAdapter.SetFlowAction(flowAddFail, flowDeleteFail)
khenaidoo8b4abbf2020-04-24 17:04:30 -04001056
khenaidoo67b22152020-03-02 16:01:25 -05001057 // Wait until a logical device is ready
1058 var vlFunction isLogicalDevicesConditionSatisfied = func(lds *voltha.LogicalDevices) bool {
1059 if lds == nil || len(lds.Items) != 1 {
1060 return false
1061 }
1062 // Ensure there are both NNI ports and at least one UNI port on the logical device
1063 ld := lds.Items[0]
1064 nniPort := false
1065 uniPort := false
1066 for _, p := range ld.Ports {
1067 nniPort = nniPort || p.RootPort == true
1068 uniPort = uniPort || p.RootPort == false
1069 if nniPort && uniPort {
1070 return true
1071 }
1072 }
1073 return false
1074 }
1075 err := waitUntilConditionForLogicalDevices(nb.maxTimeout, nbi, vlFunction)
1076 assert.Nil(t, err)
1077
1078 logicalDevices, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{})
1079 assert.Nil(t, err)
1080 assert.NotNil(t, logicalDevices)
1081 assert.Equal(t, 1, len(logicalDevices.Items))
1082
1083 logicalDevice := logicalDevices.Items[0]
1084 meterID := rand.Uint32()
1085
1086 // Add a meter to the logical device
1087 meterMod := &ofp.OfpMeterMod{
1088 Command: ofp.OfpMeterModCommand_OFPMC_ADD,
1089 Flags: rand.Uint32(),
1090 MeterId: meterID,
1091 Bands: []*ofp.OfpMeterBandHeader{
1092 {Type: ofp.OfpMeterBandType_OFPMBT_EXPERIMENTER,
1093 Rate: rand.Uint32(),
1094 BurstSize: rand.Uint32(),
1095 Data: nil,
1096 },
1097 },
1098 }
1099 _, err = nbi.UpdateLogicalDeviceMeterTable(getContext(), &ofp.MeterModUpdate{Id: logicalDevice.Id, MeterMod: meterMod})
1100 assert.Nil(t, err)
1101
1102 // Send initial set of Trap flows
1103 startingVlan := 4091
1104 nb.sendTrapFlows(t, nbi, logicalDevice, uint64(meterID), startingVlan)
1105
1106 // Listen for port events
khenaidoo442e7c72020-03-10 16:13:48 -04001107 start := time.Now()
Girish Gowdra408cd962020-03-11 14:31:31 -07001108 processedNniLogicalPorts := 0
1109 processedUniLogicalPorts := 0
1110
Kent Hagerman45a13e42020-04-13 12:23:50 -04001111 for event := range nbi.GetChangeEventsQueueForTest() {
khenaidoo67b22152020-03-02 16:01:25 -05001112 startingVlan++
1113 if portStatus, ok := (event.Event).(*ofp.ChangeEvent_PortStatus); ok {
1114 ps := portStatus.PortStatus
1115 if ps.Reason == ofp.OfpPortReason_OFPPR_ADD {
khenaidoo67b22152020-03-02 16:01:25 -05001116 if ps.Desc.PortNo >= uint32(nb.startingUNIPortNo) {
Girish Gowdra408cd962020-03-11 14:31:31 -07001117 processedUniLogicalPorts++
khenaidoo67b22152020-03-02 16:01:25 -05001118 nb.sendEAPFlows(t, nbi, logicalDevice.Id, ps.Desc, startingVlan, uint64(meterID))
Girish Gowdra408cd962020-03-11 14:31:31 -07001119 } else {
1120 processedNniLogicalPorts++
khenaidoo67b22152020-03-02 16:01:25 -05001121 }
1122 }
1123 }
Girish Gowdra408cd962020-03-11 14:31:31 -07001124
1125 if processedNniLogicalPorts >= numNNIPorts && processedUniLogicalPorts >= numUNIPorts {
khenaidoo442e7c72020-03-10 16:13:48 -04001126 fmt.Println("Total time to send all flows:", time.Since(start))
khenaidoo67b22152020-03-02 16:01:25 -05001127 break
1128 }
1129 }
1130 //Verify the flow count on the logical device
khenaidoo8b4abbf2020-04-24 17:04:30 -04001131 nb.verifyLogicalDeviceFlowCount(t, nbi, numNNIPorts, numUNIPorts, flowAddFail)
khenaidoo67b22152020-03-02 16:01:25 -05001132
khenaidoo8b4abbf2020-04-24 17:04:30 -04001133 // Wait until all flows have been sent to the OLT adapters (or all failed)
1134 expectedFlowCount := (numNNIPorts * 3) + numNNIPorts*numUNIPorts
1135 if flowAddFail {
1136 expectedFlowCount = 0
1137 }
khenaidoo67b22152020-03-02 16:01:25 -05001138 var oltVFunc isConditionSatisfied = func() bool {
khenaidoo8b4abbf2020-04-24 17:04:30 -04001139 return nb.oltAdapter.GetFlowCount() >= expectedFlowCount
khenaidoo67b22152020-03-02 16:01:25 -05001140 }
1141 err = waitUntilCondition(nb.maxTimeout, nbi, oltVFunc)
1142 assert.Nil(t, err)
1143
khenaidoo8b4abbf2020-04-24 17:04:30 -04001144 // Wait until all flows have been sent to the ONU adapters (or all failed)
1145 expectedFlowCount = numUNIPorts
1146 if flowAddFail {
1147 expectedFlowCount = 0
1148 }
khenaidoo67b22152020-03-02 16:01:25 -05001149 var onuVFunc isConditionSatisfied = func() bool {
khenaidoo8b4abbf2020-04-24 17:04:30 -04001150 return nb.onuAdapter.GetFlowCount() == expectedFlowCount
khenaidoo67b22152020-03-02 16:01:25 -05001151 }
1152 err = waitUntilCondition(nb.maxTimeout, nbi, onuVFunc)
1153 assert.Nil(t, err)
1154}
1155
khenaidoo8b4abbf2020-04-24 17:04:30 -04001156func (nb *NBTest) testFlowAddFailure(t *testing.T, nbi *NBIHandler) {
1157
1158 // Create a logical device monitor will automatically send trap and eapol flows to the devices being enables
1159 var wg sync.WaitGroup
1160 wg.Add(1)
khenaidoo0db4c812020-05-27 15:27:30 -04001161 go nb.monitorLogicalDevice(t, nbi, 1, nb.numONUPerOLT, &wg, true, false)
khenaidoo8b4abbf2020-04-24 17:04:30 -04001162
1163 // Create the device with valid data
1164 oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"})
1165 assert.Nil(t, err)
1166 assert.NotNil(t, oltDevice)
1167
1168 // Verify oltDevice exist in the core
1169 devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
1170 assert.Nil(t, err)
1171 assert.Equal(t, 1, len(devices.Items))
1172 assert.Equal(t, oltDevice.Id, devices.Items[0].Id)
1173
1174 // Enable the oltDevice
1175 _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
1176 assert.Nil(t, err)
1177
1178 // Wait for the logical device to be in the ready state
1179 var vldFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool {
1180 return ld != nil && len(ld.Ports) == nb.numONUPerOLT+1
1181 }
1182 err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vldFunction)
1183 assert.Nil(t, err)
1184
1185 // Verify that the devices have been setup correctly
1186 nb.verifyDevices(t, nbi)
1187
1188 // Get latest oltDevice data
1189 oltDevice, err = nbi.GetDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
1190 assert.Nil(t, err)
1191
1192 // Verify that the logical device has been setup correctly
1193 nb.verifyLogicalDevices(t, oltDevice, nbi)
1194
1195 // Wait until all flows has been sent to the devices successfully
1196 wg.Wait()
1197}
1198
Matteo Scandolod525ae32020-04-02 17:27:29 -07001199func TestSuiteNbiApiHandler(t *testing.T) {
Kent Hagerman2b216042020-04-03 18:28:56 -04001200 f, err := os.Create("../../../tests/results/profile.cpu")
khenaidoo67b22152020-03-02 16:01:25 -05001201 if err != nil {
Girish Kumarf56a4682020-03-20 20:07:46 +00001202 logger.Fatalf("could not create CPU profile: %v\n ", err)
khenaidoo67b22152020-03-02 16:01:25 -05001203 }
1204 defer f.Close()
1205 runtime.SetBlockProfileRate(1)
1206 runtime.SetMutexProfileFraction(-1)
1207 if err := pprof.StartCPUProfile(f); err != nil {
Girish Kumarf56a4682020-03-20 20:07:46 +00001208 logger.Fatalf("could not start CPU profile: %v\n", err)
khenaidoo67b22152020-03-02 16:01:25 -05001209 }
1210 defer pprof.StopCPUProfile()
1211
khenaidoo442e7c72020-03-10 16:13:48 -04001212 //log.SetPackageLogLevel("github.com/opencord/voltha-go/rw_core/core", log.DebugLevel)
1213
khenaidoob64fc8a2019-11-27 15:08:19 -05001214 nb := newNBTest()
1215 assert.NotNil(t, nb)
1216
1217 defer nb.stopAll()
1218
1219 // Start the Core
1220 nb.startCore(false)
1221
1222 // Set the grpc API interface - no grpc server is running in unit test
Kent Hagerman45a13e42020-04-13 12:23:50 -04001223 nbi := NewNBIHandler(nb.deviceMgr, nb.logicalDeviceMgr, nb.adapterMgr)
khenaidoob64fc8a2019-11-27 15:08:19 -05001224
1225 // 1. Basic test with no data in Core
1226 nb.testCoreWithoutData(t, nbi)
1227
1228 // Create/register the adapters
Mahir Gunyel03de0d32020-06-03 01:36:59 -07001229 nb.oltAdapter, nb.onuAdapter = tst.CreateAndregisterAdapters(t, nb.kClient, nb.coreInstanceID, nb.oltAdapterName, nb.onuAdapterName, nb.adapterMgr)
1230 nb.numONUPerOLT = nb.oltAdapter.GetNumONUPerOLT()
1231 nb.startingUNIPortNo = nb.oltAdapter.GetStartingUNIPortNo()
khenaidoob64fc8a2019-11-27 15:08:19 -05001232
1233 // 2. Test adapter registration
1234 nb.testAdapterRegistration(t, nbi)
1235
khenaidoo8b4abbf2020-04-24 17:04:30 -04001236 numberOfTestRuns := 2
1237 for i := 1; i <= numberOfTestRuns; i++ {
khenaidoo67b22152020-03-02 16:01:25 -05001238 //3. Test create device
khenaidoo93d5a3d2020-01-15 12:37:05 -05001239 nb.testCreateDevice(t, nbi)
khenaidoob64fc8a2019-11-27 15:08:19 -05001240
khenaidoo93d5a3d2020-01-15 12:37:05 -05001241 // 4. Test Enable a device
1242 nb.testEnableDevice(t, nbi)
khenaidoob64fc8a2019-11-27 15:08:19 -05001243
khenaidoo0db4c812020-05-27 15:27:30 -04001244 //// 5. Test disable and ReEnable a root device
khenaidoo93d5a3d2020-01-15 12:37:05 -05001245 nb.testDisableAndReEnableRootDevice(t, nbi)
khenaidoo67b22152020-03-02 16:01:25 -05001246
kesavandbc2d1622020-01-21 00:42:01 -05001247 // 6. Test disable and Enable pon port of OLT device
1248 nb.testDisableAndEnablePort(t, nbi)
khenaidoo93d5a3d2020-01-15 12:37:05 -05001249
Girish Gowdra408cd962020-03-11 14:31:31 -07001250 // 7.Test Device unreachable when OLT is enabled
1251 nb.testDeviceRebootWhenOltIsEnabled(t, nbi)
1252
1253 // 8. Test disable and delete all devices
khenaidoo93d5a3d2020-01-15 12:37:05 -05001254 nb.testDisableAndDeleteAllDevice(t, nbi)
Chaitrashree G S543df3e2020-02-24 22:36:54 -05001255
Girish Gowdra408cd962020-03-11 14:31:31 -07001256 // 9. Test enable and delete all devices
Chaitrashree G S543df3e2020-02-24 22:36:54 -05001257 nb.testEnableAndDeleteAllDevice(t, nbi)
Scott Baker432f9be2020-03-26 11:56:30 -07001258
1259 // 10. Test omci test
1260 nb.testStartOmciTestAction(t, nbi)
khenaidoob64fc8a2019-11-27 15:08:19 -05001261
khenaidoo0db4c812020-05-27 15:27:30 -04001262 // 11. Remove all devices from tests above
1263 nb.deleteAllDevices(t, nbi)
1264
khenaidoo8b4abbf2020-04-24 17:04:30 -04001265 // 11. Test flow add failure
1266 nb.testFlowAddFailure(t, nbi)
1267
1268 // 12. Clean up
1269 nb.deleteAllDevices(t, nbi)
1270 }
khenaidoob64fc8a2019-11-27 15:08:19 -05001271}