Merge "Added UT cases for Del Req e2ap un/packing errors"
authorAnssi Mannila <anssi.mannila@nokia.com>
Thu, 27 May 2021 07:09:06 +0000 (07:09 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Thu, 27 May 2021 07:09:06 +0000 (07:09 +0000)
1  2 
pkg/control/ut_messaging_test.go

@@@ -30,14 -30,56 +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)
  
        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
  //
@@@ -2259,12 -2409,15 +2409,12 @@@ func TestRESTSubReqAndRouteNok(t *testi
        })
  
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
        // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
        waiter := rtmgrHttp.AllocNextSleep(50, false)
        newSubsId := mainCtrl.get_registry_next_subid(t)
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xappConn1.ExpectRESTNotification(t, restSubId)
        waiter.WaitResult(t)
@@@ -2307,7 -2460,7 +2457,7 @@@ func TestRESTSubReqAndRouteUpdateNok(t 
        // xapp2 ROUTE creation shall fail with  400 from rtmgr -> submgr
        waiter := rtmgrHttp.AllocNextEvent(false)
        newSubsId := mainCtrl.get_registry_next_subid(t)
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
@@@ -2458,11 -2611,14 +2608,11 @@@ func TestRESTSubReqRetransmission(t *te
  
        // Subs Create
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
  
        // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
        // gets into execution before the rtmgrg responds for the first one.
        waiter := rtmgrHttp.AllocNextSleep(10, true)
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params)
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
  
@@@ -2579,9 -2735,12 +2729,9 @@@ func TestRESTSubReqDelReq(t *testing.T
        })
  
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        // Del. This will fail as processing of the subscription
@@@ -2624,12 -2783,12 +2774,12 @@@ func TestRESTSubReqAndSubDelOkTwoParall
        })
  
        //Req1
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
  
        //Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
  
@@@ -2676,11 -2835,11 +2826,11 @@@ func TestRESTSameSubsDiffRan(t *testing
                Counter{cSubDelRespToXapp, 2},
        })
  
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
        xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
  
 -      params = xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_2")
        restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
        xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
@@@ -2714,7 -2873,7 +2864,7 @@@ func TestRESTSubReqRetryInSubmgr(t *tes
                Counter{cSubDelRespToXapp, 1},
        })
  
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
@@@ -2792,7 -2951,7 +2942,7 @@@ func TestRESTSubReqRetryNoRespSubDelRes
                Counter{cSubDelRespFromE2, 1},
        })
  
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
  
@@@ -2827,7 -2986,7 +2977,7 @@@ func TestREST2eTermNotRespondingToSubRe
                Counter{cSubDelReqTimerExpiry, 2},
        })
  
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
  
@@@ -2904,7 -3063,7 +3054,7 @@@ func TestRESTSubReqTwoRetriesNoRespAtAl
                Counter{cSubDelReqTimerExpiry, 2},
        })
  
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
  
@@@ -2973,8 -3132,11 +3123,8 @@@ func TestRESTSubReqSubFailRespInSubmgr(
        })
  
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
  
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
@@@ -3248,7 -3410,7 +3398,7 @@@ func TestRESTSubReqAndSubDelOkSameActio
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
  
        xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
@@@ -3335,11 -3497,11 +3485,11 @@@ func TestRESTSubReqAndSubDelOkSameActio
                Counter{cSubDelRespToXapp, 2},
        })
  
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params)
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
  
 -      params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
        restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
  
        xappConn1.ExpectRESTNotification(t, restSubId1)
@@@ -3432,15 -3594,18 +3582,15 @@@ func TestRESTSubReqAndSubDelNoAnswerSam
        })
  
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
  
        // Req1
 -      params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
        crereq1, _ := e2termConn1.RecvSubsReq(t)
  
        // Req2
        subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
 -      params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params2.SetMeid("RAN_NAME_1")
        restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
        mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
@@@ -3536,15 -3701,18 +3686,15 @@@ func TestRESTSubReqAndSubDelNokSameActi
        })
  
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
  
        // Req1
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params)
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
  
        // Req2
        subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
 -      params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params2.SetMeid("RAN_NAME_1")
        restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
        mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
@@@ -3593,8 -3761,11 +3743,8 @@@ func TestRESTSubReqPolicyAndSubDelOk(t 
        })
  
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
  
 -      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
  
@@@ -3677,15 -3848,18 +3827,15 @@@ func TestRESTSubReqPolicyChangeAndSubDe
        })
  
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const policyParamCount int = 1
  
        // Req
 -      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
  
        // Policy change
        instanceId := int64(e2SubsId)
        // GetRESTSubsReqPolicyParams sets some coutners on tc side.
 -      params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        params.SubsReqParams.SubscriptionDetails[0].InstanceID = &instanceId
        params.SetTimeToWait("w200ms")
        restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
