khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -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 | 6e55d9e | 2019-12-12 18:26:26 -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 device |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 18 | |
| 19 | import ( |
| 20 | "context" |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 21 | "math/rand" |
| 22 | "sort" |
Neha Sharma | d1387da | 2020-05-07 20:07:28 +0000 | [diff] [blame] | 23 | "strconv" |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 24 | "strings" |
| 25 | "sync" |
| 26 | "testing" |
| 27 | "time" |
| 28 | |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 29 | "github.com/gogo/protobuf/proto" |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 30 | "github.com/opencord/voltha-go/db/model" |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 31 | "github.com/opencord/voltha-go/rw_core/config" |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 32 | "github.com/opencord/voltha-go/rw_core/core/adapter" |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 33 | cm "github.com/opencord/voltha-go/rw_core/mocks" |
| 34 | tst "github.com/opencord/voltha-go/rw_core/test" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 35 | com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common" |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 36 | "github.com/opencord/voltha-lib-go/v3/pkg/db" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 37 | "github.com/opencord/voltha-lib-go/v3/pkg/kafka" |
Scott Baker | 504b480 | 2020-04-17 10:12:20 -0700 | [diff] [blame] | 38 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
Matteo Scandolo | d525ae3 | 2020-04-02 17:27:29 -0700 | [diff] [blame] | 39 | mock_etcd "github.com/opencord/voltha-lib-go/v3/pkg/mocks/etcd" |
| 40 | mock_kafka "github.com/opencord/voltha-lib-go/v3/pkg/mocks/kafka" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 41 | ofp "github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 42 | "github.com/opencord/voltha-protos/v3/go/voltha" |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 43 | "github.com/phayes/freeport" |
| 44 | "github.com/stretchr/testify/assert" |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 45 | ) |
| 46 | |
| 47 | type DATest struct { |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 48 | etcdServer *mock_etcd.EtcdServer |
| 49 | deviceMgr *Manager |
| 50 | logicalDeviceMgr *LogicalManager |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 51 | adapterMgr *adapter.Manager |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 52 | kmp kafka.InterContainerProxy |
| 53 | kClient kafka.Client |
| 54 | kvClientPort int |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 55 | oltAdapter *cm.OLTAdapter |
| 56 | onuAdapter *cm.ONUAdapter |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 57 | oltAdapterName string |
| 58 | onuAdapterName string |
| 59 | coreInstanceID string |
| 60 | defaultTimeout time.Duration |
| 61 | maxTimeout time.Duration |
| 62 | device *voltha.Device |
| 63 | done chan int |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | func newDATest() *DATest { |
| 67 | test := &DATest{} |
| 68 | // Start the embedded etcd server |
| 69 | var err error |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 70 | test.etcdServer, test.kvClientPort, err = tst.StartEmbeddedEtcdServer("voltha.rwcore.da.test", "voltha.rwcore.da.etcd", "error") |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 71 | if err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 72 | logger.Fatal(err) |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 73 | } |
| 74 | // Create the kafka client |
Matteo Scandolo | d525ae3 | 2020-04-02 17:27:29 -0700 | [diff] [blame] | 75 | test.kClient = mock_kafka.NewKafkaClient() |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 76 | test.oltAdapterName = "olt_adapter_mock" |
| 77 | test.onuAdapterName = "onu_adapter_mock" |
| 78 | test.coreInstanceID = "rw-da-test" |
| 79 | test.defaultTimeout = 5 * time.Second |
| 80 | test.maxTimeout = 20 * time.Second |
| 81 | test.done = make(chan int) |
| 82 | parentID := com.GetRandomString(10) |
| 83 | test.device = &voltha.Device{ |
| 84 | Type: "onu_adapter_mock", |
| 85 | ParentId: parentID, |
| 86 | ParentPortNo: 1, |
| 87 | VendorId: "onu_adapter_mock", |
| 88 | Adapter: "onu_adapter_mock", |
| 89 | Vlan: 100, |
| 90 | Address: nil, |
| 91 | ProxyAddress: &voltha.Device_ProxyAddress{ |
| 92 | DeviceId: parentID, |
| 93 | DeviceType: "olt_adapter_mock", |
| 94 | ChannelId: 100, |
| 95 | ChannelGroupId: 0, |
| 96 | ChannelTermination: "", |
| 97 | OnuId: 2, |
| 98 | }, |
| 99 | AdminState: voltha.AdminState_PREPROVISIONED, |
| 100 | OperStatus: voltha.OperStatus_UNKNOWN, |
| 101 | Reason: "All good", |
| 102 | ConnectStatus: voltha.ConnectStatus_UNKNOWN, |
| 103 | Custom: nil, |
| 104 | Ports: []*voltha.Port{ |
| 105 | {PortNo: 1, Label: "pon-1", Type: voltha.Port_PON_ONU, AdminState: voltha.AdminState_ENABLED, |
| 106 | OperStatus: voltha.OperStatus_ACTIVE, Peers: []*voltha.Port_PeerPort{{DeviceId: parentID, PortNo: 1}}}, |
| 107 | {PortNo: 100, Label: "uni-100", Type: voltha.Port_ETHERNET_UNI, AdminState: voltha.AdminState_ENABLED, |
| 108 | OperStatus: voltha.OperStatus_ACTIVE}, |
| 109 | }, |
| 110 | } |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 111 | return test |
| 112 | } |
| 113 | |
David Bainbridge | 9ae1313 | 2020-06-22 17:28:01 -0700 | [diff] [blame] | 114 | func (dat *DATest) startCore() { |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 115 | cfg := config.NewRWCoreFlags() |
serkant.uluderya | 8ff291d | 2020-05-20 00:58:00 -0700 | [diff] [blame] | 116 | cfg.CoreTopic = "rw_core" |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 117 | cfg.DefaultRequestTimeout = dat.defaultTimeout |
Neha Sharma | d1387da | 2020-05-07 20:07:28 +0000 | [diff] [blame] | 118 | cfg.KVStoreAddress = "127.0.0.1" + ":" + strconv.Itoa(dat.kvClientPort) |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 119 | grpcPort, err := freeport.GetFreePort() |
| 120 | if err != nil { |
Girish Kumar | f56a468 | 2020-03-20 20:07:46 +0000 | [diff] [blame] | 121 | logger.Fatal("Cannot get a freeport for grpc") |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 122 | } |
Neha Sharma | d1387da | 2020-05-07 20:07:28 +0000 | [diff] [blame] | 123 | cfg.GrpcAddress = "127.0.0.1" + ":" + strconv.Itoa(grpcPort) |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 124 | client := tst.SetupKVClient(cfg, dat.coreInstanceID) |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 125 | backend := &db.Backend{ |
| 126 | Client: client, |
| 127 | StoreType: cfg.KVStoreType, |
Neha Sharma | d1387da | 2020-05-07 20:07:28 +0000 | [diff] [blame] | 128 | Address: cfg.KVStoreAddress, |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 129 | Timeout: cfg.KVStoreTimeout, |
serkant.uluderya | 8ff291d | 2020-05-20 00:58:00 -0700 | [diff] [blame] | 130 | LivenessChannelInterval: cfg.LiveProbeInterval / 2} |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 131 | dat.kmp = kafka.NewInterContainerProxy( |
Neha Sharma | d1387da | 2020-05-07 20:07:28 +0000 | [diff] [blame] | 132 | kafka.InterContainerAddress(cfg.KafkaAdapterAddress), |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 133 | kafka.MsgClient(dat.kClient), |
David Bainbridge | 9ae1313 | 2020-06-22 17:28:01 -0700 | [diff] [blame] | 134 | kafka.DefaultTopic(&kafka.Topic{Name: cfg.CoreTopic})) |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 135 | |
| 136 | endpointMgr := kafka.NewEndpointManager(backend) |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 137 | proxy := model.NewDBPath(backend) |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 138 | dat.adapterMgr = adapter.NewAdapterManager(proxy, dat.coreInstanceID, dat.kClient) |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 139 | |
serkant.uluderya | 8ff291d | 2020-05-20 00:58:00 -0700 | [diff] [blame] | 140 | dat.deviceMgr, dat.logicalDeviceMgr = NewManagers(proxy, dat.adapterMgr, dat.kmp, endpointMgr, cfg.CoreTopic, dat.coreInstanceID, cfg.DefaultCoreTimeout) |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 141 | dat.adapterMgr.Start(context.Background()) |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 142 | if err = dat.kmp.Start(); err != nil { |
| 143 | logger.Fatal("Cannot start InterContainerProxy") |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 144 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 145 | |
serkant.uluderya | 8ff291d | 2020-05-20 00:58:00 -0700 | [diff] [blame] | 146 | if err := dat.kmp.SubscribeWithDefaultRequestHandler(kafka.Topic{Name: cfg.CoreTopic}, kafka.OffsetNewest); err != nil { |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 147 | logger.Fatalf("Cannot add default request handler: %s", err) |
| 148 | } |
| 149 | |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | func (dat *DATest) stopAll() { |
| 153 | if dat.kClient != nil { |
| 154 | dat.kClient.Stop() |
| 155 | } |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 156 | if dat.kmp != nil { |
| 157 | dat.kmp.Stop() |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 158 | } |
| 159 | if dat.etcdServer != nil { |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 160 | tst.StopEmbeddedEtcdServer(dat.etcdServer) |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 161 | } |
| 162 | } |
| 163 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 164 | func (dat *DATest) createDeviceAgent(t *testing.T) *Agent { |
| 165 | deviceMgr := dat.deviceMgr |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 166 | clonedDevice := proto.Clone(dat.device).(*voltha.Device) |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 167 | deviceAgent := newAgent(deviceMgr.adapterProxy, clonedDevice, deviceMgr, deviceMgr.dbPath, deviceMgr.dProxy, deviceMgr.defaultTimeout) |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 168 | d, err := deviceAgent.start(context.TODO(), clonedDevice) |
| 169 | assert.Nil(t, err) |
| 170 | assert.NotNil(t, d) |
| 171 | deviceMgr.addDeviceAgentToMap(deviceAgent) |
| 172 | return deviceAgent |
| 173 | } |
| 174 | |
Kent Hagerman | 2b21604 | 2020-04-03 18:28:56 -0400 | [diff] [blame] | 175 | func (dat *DATest) updateDeviceConcurrently(t *testing.T, da *Agent, globalWG *sync.WaitGroup) { |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 176 | originalDevice, err := da.getDevice(context.Background()) |
| 177 | assert.Nil(t, err) |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 178 | assert.NotNil(t, originalDevice) |
| 179 | var localWG sync.WaitGroup |
| 180 | |
| 181 | // Update device routine |
| 182 | var ( |
| 183 | root = false |
| 184 | vendor = "onu_adapter_mock" |
| 185 | model = "go-mock" |
| 186 | serialNumber = com.GetRandomSerialNumber() |
| 187 | macAddress = strings.ToUpper(com.GetRandomMacAddress()) |
| 188 | vlan = rand.Uint32() |
| 189 | reason = "testing concurrent device update" |
| 190 | portToAdd = &voltha.Port{PortNo: 101, Label: "uni-101", Type: voltha.Port_ETHERNET_UNI, AdminState: voltha.AdminState_ENABLED, |
| 191 | OperStatus: voltha.OperStatus_ACTIVE} |
| 192 | ) |
| 193 | localWG.Add(1) |
| 194 | go func() { |
| 195 | deviceToUpdate := proto.Clone(originalDevice).(*voltha.Device) |
| 196 | deviceToUpdate.Root = root |
| 197 | deviceToUpdate.Vendor = vendor |
| 198 | deviceToUpdate.Model = model |
| 199 | deviceToUpdate.SerialNumber = serialNumber |
| 200 | deviceToUpdate.MacAddress = macAddress |
| 201 | deviceToUpdate.Vlan = vlan |
| 202 | deviceToUpdate.Reason = reason |
npujar | 467fe75 | 2020-01-16 20:17:45 +0530 | [diff] [blame] | 203 | err := da.updateDeviceUsingAdapterData(context.Background(), deviceToUpdate) |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 204 | assert.Nil(t, err) |
| 205 | localWG.Done() |
| 206 | }() |
| 207 | |
| 208 | // Update the device status routine |
| 209 | localWG.Add(1) |
| 210 | go func() { |
npujar | 467fe75 | 2020-01-16 20:17:45 +0530 | [diff] [blame] | 211 | err := da.updateDeviceStatus(context.Background(), voltha.OperStatus_ACTIVE, voltha.ConnectStatus_REACHABLE) |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 212 | assert.Nil(t, err) |
| 213 | localWG.Done() |
| 214 | }() |
| 215 | |
| 216 | // Add a port routine |
| 217 | localWG.Add(1) |
| 218 | go func() { |
npujar | 467fe75 | 2020-01-16 20:17:45 +0530 | [diff] [blame] | 219 | err := da.addPort(context.Background(), portToAdd) |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 220 | assert.Nil(t, err) |
| 221 | localWG.Done() |
| 222 | }() |
| 223 | |
| 224 | // wait for go routines to be done |
| 225 | localWG.Wait() |
| 226 | |
| 227 | expectedChange := proto.Clone(originalDevice).(*voltha.Device) |
| 228 | expectedChange.OperStatus = voltha.OperStatus_ACTIVE |
| 229 | expectedChange.ConnectStatus = voltha.ConnectStatus_REACHABLE |
| 230 | expectedChange.Ports = append(expectedChange.Ports, portToAdd) |
| 231 | expectedChange.Root = root |
| 232 | expectedChange.Vendor = vendor |
| 233 | expectedChange.Model = model |
| 234 | expectedChange.SerialNumber = serialNumber |
| 235 | expectedChange.MacAddress = macAddress |
| 236 | expectedChange.Vlan = vlan |
| 237 | expectedChange.Reason = reason |
| 238 | |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 239 | updatedDevice, _ := da.getDevice(context.Background()) |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 240 | assert.NotNil(t, updatedDevice) |
| 241 | assert.True(t, proto.Equal(expectedChange, updatedDevice)) |
| 242 | |
| 243 | globalWG.Done() |
| 244 | } |
| 245 | |
| 246 | func TestConcurrentDevices(t *testing.T) { |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 247 | for i := 0; i < 2; i++ { |
| 248 | da := newDATest() |
| 249 | assert.NotNil(t, da) |
| 250 | defer da.stopAll() |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 251 | log.SetPackageLogLevel("github.com/opencord/voltha-go/rw_core/core", log.DebugLevel) |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 252 | // Start the Core |
David Bainbridge | 9ae1313 | 2020-06-22 17:28:01 -0700 | [diff] [blame] | 253 | da.startCore() |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 254 | |
khenaidoo | 442e7c7 | 2020-03-10 16:13:48 -0400 | [diff] [blame] | 255 | var wg sync.WaitGroup |
| 256 | numConCurrentDeviceAgents := 20 |
| 257 | for i := 0; i < numConCurrentDeviceAgents; i++ { |
| 258 | wg.Add(1) |
| 259 | a := da.createDeviceAgent(t) |
| 260 | go da.updateDeviceConcurrently(t, a, &wg) |
| 261 | } |
| 262 | |
| 263 | wg.Wait() |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 264 | } |
khenaidoo | 6e55d9e | 2019-12-12 18:26:26 -0500 | [diff] [blame] | 265 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 266 | func TestFlowUpdates(t *testing.T) { |
| 267 | da := newDATest() |
| 268 | assert.NotNil(t, da) |
| 269 | defer da.stopAll() |
| 270 | |
| 271 | log.SetPackageLogLevel("github.com/opencord/voltha-go/rw_core/core", log.DebugLevel) |
| 272 | // Start the Core |
David Bainbridge | 9ae1313 | 2020-06-22 17:28:01 -0700 | [diff] [blame] | 273 | da.startCore() |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 274 | da.oltAdapter, da.onuAdapter = tst.CreateAndregisterAdapters(t, da.kClient, da.coreInstanceID, da.oltAdapterName, da.onuAdapterName, da.adapterMgr) |
| 275 | |
| 276 | a := da.createDeviceAgent(t) |
| 277 | cloned := a.getDeviceWithoutLock() |
| 278 | err := a.updateDeviceStateInStoreWithoutLock(context.Background(), cloned, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE) |
| 279 | assert.Nil(t, err) |
| 280 | da.testFlowAddDeletes(t, a) |
| 281 | } |
| 282 | |
| 283 | func TestGroupUpdates(t *testing.T) { |
| 284 | da := newDATest() |
| 285 | assert.NotNil(t, da) |
| 286 | defer da.stopAll() |
| 287 | |
| 288 | // Start the Core |
David Bainbridge | 9ae1313 | 2020-06-22 17:28:01 -0700 | [diff] [blame] | 289 | da.startCore() |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 290 | da.oltAdapter, da.onuAdapter = tst.CreateAndregisterAdapters(t, da.kClient, da.coreInstanceID, da.oltAdapterName, da.onuAdapterName, da.adapterMgr) |
| 291 | a := da.createDeviceAgent(t) |
| 292 | cloned := a.getDeviceWithoutLock() |
| 293 | err := a.updateDeviceStateInStoreWithoutLock(context.Background(), cloned, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE) |
| 294 | assert.Nil(t, err) |
| 295 | da.testGroupAddDeletes(t, a) |
| 296 | } |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 297 | |
| 298 | func isFlowSliceEqual(a, b []*ofp.OfpFlowStats) bool { |
| 299 | if len(a) != len(b) { |
| 300 | return false |
| 301 | } |
| 302 | sort.Slice(a, func(i, j int) bool { |
| 303 | return a[i].Id < a[j].Id |
| 304 | }) |
| 305 | sort.Slice(b, func(i, j int) bool { |
| 306 | return b[i].Id < b[j].Id |
| 307 | }) |
| 308 | for idx := range a { |
| 309 | if !proto.Equal(a[idx], b[idx]) { |
| 310 | return false |
| 311 | } |
| 312 | } |
| 313 | return true |
| 314 | } |
| 315 | |
| 316 | func isGroupSliceEqual(a, b []*ofp.OfpGroupEntry) bool { |
| 317 | if len(a) != len(b) { |
| 318 | return false |
| 319 | } |
| 320 | sort.Slice(a, func(i, j int) bool { |
| 321 | return a[i].Desc.GroupId < a[j].Desc.GroupId |
| 322 | }) |
| 323 | sort.Slice(b, func(i, j int) bool { |
| 324 | return b[i].Desc.GroupId < b[j].Desc.GroupId |
| 325 | }) |
| 326 | for idx := range a { |
| 327 | if !proto.Equal(a[idx], b[idx]) { |
| 328 | return false |
| 329 | } |
| 330 | } |
| 331 | return true |
| 332 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 333 | func changeToFlowList(flowList map[uint64]*ofp.OfpFlowStats) []*ofp.OfpFlowStats { |
| 334 | flows := make([]*ofp.OfpFlowStats, 0) |
| 335 | for _, flow := range flowList { |
| 336 | flows = append(flows, flow) |
| 337 | } |
| 338 | return flows |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 339 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 340 | func changeToGroupList(groupList map[uint32]*ofp.OfpGroupEntry) []*ofp.OfpGroupEntry { |
| 341 | groups := make([]*ofp.OfpGroupEntry, 0) |
| 342 | for _, group := range groupList { |
| 343 | groups = append(groups, group) |
| 344 | } |
| 345 | return groups |
| 346 | } |
| 347 | func (dat *DATest) testFlowAddDeletes(t *testing.T, da *Agent) { |
| 348 | //Add new Flows on empty list |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 349 | newFlows := []*ofp.OfpFlowStats{ |
| 350 | {Id: 123, TableId: 1230, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1230000, PacketCount: 0}, |
| 351 | {Id: 124, TableId: 1240, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1240000, PacketCount: 0}, |
| 352 | {Id: 125, TableId: 1250, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1250000, PacketCount: 0}, |
| 353 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 354 | err := da.addFlowsAndGroups(context.Background(), newFlows, []*ofp.OfpGroupEntry{}, &voltha.FlowMetadata{}) |
| 355 | assert.Nil(t, err) |
| 356 | daFlows := changeToFlowList(da.listDeviceFlows()) |
| 357 | assert.True(t, isFlowSliceEqual(newFlows, daFlows)) |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 358 | |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 359 | //Add new Flows on existing ones |
| 360 | newFlows = []*ofp.OfpFlowStats{ |
| 361 | {Id: 126, TableId: 1260, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1260000, PacketCount: 0}, |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 362 | {Id: 127, TableId: 1270, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1270000, PacketCount: 0}, |
| 363 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 364 | |
| 365 | expectedFlows := []*ofp.OfpFlowStats{ |
| 366 | {Id: 123, TableId: 1230, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1230000, PacketCount: 0}, |
| 367 | {Id: 124, TableId: 1240, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1240000, PacketCount: 0}, |
| 368 | {Id: 125, TableId: 1250, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1250000, PacketCount: 0}, |
| 369 | {Id: 126, TableId: 1260, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1260000, PacketCount: 0}, |
| 370 | {Id: 127, TableId: 1270, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1270000, PacketCount: 0}, |
| 371 | } |
| 372 | |
| 373 | err = da.addFlowsAndGroups(context.Background(), newFlows, []*ofp.OfpGroupEntry{}, &voltha.FlowMetadata{}) |
| 374 | assert.Nil(t, err) |
| 375 | daFlows = changeToFlowList(da.listDeviceFlows()) |
| 376 | assert.True(t, isFlowSliceEqual(expectedFlows, daFlows)) |
| 377 | |
| 378 | //Add existing Flows again with a new flow |
| 379 | newFlows = []*ofp.OfpFlowStats{ |
| 380 | {Id: 126, TableId: 1260, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1260000, PacketCount: 0}, |
| 381 | {Id: 127, TableId: 1270, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1270001, PacketCount: 0}, |
| 382 | {Id: 128, TableId: 1280, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1280000, PacketCount: 0}, |
| 383 | } |
| 384 | |
| 385 | expectedFlows = []*ofp.OfpFlowStats{ |
| 386 | {Id: 123, TableId: 1230, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1230000, PacketCount: 0}, |
| 387 | {Id: 124, TableId: 1240, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1240000, PacketCount: 0}, |
| 388 | {Id: 125, TableId: 1250, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1250000, PacketCount: 0}, |
| 389 | {Id: 126, TableId: 1260, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1260000, PacketCount: 0}, |
| 390 | {Id: 127, TableId: 1270, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1270001, PacketCount: 0}, |
| 391 | {Id: 128, TableId: 1280, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1280000, PacketCount: 0}, |
| 392 | } |
| 393 | |
| 394 | err = da.addFlowsAndGroups(context.Background(), newFlows, []*ofp.OfpGroupEntry{}, &voltha.FlowMetadata{}) |
| 395 | assert.Nil(t, err) |
| 396 | daFlows = changeToFlowList(da.listDeviceFlows()) |
| 397 | assert.True(t, isFlowSliceEqual(expectedFlows, daFlows)) |
| 398 | |
| 399 | //Add already existing flows again |
| 400 | newFlows = []*ofp.OfpFlowStats{ |
| 401 | {Id: 126, TableId: 1260, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1260000, PacketCount: 0}, |
| 402 | {Id: 127, TableId: 1270, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1270001, PacketCount: 0}, |
| 403 | {Id: 128, TableId: 1280, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1280000, PacketCount: 0}, |
| 404 | } |
| 405 | |
| 406 | expectedFlows = []*ofp.OfpFlowStats{ |
| 407 | {Id: 123, TableId: 1230, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1230000, PacketCount: 0}, |
| 408 | {Id: 124, TableId: 1240, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1240000, PacketCount: 0}, |
| 409 | {Id: 125, TableId: 1250, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1250000, PacketCount: 0}, |
| 410 | {Id: 126, TableId: 1260, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1260000, PacketCount: 0}, |
| 411 | {Id: 127, TableId: 1270, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1270001, PacketCount: 0}, |
| 412 | {Id: 128, TableId: 1280, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1280000, PacketCount: 0}, |
| 413 | } |
| 414 | |
| 415 | err = da.addFlowsAndGroups(context.Background(), newFlows, []*ofp.OfpGroupEntry{}, &voltha.FlowMetadata{}) |
| 416 | assert.Nil(t, err) |
| 417 | daFlows = changeToFlowList(da.listDeviceFlows()) |
| 418 | assert.True(t, isFlowSliceEqual(expectedFlows, daFlows)) |
| 419 | |
| 420 | //Delete flows |
| 421 | flowsToDelete := []*ofp.OfpFlowStats{ |
| 422 | {Id: 126, TableId: 1260, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1260000, PacketCount: 0}, |
| 423 | {Id: 127, TableId: 1270, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1270001, PacketCount: 0}, |
| 424 | {Id: 128, TableId: 1280, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1280000, PacketCount: 0}, |
| 425 | } |
| 426 | |
| 427 | expectedFlows = []*ofp.OfpFlowStats{ |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 428 | {Id: 123, TableId: 1230, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1230000, PacketCount: 0}, |
| 429 | {Id: 124, TableId: 1240, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1240000, PacketCount: 0}, |
| 430 | {Id: 125, TableId: 1250, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1250000, PacketCount: 0}, |
| 431 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 432 | |
| 433 | err = da.deleteFlowsAndGroups(context.Background(), flowsToDelete, []*ofp.OfpGroupEntry{}, &voltha.FlowMetadata{}) |
| 434 | assert.Nil(t, err) |
| 435 | daFlows = changeToFlowList(da.listDeviceFlows()) |
| 436 | assert.True(t, isFlowSliceEqual(expectedFlows, daFlows)) |
| 437 | //Delete flows with an unexisting one |
| 438 | flowsToDelete = []*ofp.OfpFlowStats{ |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 439 | {Id: 125, TableId: 1250, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1250000, PacketCount: 0}, |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 440 | {Id: 129, TableId: 1290, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1290000, PacketCount: 0}, |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 441 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 442 | |
| 443 | expectedFlows = []*ofp.OfpFlowStats{ |
| 444 | {Id: 123, TableId: 1230, Priority: 100, IdleTimeout: 0, Flags: 0, Cookie: 1230000, PacketCount: 0}, |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 445 | {Id: 124, TableId: 1240, Priority: 1000, IdleTimeout: 0, Flags: 0, Cookie: 1240000, PacketCount: 0}, |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 446 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 447 | |
| 448 | err = da.deleteFlowsAndGroups(context.Background(), flowsToDelete, []*ofp.OfpGroupEntry{}, &voltha.FlowMetadata{}) |
| 449 | assert.Nil(t, err) |
| 450 | daFlows = changeToFlowList(da.listDeviceFlows()) |
| 451 | assert.True(t, isFlowSliceEqual(expectedFlows, daFlows)) |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 452 | } |
| 453 | |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 454 | func (dat *DATest) testGroupAddDeletes(t *testing.T, da *Agent) { |
| 455 | //Add new Groups on empty list |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 456 | newGroups := []*ofp.OfpGroupEntry{ |
| 457 | {Desc: &ofp.OfpGroupDesc{Type: 1, GroupId: 10, Buckets: nil}}, |
| 458 | {Desc: &ofp.OfpGroupDesc{Type: 2, GroupId: 20, Buckets: nil}}, |
| 459 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 460 | err := da.addFlowsAndGroups(context.Background(), []*ofp.OfpFlowStats{}, newGroups, &voltha.FlowMetadata{}) |
| 461 | assert.Nil(t, err) |
| 462 | daGroups := changeToGroupList(da.listDeviceGroups()) |
| 463 | assert.True(t, isGroupSliceEqual(newGroups, daGroups)) |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 464 | |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 465 | //Add new Groups on existing ones |
| 466 | newGroups = []*ofp.OfpGroupEntry{ |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 467 | {Desc: &ofp.OfpGroupDesc{Type: 3, GroupId: 30, Buckets: nil}}, |
| 468 | {Desc: &ofp.OfpGroupDesc{Type: 4, GroupId: 40, Buckets: nil}}, |
| 469 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 470 | expectedGroups := []*ofp.OfpGroupEntry{ |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 471 | {Desc: &ofp.OfpGroupDesc{Type: 1, GroupId: 10, Buckets: nil}}, |
| 472 | {Desc: &ofp.OfpGroupDesc{Type: 2, GroupId: 20, Buckets: nil}}, |
| 473 | {Desc: &ofp.OfpGroupDesc{Type: 3, GroupId: 30, Buckets: nil}}, |
| 474 | {Desc: &ofp.OfpGroupDesc{Type: 4, GroupId: 40, Buckets: nil}}, |
| 475 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 476 | err = da.addFlowsAndGroups(context.Background(), []*ofp.OfpFlowStats{}, newGroups, &voltha.FlowMetadata{}) |
| 477 | assert.Nil(t, err) |
| 478 | daGroups = changeToGroupList(da.listDeviceGroups()) |
| 479 | assert.True(t, isGroupSliceEqual(expectedGroups, daGroups)) |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 480 | |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 481 | //Add new Groups on existing ones |
| 482 | newGroups = []*ofp.OfpGroupEntry{ |
| 483 | {Desc: &ofp.OfpGroupDesc{Type: 3, GroupId: 30, Buckets: nil}}, |
| 484 | {Desc: &ofp.OfpGroupDesc{Type: 44, GroupId: 40, Buckets: nil}}, |
| 485 | {Desc: &ofp.OfpGroupDesc{Type: 5, GroupId: 50, Buckets: nil}}, |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 486 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 487 | expectedGroups = []*ofp.OfpGroupEntry{ |
| 488 | {Desc: &ofp.OfpGroupDesc{Type: 1, GroupId: 10, Buckets: nil}}, |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 489 | {Desc: &ofp.OfpGroupDesc{Type: 2, GroupId: 20, Buckets: nil}}, |
| 490 | {Desc: &ofp.OfpGroupDesc{Type: 3, GroupId: 30, Buckets: nil}}, |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 491 | {Desc: &ofp.OfpGroupDesc{Type: 44, GroupId: 40, Buckets: nil}}, |
| 492 | {Desc: &ofp.OfpGroupDesc{Type: 5, GroupId: 50, Buckets: nil}}, |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 493 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 494 | err = da.addFlowsAndGroups(context.Background(), []*ofp.OfpFlowStats{}, newGroups, &voltha.FlowMetadata{}) |
| 495 | assert.Nil(t, err) |
| 496 | daGroups = changeToGroupList(da.listDeviceGroups()) |
| 497 | assert.True(t, isGroupSliceEqual(expectedGroups, daGroups)) |
| 498 | |
| 499 | //Modify Group |
| 500 | updtGroups := []*ofp.OfpGroupEntry{ |
| 501 | {Desc: &ofp.OfpGroupDesc{Type: 33, GroupId: 30, Buckets: nil}}, |
| 502 | } |
| 503 | expectedGroups = []*ofp.OfpGroupEntry{ |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 504 | {Desc: &ofp.OfpGroupDesc{Type: 1, GroupId: 10, Buckets: nil}}, |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 505 | {Desc: &ofp.OfpGroupDesc{Type: 2, GroupId: 20, Buckets: nil}}, |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 506 | {Desc: &ofp.OfpGroupDesc{Type: 33, GroupId: 30, Buckets: nil}}, |
| 507 | {Desc: &ofp.OfpGroupDesc{Type: 44, GroupId: 40, Buckets: nil}}, |
| 508 | {Desc: &ofp.OfpGroupDesc{Type: 5, GroupId: 50, Buckets: nil}}, |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 509 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 510 | err = da.updateFlowsAndGroups(context.Background(), []*ofp.OfpFlowStats{}, updtGroups, &voltha.FlowMetadata{}) |
| 511 | assert.Nil(t, err) |
| 512 | daGroups = changeToGroupList(da.listDeviceGroups()) |
| 513 | assert.True(t, isGroupSliceEqual(expectedGroups, daGroups)) |
| 514 | |
| 515 | //Delete Group |
| 516 | delGroups := []*ofp.OfpGroupEntry{ |
| 517 | {Desc: &ofp.OfpGroupDesc{Type: 33, GroupId: 30, Buckets: nil}}, |
| 518 | } |
| 519 | expectedGroups = []*ofp.OfpGroupEntry{ |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 520 | {Desc: &ofp.OfpGroupDesc{Type: 1, GroupId: 10, Buckets: nil}}, |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 521 | {Desc: &ofp.OfpGroupDesc{Type: 2, GroupId: 20, Buckets: nil}}, |
| 522 | {Desc: &ofp.OfpGroupDesc{Type: 44, GroupId: 40, Buckets: nil}}, |
| 523 | {Desc: &ofp.OfpGroupDesc{Type: 5, GroupId: 50, Buckets: nil}}, |
| 524 | } |
| 525 | err = da.deleteFlowsAndGroups(context.Background(), []*ofp.OfpFlowStats{}, delGroups, &voltha.FlowMetadata{}) |
| 526 | assert.Nil(t, err) |
| 527 | daGroups = changeToGroupList(da.listDeviceGroups()) |
| 528 | assert.True(t, isGroupSliceEqual(expectedGroups, daGroups)) |
| 529 | |
| 530 | //Delete Group |
| 531 | delGroups = []*ofp.OfpGroupEntry{ |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 532 | {Desc: &ofp.OfpGroupDesc{Type: 4, GroupId: 40, Buckets: nil}}, |
| 533 | } |
Mahir Gunyel | 03de0d3 | 2020-06-03 01:36:59 -0700 | [diff] [blame] | 534 | expectedGroups = []*ofp.OfpGroupEntry{ |
| 535 | {Desc: &ofp.OfpGroupDesc{Type: 1, GroupId: 10, Buckets: nil}}, |
| 536 | {Desc: &ofp.OfpGroupDesc{Type: 2, GroupId: 20, Buckets: nil}}, |
| 537 | {Desc: &ofp.OfpGroupDesc{Type: 5, GroupId: 50, Buckets: nil}}, |
| 538 | } |
| 539 | err = da.deleteFlowsAndGroups(context.Background(), []*ofp.OfpFlowStats{}, delGroups, &voltha.FlowMetadata{}) |
| 540 | assert.Nil(t, err) |
| 541 | daGroups = changeToGroupList(da.listDeviceGroups()) |
| 542 | assert.True(t, isGroupSliceEqual(expectedGroups, daGroups)) |
khenaidoo | b2121e5 | 2019-12-16 17:17:22 -0500 | [diff] [blame] | 543 | } |