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