@@@ -3758,14 -3932,17 +3908,14 @@@ func TestRESTSubReqAndSubDelOkTwoE2term
        })
  
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
  
        // Req1
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId1 := xappConn1.SendRESTSubsReq(t, params)
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_11")
        // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
        // would not work as notification would not be received
@@@ -3883,8 -4060,11 +4033,8 @@@ func TestRESTSubReqInsertAndSubDelOk(t 
        })
  
        const subReqCount int = 1
 -      const parameterSet int = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
  
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        params.SetSubActionTypes("insert")
  
        // Req
@@@ -3941,11 -4121,14 +4091,11 @@@ func TestRESTSubReqNokAndSubDelOkWithRe
        })
  
        const subReqCount int = 1
 -      const parameterSet = 1
 -      const actionDefinitionPresent bool = true
 -      const actionParamCount int = 1
  
        // Remove possible existing subscription
        mainCtrl.removeExistingSubscriptions(t)
  
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
  
        //Req
        mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
@@@ -4133,7 -4316,7 +4283,7 @@@ func TestRESTSubReqAndSubDelOkSameActio
        xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
  
        // Create subscription 2 with same action
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
        xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
  func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
        CaseBegin("TestRESTReportSubReqAndSubDelOk")
        subReqCount := 1
 -      parameterSet := 1 // E2SM-gNB-X2
 -      actionDefinitionPresent := true
 -      actionParamCount := 1
        testIndex := 1
 -      RESTReportSubReqAndSubDelOk(t, subReqCount, parameterSet, actionDefinitionPresent, actionParamCount, testIndex)
 +      RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
  }
  
 -func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, parameterSet int, actionDefinitionPresent bool, actionParamCount int, testIndex int) {
 -      xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with parameter set %v", testIndex)
 +func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
 +      xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        var e2SubsId []uint32
@@@ -4270,21 -4456,25 +4420,21 @@@ func TestRESTPolicySubReqAndSubDelOk(t 
        CaseBegin("TestRESTPolicySubReqAndSubDelOk")
  
        subReqCount := 2
 -      actionDefinitionPresent := true
 -      policyParamCount := 1
        testIndex := 1
 -      RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
 +      RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
  
        subReqCount = 19
 -      actionDefinitionPresent = false
 -      policyParamCount = 0
        testIndex = 2
 -      RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
 +      RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
  }
  */
 -func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, actionDefinitionPresent bool, policyParamCount int, testIndex int) {
 -      xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with parameter set %v", testIndex)
 +func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
 +      xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
  
        // Req
 -      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
 -      //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount, actionDefinitionPresent, policyParamCount)
 +      //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
        //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
  
        var e2SubsId []uint32
@@@ -4330,7 -4520,7 +4480,7 @@@ func TestRESTTwoPolicySubReqAndSubDelOk
        })
  
        // Req
 -      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
  
@@@ -4362,7 -4552,7 +4512,7 @@@ func TestRESTPolicySubReqAndSubDelOkFul
        })
  
        // Req
 -      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
  
  func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
  
        subReqCount := 2
 -      parameterSet := 1
 -      actionDefinitionPresent := true
 -      actionParamCount := 1
  
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
                Counter{cSubReqFromXapp, 1},
        })
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
  
  func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
  
        subReqCount := 2
 -      parameterSet := 1
 -      actionDefinitionPresent := false
 -      actionParamCount := 0
  
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
                Counter{cSubReqFromXapp, 1},
        })
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
  
  func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
  
        subReqCount := 19
 -      parameterSet := 1
 -      actionDefinitionPresent := false
 -      actionParamCount := 0
  
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
                Counter{cSubReqFromXapp, 1},
        })
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
  
@@@ -4500,7 -4699,7 +4650,7 @@@ func TestRESTSubReqReportSameActionDiff
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        eventTriggerDefinition := "1234"
        params.SetSubEventTriggerDefinition(eventTriggerDefinition)
@@@ -4546,7 -4745,7 +4696,7 @@@ func TestRESTSubReqReportSameActionDiff
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
  
        actionId := int64(1)
@@@ -4597,7 -4796,7 +4747,7 @@@ func TestRESTSubReqReportSameActionDiff
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        params.SetSubActionIDs(int64(2))
  
@@@ -4633,7 -4832,7 +4783,7 @@@ func TestRESTSubReqDiffActionType(t *te
        })
  
        // Req1
 -      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
  
        //Subs Create
        restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
  
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
@@@ -4677,7 -4876,7 +4827,7 @@@ func TestRESTSubReqPolicyAndSubDelOkSam
        })
  
        // Req1
 -      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
  
        //Subs Create
        restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
  
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
@@@ -4730,7 -4929,7 +4880,7 @@@ func TestRESTSubReqReportSameActionDiff
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        actionDefinition := "5678"
        params.SetSubActionDefinition(actionDefinition)
@@@ -4776,7 -4975,7 +4926,7 @@@ func TestRESTSubReqReportSameActionDiff
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        actionDefinition := "56782"
        params.SetSubActionDefinition(actionDefinition)
