RICPLT-3059 multi e2term crash in rmr library

Change-Id: I0b3c44d6767c891561a8fab4d2271137d4044f15
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go
index 5d57832..53d8a85 100644
--- a/pkg/control/ut_messaging_test.go
+++ b/pkg/control/ut_messaging_test.go
@@ -61,7 +61,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -106,14 +106,14 @@
 	cretrans := xappConn1.SendSubsReq(t, nil, nil)
 	waiter.WaitResult(t)
 
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
 
 	waiter = rtmgrHttp.AllocNextEvent(true)
-	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 	xappConn1.RecvSubsDelResp(t, deltrans)
 	waiter.WaitResult(t)
 
@@ -122,7 +122,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -159,19 +159,19 @@
 
 	//Subs Create
 	cretrans := xappConn1.SendSubsReq(t, nil, nil)
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
 
 	seqBef := mainCtrl.get_msgcounter(t)
 	xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
 	mainCtrl.wait_msgcounter_change(t, seqBef, 10)
 
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	//Subs Delete
 	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	//Wait that subs is cleaned
@@ -179,7 +179,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -217,19 +217,19 @@
 
 	//Subs Create
 	cretrans := xappConn1.SendSubsReq(t, nil, nil)
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	//Subs Delete
 	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
 
 	seqBef := mainCtrl.get_msgcounter(t)
 	xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
 	mainCtrl.wait_msgcounter_change(t, seqBef, 10)
 
-	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	//Wait that subs is cleaned
@@ -237,7 +237,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -279,13 +279,13 @@
 
 	//Subs Create
 	cretrans := xappConn1.SendSubsReq(t, nil, nil)
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	//Subs Delete
 	xappConn1.SendSubsDelReq(t, nil, e2SubsId)
-	delreq1, delmsg1 := e2termConn.RecvSubsDelReq(t)
+	delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
 
 	// Subs Delete colliding
 	seqBef := mainCtrl.get_msgcounter(t)
@@ -294,7 +294,7 @@
 	mainCtrl.wait_msgcounter_change(t, seqBef, 10)
 
 	// Del resp for first and second
-	e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
+	e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
 
 	// don't care in which order responses are received
 	xappConn1.RecvSubsDelResp(t, nil)
@@ -305,46 +305,46 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelOkTwoParallel
 //
-//   stub                          stub
-// +-------+     +---------+    +---------+
-// | xapp  |     | submgr  |    | e2term  |
-// +-------+     +---------+    +---------+
-//     |              |              |
-//     |              |              |
-//     |              |              |
-//     | SubReq1      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq1      |
-//     |              |------------->|
-//     |              |              |
-//     | SubReq2      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq2      |
-//     |              |------------->|
-//     |              |              |
-//     |              |    SubResp1  |
-//     |              |<-------------|
-//     |              |    SubResp2  |
-//     |              |<-------------|
-//     |              |              |
-//     |    SubResp1  |              |
-//     |<-------------|              |
-//     |    SubResp2  |              |
-//     |<-------------|              |
-//     |              |              |
-//     |        [SUBS 1 DELETE]      |
-//     |              |              |
-//     |        [SUBS 2 DELETE]      |
-//     |              |              |
+//   stub       stub                          stub
+// +-------+  +-------+     +---------+    +---------+
+// | xapp  |  | xapp  |     | submgr  |    | e2term  |
+// +-------+  +-------+     +---------+    +---------+
+//     |          |              |              |
+//     |          |              |              |
+//     |          |              |              |
+//     |          | SubReq1      |              |
+//     |          |------------->|              |
+//     |          |              |              |
+//     |          |              | SubReq1      |
+//     |          |              |------------->|
+//     |          |              |              |
+//     |       SubReq2           |              |
+//     |------------------------>|              |
+//     |          |              |              |
+//     |          |              | SubReq2      |
+//     |          |              |------------->|
+//     |          |              |              |
+//     |          |              |    SubResp1  |
+//     |          |              |<-------------|
+//     |          |    SubResp1  |              |
+//     |          |<-------------|              |
+//     |          |              |              |
+//     |          |              |    SubResp2  |
+//     |          |              |<-------------|
+//     |       SubResp2          |              |
+//     |<------------------------|              |
+//     |          |              |              |
+//     |          |        [SUBS 1 DELETE]      |
+//     |          |              |              |
+//     |          |        [SUBS 2 DELETE]      |
+//     |          |              |              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
@@ -355,42 +355,42 @@
 	rparams1.Init()
 	rparams1.Req.EventTriggerDefinition.ProcedureCode = 5
 	cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
