VOL-1774 Etcd Crash Handling
Change-Id: I1eeb726654c3972fd0a4fafae134607e5a810415
diff --git a/db/model/proxy_load_test.go b/db/model/proxy_load_test.go
index 3f3327b..e5ae1c1 100644
--- a/db/model/proxy_load_test.go
+++ b/db/model/proxy_load_test.go
@@ -23,6 +23,7 @@
"github.com/opencord/voltha-protos/v2/go/common"
"github.com/opencord/voltha-protos/v2/go/openflow_13"
"github.com/opencord/voltha-protos/v2/go/voltha"
+ "github.com/stretchr/testify/assert"
"math/rand"
"reflect"
"strconv"
@@ -81,6 +82,7 @@
}
func init() {
+ var err error
BenchmarkProxy_Root = NewRoot(&voltha.Voltha{}, nil)
BenchmarkProxy_Logger, _ = log.AddPackage(log.JSON, log.DebugLevel, log.Fields{"instanceId": "PLT"})
@@ -96,7 +98,9 @@
}
log.SetPackageLogLevel("github.com/opencord/voltha-go/db/model", log.DebugLevel)
- BenchmarkProxy_DeviceProxy = BenchmarkProxy_Root.node.CreateProxy(context.Background(), "/", false)
+ if BenchmarkProxy_DeviceProxy, err = BenchmarkProxy_Root.node.CreateProxy(context.Background(), "/", false); err != nil {
+ log.With(log.Fields{"error": err}).Fatal("Cannot create benchmark proxy")
+ }
// Register ADD instructions callbacks
BenchmarkProxy_PLT = &proxyLoadTest{}
@@ -110,6 +114,7 @@
}
func BenchmarkProxy_AddDevice(b *testing.B) {
+ var err error
defer GetProfiling().Report()
b.RunParallel(func(pb *testing.PB) {
b.Log("Started adding devices")
@@ -150,7 +155,10 @@
var added interface{}
// Add the device
- if added = BenchmarkProxy_DeviceProxy.AddWithID(context.Background(), "/devices", ltDevID, ltDevice, ""); added == nil {
+ if added, err = BenchmarkProxy_DeviceProxy.AddWithID(context.Background(), "/devices", ltDevID, ltDevice, ""); err != nil {
+ log.With(log.Fields{"error": err}).Fatal("Cannot create proxy")
+ }
+ if added == nil {
BenchmarkProxy_Logger.Errorf("Failed to add device: %+v", ltDevice)
continue
} else {
@@ -174,9 +182,17 @@
if len(BenchmarkProxy_PLT.addedDevices) > 0 {
var target interface{}
randomID := BenchmarkProxy_PLT.addedDevices[rand.Intn(len(BenchmarkProxy_PLT.addedDevices))]
- firmProxy := BenchmarkProxy_Root.node.CreateProxy(context.Background(), "/", false)
- if target = firmProxy.Get(context.Background(), "/devices/"+randomID, 0, false,
- ""); !reflect.ValueOf(target).IsValid() {
+ firmProxy, err := BenchmarkProxy_Root.node.CreateProxy(context.Background(), "/", false)
+ if err != nil {
+ log.With(log.Fields{"error": err}).Fatal("Cannot create firmware proxy")
+ }
+ target, err = firmProxy.Get(context.Background(), "/devices/"+randomID, 0, false,
+ "")
+ if err != nil {
+ BenchmarkProxy_Logger.Errorf("Failed to create target due to error %v", err)
+ assert.NotNil(b, err)
+ }
+ if !reflect.ValueOf(target).IsValid() {
BenchmarkProxy_Logger.Errorf("Failed to find device: %s %+v", randomID, target)
continue
}
@@ -200,8 +216,11 @@
after := target.(*voltha.Device).FirmwareVersion
var updated interface{}
- if updated = firmProxy.Update(context.Background(), "/devices/"+randomID, target.(*voltha.Device), false,
- ""); updated == nil {
+ if updated, err = firmProxy.Update(context.Background(), "/devices/"+randomID, target.(*voltha.Device), false, ""); err != nil {
+ BenchmarkProxy_Logger.Errorf("Failed to update firmware proxy due to error %v", err)
+ assert.NotNil(b, err)
+ }
+ if updated == nil {
BenchmarkProxy_Logger.Errorf("Failed to update device: %+v", target)
continue
} else {
@@ -209,8 +228,12 @@
}
- if d := firmProxy.Get(context.Background(), "/devices/"+randomID, 0, false,
- ""); !reflect.ValueOf(d).IsValid() {
+ d, err := firmProxy.Get(context.Background(), "/devices/"+randomID, 0, false, "")
+ if err != nil {
+ BenchmarkProxy_Logger.Errorf("Failed to get device info from firmware proxy due to error %v", err)
+ assert.NotNil(b, err)
+ }
+ if !reflect.ValueOf(d).IsValid() {
BenchmarkProxy_Logger.Errorf("Failed to get device: %s", randomID)
continue
} else if d.(*voltha.Device).FirmwareVersion == after {
@@ -264,8 +287,15 @@
if len(BenchmarkProxy_PLT.addedDevices) > 0 {
randomID := BenchmarkProxy_PLT.addedDevices[rand.Intn(len(BenchmarkProxy_PLT.addedDevices))]
- flowsProxy := BenchmarkProxy_Root.node.CreateProxy(context.Background(), "/devices/"+randomID+"/flows", false)
- flows := flowsProxy.Get(context.Background(), "/", 0, false, "")
+ flowsProxy, err := BenchmarkProxy_Root.node.CreateProxy(context.Background(), "/devices/"+randomID+"/flows", false)
+ if err != nil {
+ log.With(log.Fields{"error": err}).Fatal("Cannot create flows proxy")
+ }
+ flows, err := flowsProxy.Get(context.Background(), "/", 0, false, "")
+ if err != nil {
+ BenchmarkProxy_Logger.Errorf("Failed to get flows from flows proxy due to error: %v", err)
+ assert.NotNil(b, err)
+ }
before := flows.(*openflow_13.Flows).Items[0].TableId
flows.(*openflow_13.Flows).Items[0].TableId = uint32(rand.Intn(3000))
@@ -281,7 +311,11 @@
)
var updated interface{}
- if updated = flowsProxy.Update(context.Background(), "/", flows.(*openflow_13.Flows), false, ""); updated == nil {
+ if updated, err = flowsProxy.Update(context.Background(), "/", flows.(*openflow_13.Flows), false, ""); err != nil {
+ BenchmarkProxy_Logger.Errorf("Cannot update flows proxy due to error: %v", err)
+ assert.NotNil(b, err)
+ }
+ if updated == nil {
b.Errorf("Failed to update flows for device: %+v", flows)
} else {
BenchmarkProxy_Logger.Infof("Flows were updated : %+v", updated)
@@ -303,8 +337,12 @@
for i := 0; i < len(BenchmarkProxy_PLT.addedDevices); i++ {
devToGet := BenchmarkProxy_PLT.addedDevices[i]
// Verify that the added device can now be retrieved
- if d := BenchmarkProxy_DeviceProxy.Get(context.Background(), "/devices/"+devToGet, 0, false,
- ""); !reflect.ValueOf(d).IsValid() {
+ d, err := BenchmarkProxy_DeviceProxy.Get(context.Background(), "/devices/"+devToGet, 0, false, "")
+ if err != nil {
+ BenchmarkProxy_Logger.Errorf("Failed to get device info from device proxy due to error: %v", err)
+ assert.NotNil(b, err)
+ }
+ if !reflect.ValueOf(d).IsValid() {
BenchmarkProxy_Logger.Errorf("Failed to get device: %s", devToGet)
continue
} else {
@@ -317,8 +355,12 @@
for i := 0; i < len(BenchmarkProxy_PLT.updatedFirmwares); i++ {
devToGet := BenchmarkProxy_PLT.updatedFirmwares[i].ID
// Verify that the updated device can be retrieved and that the updates were actually applied
- if d := BenchmarkProxy_DeviceProxy.Get(context.Background(), "/devices/"+devToGet, 0, false,
- ""); !reflect.ValueOf(d).IsValid() {
+ d, err := BenchmarkProxy_DeviceProxy.Get(context.Background(), "/devices/"+devToGet, 0, false, "")
+ if err != nil {
+ BenchmarkProxy_Logger.Errorf("Failed to get device info from device proxy due to error: %v", err)
+ assert.NotNil(b, err)
+ }
+ if !reflect.ValueOf(d).IsValid() {
BenchmarkProxy_Logger.Errorf("Failed to get device: %s", devToGet)
continue
} else if d.(*voltha.Device).FirmwareVersion == BenchmarkProxy_PLT.updatedFirmwares[i].After.(string) {