sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package model |
| 17 | |
| 18 | import ( |
| 19 | "context" |
| 20 | "encoding/hex" |
| 21 | "encoding/json" |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 22 | "strconv" |
| 23 | "strings" |
| 24 | "sync" |
| 25 | "testing" |
| 26 | |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 27 | "github.com/google/uuid" |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 28 | "github.com/opencord/voltha-lib-go/v3/pkg/db" |
| 29 | "github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 30 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 31 | "github.com/opencord/voltha-protos/v3/go/common" |
| 32 | "github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 33 | "github.com/opencord/voltha-protos/v3/go/voltha" |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 34 | "github.com/stretchr/testify/assert" |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 35 | ) |
| 36 | |
| 37 | var ( |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 38 | BenchmarkProxyLogger log.Logger |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 39 | TestProxyRootLogicalDevice *Proxy |
| 40 | TestProxyRootDevice *Proxy |
| 41 | TestProxyRootAdapter *Proxy |
| 42 | TestProxyDeviceID string |
| 43 | TestProxyAdapterID string |
| 44 | TestProxyLogicalDeviceID string |
| 45 | TestProxyTargetDeviceID string |
| 46 | TestProxyTargetLogicalDeviceID string |
| 47 | TestProxyLogicalPorts []*voltha.LogicalPort |
| 48 | TestProxyPorts []*voltha.Port |
| 49 | TestProxyStats *openflow_13.OfpFlowStats |
| 50 | TestProxyFlows *openflow_13.Flows |
| 51 | TestProxyDevice *voltha.Device |
| 52 | TestProxyLogicalDevice *voltha.LogicalDevice |
| 53 | TestProxyAdapter *voltha.Adapter |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 54 | ) |
| 55 | |
| 56 | func init() { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 57 | BenchmarkProxyLogger, _ = log.AddPackage(log.JSON, log.DebugLevel, log.Fields{"instanceId": "PLT"}) |
| 58 | //log.UpdateAllLoggers(log.Fields{"instanceId": "PROXY_LOAD_TEST"}) |
| 59 | //Setup default logger - applies for packages that do not have specific logger set |
| 60 | if _, err := log.SetDefaultLogger(log.JSON, log.DebugLevel, log.Fields{"instanceId": "PLT"}); err != nil { |
| 61 | log.With(log.Fields{"error": err}).Fatal("Cannot setup logging") |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 62 | } |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 63 | |
| 64 | // Update all loggers (provisioned via init) with a common field |
| 65 | if err := log.UpdateAllLoggers(log.Fields{"instanceId": "PLT"}); err != nil { |
| 66 | log.With(log.Fields{"error": err}).Fatal("Cannot setup logging") |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 67 | } |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 68 | log.SetPackageLogLevel("github.com/opencord/voltha-go/db/model", log.DebugLevel) |
| 69 | |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 70 | proxy := NewDBPath(mockBackend) |
| 71 | TestProxyRootLogicalDevice = proxy.Proxy("logical_devices") |
| 72 | TestProxyRootDevice = proxy.Proxy("device") |
| 73 | TestProxyRootAdapter = proxy.Proxy("adapters") |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 74 | |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 75 | TestProxyLogicalPorts = []*voltha.LogicalPort{ |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 76 | { |
| 77 | Id: "123", |
| 78 | DeviceId: "logicalport-0-device-id", |
| 79 | DevicePortNo: 123, |
| 80 | RootPort: false, |
| 81 | }, |
| 82 | } |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 83 | TestProxyPorts = []*voltha.Port{ |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 84 | { |
| 85 | PortNo: 123, |
| 86 | Label: "test-port-0", |
| 87 | Type: voltha.Port_PON_OLT, |
| 88 | AdminState: common.AdminState_ENABLED, |
| 89 | OperStatus: common.OperStatus_ACTIVE, |
| 90 | DeviceId: "etcd_port-0-device-id", |
| 91 | Peers: []*voltha.Port_PeerPort{}, |
| 92 | }, |
| 93 | } |
| 94 | |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 95 | TestProxyStats = &openflow_13.OfpFlowStats{ |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 96 | Id: 1111, |
| 97 | } |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 98 | TestProxyFlows = &openflow_13.Flows{ |
| 99 | Items: []*openflow_13.OfpFlowStats{TestProxyStats}, |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 100 | } |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 101 | TestProxyDevice = &voltha.Device{ |
| 102 | Id: TestProxyDeviceID, |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 103 | Type: "simulated_olt", |
| 104 | Address: &voltha.Device_HostAndPort{HostAndPort: "1.2.3.4:5555"}, |
| 105 | AdminState: voltha.AdminState_PREPROVISIONED, |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 106 | Flows: TestProxyFlows, |
| 107 | Ports: TestProxyPorts, |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 108 | } |
| 109 | |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 110 | TestProxyLogicalDevice = &voltha.LogicalDevice{ |
| 111 | Id: TestProxyDeviceID, |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 112 | DatapathId: 0, |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 113 | Ports: TestProxyLogicalPorts, |
| 114 | Flows: TestProxyFlows, |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 115 | } |
| 116 | |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 117 | TestProxyAdapter = &voltha.Adapter{ |
| 118 | Id: TestProxyAdapterID, |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 119 | Vendor: "test-adapter-vendor", |
| 120 | Version: "test-adapter-version", |
| 121 | } |
| 122 | } |
| 123 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 124 | type mockKV struct { |
| 125 | kvstore.Client // pretend we implement everything |
| 126 | |
| 127 | mutex sync.RWMutex |
| 128 | data map[string]interface{} |
| 129 | } |
| 130 | |
| 131 | func (kv *mockKV) List(_ context.Context, key string) (map[string]*kvstore.KVPair, error) { |
| 132 | kv.mutex.RLock() |
| 133 | defer kv.mutex.RUnlock() |
| 134 | |
| 135 | ret := make(map[string]*kvstore.KVPair, len(kv.data)) |
| 136 | for k, v := range kv.data { |
| 137 | if strings.HasPrefix(k, key) { |
| 138 | ret[k] = &kvstore.KVPair{Key: k, Value: v} |
| 139 | } |
| 140 | } |
| 141 | return ret, nil |
| 142 | } |
| 143 | func (kv *mockKV) Get(_ context.Context, key string) (*kvstore.KVPair, error) { |
| 144 | kv.mutex.RLock() |
| 145 | defer kv.mutex.RUnlock() |
| 146 | |
| 147 | if val, have := kv.data[key]; have { |
| 148 | return &kvstore.KVPair{Key: key, Value: val}, nil |
| 149 | } |
| 150 | return nil, nil |
| 151 | } |
| 152 | func (kv *mockKV) Put(_ context.Context, key string, value interface{}) error { |
| 153 | kv.mutex.Lock() |
| 154 | defer kv.mutex.Unlock() |
| 155 | |
| 156 | kv.data[key] = value |
| 157 | return nil |
| 158 | } |
| 159 | func (kv *mockKV) Delete(_ context.Context, key string) error { |
| 160 | kv.mutex.Lock() |
| 161 | defer kv.mutex.Unlock() |
| 162 | |
| 163 | delete(kv.data, key) |
| 164 | return nil |
| 165 | } |
| 166 | |
| 167 | var mockBackend = &db.Backend{Client: &mockKV{data: make(map[string]interface{})}} |
| 168 | |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 169 | func TestProxy_1_1_1_Add_NewDevice(t *testing.T) { |
| 170 | devIDBin, _ := uuid.New().MarshalBinary() |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 171 | TestProxyDeviceID = "0001" + hex.EncodeToString(devIDBin)[:12] |
| 172 | TestProxyDevice.Id = TestProxyDeviceID |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 173 | |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 174 | if err := TestProxyRootDevice.Set(context.Background(), TestProxyDeviceID, TestProxyDevice); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 175 | BenchmarkProxyLogger.Errorf("Failed to add test proxy device due to error: %v", err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 176 | t.Errorf("failed to add device: %s", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 177 | } |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 178 | t.Logf("Added device : %+v", TestProxyDevice.Id) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 179 | |
| 180 | // Verify that the added device can now be retrieved |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 181 | d := &voltha.Device{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 182 | if have, err := TestProxyRootDevice.Get(context.Background(), TestProxyDeviceID, d); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 183 | BenchmarkProxyLogger.Errorf("Failed get device info from test proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 184 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 185 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 186 | t.Error("Failed to find added device") |
| 187 | } else { |
| 188 | djson, _ := json.Marshal(d) |
| 189 | t.Logf("Found device: %s", string(djson)) |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | func TestProxy_1_1_2_Add_ExistingDevice(t *testing.T) { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 194 | TestProxyDevice.Id = TestProxyDeviceID |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 195 | |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 196 | if err := TestProxyRootDevice.Set(context.Background(), "devices", TestProxyDevice); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 197 | BenchmarkProxyLogger.Errorf("Failed to add device to test proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 198 | assert.NotNil(t, err) |
| 199 | } |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 200 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 201 | d := &voltha.Device{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 202 | if have, err := TestProxyRootDevice.Get(context.Background(), TestProxyDeviceID, d); err != nil { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 203 | BenchmarkProxyLogger.Errorf("Failed get device info from test proxy due to error: %v", err) |
| 204 | assert.NotNil(t, err) |
| 205 | } else if !have { |
| 206 | t.Error("Failed to find added device") |
| 207 | } else { |
| 208 | if d.String() != TestProxyDevice.String() { |
| 209 | t.Errorf("Devices don't match - existing: %+v returned: %+v", TestProxyLogicalDevice, d) |
| 210 | } |
| 211 | djson, _ := json.Marshal(d) |
| 212 | t.Logf("Found device: %s", string(djson)) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 213 | } |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 214 | |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | func TestProxy_1_1_3_Add_NewAdapter(t *testing.T) { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 218 | TestProxyAdapterID = "test-adapter" |
| 219 | TestProxyAdapter.Id = TestProxyAdapterID |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 220 | |
| 221 | // Add the adapter |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 222 | if err := TestProxyRootAdapter.Set(context.Background(), TestProxyAdapterID, TestProxyAdapter); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 223 | BenchmarkProxyLogger.Errorf("Failed to add adapter to test proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 224 | assert.NotNil(t, err) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 225 | } else { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 226 | t.Logf("Added adapter : %+v", TestProxyAdapter.Id) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 227 | } |
| 228 | |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 229 | // Verify that the added device can now be retrieved |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 230 | d := &voltha.Device{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 231 | if have, err := TestProxyRootAdapter.Get(context.Background(), TestProxyAdapterID, d); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 232 | BenchmarkProxyLogger.Errorf("Failed to retrieve device info from test proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 233 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 234 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 235 | t.Error("Failed to find added adapter") |
| 236 | } else { |
| 237 | djson, _ := json.Marshal(d) |
| 238 | t.Logf("Found adapter: %s", string(djson)) |
| 239 | } |
| 240 | |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | func TestProxy_1_2_1_Get_AllDevices(t *testing.T) { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 244 | var devices []*voltha.Device |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 245 | if err := TestProxyRootDevice.List(context.Background(), &devices); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 246 | BenchmarkProxyLogger.Errorf("Failed to get all devices info from test proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 247 | assert.NotNil(t, err) |
| 248 | } |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 249 | if len(devices) == 0 { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 250 | t.Error("there are no available devices to retrieve") |
| 251 | } else { |
| 252 | // Save the target device id for later tests |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 253 | TestProxyTargetDeviceID = devices[0].Id |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 254 | t.Logf("retrieved all devices: %+v", devices) |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | func TestProxy_1_2_2_Get_SingleDevice(t *testing.T) { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 259 | d := &voltha.Device{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 260 | if have, err := TestProxyRootDevice.Get(context.Background(), TestProxyTargetDeviceID, d); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 261 | BenchmarkProxyLogger.Errorf("Failed to get single device info from test proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 262 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 263 | } else if !have { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 264 | t.Errorf("Failed to find device : %s", TestProxyTargetDeviceID) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 265 | } else { |
| 266 | djson, _ := json.Marshal(d) |
| 267 | t.Logf("Found device: %s", string(djson)) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | func TestProxy_1_3_1_Update_Device(t *testing.T) { |
| 272 | var fwVersion int |
| 273 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 274 | retrieved := &voltha.Device{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 275 | if have, err := TestProxyRootDevice.Get(context.Background(), TestProxyTargetDeviceID, retrieved); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 276 | BenchmarkProxyLogger.Errorf("Failed to get device info from test proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 277 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 278 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 279 | t.Error("Failed to get device") |
| 280 | } else { |
| 281 | t.Logf("Found raw device (root proxy): %+v", retrieved) |
| 282 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 283 | if retrieved.FirmwareVersion == "n/a" { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 284 | fwVersion = 0 |
| 285 | } else { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 286 | fwVersion, _ = strconv.Atoi(retrieved.FirmwareVersion) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 287 | fwVersion++ |
| 288 | } |
| 289 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 290 | retrieved.FirmwareVersion = strconv.Itoa(fwVersion) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 291 | |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 292 | if err := TestProxyRootDevice.Set(context.Background(), TestProxyTargetDeviceID, retrieved); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 293 | BenchmarkProxyLogger.Errorf("Failed to update device info test proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 294 | assert.NotNil(t, err) |
| 295 | } |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 296 | afterUpdate := &voltha.Device{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 297 | if have, err := TestProxyRootDevice.Get(context.Background(), TestProxyTargetDeviceID, afterUpdate); err != nil { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 298 | BenchmarkProxyLogger.Errorf("Failed to get device info from test proxy due to error: %v", err) |
| 299 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 300 | t.Error("Failed to update device") |
| 301 | } else { |
| 302 | t.Logf("Updated device : %+v", afterUpdate) |
| 303 | } |
| 304 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 305 | d := &voltha.Device{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 306 | if have, err := TestProxyRootDevice.Get(context.Background(), TestProxyTargetDeviceID, d); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 307 | BenchmarkProxyLogger.Errorf("Failed to get device info from test proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 308 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 309 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 310 | t.Error("Failed to find updated device (root proxy)") |
| 311 | } else { |
| 312 | djson, _ := json.Marshal(d) |
| 313 | t.Logf("Found device (root proxy): %s raw: %+v", string(djson), d) |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 318 | func TestProxy_1_3_3_Update_Adapter(t *testing.T) { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 319 | |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 320 | adaptersProxy := NewDBPath(mockBackend).Proxy("adapters") |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 321 | |
| 322 | retrieved := &voltha.Adapter{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 323 | if have, err := TestProxyRootAdapter.Get(context.Background(), TestProxyAdapterID, retrieved); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 324 | BenchmarkProxyLogger.Errorf("Failed to retrieve adapter info from adapters proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 325 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 326 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 327 | t.Error("Failed to get adapter") |
| 328 | } else { |
| 329 | t.Logf("Found raw adapter (root proxy): %+v", retrieved) |
| 330 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 331 | retrieved.Version = "test-adapter-version-2" |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 332 | |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 333 | if err := adaptersProxy.Set(context.Background(), TestProxyAdapterID, retrieved); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 334 | BenchmarkProxyLogger.Errorf("Failed to update adapter info in adapters proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 335 | assert.NotNil(t, err) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 336 | } else { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 337 | t.Logf("Updated adapter : %s", retrieved.Id) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 338 | } |
| 339 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 340 | d := &voltha.Adapter{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 341 | if have, err := TestProxyRootAdapter.Get(context.Background(), TestProxyAdapterID, d); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 342 | BenchmarkProxyLogger.Errorf("Failed to get updated adapter info from adapters proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 343 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 344 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 345 | t.Error("Failed to find updated adapter (root proxy)") |
| 346 | } else { |
| 347 | djson, _ := json.Marshal(d) |
| 348 | t.Logf("Found adapter (root proxy): %s raw: %+v", string(djson), d) |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | func TestProxy_1_4_1_Remove_Device(t *testing.T) { |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 354 | if err := TestProxyRootDevice.Remove(context.Background(), TestProxyDeviceID); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 355 | BenchmarkProxyLogger.Errorf("Failed to remove device from devices proxy due to error: %v", err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 356 | t.Errorf("failed to remove device: %s", err) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 357 | } else { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 358 | t.Logf("Removed device : %+v", TestProxyDeviceID) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 359 | } |
| 360 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 361 | d := &voltha.Device{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 362 | have, err := TestProxyRootDevice.Get(context.Background(), TestProxyDeviceID, d) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 363 | if err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 364 | BenchmarkProxyLogger.Errorf("Failed to get device info from devices proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 365 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 366 | } else if have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 367 | djson, _ := json.Marshal(d) |
| 368 | t.Errorf("Device was not removed - %s", djson) |
| 369 | } else { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 370 | t.Logf("Device was removed: %s", TestProxyDeviceID) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 371 | } |
| 372 | } |
| 373 | |
| 374 | func TestProxy_2_1_1_Add_NewLogicalDevice(t *testing.T) { |
| 375 | |
| 376 | ldIDBin, _ := uuid.New().MarshalBinary() |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 377 | TestProxyLogicalDeviceID = "0001" + hex.EncodeToString(ldIDBin)[:12] |
| 378 | TestProxyLogicalDevice.Id = TestProxyLogicalDeviceID |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 379 | |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 380 | if err := TestProxyRootLogicalDevice.Set(context.Background(), TestProxyLogicalDeviceID, TestProxyLogicalDevice); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 381 | BenchmarkProxyLogger.Errorf("Failed to add new logical device into proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 382 | assert.NotNil(t, err) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 383 | } else { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 384 | t.Logf("Added logical device : %s", TestProxyLogicalDevice.Id) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 385 | } |
| 386 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 387 | ld := &voltha.LogicalDevice{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 388 | if have, err := TestProxyRootLogicalDevice.Get(context.Background(), TestProxyLogicalDeviceID, ld); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 389 | BenchmarkProxyLogger.Errorf("Failed to get logical device info from logical device proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 390 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 391 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 392 | t.Error("Failed to find added logical device") |
| 393 | } else { |
| 394 | ldJSON, _ := json.Marshal(ld) |
| 395 | t.Logf("Found logical device: %s", string(ldJSON)) |
| 396 | } |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | func TestProxy_2_1_2_Add_ExistingLogicalDevice(t *testing.T) { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 400 | TestProxyLogicalDevice.Id = TestProxyLogicalDeviceID |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 401 | |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 402 | if err := TestProxyRootLogicalDevice.Set(context.Background(), "logical_devices", TestProxyLogicalDevice); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 403 | BenchmarkProxyLogger.Errorf("Failed to add logical device due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 404 | assert.NotNil(t, err) |
| 405 | } |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 406 | |
| 407 | device := &voltha.LogicalDevice{} |
| 408 | if have, err := TestProxyRootLogicalDevice.Get(context.Background(), "logical_devices", device); err != nil { |
| 409 | BenchmarkProxyLogger.Errorf("Failed to get logical device info from logical device proxy due to error: %v", err) |
| 410 | assert.NotNil(t, err) |
| 411 | } else if !have { |
| 412 | t.Error("Failed to find added logical device") |
| 413 | } else { |
| 414 | if device.String() != TestProxyLogicalDevice.String() { |
| 415 | t.Errorf("Logical devices don't match - existing: %+v returned: %+v", TestProxyLogicalDevice, device) |
| 416 | } |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 417 | } |
| 418 | } |
| 419 | |
| 420 | func TestProxy_2_2_1_Get_AllLogicalDevices(t *testing.T) { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 421 | var logicalDevices []*voltha.LogicalDevice |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 422 | if err := TestProxyRootLogicalDevice.List(context.Background(), &logicalDevices); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 423 | BenchmarkProxyLogger.Errorf("Failed to get all logical devices from proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 424 | assert.NotNil(t, err) |
| 425 | } |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 426 | if len(logicalDevices) == 0 { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 427 | t.Error("there are no available logical devices to retrieve") |
| 428 | } else { |
| 429 | // Save the target device id for later tests |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 430 | TestProxyTargetLogicalDeviceID = logicalDevices[0].Id |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 431 | t.Logf("retrieved all logical devices: %+v", logicalDevices) |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | func TestProxy_2_2_2_Get_SingleLogicalDevice(t *testing.T) { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 436 | ld := &voltha.LogicalDevice{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 437 | if have, err := TestProxyRootLogicalDevice.Get(context.Background(), TestProxyTargetLogicalDeviceID, ld); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 438 | BenchmarkProxyLogger.Errorf("Failed to get single logical device from proxy due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 439 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 440 | } else if !have { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 441 | t.Errorf("Failed to find logical device : %s", TestProxyTargetLogicalDeviceID) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 442 | } else { |
| 443 | ldJSON, _ := json.Marshal(ld) |
| 444 | t.Logf("Found logical device: %s", string(ldJSON)) |
| 445 | } |
| 446 | |
| 447 | } |
| 448 | |
| 449 | func TestProxy_2_3_1_Update_LogicalDevice(t *testing.T) { |
| 450 | var fwVersion int |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 451 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 452 | retrieved := &voltha.LogicalDevice{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 453 | if have, err := TestProxyRootLogicalDevice.Get(context.Background(), TestProxyTargetLogicalDeviceID, retrieved); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 454 | BenchmarkProxyLogger.Errorf("Failed to get logical devices due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 455 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 456 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 457 | t.Error("Failed to get logical device") |
| 458 | } else { |
| 459 | t.Logf("Found raw logical device (root proxy): %+v", retrieved) |
| 460 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 461 | if retrieved.RootDeviceId == "" { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 462 | fwVersion = 0 |
| 463 | } else { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 464 | fwVersion, _ = strconv.Atoi(retrieved.RootDeviceId) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 465 | fwVersion++ |
| 466 | } |
| 467 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 468 | retrieved.RootDeviceId = strconv.Itoa(fwVersion) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 469 | |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 470 | if err := TestProxyRootLogicalDevice.Set(context.Background(), TestProxyTargetLogicalDeviceID, retrieved); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 471 | BenchmarkProxyLogger.Errorf("Faield to update logical device info due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 472 | assert.NotNil(t, err) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 473 | } else { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 474 | t.Log("Updated logical device") |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 475 | } |
| 476 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 477 | d := &voltha.LogicalDevice{} |
Kent Hagerman | f5a6735 | 2020-04-30 15:15:26 -0400 | [diff] [blame] | 478 | if have, err := TestProxyRootLogicalDevice.Get(context.Background(), TestProxyTargetLogicalDeviceID, d); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 479 | BenchmarkProxyLogger.Errorf("Failed to get logical device info due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 480 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 481 | } else if !have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 482 | t.Error("Failed to find updated logical device (root proxy)") |
| 483 | } else { |
| 484 | djson, _ := json.Marshal(d) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 485 | t.Logf("Found logical device (root proxy): %s raw: %+v", string(djson), d) |
| 486 | } |
| 487 | } |
| 488 | } |
| 489 | |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 490 | func TestProxy_2_4_1_Remove_Device(t *testing.T) { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 491 | if err := TestProxyRootLogicalDevice.Remove(context.Background(), "logical_devices/"+TestProxyLogicalDeviceID); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 492 | BenchmarkProxyLogger.Errorf("Failed to remove device from logical devices proxy due to error: %v", err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 493 | t.Errorf("Failed to remove logical device: %s", err) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 494 | } else { |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 495 | t.Logf("Removed device : %+v", TestProxyLogicalDeviceID) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 496 | } |
| 497 | |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 498 | d := &voltha.LogicalDevice{} |
| 499 | if have, err := TestProxyRootLogicalDevice.Get(context.Background(), "logical_devices/"+TestProxyLogicalDeviceID, d); err != nil { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 500 | BenchmarkProxyLogger.Errorf("Failed to get logical device info due to error: %v", err) |
Thomas Lee S | e5a4401 | 2019-11-07 20:32:24 +0530 | [diff] [blame] | 501 | assert.NotNil(t, err) |
Kent Hagerman | 4f355f5 | 2020-03-30 16:01:33 -0400 | [diff] [blame] | 502 | } else if have { |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 503 | djson, _ := json.Marshal(d) |
| 504 | t.Errorf("Device was not removed - %s", djson) |
| 505 | } else { |
npujar | 9a30c70 | 2019-11-14 17:06:39 +0530 | [diff] [blame] | 506 | t.Logf("Device was removed: %s", TestProxyLogicalDeviceID) |
sbarbari | 17d7e22 | 2019-11-05 10:02:29 -0500 | [diff] [blame] | 507 | } |
| 508 | } |