-	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
+	crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
 
 	//Req2
 	rparams2 := &teststube2ap.E2StubSubsReqParams{}
 	rparams2.Init()
 	rparams2.Req.EventTriggerDefinition.ProcedureCode = 28
 	cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
-	crereq2, cremsg2 := e2termConn.RecvSubsReq(t)
+	crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
 
 	//Resp1
-	e2termConn.SendSubsResp(t, crereq1, cremsg1)
+	e2termConn1.SendSubsResp(t, crereq1, cremsg1)
 	e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
 
 	//Resp2
-	e2termConn.SendSubsResp(t, crereq2, cremsg2)
+	e2termConn1.SendSubsResp(t, crereq2, cremsg2)
 	e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
 
 	//Del1
 	deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
-	delreq1, delmsg1 := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
+	delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
 	xappConn1.RecvSubsDelResp(t, deltrans1)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
 
 	//Del2
 	deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
-	delreq2, delmsg2 := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq2, delmsg2)
+	delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
 	xappConn2.RecvSubsDelResp(t, deltrans2)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -441,22 +441,22 @@
 	//Req1
 	cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
 	xappConn1.SendSubsReq(t, nil, cretrans1)
-	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq1, cremsg1)
+	crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq1, cremsg1)
 	e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
 
 	//Req2
 	cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
 	xappConn1.SendSubsReq(t, nil, cretrans2)
-	crereq2, cremsg2 := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq2, cremsg2)
+	crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq2, cremsg2)
 	e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
 
 	//Del1
 	deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
 	xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
-	delreq1, delmsg1 := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
+	delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
 	xappConn1.RecvSubsDelResp(t, deltrans1)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
@@ -464,15 +464,15 @@
 	//Del2
 	deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
 	xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
-	delreq2, delmsg2 := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq2, delmsg2)
+	delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
 	xappConn1.RecvSubsDelResp(t, deltrans2)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -513,18 +513,18 @@
 	cretrans := xappConn1.SendSubsReq(t, nil, nil)
 
 	// E2t: Receive 1st SubsReq
-	e2termConn.RecvSubsReq(t)
+	e2termConn1.RecvSubsReq(t)
 
 	// E2t: Receive 2nd SubsReq and send SubsResp
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 
 	// Xapp: Receive SubsResp
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	// Wait that subs is cleaned
@@ -532,7 +532,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -576,21 +576,21 @@
 	xappConn1.SendSubsReq(t, nil, nil)
 
 	// E2t: Receive 1st SubsReq
-	e2termConn.RecvSubsReq(t)
+	e2termConn1.RecvSubsReq(t)
 
 	// E2t: Receive 2nd SubsReq
-	e2termConn.RecvSubsReq(t)
+	e2termConn1.RecvSubsReq(t)
 
 	// E2t: Send receive SubsDelReq and send SubsResp
-	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 
 	// Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, delreq.RequestId.Seq, 10)
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -631,23 +631,23 @@
 	xappConn1.SendSubsReq(t, nil, nil)
 
 	// E2t: Receive 1st SubsReq
-	e2termConn.RecvSubsReq(t)
+	e2termConn1.RecvSubsReq(t)
 
 	// E2t: Receive 2nd SubsReq
