Merge "Added UT cases for Del Req e2ap un/packing errors"
[ric-plt/submgr.git] / pkg / control / ut_messaging_test.go
index 92ff178..5e7d5a7 100644 (file)
@@ -30,14 +30,56 @@ import (
        "github.com/stretchr/testify/assert"
 )
 
-func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
-
+func TestSuiteSetup(t *testing.T) {
        // The effect of this call shall endure thgough the UT suite!
        // If this causes any issues, the previout interface can be restored
-       // like this:
+       // like this:git log
        // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
 
        SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
+//
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|  // The order of these events may vary
+//     |                 |              |             |
+//     |     RESTSubResp |              |             |  // The order of these events may vary
+//     |<----------------|              |             |
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|  // The order of these events may vary
+//     |                 |              |             |
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |  // The order of these events may vary
+//     |                 |              |             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 |              |             |
+//     |                 |              |             |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
 
        restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
 
@@ -46,6 +88,114 @@ func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
        waitSubsCleanup(t, e2SubsId, 10)
 }
 
+//-----------------------------------------------------------------------------
+// TestRESTSubReqAndE1apDeleteReqPackingError
+//
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|  // The order of these events may vary
+//     |                 |              |             |
+//     |     RESTSubResp |              |             |  // The order of these events may vary
+//     |<----------------|              |             |
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|  // The order of these events may vary
+//     |                 |              |             |
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |  // The order of these events may vary
+//     |                 |              |             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |                 |              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     |                 |              |             |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
+
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
+
+       e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqAndE1apDeleteRespUnpackingError
+//
+//   stub                             stub          stub
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+// +-------+        +---------+    +---------+   +---------+
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|  // The order of these events may vary
+//     |                 |              |             |
+//     |     RESTSubResp |              |             |  // The order of these events may vary
+//     |<----------------|              |             |
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|  // The order of these events may vary
+//     |                 |              |             |
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |  // The order of these events may vary
+//     |                 |              |             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             | // The order of these events may vary
+//     |                 |              |             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             | // 1.st NOK
+//     |                 |              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |              |             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             | // 2.nd NOK
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
+
+       restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
+
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+}
+
 //-----------------------------------------------------------------------------
 // TestSubReqAndRouteNok
 //