VOL-3356 - Changed the way devices are updated.
so that state transitions will execute in the calling thread.
Also changed the locking guarantees when accessing devices.
Change-Id: I0d40215bf35ffafd2ee4fcef6b34515001adcc9c
diff --git a/rw_core/core/device/agent_test.go b/rw_core/core/device/agent_test.go
index 92977ac..9249198 100755
--- a/rw_core/core/device/agent_test.go
+++ b/rw_core/core/device/agent_test.go
@@ -18,6 +18,7 @@
import (
"context"
+ "fmt"
"math/rand"
"sort"
"strconv"
@@ -244,6 +245,8 @@
updatedDevice, _ := da.getDevice(context.Background())
updatedDevicePorts := da.listDevicePorts()
assert.NotNil(t, updatedDevice)
+ fmt.Printf("1 %+v\n", expectedChange)
+ fmt.Printf("2 %+v\n", updatedDevice)
assert.True(t, proto.Equal(expectedChange, updatedDevice))
assert.Equal(t, len(originalDevicePorts)+1, len(updatedDevicePorts))
assert.True(t, proto.Equal(updatedDevicePorts[portToAdd.PortNo], portToAdd))
@@ -284,9 +287,12 @@
da.oltAdapter, da.onuAdapter = tst.CreateAndregisterAdapters(ctx, t, da.kClient, da.coreInstanceID, da.oltAdapterName, da.onuAdapterName, da.adapterMgr)
a := da.createDeviceAgent(t)
- cloned := a.getDeviceWithoutLock()
- err := a.updateDeviceStateInStoreWithoutLock(ctx, cloned, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
- assert.Nil(t, err)
+ err1 := a.requestQueue.WaitForGreenLight(ctx)
+ assert.Nil(t, err1)
+ cloned := a.cloneDeviceWithoutLock()
+ cloned.AdminState, cloned.ConnectStatus, cloned.OperStatus = voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE
+ err2 := a.updateDeviceAndReleaseLock(ctx, cloned)
+ assert.Nil(t, err2)
da.testFlowAddDeletes(t, a)
}
@@ -300,9 +306,12 @@
da.startCore(ctx)
da.oltAdapter, da.onuAdapter = tst.CreateAndregisterAdapters(ctx, t, da.kClient, da.coreInstanceID, da.oltAdapterName, da.onuAdapterName, da.adapterMgr)
a := da.createDeviceAgent(t)
- cloned := a.getDeviceWithoutLock()
- err := a.updateDeviceStateInStoreWithoutLock(ctx, cloned, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
- assert.Nil(t, err)
+ err1 := a.requestQueue.WaitForGreenLight(ctx)
+ assert.Nil(t, err1)
+ cloned := a.cloneDeviceWithoutLock()
+ cloned.AdminState, cloned.ConnectStatus, cloned.OperStatus = voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE
+ err2 := a.updateDeviceAndReleaseLock(ctx, cloned)
+ assert.Nil(t, err2)
da.testGroupAddDeletes(t, a)
}