-	e2termConn.RecvSubsReq(t)
+	e2termConn1.RecvSubsReq(t)
 
 	// E2t: Receive 1st SubsDelReq
-	e2termConn.RecvSubsDelReq(t)
+	e2termConn1.RecvSubsDelReq(t)
 
 	// E2t: Receive 2nd SubsDelReq
-	delreq, _ := e2termConn.RecvSubsDelReq(t)
+	delreq, _ := e2termConn1.RecvSubsDelReq(t)
 
 	// Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, delreq.RequestId.Seq, 15)
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -682,10 +682,10 @@
 	cretrans := xappConn1.SendSubsReq(t, nil, nil)
 
 	// E2t: Receive SubsReq and send SubsFail
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
 	fparams := &teststube2ap.E2StubSubsFailParams{}
 	fparams.Set(crereq)
-	e2termConn.SendSubsFail(t, fparams, cremsg)
+	e2termConn1.SendSubsFail(t, fparams, cremsg)
 
 	// Xapp: Receive SubsFail
 	e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
@@ -695,7 +695,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -733,8 +733,8 @@
 
 	// Subs Create
 	cretrans := xappConn1.SendSubsReq(t, nil, nil)
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	// Subs Delete
@@ -742,11 +742,11 @@
 	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
 
 	// E2t: Receive 1st SubsDelReq
-	e2termConn.RecvSubsDelReq(t)
+	e2termConn1.RecvSubsDelReq(t)
 
 	// E2t: Receive 2nd SubsDelReq and send SubsDelResp
-	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 
 	// Xapp: Receive SubsDelResp
 	xappConn1.RecvSubsDelResp(t, deltrans)
@@ -756,7 +756,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -792,8 +792,8 @@
 
 	// Subs Create
 	cretrans := xappConn1.SendSubsReq(t, nil, nil)
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	// Subs Delete
@@ -801,10 +801,10 @@
 	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
 
 	// E2t: Receive 1st SubsDelReq
-	e2termConn.RecvSubsDelReq(t)
+	e2termConn1.RecvSubsDelReq(t)
 
 	// E2t: Receive 2nd SubsDelReq
-	e2termConn.RecvSubsDelReq(t)
+	e2termConn1.RecvSubsDelReq(t)
 
 	// Xapp: Receive SubsDelResp
 	xappConn1.RecvSubsDelResp(t, deltrans)
@@ -814,7 +814,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -850,16 +850,16 @@
 
 	// Subs Create
 	cretrans := xappConn1.SendSubsReq(t, nil, nil)
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	// Xapp: Send SubsDelReq
 	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
 
 	// E2t: Send receive SubsDelReq and send SubsDelFail
-	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelFail(t, delreq, delmsg)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelFail(t, delreq, delmsg)
 
 	// Xapp: Receive SubsDelResp
 	xappConn1.RecvSubsDelResp(t, deltrans)
@@ -869,7 +869,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -877,45 +877,45 @@
 // TestSubReqAndSubDelOkSameAction
 //
 //   stub                          stub
