Support for handling unordered IEs in RIC Subscription Response messgae

Inorder to support interoperability with other RAN simulators, adding
config parameter using which strict order checking of IEs can be
enabled or disabled.

Resolves RIC-963 partially.

Change-Id: Ie9c60f9dcbb8159ae21ee29451da24901dad1d6f

Change-Id: Icd660d38efb0331ad4f03b309dd7a3082a74e8e8
Signed-off-by: himanshup <himanshu.purohit@gslab.com>
diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go
index c61a495..3d0b448 100644
--- a/pkg/control/ut_messaging_test.go
+++ b/pkg/control/ut_messaging_test.go
@@ -881,6 +881,100 @@
 }
 
 //-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// TestSubReqAndSubDelOkOutofOrderIEs
+//
+//   stub                          stub
+// +-------+     +---------+    +---------+
+// | xapp  |     | submgr  |    | e2term  |
+// +-------+     +---------+    +---------+
+//     |              |              |
+//     | SubReq       |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubReq       |
+//     |              |------------->|
+//     |              |              |
+//     |              |      SubResp | (Out of Order IEs)
+//     |              |<-------------|
+//     |              |              |
+//     |      SubResp |              |
+//     |<-------------|              |
+//     |              |              |
+//     |              |              |
+//     | SubDelReq    |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubDelReq    |
+//     |              |------------->|
+//     |              |              |
+//     |              |   SubDelResp |
+//     |              |<-------------|
+//     |              |              |
+//     |   SubDelResp |              |
+//     |<-------------|              |
+//
+//-----------------------------------------------------------------------------
+
+func TestSubReqAndSubDelOkOutofOrderIEs(t *testing.T) {
+	CaseBegin("TestSubReqAndSubDelOkOutofOrderIEs")
+
+	mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
+	// Init counter check
+	mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+		Counter{cSubReqFromXapp, 1},
+		Counter{cSubReqToE2, 1},
+		Counter{cSubRespFromE2, 1},
+		Counter{cSubRespToXapp, 1},
+		Counter{cSubDelReqFromXapp, 1},
+		Counter{cSubDelReqToE2, 1},
+		Counter{cSubDelRespFromE2, 1},
+		Counter{cSubDelRespToXapp, 1},
+	})
+
+	cretrans := xappConn1.SendSubsReq(t, nil, nil)
+	if cretrans == nil {
+		t.Logf("Could not send SubsReq")
+		t.FailNow()
+	}
+	crereq, cremsg := e2termConn1.RecvSubsReq(t)
+	if crereq == nil || cremsg == nil {
+		t.Logf("Could not recieve SubsReq")
+		t.FailNow()
+	}
+
+	e2termConn1.SendSubsResp(t, crereq, cremsg)
+
+	mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
+
+	e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
+	resp, _ := xapp.Subscription.QuerySubscriptions()
+	assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
+	assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
+	assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
+
+	deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
+	delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+
+	e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+	xappConn1.RecvSubsDelResp(t, deltrans)
+
+	//Wait that subs is cleaned
+	mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+	xappConn1.TestMsgChanEmpty(t)
+	xappConn2.TestMsgChanEmpty(t)
+	e2termConn1.TestMsgChanEmpty(t)
+	mainCtrl.wait_registry_empty(t, 10)
+
+	mainCtrl.VerifyCounterValues(t)
+	mainCtrl.c.e2ap.SetE2IEOrderCheck(1)
+}
+
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
 // TestSubReqRetransmission
 //
 //   stub                          stub