khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 1 | /* |
Kent Hagerman | 45a13e4 | 2020-04-13 12:23:50 -0400 | [diff] [blame] | 2 | * 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. |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 15 | */ |
Kent Hagerman | 45a13e4 | 2020-04-13 12:23:50 -0400 | [diff] [blame] | 16 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 17 | package api |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 18 | |
| 19 | import ( |
| 20 | "context" |
| 21 | "errors" |
| 22 | "fmt" |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 23 | "math/rand" |
| 24 | "os" |
| 25 | "runtime" |
| 26 | "runtime/pprof" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 27 | "strings" |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 28 | "sync" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 29 | "testing" |
| 30 | "time" |
| 31 | |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 32 | "github.com/golang/protobuf/ptypes/empty" |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 33 | "github.com/opencord/voltha-go/db/model" |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 34 | "github.com/opencord/voltha-go/rw_core/config" |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 35 | "github.com/opencord/voltha-go/rw_core/core/adapter" |
| 36 | "github.com/opencord/voltha-go/rw_core/core/device" |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 37 | cm "github.com/opencord/voltha-go/rw_core/mocks" |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 38 | "github.com/opencord/voltha-lib-go/v3/pkg/db" |
| 39 | "github.com/opencord/voltha-lib-go/v3/pkg/flows" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 40 | "github.com/opencord/voltha-lib-go/v3/pkg/kafka" |
| 41 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
Matteo Scandolo | d525ae3 | 2020-04-02 17:27:29 -0700 | [diff] [blame] | 42 | 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.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 44 | "github.com/opencord/voltha-lib-go/v3/pkg/version" |
| 45 | ofp "github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 46 | "github.com/opencord/voltha-protos/v3/go/voltha" |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 47 | "github.com/phayes/freeport" |
| 48 | "github.com/stretchr/testify/assert" |
| 49 | "google.golang.org/grpc/codes" |
| 50 | "google.golang.org/grpc/status" |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 51 | ) |
| 52 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 53 | const ( |
| 54 | coreName = "rw_core" |
| 55 | ) |
| 56 | |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 57 | type NBTest struct { |
Matteo Scandolo | d525ae3 | 2020-04-02 17:27:29 -0700 | [diff] [blame] | 58 | etcdServer *mock_etcd.EtcdServer |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 59 | deviceMgr *device.Manager |
| 60 | logicalDeviceMgr *device.LogicalManager |
| 61 | adapterMgr *adapter.Manager |
| 62 | kmp kafka.InterContainerProxy |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 63 | kClient kafka.Client |
| 64 | kvClientPort int |
| 65 | numONUPerOLT int |
| 66 | startingUNIPortNo int |
| 67 | oltAdapter *cm.OLTAdapter |
| 68 | onuAdapter *cm.ONUAdapter |
| 69 | oltAdapterName string |
| 70 | onuAdapterName string |
| 71 | coreInstanceID string |
| 72 | defaultTimeout time.Duration |
| 73 | maxTimeout time.Duration |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | func newNBTest() *NBTest { |
| 77 | test := &NBTest{} |
| 78 | // Start the embedded etcd server |
| 79 | var err error |
| 80 | test.etcdServer, test.kvClientPort, err = startEmbeddedEtcdServer("voltha.rwcore.nb.test", "voltha.rwcore.nb.etcd", "error") |
| 81 | if err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 82 | logger.Fatal(err) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 83 | } |
| 84 | // Create the kafka client |
Matteo Scandolo | d525ae3 | 2020-04-02 17:27:29 -0700 | [diff] [blame] | 85 | test.kClient = mock_kafka.NewKafkaClient() |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 86 | test.oltAdapterName = "olt_adapter_mock" |
| 87 | test.onuAdapterName = "onu_adapter_mock" |
| 88 | test.coreInstanceID = "rw-nbi-test" |
khenaidoo | 3283673 | 2020-03-05 16:10:44 -0500 | [diff] [blame] | 89 | test.defaultTimeout = 10 * time.Second |
| 90 | test.maxTimeout = 20 * time.Second |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 91 | return test |
| 92 | } |
| 93 | |
| 94 | func (nb *NBTest) startCore(inCompeteMode bool) { |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 95 | ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) |
| 96 | defer cancel() |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 97 | cfg := config.NewRWCoreFlags() |
| 98 | cfg.CorePairTopic = "rw_core" |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 99 | cfg.DefaultRequestTimeout = nb.defaultTimeout |
| 100 | cfg.DefaultCoreTimeout = nb.defaultTimeout |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 101 | cfg.KVStorePort = nb.kvClientPort |
| 102 | cfg.InCompetingMode = inCompeteMode |
| 103 | grpcPort, err := freeport.GetFreePort() |
| 104 | if err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 105 | logger.Fatal("Cannot get a freeport for grpc") |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 106 | } |
| 107 | cfg.GrpcPort = grpcPort |
| 108 | cfg.GrpcHost = "127.0.0.1" |
| 109 | setCoreCompeteMode(inCompeteMode) |
| 110 | client := setupKVClient(cfg, nb.coreInstanceID) |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 111 | backend := &db.Backend{ |
| 112 | Client: client, |
| 113 | StoreType: cfg.KVStoreType, |
| 114 | Host: cfg.KVStoreHost, |
| 115 | Port: cfg.KVStorePort, |
| 116 | Timeout: cfg.KVStoreTimeout, |
| 117 | LivenessChannelInterval: cfg.LiveProbeInterval / 2, |
| 118 | PathPrefix: cfg.KVStoreDataPrefix} |
| 119 | nb.kmp = kafka.NewInterContainerProxy( |
| 120 | kafka.InterContainerHost(cfg.KafkaAdapterHost), |
| 121 | kafka.InterContainerPort(cfg.KafkaAdapterPort), |
| 122 | kafka.MsgClient(nb.kClient), |
| 123 | kafka.DefaultTopic(&kafka.Topic{Name: cfg.CoreTopic}), |
| 124 | kafka.DeviceDiscoveryTopic(&kafka.Topic{Name: cfg.AffinityRouterTopic})) |
| 125 | |
| 126 | endpointMgr := kafka.NewEndpointManager(backend) |
| 127 | proxy := model.NewProxy(backend, "/") |
| 128 | nb.adapterMgr = adapter.NewAdapterManager(proxy, nb.coreInstanceID, nb.kClient) |
Kent Hagerman | 45a13e4 | 2020-04-13 12:23:50 -0400 | [diff] [blame] | 129 | nb.deviceMgr, nb.logicalDeviceMgr = device.NewManagers(proxy, nb.adapterMgr, nb.kmp, endpointMgr, cfg.CorePairTopic, nb.coreInstanceID, cfg.DefaultCoreTimeout) |
Kent Hagerman | 2f0d055 | 2020-04-23 17:28:52 -0400 | [diff] [blame] | 130 | nb.adapterMgr.Start(ctx) |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 131 | |
Kent Hagerman | 2f0d055 | 2020-04-23 17:28:52 -0400 | [diff] [blame] | 132 | if err := nb.kmp.Start(); err != nil { |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 133 | logger.Fatalf("Cannot start InterContainerProxy: %s", err) |
| 134 | } |
Kent Hagerman | 2f0d055 | 2020-04-23 17:28:52 -0400 | [diff] [blame] | 135 | requestProxy := NewAdapterRequestHandlerProxy(nb.deviceMgr, nb.adapterMgr) |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 136 | if err := nb.kmp.SubscribeWithRequestHandlerInterface(kafka.Topic{Name: cfg.CoreTopic}, requestProxy); err != nil { |
| 137 | logger.Fatalf("Cannot add request handler: %s", err) |
| 138 | } |
| 139 | if err := nb.kmp.SubscribeWithDefaultRequestHandler(kafka.Topic{Name: cfg.CorePairTopic}, kafka.OffsetNewest); err != nil { |
| 140 | logger.Fatalf("Cannot add default request handler: %s", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 141 | } |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 142 | } |
| 143 | |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 144 | func (nb *NBTest) createAndregisterAdapters(t *testing.T) { |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 145 | // Setup the mock OLT adapter |
| 146 | oltAdapter, err := createMockAdapter(OltAdapter, nb.kClient, nb.coreInstanceID, coreName, nb.oltAdapterName) |
| 147 | if err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 148 | logger.Fatalw("setting-mock-olt-adapter-failed", log.Fields{"error": err}) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 149 | } |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 150 | nb.oltAdapter = (oltAdapter).(*cm.OLTAdapter) |
| 151 | nb.numONUPerOLT = nb.oltAdapter.GetNumONUPerOLT() |
| 152 | nb.startingUNIPortNo = nb.oltAdapter.GetStartingUNIPortNo() |
| 153 | |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 154 | // Register the adapter |
| 155 | registrationData := &voltha.Adapter{ |
Matteo Scandolo | d525ae3 | 2020-04-02 17:27:29 -0700 | [diff] [blame] | 156 | Id: nb.oltAdapterName, |
| 157 | Vendor: "Voltha-olt", |
| 158 | Version: version.VersionInfo.Version, |
| 159 | Type: nb.oltAdapterName, |
| 160 | CurrentReplica: 1, |
| 161 | TotalReplicas: 1, |
| 162 | Endpoint: nb.oltAdapterName, |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 163 | } |
| 164 | types := []*voltha.DeviceType{{Id: nb.oltAdapterName, Adapter: nb.oltAdapterName, AcceptsAddRemoveFlowUpdates: true}} |
| 165 | deviceTypes := &voltha.DeviceTypes{Items: types} |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 166 | if _, err := nb.adapterMgr.RegisterAdapter(registrationData, deviceTypes); err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 167 | logger.Errorw("failed-to-register-adapter", log.Fields{"error": err}) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 168 | assert.NotNil(t, err) |
| 169 | } |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 170 | |
| 171 | // Setup the mock ONU adapter |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 172 | onuAdapter, err := createMockAdapter(OnuAdapter, nb.kClient, nb.coreInstanceID, coreName, nb.onuAdapterName) |
| 173 | if err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 174 | logger.Fatalw("setting-mock-onu-adapter-failed", log.Fields{"error": err}) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 175 | } |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 176 | nb.onuAdapter = (onuAdapter).(*cm.ONUAdapter) |
| 177 | |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 178 | // Register the adapter |
| 179 | registrationData = &voltha.Adapter{ |
Matteo Scandolo | d525ae3 | 2020-04-02 17:27:29 -0700 | [diff] [blame] | 180 | Id: nb.onuAdapterName, |
| 181 | Vendor: "Voltha-onu", |
| 182 | Version: version.VersionInfo.Version, |
| 183 | Type: nb.onuAdapterName, |
| 184 | CurrentReplica: 1, |
| 185 | TotalReplicas: 1, |
| 186 | Endpoint: nb.onuAdapterName, |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 187 | } |
| 188 | types = []*voltha.DeviceType{{Id: nb.onuAdapterName, Adapter: nb.onuAdapterName, AcceptsAddRemoveFlowUpdates: true}} |
| 189 | deviceTypes = &voltha.DeviceTypes{Items: types} |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 190 | if _, err := nb.adapterMgr.RegisterAdapter(registrationData, deviceTypes); err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 191 | logger.Errorw("failed-to-register-adapter", log.Fields{"error": err}) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 192 | assert.NotNil(t, err) |
| 193 | } |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | func (nb *NBTest) stopAll() { |
| 197 | if nb.kClient != nil { |
| 198 | nb.kClient.Stop() |
| 199 | } |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 200 | if nb.kmp != nil { |
| 201 | nb.kmp.Stop() |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 202 | } |
| 203 | if nb.etcdServer != nil { |
| 204 | stopEmbeddedEtcdServer(nb.etcdServer) |
| 205 | } |
| 206 | } |
| 207 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 208 | func (nb *NBTest) verifyLogicalDevices(t *testing.T, oltDevice *voltha.Device, nbi *NBIHandler) { |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 209 | // Get the latest set of logical devices |
| 210 | logicalDevices, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{}) |
| 211 | assert.Nil(t, err) |
| 212 | assert.NotNil(t, logicalDevices) |
| 213 | assert.Equal(t, 1, len(logicalDevices.Items)) |
| 214 | |
| 215 | ld := logicalDevices.Items[0] |
| 216 | assert.NotEqual(t, "", ld.Id) |
| 217 | assert.NotEqual(t, uint64(0), ld.DatapathId) |
| 218 | assert.Equal(t, "olt_adapter_mock", ld.Desc.HwDesc) |
| 219 | assert.Equal(t, "olt_adapter_mock", ld.Desc.SwDesc) |
| 220 | assert.NotEqual(t, "", ld.RootDeviceId) |
| 221 | assert.NotEqual(t, "", ld.Desc.SerialNum) |
| 222 | assert.Equal(t, uint32(256), ld.SwitchFeatures.NBuffers) |
| 223 | assert.Equal(t, uint32(2), ld.SwitchFeatures.NTables) |
| 224 | assert.Equal(t, uint32(15), ld.SwitchFeatures.Capabilities) |
| 225 | assert.Equal(t, 1+nb.numONUPerOLT, len(ld.Ports)) |
| 226 | assert.Equal(t, oltDevice.ParentId, ld.Id) |
| 227 | //Expected port no |
| 228 | expectedPortNo := make(map[uint32]bool) |
| 229 | expectedPortNo[uint32(2)] = false |
| 230 | for i := 0; i < nb.numONUPerOLT; i++ { |
| 231 | expectedPortNo[uint32(i+100)] = false |
| 232 | } |
| 233 | for _, p := range ld.Ports { |
| 234 | assert.Equal(t, p.OfpPort.PortNo, p.DevicePortNo) |
| 235 | assert.Equal(t, uint32(4), p.OfpPort.State) |
| 236 | expectedPortNo[p.OfpPort.PortNo] = true |
| 237 | if strings.HasPrefix(p.Id, "nni") { |
| 238 | assert.Equal(t, true, p.RootPort) |
| 239 | //assert.Equal(t, uint32(2), p.OfpPort.PortNo) |
| 240 | assert.Equal(t, p.Id, fmt.Sprintf("nni-%d", p.DevicePortNo)) |
| 241 | } else { |
| 242 | assert.Equal(t, p.Id, fmt.Sprintf("uni-%d", p.DevicePortNo)) |
| 243 | assert.Equal(t, false, p.RootPort) |
| 244 | } |
| 245 | } |
| 246 | } |
| 247 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 248 | func (nb *NBTest) verifyDevices(t *testing.T, nbi *NBIHandler) { |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 249 | // Get the latest set of devices |
| 250 | devices, err := nbi.ListDevices(getContext(), &empty.Empty{}) |
| 251 | assert.Nil(t, err) |
| 252 | assert.NotNil(t, devices) |
| 253 | |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 254 | // A device is ready to be examined when its ADMIN state is ENABLED and OPERATIONAL state is ACTIVE |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 255 | var vFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool { |
| 256 | return device.AdminState == voltha.AdminState_ENABLED && device.OperStatus == voltha.OperStatus_ACTIVE |
| 257 | } |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 258 | |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 259 | var wg sync.WaitGroup |
| 260 | for _, device := range devices.Items { |
| 261 | wg.Add(1) |
| 262 | go func(wg *sync.WaitGroup, device *voltha.Device) { |
| 263 | // Wait until the device is in the right state |
| 264 | err := waitUntilDeviceReadiness(device.Id, nb.maxTimeout, vFunction, nbi) |
| 265 | assert.Nil(t, err) |
| 266 | |
| 267 | // Now, verify the details of the device. First get the latest update |
| 268 | d, err := nbi.GetDevice(getContext(), &voltha.ID{Id: device.Id}) |
| 269 | assert.Nil(t, err) |
| 270 | assert.Equal(t, voltha.AdminState_ENABLED, d.AdminState) |
| 271 | assert.Equal(t, voltha.ConnectStatus_REACHABLE, d.ConnectStatus) |
| 272 | assert.Equal(t, voltha.OperStatus_ACTIVE, d.OperStatus) |
| 273 | assert.Equal(t, d.Type, d.Adapter) |
| 274 | assert.NotEqual(t, "", d.MacAddress) |
| 275 | assert.NotEqual(t, "", d.SerialNumber) |
| 276 | |
| 277 | if d.Type == "olt_adapter_mock" { |
| 278 | assert.Equal(t, true, d.Root) |
| 279 | assert.NotEqual(t, "", d.Id) |
| 280 | assert.NotEqual(t, "", d.ParentId) |
| 281 | assert.Nil(t, d.ProxyAddress) |
| 282 | } else if d.Type == "onu_adapter_mock" { |
| 283 | assert.Equal(t, false, d.Root) |
| 284 | assert.NotEqual(t, uint32(0), d.Vlan) |
| 285 | assert.NotEqual(t, "", d.Id) |
| 286 | assert.NotEqual(t, "", d.ParentId) |
| 287 | assert.NotEqual(t, "", d.ProxyAddress.DeviceId) |
| 288 | assert.Equal(t, "olt_adapter_mock", d.ProxyAddress.DeviceType) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 289 | } else { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 290 | assert.Error(t, errors.New("invalid-device-type")) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 291 | } |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 292 | assert.Equal(t, 2, len(d.Ports)) |
| 293 | for _, p := range d.Ports { |
| 294 | assert.Equal(t, voltha.AdminState_ENABLED, p.AdminState) |
| 295 | assert.Equal(t, voltha.OperStatus_ACTIVE, p.OperStatus) |
| 296 | if p.Type == voltha.Port_ETHERNET_NNI || p.Type == voltha.Port_ETHERNET_UNI { |
| 297 | assert.Equal(t, 0, len(p.Peers)) |
| 298 | } else if p.Type == voltha.Port_PON_OLT { |
| 299 | assert.Equal(t, nb.numONUPerOLT, len(p.Peers)) |
| 300 | assert.Equal(t, uint32(1), p.PortNo) |
| 301 | } else if p.Type == voltha.Port_PON_ONU { |
| 302 | assert.Equal(t, 1, len(p.Peers)) |
| 303 | assert.Equal(t, uint32(1), p.PortNo) |
| 304 | } else { |
| 305 | assert.Error(t, errors.New("invalid-port")) |
| 306 | } |
| 307 | } |
| 308 | wg.Done() |
| 309 | }(&wg, device) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 310 | } |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 311 | wg.Wait() |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 312 | } |
| 313 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 314 | func (nb *NBTest) getADevice(rootDevice bool, nbi *NBIHandler) (*voltha.Device, error) { |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 315 | devices, err := nbi.ListDevices(getContext(), &empty.Empty{}) |
| 316 | if err != nil { |
| 317 | return nil, err |
| 318 | } |
| 319 | for _, d := range devices.Items { |
| 320 | if d.Root == rootDevice { |
| 321 | return d, nil |
| 322 | } |
| 323 | } |
| 324 | return nil, status.Errorf(codes.NotFound, "%v device not found", rootDevice) |
| 325 | } |
| 326 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 327 | func (nb *NBTest) testCoreWithoutData(t *testing.T, nbi *NBIHandler) { |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 328 | lds, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{}) |
| 329 | assert.Nil(t, err) |
| 330 | assert.NotNil(t, lds) |
| 331 | assert.Equal(t, 0, len(lds.Items)) |
| 332 | devices, err := nbi.ListDevices(getContext(), &empty.Empty{}) |
| 333 | assert.Nil(t, err) |
| 334 | assert.NotNil(t, devices) |
| 335 | assert.Equal(t, 0, len(devices.Items)) |
| 336 | adapters, err := nbi.ListAdapters(getContext(), &empty.Empty{}) |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 337 | assert.Equal(t, 0, len(adapters.Items)) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 338 | assert.Nil(t, err) |
| 339 | assert.NotNil(t, adapters) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 340 | } |
| 341 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 342 | func (nb *NBTest) testAdapterRegistration(t *testing.T, nbi *NBIHandler) { |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 343 | adapters, err := nbi.ListAdapters(getContext(), &empty.Empty{}) |
| 344 | assert.Nil(t, err) |
| 345 | assert.NotNil(t, adapters) |
| 346 | assert.Equal(t, 2, len(adapters.Items)) |
| 347 | for _, a := range adapters.Items { |
| 348 | switch a.Id { |
| 349 | case nb.oltAdapterName: |
| 350 | assert.Equal(t, "Voltha-olt", a.Vendor) |
| 351 | case nb.onuAdapterName: |
| 352 | assert.Equal(t, "Voltha-onu", a.Vendor) |
| 353 | default: |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 354 | logger.Fatal("unregistered-adapter", a.Id) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 355 | } |
| 356 | } |
| 357 | deviceTypes, err := nbi.ListDeviceTypes(getContext(), &empty.Empty{}) |
| 358 | assert.Nil(t, err) |
| 359 | assert.NotNil(t, deviceTypes) |
| 360 | assert.Equal(t, 2, len(deviceTypes.Items)) |
| 361 | for _, dt := range deviceTypes.Items { |
| 362 | switch dt.Id { |
| 363 | case nb.oltAdapterName: |
| 364 | assert.Equal(t, nb.oltAdapterName, dt.Adapter) |
| 365 | assert.Equal(t, false, dt.AcceptsBulkFlowUpdate) |
| 366 | assert.Equal(t, true, dt.AcceptsAddRemoveFlowUpdates) |
| 367 | case nb.onuAdapterName: |
| 368 | assert.Equal(t, nb.onuAdapterName, dt.Adapter) |
| 369 | assert.Equal(t, false, dt.AcceptsBulkFlowUpdate) |
| 370 | assert.Equal(t, true, dt.AcceptsAddRemoveFlowUpdates) |
| 371 | default: |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 372 | logger.Fatal("invalid-device-type", dt.Id) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 377 | func (nb *NBTest) testCreateDevice(t *testing.T, nbi *NBIHandler) { |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 378 | // Create a valid device |
| 379 | oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"}) |
| 380 | assert.Nil(t, err) |
| 381 | assert.NotNil(t, oltDevice) |
| 382 | device, err := nbi.GetDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 383 | assert.Nil(t, err) |
| 384 | assert.NotNil(t, device) |
| 385 | assert.Equal(t, oltDevice.String(), device.String()) |
| 386 | |
| 387 | // Try to create the same device |
| 388 | _, err = nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"}) |
| 389 | assert.NotNil(t, err) |
Kent Hagerman | 45a13e4 | 2020-04-13 12:23:50 -0400 | [diff] [blame] | 390 | assert.Equal(t, "device is already pre-provisioned", err.Error()) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 391 | |
| 392 | // Try to create a device with invalid data |
| 393 | _, err = nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName}) |
| 394 | assert.NotNil(t, err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 395 | assert.Equal(t, "no-device-info-present; MAC or HOSTIP&PORT", err.Error()) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 396 | |
| 397 | // Ensure we only have 1 device in the Core |
| 398 | devices, err := nbi.ListDevices(getContext(), &empty.Empty{}) |
| 399 | assert.Nil(t, err) |
| 400 | assert.NotNil(t, devices) |
| 401 | assert.Equal(t, 1, len(devices.Items)) |
| 402 | assert.Equal(t, oltDevice.String(), devices.Items[0].String()) |
| 403 | |
| 404 | //Remove the device |
| 405 | _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 406 | assert.Nil(t, err) |
| 407 | |
| 408 | //Ensure there are no devices in the Core now - wait until condition satisfied or timeout |
| 409 | var vFunction isDevicesConditionSatisfied = func(devices *voltha.Devices) bool { |
| 410 | return devices != nil && len(devices.Items) == 0 |
| 411 | } |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 412 | err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 413 | assert.Nil(t, err) |
| 414 | } |
| 415 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 416 | func (nb *NBTest) testEnableDevice(t *testing.T, nbi *NBIHandler) { |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 417 | // Create a device that has no adapter registered |
| 418 | oltDeviceNoAdapter, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: "noAdapterRegistered", MacAddress: "aa:bb:cc:cc:ee:ff"}) |
| 419 | assert.Nil(t, err) |
| 420 | assert.NotNil(t, oltDeviceNoAdapter) |
| 421 | |
| 422 | // Try to enable the oltDevice and check the error message |
| 423 | _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDeviceNoAdapter.Id}) |
| 424 | assert.NotNil(t, err) |
Kent Hagerman | 45a13e4 | 2020-04-13 12:23:50 -0400 | [diff] [blame] | 425 | assert.Equal(t, "adapter-not-registered-for-device-type noAdapterRegistered", err.Error()) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 426 | |
| 427 | //Remove the device |
| 428 | _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDeviceNoAdapter.Id}) |
| 429 | assert.Nil(t, err) |
| 430 | |
| 431 | //Ensure there are no devices in the Core now - wait until condition satisfied or timeout |
| 432 | var vdFunction isDevicesConditionSatisfied = func(devices *voltha.Devices) bool { |
| 433 | return devices != nil && len(devices.Items) == 0 |
| 434 | } |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 435 | err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vdFunction) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 436 | assert.Nil(t, err) |
| 437 | |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 438 | // Create a logical device monitor will automatically send trap and eapol flows to the devices being enables |
| 439 | var wg sync.WaitGroup |
| 440 | wg.Add(1) |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 441 | go nb.monitorLogicalDevice(t, nbi, 1, nb.numONUPerOLT, &wg, false, false) |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 442 | |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 443 | // Create the device with valid data |
| 444 | oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"}) |
| 445 | assert.Nil(t, err) |
| 446 | assert.NotNil(t, oltDevice) |
| 447 | |
| 448 | // Verify oltDevice exist in the core |
| 449 | devices, err := nbi.ListDevices(getContext(), &empty.Empty{}) |
| 450 | assert.Nil(t, err) |
| 451 | assert.Equal(t, 1, len(devices.Items)) |
| 452 | assert.Equal(t, oltDevice.Id, devices.Items[0].Id) |
| 453 | |
| 454 | // Enable the oltDevice |
| 455 | _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 456 | assert.Nil(t, err) |
| 457 | |
| 458 | // Wait for the logical device to be in the ready state |
| 459 | var vldFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool { |
| 460 | return ld != nil && len(ld.Ports) == nb.numONUPerOLT+1 |
| 461 | } |
| 462 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vldFunction) |
| 463 | assert.Nil(t, err) |
| 464 | |
| 465 | // Verify that the devices have been setup correctly |
| 466 | nb.verifyDevices(t, nbi) |
| 467 | |
| 468 | // Get latest oltDevice data |
| 469 | oltDevice, err = nbi.GetDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 470 | assert.Nil(t, err) |
| 471 | |
| 472 | // Verify that the logical device has been setup correctly |
| 473 | nb.verifyLogicalDevices(t, oltDevice, nbi) |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 474 | |
| 475 | // Wait until all flows has been sent to the devices successfully |
| 476 | wg.Wait() |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 477 | } |
| 478 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 479 | func (nb *NBTest) testDisableAndReEnableRootDevice(t *testing.T, nbi *NBIHandler) { |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 480 | //Get an OLT device |
| 481 | oltDevice, err := nb.getADevice(true, nbi) |
| 482 | assert.Nil(t, err) |
| 483 | assert.NotNil(t, oltDevice) |
| 484 | |
| 485 | // Disable the oltDevice |
| 486 | _, err = nbi.DisableDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 487 | assert.Nil(t, err) |
| 488 | |
| 489 | // Wait for the old device to be disabled |
| 490 | var vdFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool { |
| 491 | return device.AdminState == voltha.AdminState_DISABLED && device.OperStatus == voltha.OperStatus_UNKNOWN |
| 492 | } |
| 493 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi) |
| 494 | assert.Nil(t, err) |
| 495 | |
| 496 | // Verify that all onu devices are disabled as well |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 497 | onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 498 | assert.Nil(t, err) |
| 499 | for _, onu := range onuDevices.Items { |
| 500 | err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunction, nbi) |
| 501 | assert.Nil(t, err) |
| 502 | } |
| 503 | |
| 504 | // Wait for the logical device to satisfy the expected condition |
| 505 | var vlFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 506 | if ld == nil { |
| 507 | return false |
| 508 | } |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 509 | for _, lp := range ld.Ports { |
| 510 | if (lp.OfpPort.Config&uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN) != lp.OfpPort.Config) || |
| 511 | lp.OfpPort.State != uint32(ofp.OfpPortState_OFPPS_LINK_DOWN) { |
| 512 | return false |
| 513 | } |
| 514 | } |
| 515 | return true |
| 516 | } |
| 517 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction) |
| 518 | assert.Nil(t, err) |
| 519 | |
| 520 | // Reenable the oltDevice |
| 521 | _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 522 | assert.Nil(t, err) |
| 523 | |
| 524 | // Wait for the old device to be enabled |
| 525 | vdFunction = func(device *voltha.Device) bool { |
| 526 | return device.AdminState == voltha.AdminState_ENABLED && device.OperStatus == voltha.OperStatus_ACTIVE |
| 527 | } |
| 528 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi) |
| 529 | assert.Nil(t, err) |
| 530 | |
| 531 | // Verify that all onu devices are enabled as well |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 532 | onuDevices, err = nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 533 | assert.Nil(t, err) |
| 534 | for _, onu := range onuDevices.Items { |
| 535 | err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunction, nbi) |
| 536 | assert.Nil(t, err) |
| 537 | } |
| 538 | |
| 539 | // Wait for the logical device to satisfy the expected condition |
| 540 | vlFunction = func(ld *voltha.LogicalDevice) bool { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 541 | if ld == nil { |
| 542 | return false |
| 543 | } |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 544 | for _, lp := range ld.Ports { |
| 545 | if (lp.OfpPort.Config&^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN) != lp.OfpPort.Config) || |
| 546 | lp.OfpPort.State != uint32(ofp.OfpPortState_OFPPS_LIVE) { |
| 547 | return false |
| 548 | } |
| 549 | } |
| 550 | return true |
| 551 | } |
| 552 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction) |
| 553 | assert.Nil(t, err) |
| 554 | } |
| 555 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 556 | func (nb *NBTest) testDisableAndDeleteAllDevice(t *testing.T, nbi *NBIHandler) { |
khenaidoo | 93d5a3d | 2020-01-15 12:37:05 -0500 | [diff] [blame] | 557 | //Get an OLT device |
| 558 | oltDevice, err := nb.getADevice(true, nbi) |
| 559 | assert.Nil(t, err) |
| 560 | assert.NotNil(t, oltDevice) |
| 561 | |
| 562 | // Disable the oltDevice |
| 563 | _, err = nbi.DisableDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 564 | assert.Nil(t, err) |
| 565 | |
| 566 | // Wait for the olt device to be disabled |
| 567 | var vdFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool { |
| 568 | return device.AdminState == voltha.AdminState_DISABLED && device.OperStatus == voltha.OperStatus_UNKNOWN |
| 569 | } |
| 570 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi) |
| 571 | assert.Nil(t, err) |
| 572 | |
| 573 | // Verify that all onu devices are disabled as well |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 574 | onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id) |
khenaidoo | 93d5a3d | 2020-01-15 12:37:05 -0500 | [diff] [blame] | 575 | assert.Nil(t, err) |
| 576 | for _, onu := range onuDevices.Items { |
| 577 | err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunction, nbi) |
| 578 | assert.Nil(t, err) |
| 579 | } |
| 580 | |
| 581 | // Delete the oltDevice |
| 582 | _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 583 | assert.Nil(t, err) |
| 584 | |
| 585 | var vFunction isDevicesConditionSatisfied = func(devices *voltha.Devices) bool { |
| 586 | return devices != nil && len(devices.Items) == 0 |
| 587 | } |
| 588 | err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction) |
| 589 | assert.Nil(t, err) |
| 590 | |
| 591 | // Wait for absence of logical device |
| 592 | var vlFunction isLogicalDevicesConditionSatisfied = func(lds *voltha.LogicalDevices) bool { |
| 593 | return lds != nil && len(lds.Items) == 0 |
| 594 | } |
| 595 | |
| 596 | err = waitUntilConditionForLogicalDevices(nb.maxTimeout, nbi, vlFunction) |
| 597 | assert.Nil(t, err) |
| 598 | } |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 599 | |
| 600 | func (nb *NBTest) deleteAllDevices(t *testing.T, nbi *NBIHandler) { |
| 601 | //Get an OLT device |
| 602 | oltDevice, err := nb.getADevice(true, nbi) |
| 603 | assert.Nil(t, err) |
| 604 | assert.NotNil(t, oltDevice) |
| 605 | |
| 606 | // Delete the oltDevice |
| 607 | _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 608 | assert.Nil(t, err) |
| 609 | |
| 610 | // Wait for all devices to be deleted |
| 611 | vFunction := func(devices *voltha.Devices) bool { |
| 612 | return devices != nil && len(devices.Items) == 0 |
| 613 | } |
| 614 | err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction) |
| 615 | assert.Nil(t, err) |
| 616 | |
| 617 | // Wait for absence of logical device |
| 618 | vlFunction := func(lds *voltha.LogicalDevices) bool { |
| 619 | return lds != nil && len(lds.Items) == 0 |
| 620 | } |
| 621 | |
| 622 | err = waitUntilConditionForLogicalDevices(nb.maxTimeout, nbi, vlFunction) |
| 623 | assert.Nil(t, err) |
| 624 | } |
| 625 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 626 | func (nb *NBTest) testEnableAndDeleteAllDevice(t *testing.T, nbi *NBIHandler) { |
Chaitrashree G S | 543df3e | 2020-02-24 22:36:54 -0500 | [diff] [blame] | 627 | //Create the device with valid data |
| 628 | oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"}) |
| 629 | assert.Nil(t, err) |
| 630 | assert.NotNil(t, oltDevice) |
| 631 | |
| 632 | //Get an OLT device |
| 633 | oltDevice, err = nb.getADevice(true, nbi) |
| 634 | assert.Nil(t, err) |
| 635 | assert.NotNil(t, oltDevice) |
| 636 | |
| 637 | // Enable the oltDevice |
| 638 | _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 639 | assert.Nil(t, err) |
| 640 | |
| 641 | // Wait for the logical device to be in the ready state |
| 642 | var vldFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool { |
| 643 | return ld != nil && len(ld.Ports) == nb.numONUPerOLT+1 |
| 644 | } |
| 645 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vldFunction) |
| 646 | assert.Nil(t, err) |
| 647 | |
| 648 | //Get all child devices |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 649 | onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id) |
Chaitrashree G S | 543df3e | 2020-02-24 22:36:54 -0500 | [diff] [blame] | 650 | assert.Nil(t, err) |
| 651 | |
| 652 | // Wait for the all onu devices to be enabled |
| 653 | var vdFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool { |
| 654 | return device.AdminState == voltha.AdminState_ENABLED |
| 655 | } |
| 656 | for _, onu := range onuDevices.Items { |
| 657 | err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunction, nbi) |
| 658 | assert.Nil(t, err) |
| 659 | } |
Chaitrashree G S | e8ad020 | 2020-02-27 18:48:00 -0500 | [diff] [blame] | 660 | // Wait for each onu device to get deleted |
| 661 | var vdFunc isDeviceConditionSatisfied = func(device *voltha.Device) bool { |
| 662 | return device == nil |
| 663 | } |
| 664 | |
Chaitrashree G S | 543df3e | 2020-02-24 22:36:54 -0500 | [diff] [blame] | 665 | // Delete the onuDevice |
| 666 | for _, onu := range onuDevices.Items { |
| 667 | _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: onu.Id}) |
| 668 | assert.Nil(t, err) |
Chaitrashree G S | e8ad020 | 2020-02-27 18:48:00 -0500 | [diff] [blame] | 669 | err = waitUntilDeviceReadiness(onu.Id, nb.maxTimeout, vdFunc, nbi) |
| 670 | assert.Nil(t, err) |
Chaitrashree G S | 543df3e | 2020-02-24 22:36:54 -0500 | [diff] [blame] | 671 | } |
Chaitrashree G S | e8ad020 | 2020-02-27 18:48:00 -0500 | [diff] [blame] | 672 | |
Chaitrashree G S | 543df3e | 2020-02-24 22:36:54 -0500 | [diff] [blame] | 673 | // Disable the oltDevice |
| 674 | _, err = nbi.DisableDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 675 | assert.Nil(t, err) |
| 676 | |
| 677 | // Wait for the olt device to be disabled |
| 678 | var vFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool { |
| 679 | return device.AdminState == voltha.AdminState_DISABLED && device.OperStatus == voltha.OperStatus_UNKNOWN |
| 680 | } |
| 681 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vFunction, nbi) |
| 682 | assert.Nil(t, err) |
| 683 | |
| 684 | // Delete the oltDevice |
| 685 | _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 686 | assert.Nil(t, err) |
| 687 | |
| 688 | var vFunc isDevicesConditionSatisfied = func(devices *voltha.Devices) bool { |
| 689 | return devices != nil && len(devices.Items) == 0 |
| 690 | } |
| 691 | err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunc) |
| 692 | assert.Nil(t, err) |
| 693 | } |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 694 | func (nb *NBTest) testDisableAndEnablePort(t *testing.T, nbi *NBIHandler) { |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 695 | //Get an OLT device |
| 696 | var cp *voltha.Port |
| 697 | oltDevice, err := nb.getADevice(true, nbi) |
| 698 | assert.Nil(t, err) |
| 699 | assert.NotNil(t, oltDevice) |
| 700 | |
| 701 | for _, cp = range oltDevice.Ports { |
| 702 | if cp.Type == voltha.Port_PON_OLT { |
| 703 | break |
| 704 | } |
| 705 | |
| 706 | } |
| 707 | assert.NotNil(t, cp) |
| 708 | cp.DeviceId = oltDevice.Id |
| 709 | |
| 710 | // Disable the NW Port of oltDevice |
| 711 | _, err = nbi.DisablePort(getContext(), cp) |
| 712 | assert.Nil(t, err) |
| 713 | // Wait for the olt device Port to be disabled |
| 714 | var vdFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool { |
| 715 | for _, port := range device.Ports { |
| 716 | if port.PortNo == cp.PortNo { |
| 717 | return port.AdminState == voltha.AdminState_DISABLED |
| 718 | } |
| 719 | } |
| 720 | return false |
| 721 | } |
| 722 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi) |
| 723 | assert.Nil(t, err) |
| 724 | // Wait for the logical device to satisfy the expected condition |
| 725 | var vlFunction = func(ld *voltha.LogicalDevice) bool { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 726 | if ld == nil { |
| 727 | return false |
| 728 | } |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 729 | for _, lp := range ld.Ports { |
| 730 | if (lp.OfpPort.Config&^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN) != lp.OfpPort.Config) || |
| 731 | lp.OfpPort.State != uint32(ofp.OfpPortState_OFPPS_LIVE) { |
| 732 | return false |
| 733 | } |
| 734 | } |
| 735 | return true |
| 736 | } |
| 737 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction) |
| 738 | assert.Nil(t, err) |
| 739 | |
| 740 | // Enable the NW Port of oltDevice |
| 741 | _, err = nbi.EnablePort(getContext(), cp) |
| 742 | assert.Nil(t, err) |
| 743 | |
| 744 | // Wait for the olt device Port to be enabled |
| 745 | vdFunction = func(device *voltha.Device) bool { |
| 746 | for _, port := range device.Ports { |
| 747 | if port.PortNo == cp.PortNo { |
| 748 | return port.AdminState == voltha.AdminState_ENABLED |
| 749 | } |
| 750 | } |
| 751 | return false |
| 752 | } |
| 753 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi) |
| 754 | assert.Nil(t, err) |
| 755 | // Wait for the logical device to satisfy the expected condition |
| 756 | vlFunction = func(ld *voltha.LogicalDevice) bool { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 757 | if ld == nil { |
| 758 | return false |
| 759 | } |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 760 | for _, lp := range ld.Ports { |
| 761 | if (lp.OfpPort.Config&^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN) != lp.OfpPort.Config) || |
| 762 | lp.OfpPort.State != uint32(ofp.OfpPortState_OFPPS_LIVE) { |
| 763 | return false |
| 764 | } |
| 765 | } |
| 766 | return true |
| 767 | } |
| 768 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction) |
| 769 | assert.Nil(t, err) |
| 770 | |
| 771 | // Disable a non-PON port |
| 772 | for _, cp = range oltDevice.Ports { |
| 773 | if cp.Type != voltha.Port_PON_OLT { |
| 774 | break |
| 775 | } |
| 776 | |
| 777 | } |
| 778 | assert.NotNil(t, cp) |
| 779 | cp.DeviceId = oltDevice.Id |
| 780 | |
| 781 | // Disable the NW Port of oltDevice |
| 782 | _, err = nbi.DisablePort(getContext(), cp) |
| 783 | assert.NotNil(t, err) |
| 784 | |
| 785 | } |
khenaidoo | 93d5a3d | 2020-01-15 12:37:05 -0500 | [diff] [blame] | 786 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 787 | func (nb *NBTest) testDeviceRebootWhenOltIsEnabled(t *testing.T, nbi *NBIHandler) { |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 788 | //Get an OLT device |
| 789 | oltDevice, err := nb.getADevice(true, nbi) |
| 790 | assert.Nil(t, err) |
| 791 | assert.NotNil(t, oltDevice) |
| 792 | assert.Equal(t, oltDevice.ConnectStatus, voltha.ConnectStatus_REACHABLE) |
| 793 | assert.Equal(t, oltDevice.AdminState, voltha.AdminState_ENABLED) |
| 794 | |
| 795 | // Verify that we have one or more ONUs to start with |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 796 | onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id) |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 797 | assert.Nil(t, err) |
| 798 | assert.NotNil(t, onuDevices) |
| 799 | assert.Greater(t, len(onuDevices.Items), 0) |
| 800 | |
| 801 | // Reboot the OLT and very that Connection Status goes to UNREACHABLE and operation status to UNKNOWN |
| 802 | _, err = nbi.RebootDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 803 | assert.Nil(t, err) |
| 804 | |
| 805 | var vlFunction0 = func(d *voltha.Device) bool { |
| 806 | return d.ConnectStatus == voltha.ConnectStatus_UNREACHABLE && d.OperStatus == voltha.OperStatus_UNKNOWN |
| 807 | } |
| 808 | |
| 809 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vlFunction0, nbi) |
| 810 | assert.Nil(t, err) |
| 811 | |
| 812 | // Wait for the logical device to satisfy the expected condition |
| 813 | var vlFunction1 = func(ld *voltha.LogicalDevice) bool { |
| 814 | return ld == nil |
| 815 | } |
| 816 | |
| 817 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction1) |
| 818 | assert.Nil(t, err) |
| 819 | |
| 820 | // Wait for the device to satisfy the expected condition (device does not have flows) |
| 821 | var vlFunction2 = func(d *voltha.Device) bool { |
| 822 | var deviceFlows *ofp.Flows |
| 823 | var err error |
| 824 | if deviceFlows, err = nbi.ListDeviceFlows(getContext(), &voltha.ID{Id: d.Id}); err != nil { |
| 825 | return false |
| 826 | } |
| 827 | return len(deviceFlows.Items) == 0 |
| 828 | } |
| 829 | |
| 830 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vlFunction2, nbi) |
| 831 | assert.Nil(t, err) |
| 832 | |
| 833 | // Wait for the device to satisfy the expected condition (there are no child devices) |
| 834 | var vlFunction3 = func(d *voltha.Device) bool { |
| 835 | var devices *voltha.Devices |
| 836 | var err error |
| 837 | if devices, err = nbi.ListDevices(getContext(), nil); err != nil { |
| 838 | return false |
| 839 | } |
| 840 | for _, device := range devices.Items { |
| 841 | if device.ParentId == d.Id { |
| 842 | // We have a child device still left |
| 843 | return false |
| 844 | } |
| 845 | } |
| 846 | return true |
| 847 | } |
| 848 | |
| 849 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vlFunction3, nbi) |
| 850 | assert.Nil(t, err) |
| 851 | |
| 852 | // Update the OLT Connection Status to REACHABLE and operation status to ACTIVE |
| 853 | // Normally, in a real adapter this happens after connection regain via a heartbeat mechanism with real hardware |
Kent Hagerman | 45a13e4 | 2020-04-13 12:23:50 -0400 | [diff] [blame] | 854 | err = nbi.UpdateDeviceStatus(getContext(), oltDevice.Id, voltha.OperStatus_ACTIVE, voltha.ConnectStatus_REACHABLE) |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 855 | assert.Nil(t, err) |
| 856 | |
| 857 | // Verify the device connection and operation states |
| 858 | oltDevice, err = nb.getADevice(true, nbi) |
| 859 | assert.Nil(t, err) |
| 860 | assert.NotNil(t, oltDevice) |
| 861 | assert.Equal(t, oltDevice.ConnectStatus, voltha.ConnectStatus_REACHABLE) |
| 862 | assert.Equal(t, oltDevice.AdminState, voltha.AdminState_ENABLED) |
| 863 | |
| 864 | // Wait for the logical device to satisfy the expected condition |
| 865 | var vlFunction4 = func(ld *voltha.LogicalDevice) bool { |
| 866 | return ld != nil |
| 867 | } |
| 868 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vlFunction4) |
| 869 | assert.Nil(t, err) |
| 870 | |
| 871 | // Verify that logical device is created again |
| 872 | logicalDevices, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{}) |
| 873 | assert.Nil(t, err) |
| 874 | assert.NotNil(t, logicalDevices) |
| 875 | assert.Equal(t, 1, len(logicalDevices.Items)) |
| 876 | |
| 877 | // Verify that we have no ONUs left |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 878 | onuDevices, err = nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id) |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 879 | assert.Nil(t, err) |
| 880 | assert.NotNil(t, onuDevices) |
| 881 | assert.Equal(t, 0, len(onuDevices.Items)) |
| 882 | } |
| 883 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 884 | func (nb *NBTest) testStartOmciTestAction(t *testing.T, nbi *NBIHandler) { |
Scott Baker | 432f9be | 2020-03-26 11:56:30 -0700 | [diff] [blame] | 885 | // ----------------------------------------------------------------------- |
| 886 | // SubTest 1: Omci test action should fail due to nonexistent device id |
| 887 | |
| 888 | request := &voltha.OmciTestRequest{Id: "123", Uuid: "456"} |
| 889 | _, err := nbi.StartOmciTestAction(getContext(), request) |
| 890 | assert.NotNil(t, err) |
| 891 | assert.Equal(t, "rpc error: code = NotFound desc = 123", err.Error()) |
| 892 | |
| 893 | // ----------------------------------------------------------------------- |
| 894 | // SubTest 2: Error should be returned for device with no adapter registered |
| 895 | |
| 896 | // Create a device that has no adapter registered |
| 897 | deviceNoAdapter, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: "noAdapterRegisteredOmciTest", MacAddress: "aa:bb:cc:cc:ee:01"}) |
| 898 | assert.Nil(t, err) |
| 899 | assert.NotNil(t, deviceNoAdapter) |
| 900 | |
| 901 | // Omci test action should fail due to nonexistent adapter |
| 902 | request = &voltha.OmciTestRequest{Id: deviceNoAdapter.Id, Uuid: "456"} |
| 903 | _, err = nbi.StartOmciTestAction(getContext(), request) |
| 904 | assert.NotNil(t, err) |
Kent Hagerman | 45a13e4 | 2020-04-13 12:23:50 -0400 | [diff] [blame] | 905 | assert.Equal(t, "adapter-not-registered-for-device-type noAdapterRegisteredOmciTest", err.Error()) |
Scott Baker | 432f9be | 2020-03-26 11:56:30 -0700 | [diff] [blame] | 906 | |
| 907 | //Remove the device |
| 908 | _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: deviceNoAdapter.Id}) |
| 909 | assert.Nil(t, err) |
| 910 | |
| 911 | //Ensure there are no devices in the Core now - wait until condition satisfied or timeout |
| 912 | var vFunction isDevicesConditionSatisfied = func(devices *voltha.Devices) bool { |
| 913 | return devices != nil && len(devices.Items) == 0 |
| 914 | } |
| 915 | err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction) |
| 916 | assert.Nil(t, err) |
| 917 | |
| 918 | // ----------------------------------------------------------------------- |
| 919 | // SubTest 3: Omci test action should succeed on valid ONU |
| 920 | |
| 921 | // Create the device with valid data |
| 922 | oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"}) |
| 923 | assert.Nil(t, err) |
| 924 | assert.NotNil(t, oltDevice) |
| 925 | |
| 926 | // Verify oltDevice exist in the core |
| 927 | devices, err := nbi.ListDevices(getContext(), &empty.Empty{}) |
| 928 | assert.Nil(t, err) |
| 929 | assert.Equal(t, 1, len(devices.Items)) |
| 930 | assert.Equal(t, oltDevice.Id, devices.Items[0].Id) |
| 931 | |
| 932 | // Enable the oltDevice |
| 933 | _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 934 | assert.Nil(t, err) |
| 935 | |
| 936 | // Wait for the logical device to be in the ready state |
| 937 | var vldFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool { |
| 938 | return ld != nil && len(ld.Ports) == nb.numONUPerOLT+1 |
| 939 | } |
| 940 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vldFunction) |
| 941 | assert.Nil(t, err) |
| 942 | |
| 943 | // Wait for the olt device to be enabled |
| 944 | vdFunction := func(device *voltha.Device) bool { |
| 945 | return device.AdminState == voltha.AdminState_ENABLED && device.OperStatus == voltha.OperStatus_ACTIVE |
| 946 | } |
| 947 | err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi) |
| 948 | assert.Nil(t, err) |
| 949 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 950 | onuDevices, err := nb.deviceMgr.GetAllChildDevices(getContext(), oltDevice.Id) |
Scott Baker | 432f9be | 2020-03-26 11:56:30 -0700 | [diff] [blame] | 951 | assert.Nil(t, err) |
| 952 | assert.Greater(t, len(onuDevices.Items), 0) |
| 953 | |
| 954 | onuDevice := onuDevices.Items[0] |
| 955 | |
| 956 | // Omci test action should succeed |
| 957 | request = &voltha.OmciTestRequest{Id: onuDevice.Id, Uuid: "456"} |
| 958 | resp, err := nbi.StartOmciTestAction(getContext(), request) |
| 959 | assert.Nil(t, err) |
| 960 | assert.Equal(t, resp.Result, voltha.TestResponse_SUCCESS) |
| 961 | |
| 962 | //Remove the device |
| 963 | _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 964 | assert.Nil(t, err) |
| 965 | //Ensure there are no devices in the Core now - wait until condition satisfied or timeout |
| 966 | err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction) |
| 967 | assert.Nil(t, err) |
| 968 | } |
| 969 | |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 970 | func makeSimpleFlowMod(fa *flows.FlowArgs) *ofp.OfpFlowMod { |
| 971 | matchFields := make([]*ofp.OfpOxmField, 0) |
| 972 | for _, val := range fa.MatchFields { |
| 973 | matchFields = append(matchFields, &ofp.OfpOxmField{Field: &ofp.OfpOxmField_OfbField{OfbField: val}}) |
| 974 | } |
| 975 | return flows.MkSimpleFlowMod(matchFields, fa.Actions, fa.Command, fa.KV) |
| 976 | } |
| 977 | |
| 978 | func createMetadata(cTag int, techProfile int, port int) uint64 { |
| 979 | md := 0 |
| 980 | md = (md | (cTag & 0xFFFF)) << 16 |
| 981 | md = (md | (techProfile & 0xFFFF)) << 32 |
| 982 | return uint64(md | (port & 0xFFFFFFFF)) |
| 983 | } |
| 984 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 985 | func (nb *NBTest) verifyLogicalDeviceFlowCount(t *testing.T, nbi *NBIHandler, numNNIPorts int, numUNIPorts int, flowAddFail bool) { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 986 | expectedNumFlows := numNNIPorts*3 + numNNIPorts*numUNIPorts |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 987 | if flowAddFail { |
| 988 | expectedNumFlows = 0 |
| 989 | } |
| 990 | // Wait for logical device to have the flows (or none |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 991 | var vlFunction isLogicalDevicesConditionSatisfied = func(lds *voltha.LogicalDevices) bool { |
| 992 | return lds != nil && len(lds.Items) == 1 && len(lds.Items[0].Flows.Items) == expectedNumFlows |
| 993 | } |
| 994 | // No timeout implies a success |
| 995 | err := waitUntilConditionForLogicalDevices(nb.maxTimeout, nbi, vlFunction) |
| 996 | assert.Nil(t, err) |
| 997 | } |
| 998 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 999 | func (nb *NBTest) sendTrapFlows(t *testing.T, nbi *NBIHandler, logicalDevice *voltha.LogicalDevice, meterID uint64, startingVlan int) (numNNIPorts, numUNIPorts int) { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1000 | // Send flows for the parent device |
| 1001 | var nniPorts []*voltha.LogicalPort |
| 1002 | var uniPorts []*voltha.LogicalPort |
| 1003 | for _, p := range logicalDevice.Ports { |
| 1004 | if p.RootPort { |
| 1005 | nniPorts = append(nniPorts, p) |
| 1006 | } else { |
| 1007 | uniPorts = append(uniPorts, p) |
| 1008 | } |
| 1009 | } |
| 1010 | assert.Equal(t, 1, len(nniPorts)) |
| 1011 | //assert.Greater(t, len(uniPorts), 1 ) |
| 1012 | nniPort := nniPorts[0].OfpPort.PortNo |
| 1013 | maxInt32 := uint64(0xFFFFFFFF) |
| 1014 | controllerPortMask := uint32(4294967293) // will result in 4294967293&0x7fffffff => 2147483645 which is the actual controller port |
| 1015 | var fa *flows.FlowArgs |
| 1016 | fa = &flows.FlowArgs{ |
| 1017 | KV: flows.OfpFlowModArgs{"priority": 10000, "buffer_id": maxInt32, "out_port": maxInt32, "out_group": maxInt32, "flags": 1}, |
| 1018 | MatchFields: []*ofp.OfpOxmOfbField{ |
| 1019 | flows.InPort(nniPort), |
| 1020 | flows.EthType(35020), |
| 1021 | }, |
| 1022 | Actions: []*ofp.OfpAction{ |
| 1023 | flows.Output(controllerPortMask), |
| 1024 | }, |
| 1025 | } |
| 1026 | flowLLDP := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: logicalDevice.Id} |
| 1027 | _, err := nbi.UpdateLogicalDeviceFlowTable(getContext(), &flowLLDP) |
| 1028 | assert.Nil(t, err) |
| 1029 | |
| 1030 | fa = &flows.FlowArgs{ |
| 1031 | KV: flows.OfpFlowModArgs{"priority": 10000, "buffer_id": maxInt32, "out_port": maxInt32, "out_group": maxInt32, "flags": 1}, |
| 1032 | MatchFields: []*ofp.OfpOxmOfbField{ |
| 1033 | flows.InPort(nniPort), |
| 1034 | flows.EthType(2048), |
| 1035 | flows.IpProto(17), |
| 1036 | flows.UdpSrc(67), |
| 1037 | flows.UdpDst(68), |
| 1038 | }, |
| 1039 | Actions: []*ofp.OfpAction{ |
| 1040 | flows.Output(controllerPortMask), |
| 1041 | }, |
| 1042 | } |
| 1043 | flowIPV4 := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: logicalDevice.Id} |
| 1044 | _, err = nbi.UpdateLogicalDeviceFlowTable(getContext(), &flowIPV4) |
| 1045 | assert.Nil(t, err) |
| 1046 | |
| 1047 | fa = &flows.FlowArgs{ |
| 1048 | KV: flows.OfpFlowModArgs{"priority": 10000, "buffer_id": maxInt32, "out_port": maxInt32, "out_group": maxInt32, "flags": 1}, |
| 1049 | MatchFields: []*ofp.OfpOxmOfbField{ |
| 1050 | flows.InPort(nniPort), |
| 1051 | flows.EthType(34525), |
| 1052 | flows.IpProto(17), |
| 1053 | flows.UdpSrc(546), |
| 1054 | flows.UdpDst(547), |
| 1055 | }, |
| 1056 | Actions: []*ofp.OfpAction{ |
| 1057 | flows.Output(controllerPortMask), |
| 1058 | }, |
| 1059 | } |
| 1060 | flowIPV6 := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: logicalDevice.Id} |
| 1061 | _, err = nbi.UpdateLogicalDeviceFlowTable(getContext(), &flowIPV6) |
| 1062 | assert.Nil(t, err) |
| 1063 | |
| 1064 | return len(nniPorts), len(uniPorts) |
| 1065 | } |
| 1066 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 1067 | func (nb *NBTest) sendEAPFlows(t *testing.T, nbi *NBIHandler, logicalDeviceID string, port *ofp.OfpPort, vlan int, meterID uint64) { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1068 | maxInt32 := uint64(0xFFFFFFFF) |
| 1069 | controllerPortMask := uint32(4294967293) // will result in 4294967293&0x7fffffff => 2147483645 which is the actual controller port |
| 1070 | fa := &flows.FlowArgs{ |
| 1071 | 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}, |
| 1072 | MatchFields: []*ofp.OfpOxmOfbField{ |
| 1073 | flows.InPort(port.PortNo), |
| 1074 | flows.EthType(34958), |
| 1075 | flows.VlanVid(8187), |
| 1076 | }, |
| 1077 | Actions: []*ofp.OfpAction{ |
| 1078 | flows.Output(controllerPortMask), |
| 1079 | }, |
| 1080 | } |
| 1081 | flowEAP := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: logicalDeviceID} |
| 1082 | _, err := nbi.UpdateLogicalDeviceFlowTable(getContext(), &flowEAP) |
| 1083 | assert.Nil(t, err) |
| 1084 | } |
| 1085 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1086 | func (nb *NBTest) monitorLogicalDevice(t *testing.T, nbi *NBIHandler, numNNIPorts int, numUNIPorts int, wg *sync.WaitGroup, flowAddFail bool, flowDelete bool) { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1087 | defer wg.Done() |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1088 | |
| 1089 | // Clear any existing flows on the adapters |
| 1090 | nb.oltAdapter.ClearFlows() |
| 1091 | nb.onuAdapter.ClearFlows() |
| 1092 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1093 | // Set the adapter actions on flow addition/deletion |
| 1094 | nb.oltAdapter.SetFlowAction(flowAddFail, flowDelete) |
| 1095 | nb.onuAdapter.SetFlowAction(flowAddFail, flowDelete) |
| 1096 | |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1097 | // Wait until a logical device is ready |
| 1098 | var vlFunction isLogicalDevicesConditionSatisfied = func(lds *voltha.LogicalDevices) bool { |
| 1099 | if lds == nil || len(lds.Items) != 1 { |
| 1100 | return false |
| 1101 | } |
| 1102 | // Ensure there are both NNI ports and at least one UNI port on the logical device |
| 1103 | ld := lds.Items[0] |
| 1104 | nniPort := false |
| 1105 | uniPort := false |
| 1106 | for _, p := range ld.Ports { |
| 1107 | nniPort = nniPort || p.RootPort == true |
| 1108 | uniPort = uniPort || p.RootPort == false |
| 1109 | if nniPort && uniPort { |
| 1110 | return true |
| 1111 | } |
| 1112 | } |
| 1113 | return false |
| 1114 | } |
| 1115 | err := waitUntilConditionForLogicalDevices(nb.maxTimeout, nbi, vlFunction) |
| 1116 | assert.Nil(t, err) |
| 1117 | |
| 1118 | logicalDevices, err := nbi.ListLogicalDevices(getContext(), &empty.Empty{}) |
| 1119 | assert.Nil(t, err) |
| 1120 | assert.NotNil(t, logicalDevices) |
| 1121 | assert.Equal(t, 1, len(logicalDevices.Items)) |
| 1122 | |
| 1123 | logicalDevice := logicalDevices.Items[0] |
| 1124 | meterID := rand.Uint32() |
| 1125 | |
| 1126 | // Add a meter to the logical device |
| 1127 | meterMod := &ofp.OfpMeterMod{ |
| 1128 | Command: ofp.OfpMeterModCommand_OFPMC_ADD, |
| 1129 | Flags: rand.Uint32(), |
| 1130 | MeterId: meterID, |
| 1131 | Bands: []*ofp.OfpMeterBandHeader{ |
| 1132 | {Type: ofp.OfpMeterBandType_OFPMBT_EXPERIMENTER, |
| 1133 | Rate: rand.Uint32(), |
| 1134 | BurstSize: rand.Uint32(), |
| 1135 | Data: nil, |
| 1136 | }, |
| 1137 | }, |
| 1138 | } |
| 1139 | _, err = nbi.UpdateLogicalDeviceMeterTable(getContext(), &ofp.MeterModUpdate{Id: logicalDevice.Id, MeterMod: meterMod}) |
| 1140 | assert.Nil(t, err) |
| 1141 | |
| 1142 | // Send initial set of Trap flows |
| 1143 | startingVlan := 4091 |
| 1144 | nb.sendTrapFlows(t, nbi, logicalDevice, uint64(meterID), startingVlan) |
| 1145 | |
| 1146 | // Listen for port events |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 1147 | start := time.Now() |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 1148 | processedNniLogicalPorts := 0 |
| 1149 | processedUniLogicalPorts := 0 |
| 1150 | |
Kent Hagerman | 45a13e4 | 2020-04-13 12:23:50 -0400 | [diff] [blame] | 1151 | for event := range nbi.GetChangeEventsQueueForTest() { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1152 | startingVlan++ |
| 1153 | if portStatus, ok := (event.Event).(*ofp.ChangeEvent_PortStatus); ok { |
| 1154 | ps := portStatus.PortStatus |
| 1155 | if ps.Reason == ofp.OfpPortReason_OFPPR_ADD { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1156 | if ps.Desc.PortNo >= uint32(nb.startingUNIPortNo) { |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 1157 | processedUniLogicalPorts++ |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1158 | nb.sendEAPFlows(t, nbi, logicalDevice.Id, ps.Desc, startingVlan, uint64(meterID)) |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 1159 | } else { |
| 1160 | processedNniLogicalPorts++ |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1161 | } |
| 1162 | } |
| 1163 | } |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 1164 | |
| 1165 | if processedNniLogicalPorts >= numNNIPorts && processedUniLogicalPorts >= numUNIPorts { |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 1166 | fmt.Println("Total time to send all flows:", time.Since(start)) |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1167 | break |
| 1168 | } |
| 1169 | } |
| 1170 | //Verify the flow count on the logical device |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1171 | nb.verifyLogicalDeviceFlowCount(t, nbi, numNNIPorts, numUNIPorts, flowAddFail) |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1172 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1173 | // Wait until all flows have been sent to the OLT adapters (or all failed) |
| 1174 | expectedFlowCount := (numNNIPorts * 3) + numNNIPorts*numUNIPorts |
| 1175 | if flowAddFail { |
| 1176 | expectedFlowCount = 0 |
| 1177 | } |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1178 | var oltVFunc isConditionSatisfied = func() bool { |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1179 | return nb.oltAdapter.GetFlowCount() >= expectedFlowCount |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1180 | } |
| 1181 | err = waitUntilCondition(nb.maxTimeout, nbi, oltVFunc) |
| 1182 | assert.Nil(t, err) |
| 1183 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1184 | // Wait until all flows have been sent to the ONU adapters (or all failed) |
| 1185 | expectedFlowCount = numUNIPorts |
| 1186 | if flowAddFail { |
| 1187 | expectedFlowCount = 0 |
| 1188 | } |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1189 | var onuVFunc isConditionSatisfied = func() bool { |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1190 | return nb.onuAdapter.GetFlowCount() == expectedFlowCount |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1191 | } |
| 1192 | err = waitUntilCondition(nb.maxTimeout, nbi, onuVFunc) |
| 1193 | assert.Nil(t, err) |
| 1194 | } |
| 1195 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1196 | func (nb *NBTest) testFlowAddFailure(t *testing.T, nbi *NBIHandler) { |
| 1197 | |
| 1198 | // Create a logical device monitor will automatically send trap and eapol flows to the devices being enables |
| 1199 | var wg sync.WaitGroup |
| 1200 | wg.Add(1) |
| 1201 | go nb.monitorLogicalDevice(t, nbi, 1, nb.numONUPerOLT, &wg, true, true) |
| 1202 | |
| 1203 | // Create the device with valid data |
| 1204 | oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"}) |
| 1205 | assert.Nil(t, err) |
| 1206 | assert.NotNil(t, oltDevice) |
| 1207 | |
| 1208 | // Verify oltDevice exist in the core |
| 1209 | devices, err := nbi.ListDevices(getContext(), &empty.Empty{}) |
| 1210 | assert.Nil(t, err) |
| 1211 | assert.Equal(t, 1, len(devices.Items)) |
| 1212 | assert.Equal(t, oltDevice.Id, devices.Items[0].Id) |
| 1213 | |
| 1214 | // Enable the oltDevice |
| 1215 | _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 1216 | assert.Nil(t, err) |
| 1217 | |
| 1218 | // Wait for the logical device to be in the ready state |
| 1219 | var vldFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool { |
| 1220 | return ld != nil && len(ld.Ports) == nb.numONUPerOLT+1 |
| 1221 | } |
| 1222 | err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vldFunction) |
| 1223 | assert.Nil(t, err) |
| 1224 | |
| 1225 | // Verify that the devices have been setup correctly |
| 1226 | nb.verifyDevices(t, nbi) |
| 1227 | |
| 1228 | // Get latest oltDevice data |
| 1229 | oltDevice, err = nbi.GetDevice(getContext(), &voltha.ID{Id: oltDevice.Id}) |
| 1230 | assert.Nil(t, err) |
| 1231 | |
| 1232 | // Verify that the logical device has been setup correctly |
| 1233 | nb.verifyLogicalDevices(t, oltDevice, nbi) |
| 1234 | |
| 1235 | // Wait until all flows has been sent to the devices successfully |
| 1236 | wg.Wait() |
| 1237 | } |
| 1238 | |
Matteo Scandolo | d525ae3 | 2020-04-02 17:27:29 -0700 | [diff] [blame] | 1239 | func TestSuiteNbiApiHandler(t *testing.T) { |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 1240 | f, err := os.Create("../../../tests/results/profile.cpu") |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1241 | if err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 1242 | logger.Fatalf("could not create CPU profile: %v\n ", err) |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1243 | } |
| 1244 | defer f.Close() |
| 1245 | runtime.SetBlockProfileRate(1) |
| 1246 | runtime.SetMutexProfileFraction(-1) |
| 1247 | if err := pprof.StartCPUProfile(f); err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 1248 | logger.Fatalf("could not start CPU profile: %v\n", err) |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1249 | } |
| 1250 | defer pprof.StopCPUProfile() |
| 1251 | |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 1252 | //log.SetPackageLogLevel("github.com/opencord/voltha-go/rw_core/core", log.DebugLevel) |
| 1253 | |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 1254 | nb := newNBTest() |
| 1255 | assert.NotNil(t, nb) |
| 1256 | |
| 1257 | defer nb.stopAll() |
| 1258 | |
| 1259 | // Start the Core |
| 1260 | nb.startCore(false) |
| 1261 | |
| 1262 | // Set the grpc API interface - no grpc server is running in unit test |
Kent Hagerman | 45a13e4 | 2020-04-13 12:23:50 -0400 | [diff] [blame] | 1263 | nbi := NewNBIHandler(nb.deviceMgr, nb.logicalDeviceMgr, nb.adapterMgr) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 1264 | |
| 1265 | // 1. Basic test with no data in Core |
| 1266 | nb.testCoreWithoutData(t, nbi) |
| 1267 | |
| 1268 | // Create/register the adapters |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 1269 | nb.createAndregisterAdapters(t) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 1270 | |
| 1271 | // 2. Test adapter registration |
| 1272 | nb.testAdapterRegistration(t, nbi) |
| 1273 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1274 | numberOfTestRuns := 2 |
| 1275 | for i := 1; i <= numberOfTestRuns; i++ { |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1276 | //3. Test create device |
khenaidoo | 93d5a3d | 2020-01-15 12:37:05 -0500 | [diff] [blame] | 1277 | nb.testCreateDevice(t, nbi) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 1278 | |
khenaidoo | 93d5a3d | 2020-01-15 12:37:05 -0500 | [diff] [blame] | 1279 | // 4. Test Enable a device |
| 1280 | nb.testEnableDevice(t, nbi) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 1281 | |
khenaidoo | 93d5a3d | 2020-01-15 12:37:05 -0500 | [diff] [blame] | 1282 | // 5. Test disable and ReEnable a root device |
| 1283 | nb.testDisableAndReEnableRootDevice(t, nbi) |
khenaidoo | 67b2215 | 2020-03-02 16:01:25 -0500 | [diff] [blame] | 1284 | |
kesavand | bc2d162 | 2020-01-21 00:42:01 -0500 | [diff] [blame] | 1285 | // 6. Test disable and Enable pon port of OLT device |
| 1286 | nb.testDisableAndEnablePort(t, nbi) |
khenaidoo | 93d5a3d | 2020-01-15 12:37:05 -0500 | [diff] [blame] | 1287 | |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 1288 | // 7.Test Device unreachable when OLT is enabled |
| 1289 | nb.testDeviceRebootWhenOltIsEnabled(t, nbi) |
| 1290 | |
| 1291 | // 8. Test disable and delete all devices |
khenaidoo | 93d5a3d | 2020-01-15 12:37:05 -0500 | [diff] [blame] | 1292 | nb.testDisableAndDeleteAllDevice(t, nbi) |
Chaitrashree G S | 543df3e | 2020-02-24 22:36:54 -0500 | [diff] [blame] | 1293 | |
Girish Gowdra | 408cd96 | 2020-03-11 14:31:31 -0700 | [diff] [blame] | 1294 | // 9. Test enable and delete all devices |
Chaitrashree G S | 543df3e | 2020-02-24 22:36:54 -0500 | [diff] [blame] | 1295 | nb.testEnableAndDeleteAllDevice(t, nbi) |
Scott Baker | 432f9be | 2020-03-26 11:56:30 -0700 | [diff] [blame] | 1296 | |
| 1297 | // 10. Test omci test |
| 1298 | nb.testStartOmciTestAction(t, nbi) |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 1299 | |
khenaidoo | 8b4abbf | 2020-04-24 17:04:30 -0400 | [diff] [blame^] | 1300 | // 11. Test flow add failure |
| 1301 | nb.testFlowAddFailure(t, nbi) |
| 1302 | |
| 1303 | // 12. Clean up |
| 1304 | nb.deleteAllDevices(t, nbi) |
| 1305 | } |
khenaidoo | b64fc8a | 2019-11-27 15:08:19 -0500 | [diff] [blame] | 1306 | } |