-// +-------+     +---------+    +---------+
-// | xapp  |     | submgr  |    | e2term  |
-// +-------+     +---------+    +---------+
-//     |              |              |
-//     |              |              |
-//     |              |              |
-//     | SubReq1      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq1      |
-//     |              |------------->|
-//     |              |    SubResp1  |
-//     |              |<-------------|
-//     |    SubResp1  |              |
-//     |<-------------|              |
-//     |              |              |
-//     | SubReq2      |              |
-//     |------------->|              |
-//     |              |              |
-//     |    SubResp2  |              |
-//     |<-------------|              |
-//     |              |              |
-//     | SubDelReq 1  |              |
-//     |------------->|              |
-//     |              |              |
-//     | SubDelResp 1 |              |
-//     |<-------------|              |
-//     |              |              |
-//     | SubDelReq 2  |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubDelReq 2  |
-//     |              |------------->|
-//     |              |              |
-//     |              | SubDelReq 2  |
-//     |              |------------->|
-//     |              |              |
-//     | SubDelResp 2 |              |
-//     |<-------------|              |
+// +-------+     +-------+     +---------+    +---------+
+// | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
+// +-------+     +-------+     +---------+    +---------+
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |             |              |    SubResp1  |
+//     |             |              |<-------------|
+//     |             |    SubResp1  |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |          SubReq2           |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |          SubResp2          |              |
+//     |<---------------------------|              |
+//     |             |              |              |
+//     |             | SubDelReq 1  |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             | SubDelResp 1 |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |         SubDelReq 2        |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |         SubDelResp 2       |              |
+//     |<---------------------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOkSameAction(t *testing.T) {
@@ -925,82 +925,82 @@
 	rparams1 := &teststube2ap.E2StubSubsReqParams{}
 	rparams1.Init()
 	cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
-	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq1, cremsg1)
+	crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq1, cremsg1)
 	e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
 
 	//Req2
 	rparams2 := &teststube2ap.E2StubSubsReqParams{}
 	rparams2.Init()
 	cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
-	//crereq2, cremsg2 := e2termConn.RecvSubsReq(t)
-	//e2termConn.SendSubsResp(t, crereq2, cremsg2)
+	//crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
+	//e2termConn1.SendSubsResp(t, crereq2, cremsg2)
 	e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
 
 	//Del1
 	deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
-	//e2termConn.RecvSubsDelReq(t)
-	//e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
+	//e2termConn1.RecvSubsDelReq(t)
+	//e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
 	xappConn1.RecvSubsDelResp(t, deltrans1)
 	//Wait that subs is cleaned
 	//mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
 
 	//Del2
 	deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
-	delreq2, delmsg2 := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq2, delmsg2)
+	delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
 	xappConn2.RecvSubsDelResp(t, deltrans2)
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelOkSameActionParallel
 //
-//   stub                          stub
-// +-------+     +---------+    +---------+
-// | xapp  |     | submgr  |    | e2term  |
-// +-------+     +---------+    +---------+
-//     |              |              |
-//     |              |              |
-//     |              |              |
-//     | SubReq1      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq1      |
-//     |              |------------->|
-//     | SubReq2      |              |
-//     |------------->|              |
-//     |              |    SubResp1  |
-//     |              |<-------------|
-//     |    SubResp1  |              |
-//     |<-------------|              |
-//     |              |              |
-//     |    SubResp2  |              |
-//     |<-------------|              |
-//     |              |              |
-//     | SubDelReq 1  |              |
-//     |------------->|              |
-//     |              |              |
-//     | SubDelResp 1 |              |
-//     |<-------------|              |
-//     |              |              |
-//     | SubDelReq 2  |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubDelReq 2  |
-//     |              |------------->|
-//     |              |              |
-//     |              | SubDelReq 2  |
-//     |              |------------->|
-//     |              |              |
-//     | SubDelResp 2 |              |
-//     |<-------------|              |
+//   stub          stub                          stub
+// +-------+     +-------+     +---------+    +---------+
+// | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
+// +-------+     +-------+     +---------+    +---------+
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |          SubReq2           |              |
+//     |--------------------------->|              |
+//     |             |              |    SubResp1  |
+//     |             |              |<-------------|
+//     |             |    SubResp1  |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |          SubResp2          |              |
+//     |<---------------------------|              |
+//     |             |              |              |
+//     |             | SubDelReq 1  |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             | SubDelResp 1 |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |         SubDelReq 2        |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |         SubDelResp 2       |              |
+//     |<---------------------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
@@ -1010,7 +1010,7 @@
 	rparams1 := &teststube2ap.E2StubSubsReqParams{}
 	rparams1.Init()
 	cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
-	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
+	crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
 
 	//Req2
 	rparams2 := &teststube2ap.E2StubSubsReqParams{}
