VOL-4312: Reboot OLT test fails on Edgecore GPON ASGvOLT64 OLT
- Fixed issue where 'N*N' (where N is the number of PON ports)
  number of TP Managers were getting created for an OLT device
  instead of just 'N' TP managers.
  It was seen that after OLT reboot burst of conncurrent TP
  managers (N*N) were trying to create etcd pool connections
  and at some point the etcd stopped responding and this lead
  re-connection handling to OLT after reboot failing.

VOL-4313: Stop stale go routines on monitoring flow and group
messages for the ONUs after OLT reboot or OLT delete
- There are stale go routines for the ONU monitoring for flow
  and group messages. Although these never caused problem it
  is always recomendded to stop such routines as they consume
  memory and cpu.

Change-Id: Ie4d1ce9155dbd15e1831361d50cb959402045cc8
diff --git a/internal/pkg/core/device_handler_test.go b/internal/pkg/core/device_handler_test.go
index 57103c4..f021312 100644
--- a/internal/pkg/core/device_handler_test.go
+++ b/internal/pkg/core/device_handler_test.go
@@ -234,12 +234,16 @@
 		// Create a slice of buffered channels for handling concurrent flows per ONU.
 		// The additional entry (+1) is to handle the NNI trap flows on a separate channel from individual ONUs channel
 		dh.flowMgr[i].incomingFlows = make([]chan flowControlBlock, MaxOnusPerPon+1)
+		dh.flowMgr[i].stopFlowHandlerRoutine = make([]chan bool, MaxOnusPerPon+1)
+		dh.flowMgr[i].flowHandlerRoutineActive = make([]bool, MaxOnusPerPon+1)
 		for j := range dh.flowMgr[i].incomingFlows {
 			dh.flowMgr[i].incomingFlows[j] = make(chan flowControlBlock, maxConcurrentFlowsPerOnu)
+			dh.flowMgr[i].stopFlowHandlerRoutine[j] = make(chan bool, 1)
 			// Spin up a go routine to handling incoming flows (add/remove).
 			// There will be on go routine per ONU.
 			// This routine will be blocked on the flowMgr.incomingFlows[onu-id] channel for incoming flows.
-			go dh.flowMgr[i].perOnuFlowHandlerRoutine(dh.flowMgr[i].incomingFlows[j])
+			dh.flowMgr[i].flowHandlerRoutineActive[j] = true
+			go dh.flowMgr[i].perOnuFlowHandlerRoutine(j, dh.flowMgr[i].incomingFlows[j], dh.flowMgr[i].stopFlowHandlerRoutine[j])
 		}
 		dh.flowMgr[i].onuGemInfoMap = make(map[uint32]*resourcemanager.OnuGemInfo)
 	}