@@@ -4822,7 -5021,7 +4972,7 @@@ func TestRESTSubReqReportSameActionDiff
        queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
  
        // Req2
 -      params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
        params.SetMeid("RAN_NAME_1")
        params.SetTimeToWait("w200ms")
        restSubId2 := xappConn2.SendRESTSubsReq(t, params)
  func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
        xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
        subReqCount := 1
 -      parameterSet := 1 // E2SM-gNB-X2
 -      actionDefinitionPresent := true
 -      actionParamCount := 1
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        crereq, cremsg := e2termConn1.RecvSubsReq(t)
  func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
        xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
        subReqCount := 1
 -      parameterSet := 1 // E2SM-gNB-X2
 -      actionDefinitionPresent := true
 -      actionParamCount := 1
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        crereq, cremsg := e2termConn1.RecvSubsReq(t)
  func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
        xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
        subReqCount := 1
 -      parameterSet := 1 // E2SM-gNB-X2
 -      actionDefinitionPresent := true
 -      actionParamCount := 1
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        crereq, cremsg := e2termConn1.RecvSubsReq(t)
  func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
        xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
        subReqCount := 1
 -      parameterSet := 1 // E2SM-gNB-X2
 -      actionDefinitionPresent := true
 -      actionParamCount := 1
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        crereq, cremsg := e2termConn1.RecvSubsReq(t)
  func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
        xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
        subReqCount := 1
 -      parameterSet := 1 // E2SM-gNB-X2
 -      actionDefinitionPresent := true
 -      actionParamCount := 1
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        crereq, cremsg := e2termConn1.RecvSubsReq(t)
  func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
        xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
        subReqCount := 1
 -      parameterSet := 1 // E2SM-gNB-X2
 -      actionDefinitionPresent := true
 -      actionParamCount := 1
  
        // Req
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        crereq, cremsg := e2termConn1.RecvSubsReq(t)
@@@ -5655,80 -5872,19 +5805,80 @@@ func TestRESTUnpackSubscriptionDeleteFa
        mainCtrl.wait_registry_empty(t, 10)
  }
  
 +//-----------------------------------------------------------------------------
 +// TestRESTSubReqFailAsn1PackSubReqError
 +//
 +//   stub                             stub
 +// +-------+        +---------+    +---------+
 +// | xapp  |        | submgr  |    | e2term  |
 +// +-------+        +---------+    +---------+
 +//     |                 |              |
 +//     | RESTSubReq      |              |
 +//     |---------------->|              |
 +//     |                 |              |
 +//     |     RESTSubResp |              |
 +//     |<----------------|              |
 +//     |                 |              |
 +//     |        ASN.1 encode fails      |
 +//     |                 |              |
 +//     |                 | SubDelReq    |
 +//     |                 |------------->|
 +//     |                 |              |
 +//     |                 |  SubDelFail  |
 +//     |                 |<-------------|
 +//     |                 |              |
 +//     |       RESTNotif |              |
 +//     |       unsuccess |              |
 +//     |<----------------|              |
 +//     |                 |              |
 +//     |            [SUBS DELETE]       |
 +//     |                 |              |
 +//
 +//-----------------------------------------------------------------------------
 +func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
 +
 +      mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
 +              Counter{cSubReqFromXapp, 1},
 +              Counter{cSubDelReqToE2, 1},
 +              Counter{cSubDelFailFromE2, 1},
 +              Counter{cSubRespToXapp, 1},
 +      })
 +
 +      subReqCount := 1
 +
 +      var params *teststube2ap.RESTSubsReqParams = nil
 +      params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
 +      e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
 +
 +      // Req
 +      restSubId := xappConn1.SendRESTSubsReq(t, params)
 +      xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
 +
 +      // E2t: Receive SubsDelReq
 +      delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
 +      xappConn1.ExpectRESTNotification(t, restSubId)
 +
 +      // Subscription does not exist in in E2 Node.
 +      e2termConn1.SendSubsDelFail(t, delreq, delmsg)
 +
 +      e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
 +      xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
 +
 +      e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
 +      // Wait that subs is cleaned
 +      waitSubsCleanup(t, e2SubsId, 10)
 +      mainCtrl.VerifyCounterValues(t)
 +}
 +
  ////////////////////////////////////////////////////////////////////////////////////
  //   Services for UT cases
  ////////////////////////////////////////////////////////////////////////////////////
  const subReqCount int = 1
 -const parameterSet = 1
 -const actionDefinitionPresent bool = true
 -const actionParamCount int = 1
 -const policyParamCount int = 1
  const host string = "localhost"
  
  func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
        if params == nil {
 -              params = fromXappConn.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +              params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
        }
        restSubId := fromXappConn.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
  
  func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
  
 -      params := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
        if meid != "" {
                params.SetMeid(meid)
        }
  }
  
  func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
 -      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
 +      params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
        xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
  
  }
  
  func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
 -      params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
 +      params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
        restSubId := xappConn1.SendRESTSubsReq(t, params)
  
        crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)