@@ -1018,7 +1018,7 @@
 	cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
 
 	//Resp1
-	e2termConn.SendSubsResp(t, crereq1, cremsg1)
+	e2termConn1.SendSubsResp(t, crereq1, cremsg1)
 	e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
 
 	//Resp2
@@ -1030,8 +1030,8 @@
 
 	//Del2
 	deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
-	delreq2, delmsg2 := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq2, delmsg2)
+	delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
 	xappConn2.RecvSubsDelResp(t, deltrans2)
 
 	//Wait that subs is cleaned
@@ -1039,34 +1039,34 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelNokSameActionParallel
 //
-//   stub                          stub
-// +-------+     +---------+    +---------+
-// | xapp  |     | submgr  |    | e2term  |
-// +-------+     +---------+    +---------+
-//     |              |              |
-//     |              |              |
-//     |              |              |
-//     | SubReq1      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq1      |
-//     |              |------------->|
-//     | SubReq2      |              |
-//     |------------->|              |
-//     |              |    SubFail1  |
-//     |              |<-------------|
-//     |    SubFail1  |              |
-//     |<-------------|              |
-//     |              |              |
-//     |    SubFail2  |              |
-//     |<-------------|              |
+//   stub          stub                          stub
+// +-------+     +-------+     +---------+    +---------+
+// | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
+// +-------+     +-------+     +---------+    +---------+
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |          SubReq2           |              |
+//     |--------------------------->|              |
+//     |             |              |    SubFail1  |
+//     |             |              |<-------------|
+//     |             |    SubFail1  |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |          SubFail2          |              |
+//     |<---------------------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
@@ -1076,7 +1076,7 @@
 	rparams1 := &teststube2ap.E2StubSubsReqParams{}
 	rparams1.Init()
 	cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
-	crereq1, cremsg1 := e2termConn.RecvSubsReq(t)
+	crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
 
 	//Req2
 	rparams2 := &teststube2ap.E2StubSubsReqParams{}
@@ -1088,7 +1088,7 @@
 	//E2T Fail
 	fparams := &teststube2ap.E2StubSubsFailParams{}
 	fparams.Set(crereq1)
-	e2termConn.SendSubsFail(t, fparams, cremsg1)
+	e2termConn1.SendSubsFail(t, fparams, cremsg1)
 
 	//Fail1
 	e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
@@ -1100,37 +1100,37 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelNoAnswerSameActionParallel
 //
-//   stub                          stub
-// +-------+     +---------+    +---------+
-// | xapp  |     | submgr  |    | e2term  |
-// +-------+     +---------+    +---------+
-//     |              |              |
-//     |              |              |
-//     |              |              |
-//     | SubReq1      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq1      |
-//     |              |------------->|
-//     | SubReq2      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq1      |
-//     |              |------------->|
-//     |              |              |
-//     |              |              |
-//     |              | SubDelReq    |
-//     |              |------------->|
-//     |              |              |
-//     |              |   SubDelResp |
-//     |              |<-------------|
+//   stub          stub                          stub
+// +-------+     +-------+     +---------+    +---------+
+// | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
+// +-------+     +-------+     +---------+    +---------+
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |             | SubReq2      |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              | SubDelReq    |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              |   SubDelResp |
+//     |             |              |<-------------|
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
@@ -1141,7 +1141,7 @@
 	rparams1.Init()
 	xappConn1.SendSubsReq(t, rparams1, nil)
 
-	e2termConn.RecvSubsReq(t)
+	e2termConn1.RecvSubsReq(t)
 
 	//Req2
 	rparams2 := &teststube2ap.E2StubSubsReqParams{}
@@ -1151,17 +1151,17 @@
 	mainCtrl.wait_msgcounter_change(t, seqBef2, 10)
 
 	//Req1 (retransmitted)
-	e2termConn.RecvSubsReq(t)
+	e2termConn1.RecvSubsReq(t)
 
