VOL-3504 Code changes to support force delete
Change-Id: I041ab2101a607b99e0372e432819a3f10f3a774c
diff --git a/rw_core/mocks/adapter.go b/rw_core/mocks/adapter.go
index 26f796fa4..c01fc70 100644
--- a/rw_core/mocks/adapter.go
+++ b/rw_core/mocks/adapter.go
@@ -45,13 +45,14 @@
// Adapter represents adapter attributes
type Adapter struct {
- coreProxy adapterif.CoreProxy
- flows map[uint64]*voltha.OfpFlowStats
- flowLock sync.RWMutex
- devices map[string]*voltha.Device
- deviceLock sync.RWMutex
- failFlowAdd bool
- failFlowDelete bool
+ coreProxy adapterif.CoreProxy
+ flows map[uint64]*voltha.OfpFlowStats
+ flowLock sync.RWMutex
+ devices map[string]*voltha.Device
+ deviceLock sync.RWMutex
+ failFlowAdd bool
+ failFlowDelete bool
+ failDeleteDevice bool
}
// NewAdapter creates adapter instance
@@ -133,6 +134,9 @@
// Delete_device -
func (ta *Adapter) Delete_device(ctx context.Context, device *voltha.Device) error { // nolint
+ if ta.failDeleteDevice {
+ return fmt.Errorf("delete-device-failure")
+ }
return nil
}
@@ -284,3 +288,8 @@
ta.failFlowAdd = failFlowAdd
ta.failFlowDelete = failFlowDelete
}
+
+// SetDeleteAction sets the adapter action on delete device
+func (ta *Adapter) SetDeleteAction(failDeleteDevice bool) {
+ ta.failDeleteDevice = failDeleteDevice
+}