-	delreq1, delmsg1 := e2termConn.RecvSubsDelReq(t)
-	e2termConn.SendSubsDelResp(t, delreq1, delmsg1)
+	delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
 
 	//Wait that subs is cleaned
 	mainCtrl.wait_subs_clean(t, delreq1.RequestId.Seq, 10)
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 15)
 }
 
@@ -1208,13 +1208,13 @@
 	rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
 	cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
 
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
 
-	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	//Wait that subs is cleaned
@@ -1222,7 +1222,7 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }
 
@@ -1280,8 +1280,8 @@
 	rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
 	cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
 
-	crereq, cremsg := e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
 
 	//Policy change
@@ -1289,13 +1289,13 @@
 	rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
 	xappConn1.SendSubsReq(t, rparams1, cretrans)
 
-	crereq, cremsg = e2termConn.RecvSubsReq(t)
-	e2termConn.SendSubsResp(t, crereq, cremsg)
+	crereq, cremsg = e2termConn1.RecvSubsReq(t)
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
 	e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
 	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
-	delreq, delmsg := e2termConn.RecvSubsDelReq(t)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
 
-	e2termConn.SendSubsDelResp(t, delreq, delmsg)
+	e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 	xappConn1.RecvSubsDelResp(t, deltrans)
 
 	//Wait that subs is cleaned
@@ -1303,6 +1303,86 @@
 
 	xappConn1.TestMsgChanEmpty(t)
 	xappConn2.TestMsgChanEmpty(t)
-	e2termConn.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
+	mainCtrl.wait_registry_empty(t, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestSubReqAndSubDelOkTwoE2termParallel
+//
+//   stub                          stub           stub
+// +-------+     +---------+    +---------+    +---------+
+// | xapp  |     | submgr  |    | e2term1 |    | e2term2 |
+// +-------+     +---------+    +---------+    +---------+
+//     |              |              |              |
+//     |              |              |              |
+//     |              |              |              |
+//     | SubReq1      |              |              |
+//     |------------->|              |              |
+//     |              |              |              |
+//     |              | SubReq1      |              |
+//     |              |------------->|              |
+//     |              |              |              |
+//     | SubReq2      |              |              |
+//     |------------->|              |              |
+//     |              |              |              |
+//     |              | SubReq2      |              |
+//     |              |---------------------------->|
+//     |              |              |              |
+//     |              |    SubResp1  |              |
+//     |              |<-------------|              |
+//     |    SubResp1  |              |              |
+//     |<-------------|              |              |
+//     |              |    SubResp2  |              |
+//     |              |<----------------------------|
+//     |    SubResp2  |              |              |
+//     |<-------------|              |              |
+//     |              |              |              |
+//     |        [SUBS 1 DELETE]      |              |
+//     |              |              |              |
+//     |        [SUBS 2 DELETE]      |              |
+//     |              |              |              |
+//
+//-----------------------------------------------------------------------------
+func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
+	CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
+
+	//Req1
+	cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
+	xappConn1.SendSubsReq(t, nil, cretrans1)
+	crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
+
+	cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
+	xappConn1.SendSubsReq(t, nil, cretrans2)
+	crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
+
+	//Resp1
+	e2termConn1.SendSubsResp(t, crereq1, cremsg1)
+	e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
+
+	//Resp2
+	e2termConn2.SendSubsResp(t, crereq2, cremsg2)
+	e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
+
+	//Del1
+	deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
+	delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
+	e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
+	xappConn1.RecvSubsDelResp(t, deltrans1)
+	//Wait that subs is cleaned
+	mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
+
+	//Del2
+	deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
+	delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
+	e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
+	xappConn1.RecvSubsDelResp(t, deltrans2)
+	//Wait that subs is cleaned
+	mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
+
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
+	e2termConn2.TestMsgChanEmpty(t)
 	mainCtrl.wait_registry_empty(t, 10)
 }