Xapp-frame, v0.8.1 Rest Subscription Creation /Query /Deletion
[ric-plt/submgr.git] / pkg / teststube2ap / stubE2.go
index 0ebb29f..b8d2350 100644 (file)
 package teststube2ap
 
 import (
+       "fmt"
+       "strconv"
+       "testing"
+       "time"
+
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
        "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
        "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
-       "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
+       clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-       "strconv"
-       "testing"
 )
 
 //-----------------------------------------------------------------------------
@@ -42,32 +45,60 @@ type RmrTransactionId struct {
        meid *xapp.RMRMeid
 }
 
+type E2RestIds struct {
+       RestSubsId string
+       E2SubsId   uint32
+}
+
 func (trans *RmrTransactionId) String() string {
-       return "trans(" + trans.xid + "/" + (&xapptweaks.RMRMeid{trans.meid}).String() + ")"
+       meidstr := "N/A"
+       if trans.meid != nil {
+               meidstr = trans.meid.String()
+       }
+       return "trans(" + trans.xid + "/" + meidstr + ")"
 }
 
 type E2Stub struct {
        teststub.RmrStubControl
-       xid_seq uint64
+       xid_seq                     uint64
+       subscriptionId              string
+       requestCount                int
+       CallBackNotification        chan int64
+       RESTNotification            chan uint32
+       CallBackListedNotifications chan E2RestIds
+       ListedRESTNotifications     chan E2RestIds
+       clientEndpoint              clientmodel.SubscriptionParamsClientEndpoint
+       meid                        string
+       restSubsIdList              []string
 }
 
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func CreateNewE2Stub(desc string, rtfile string, port string, stat string, mtypeseed int) *E2Stub {
+func CreateNewE2Stub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int, ranName string, host string, RMRPort int64, HTTPPort int64) *E2Stub {
        tc := &E2Stub{}
-       tc.RmrStubControl.Init(desc, rtfile, port, stat, mtypeseed)
+       tc.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
        tc.xid_seq = 1
        tc.SetCheckXid(true)
+       tc.CallBackNotification = make(chan int64)
+       tc.RESTNotification = make(chan uint32)
+       tc.CallBackListedNotifications = make(chan E2RestIds)
+       tc.ListedRESTNotifications = make(chan E2RestIds, 2)
+       var endPoint clientmodel.SubscriptionParamsClientEndpoint
+       endPoint.Host = host
+       endPoint.HTTPPort = &HTTPPort
+       endPoint.RMRPort = &RMRPort
+       tc.clientEndpoint = endPoint
+       tc.meid = ranName
        return tc
 }
 
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func CreateNewE2termStub(desc string, rtfile string, port string, stat string, mtypeseed int) *E2Stub {
+func CreateNewE2termStub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc, stat string, mtypeseed int) *E2Stub {
        tc := &E2Stub{}
-       tc.RmrStubControl.Init(desc, rtfile, port, stat, mtypeseed)
+       tc.RmrStubControl.Init(desc, srcId, rtgSvc, stat, mtypeseed)
        tc.xid_seq = 1
        tc.SetCheckXid(false)
        return tc
@@ -85,7 +116,7 @@ func (tc *E2Stub) NewRmrTransactionId(xid string, ranname string) *RmrTransactio
                trans.xid = xid
        }
        trans.meid = &xapp.RMRMeid{RanName: ranname}
-       tc.Logger.Info("New test %s", trans.String())
+       tc.Info("New test %s", trans.String())
        return trans
 }
 
@@ -100,29 +131,26 @@ func (p *E2StubSubsReqParams) Init() {
        p.Req = &e2ap.E2APSubscriptionRequest{}
 
        p.Req.RequestId.Id = 1
-       p.Req.RequestId.Seq = 0
+       p.Req.RequestId.InstanceId = 0
        p.Req.FunctionId = 1
 
-       p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present = true
-       p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mcc = "310"
-       p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Mnc = "150"
-       p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Id = 123
-       p.Req.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId.Bits = e2ap.E2AP_ENBIDHomeBits28
-
        // gnb -> enb outgoing
        // enb -> gnb incoming
        // X2 36423-f40.doc
-       p.Req.EventTriggerDefinition.InterfaceDirection = e2ap.E2AP_InterfaceDirectionIncoming
-       p.Req.EventTriggerDefinition.ProcedureCode = 5 //28 35
-       p.Req.EventTriggerDefinition.TypeOfMessage = e2ap.E2AP_InitiatingMessage
+       p.Req.EventTriggerDefinition.Data.Length = 1
+       p.Req.EventTriggerDefinition.Data.Data = make([]uint8, p.Req.EventTriggerDefinition.Data.Length)
+       p.Req.EventTriggerDefinition.Data.Data[0] = 1
 
        p.Req.ActionSetups = make([]e2ap.ActionToBeSetupItem, 1)
 
        p.Req.ActionSetups[0].ActionId = 0
        p.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeReport
-       p.Req.ActionSetups[0].ActionDefinition.Present = false // Not supported
-       //p.Req.ActionSetups[index].ActionDefinition.StyleId = 255
-       //p.Req.ActionSetups[index].ActionDefinition.ParamId = 222
+       p.Req.ActionSetups[0].RicActionDefinitionPresent = true
+
+       p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Length = 1
+       p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Data = make([]uint8, p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Length)
+       p.Req.ActionSetups[0].ActionDefinitionChoice.Data.Data[0] = 1
+
        p.Req.ActionSetups[0].SubsequentAction.Present = true
        p.Req.ActionSetups[0].SubsequentAction.Type = e2ap.E2AP_SubSeqActionTypeContinue
        p.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitZero
@@ -142,7 +170,7 @@ func (p *E2StubSubsFailParams) Set(req *e2ap.E2APSubscriptionRequest) {
 
        p.Fail = &e2ap.E2APSubscriptionFailure{}
        p.Fail.RequestId.Id = p.Req.RequestId.Id
-       p.Fail.RequestId.Seq = p.Req.RequestId.Seq
+       p.Fail.RequestId.InstanceId = p.Req.RequestId.InstanceId
        p.Fail.FunctionId = p.Req.FunctionId
        p.Fail.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(p.Req.ActionSetups))
        for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
@@ -156,12 +184,12 @@ func (p *E2StubSubsFailParams) SetCauseVal(ind int, content uint8, causeval uint
        if ind < 0 {
                for index := int(0); index < len(p.Fail.ActionNotAdmittedList.Items); index++ {
                        p.Fail.ActionNotAdmittedList.Items[index].Cause.Content = content
-                       p.Fail.ActionNotAdmittedList.Items[index].Cause.CauseVal = causeval
+                       p.Fail.ActionNotAdmittedList.Items[index].Cause.Value = causeval
                }
                return
        }
        p.Fail.ActionNotAdmittedList.Items[ind].Cause.Content = content
-       p.Fail.ActionNotAdmittedList.Items[ind].Cause.CauseVal = causeval
+       p.Fail.ActionNotAdmittedList.Items[ind].Cause.Value = causeval
 }
 
 //-----------------------------------------------------------------------------
@@ -175,7 +203,7 @@ func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTra
                trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
        }
 
-       tc.Logger.Info("SendSubsReq %s", trans.String())
+       tc.Info("SendSubsReq %s", trans.String())
        e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
 
        //---------------------------------
@@ -193,9 +221,9 @@ func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTra
                tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
                return nil
        }
-       tc.Logger.Debug("%s %s", trans.String(), e2SubsReq.String())
+       tc.Debug("%s %s", trans.String(), e2SubsReq.String())
 
-       params := xapptweaks.NewParams(nil)
+       params := &xapp.RMRParams{}
        params.Mtype = xapp.RIC_SUB_REQ
        params.SubId = -1
        params.Payload = packedMsg.Buf
@@ -204,8 +232,8 @@ func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTra
        params.Xid = trans.xid
        params.Mbuf = nil
 
-       tc.Logger.Info("SEND SUB REQ: %s", params.String())
-       snderr := tc.RmrSend(params, 5)
+       tc.Info("SEND SUB REQ: %s", params.String())
+       snderr := tc.SendWithRetry(params, false, 5)
        if snderr != nil {
                tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
                return nil
@@ -216,8 +244,8 @@ func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTra
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapptweaks.RMRParams) {
-       tc.Logger.Info("RecvSubsReq")
+func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapp.RMRParams) {
+       tc.Info("RecvSubsReq")
        e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
 
        //---------------------------------
@@ -228,7 +256,7 @@ func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xap
                if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] {
                        tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype])
                } else {
-                       tc.Logger.Info("Recv Subs Req")
+                       tc.Info("Recv Subs Req")
                        packedData := &e2ap.PackedData{}
                        packedData.Buf = msg.Payload
                        unpackerr, req := e2SubsReq.UnPack(packedData)
@@ -247,8 +275,8 @@ func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xap
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapptweaks.RMRParams) {
-       tc.Logger.Info("SendSubsResp")
+func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) {
+       tc.Info("SendSubsResp")
        e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
 
        //---------------------------------
@@ -257,7 +285,7 @@ func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest,
        resp := &e2ap.E2APSubscriptionResponse{}
 
        resp.RequestId.Id = req.RequestId.Id
-       resp.RequestId.Seq = req.RequestId.Seq
+       resp.RequestId.InstanceId = req.RequestId.InstanceId
        resp.FunctionId = req.FunctionId
 
        resp.ActionAdmittedList.Items = make([]e2ap.ActionAdmittedItem, len(req.ActionSetups))
@@ -269,7 +297,7 @@ func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest,
                item := e2ap.ActionNotAdmittedItem{}
                item.ActionId = index
                item.Cause.Content = 1
-               item.Cause.CauseVal = 1
+               item.Cause.Value = 1
                resp.ActionNotAdmittedList.Items = append(resp.ActionNotAdmittedList.Items, item)
        }
 
@@ -277,9 +305,9 @@ func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest,
        if packerr != nil {
                tc.TestError(t, "pack NOK %s", packerr.Error())
        }
-       tc.Logger.Debug("%s", e2SubsResp.String())
+       tc.Debug("%s", e2SubsResp.String())
 
-       params := xapptweaks.NewParams(nil)
+       params := &xapp.RMRParams{}
        params.Mtype = xapp.RIC_SUB_RESP
        //params.SubId = msg.SubId
        params.SubId = -1
@@ -289,8 +317,8 @@ func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest,
        //params.Xid = msg.Xid
        params.Mbuf = nil
 
-       tc.Logger.Info("SEND SUB RESP: %s", params.String())
-       snderr := tc.RmrSend(params, 5)
+       tc.Info("SEND SUB RESP: %s", params.String())
+       snderr := tc.SendWithRetry(params, false, 5)
        if snderr != nil {
                tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
        }
@@ -300,7 +328,7 @@ func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest,
 //
 //-----------------------------------------------------------------------------
 func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 {
-       tc.Logger.Info("RecvSubsResp")
+       tc.Info("RecvSubsResp")
        e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
        var e2SubsId uint32
 
@@ -327,7 +355,7 @@ func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 {
                        if unpackerr != nil {
                                tc.TestError(t, "RIC_SUB_RESP unpack failed err: %s", unpackerr.Error())
                        }
-                       tc.Logger.Info("Recv Subs Resp rmr: xid=%s subid=%d, asn: seqnro=%d", msg.Xid, msg.SubId, resp.RequestId.Seq)
+                       tc.Info("Recv Subs Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
                        return e2SubsId
                }
        } else {
@@ -340,8 +368,8 @@ func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 {
 //
 //-----------------------------------------------------------------------------
 
-func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg *xapptweaks.RMRParams) {
-       tc.Logger.Info("SendSubsFail")
+func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg *xapp.RMRParams) {
+       tc.Info("SendSubsFail")
        e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
 
        //---------------------------------
@@ -351,9 +379,9 @@ func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg
        if packerr != nil {
                tc.TestError(t, "pack NOK %s", packerr.Error())
        }
-       tc.Logger.Debug("%s", e2SubsFail.String())
+       tc.Debug("%s", e2SubsFail.String())
 
-       params := xapptweaks.NewParams(nil)
+       params := &xapp.RMRParams{}
        params.Mtype = xapp.RIC_SUB_FAILURE
        params.SubId = msg.SubId
        params.Payload = packedMsg.Buf
@@ -362,8 +390,8 @@ func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg
        params.Xid = msg.Xid
        params.Mbuf = nil
 
-       tc.Logger.Info("SEND SUB FAIL: %s", params.String())
-       snderr := tc.RmrSend(params, 5)
+       tc.Info("SEND SUB FAIL: %s", params.String())
+       snderr := tc.SendWithRetry(params, false, 5)
        if snderr != nil {
                tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
        }
@@ -373,7 +401,7 @@ func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg
 //
 //-----------------------------------------------------------------------------
 func (tc *E2Stub) RecvSubsFail(t *testing.T, trans *RmrTransactionId) uint32 {
-       tc.Logger.Info("RecvSubsFail")
+       tc.Info("RecvSubsFail")
        e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
        var e2SubsId uint32
 
@@ -400,7 +428,7 @@ func (tc *E2Stub) RecvSubsFail(t *testing.T, trans *RmrTransactionId) uint32 {
                        if unpackerr != nil {
                                tc.TestError(t, "RIC_SUB_FAILURE unpack failed err: %s", unpackerr.Error())
                        }
-                       tc.Logger.Info("Recv Subs Fail rmr: xid=%s subid=%d, asn: seqnro=%d", msg.Xid, msg.SubId, resp.RequestId.Seq)
+                       tc.Info("Recv Subs Fail rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
                        return e2SubsId
                }
        } else {
@@ -419,14 +447,14 @@ func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2Sub
                trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
        }
 
-       tc.Logger.Info("SendSubsDelReq %s", trans.String())
+       tc.Info("SendSubsDelReq %s", trans.String())
        e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
        //---------------------------------
        // xapp activity: Send Subs Del Req
        //---------------------------------
        req := &e2ap.E2APSubscriptionDeleteRequest{}
        req.RequestId.Id = 1
-       req.RequestId.Seq = e2SubsId
+       req.RequestId.InstanceId = e2SubsId
        req.FunctionId = 1
 
        err, packedMsg := e2SubsDelReq.Pack(req)
@@ -434,9 +462,9 @@ func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2Sub
                tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
                return nil
        }
-       tc.Logger.Debug("%s %s", trans.String(), e2SubsDelReq.String())
+       tc.Debug("%s %s", trans.String(), e2SubsDelReq.String())
 
-       params := xapptweaks.NewParams(nil)
+       params := &xapp.RMRParams{}
        params.Mtype = xapp.RIC_SUB_DEL_REQ
        params.SubId = int(e2SubsId)
        params.Payload = packedMsg.Buf
@@ -445,8 +473,8 @@ func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2Sub
        params.Xid = trans.xid
        params.Mbuf = nil
 
-       tc.Logger.Info("SEND SUB DEL REQ: %s", params.String())
-       snderr := tc.RmrSend(params, 5)
+       tc.Info("SEND SUB DEL REQ: %s", params.String())
+       snderr := tc.SendWithRetry(params, false, 5)
        if snderr != nil {
                tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
                return nil
@@ -457,8 +485,8 @@ func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2Sub
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapptweaks.RMRParams) {
-       tc.Logger.Info("RecvSubsDelReq")
+func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapp.RMRParams) {
+       tc.Info("RecvSubsDelReq")
        e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
 
        //---------------------------------
@@ -469,7 +497,7 @@ func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequ
                if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] {
                        tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_DEL_REQ", xapp.RicMessageTypeToName[msg.Mtype])
                } else {
-                       tc.Logger.Info("Recv Subs Del Req")
+                       tc.Info("Recv Subs Del Req")
 
                        packedData := &e2ap.PackedData{}
                        packedData.Buf = msg.Payload
@@ -488,8 +516,8 @@ func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequ
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
-       tc.Logger.Info("SendSubsDelResp")
+func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
+       tc.Info("SendSubsDelResp")
        e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
 
        //---------------------------------
@@ -497,16 +525,16 @@ func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDelete
        //---------------------------------
        resp := &e2ap.E2APSubscriptionDeleteResponse{}
        resp.RequestId.Id = req.RequestId.Id
-       resp.RequestId.Seq = req.RequestId.Seq
+       resp.RequestId.InstanceId = req.RequestId.InstanceId
        resp.FunctionId = req.FunctionId
 
        packerr, packedMsg := e2SubsDelResp.Pack(resp)
        if packerr != nil {
                tc.TestError(t, "pack NOK %s", packerr.Error())
        }
-       tc.Logger.Debug("%s", e2SubsDelResp.String())
+       tc.Debug("%s", e2SubsDelResp.String())
 
-       params := xapptweaks.NewParams(nil)
+       params := &xapp.RMRParams{}
        params.Mtype = xapp.RIC_SUB_DEL_RESP
        params.SubId = msg.SubId
        params.Payload = packedMsg.Buf
@@ -515,8 +543,8 @@ func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDelete
        params.Xid = msg.Xid
        params.Mbuf = nil
 
-       tc.Logger.Info("SEND SUB DEL RESP: %s", params.String())
-       snderr := tc.RmrSend(params, 5)
+       tc.Info("SEND SUB DEL RESP: %s", params.String())
+       snderr := tc.SendWithRetry(params, false, 5)
        if snderr != nil {
                tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
        }
@@ -526,7 +554,7 @@ func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDelete
 //
 //-----------------------------------------------------------------------------
 func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) {
-       tc.Logger.Info("RecvSubsDelResp")
+       tc.Info("RecvSubsDelResp")
        e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
 
        //---------------------------------
@@ -547,7 +575,7 @@ func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) {
                        if unpackerr != nil {
                                tc.TestError(t, "RIC_SUB_DEL_RESP unpack failed err: %s", unpackerr.Error())
                        }
-                       tc.Logger.Info("Recv Subs Del Resp rmr: xid=%s subid=%d, asn: seqnro=%d", msg.Xid, msg.SubId, resp.RequestId.Seq)
+                       tc.Info("Recv Subs Del Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
                        return
                }
        } else {
@@ -558,8 +586,8 @@ func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
-       tc.Logger.Info("SendSubsDelFail")
+func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
+       tc.Info("SendSubsDelFail")
        e2SubsDelFail := e2asnpacker.NewPackerSubscriptionDeleteFailure()
 
        //---------------------------------
@@ -567,18 +595,18 @@ func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDelete
        //---------------------------------
        resp := &e2ap.E2APSubscriptionDeleteFailure{}
        resp.RequestId.Id = req.RequestId.Id
-       resp.RequestId.Seq = req.RequestId.Seq
+       resp.RequestId.InstanceId = req.RequestId.InstanceId
        resp.FunctionId = req.FunctionId
-       resp.Cause.Content =  // CauseMisc
-       resp.Cause.CauseVal = 4 // unspecified
+       resp.Cause.Content = 4 // CauseMisc
+       resp.Cause.Value = 3   // unspecified
 
        packerr, packedMsg := e2SubsDelFail.Pack(resp)
        if packerr != nil {
                tc.TestError(t, "pack NOK %s", packerr.Error())
        }
-       tc.Logger.Debug("%s", e2SubsDelFail.String())
+       tc.Debug("%s", e2SubsDelFail.String())
 
-       params := xapptweaks.NewParams(nil)
+       params := &xapp.RMRParams{}
        params.Mtype = xapp.RIC_SUB_DEL_FAILURE
        params.SubId = msg.SubId
        params.Payload = packedMsg.Buf
@@ -587,9 +615,390 @@ func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDelete
        params.Xid = msg.Xid
        params.Mbuf = nil
 
-       tc.Logger.Info("SEND SUB DEL FAIL: %s", params.String())
-       snderr := tc.RmrSend(params, 5)
+       tc.Info("SEND SUB DEL FAIL: %s", params.String())
+       snderr := tc.SendWithRetry(params, false, 5)
        if snderr != nil {
                tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
        }
 }
+
+// REST code below all
+
+/*****************************************************************************/
+// REST interface specific functions are below
+
+//-----------------------------------------------------------------------------
+// Callback handler for subscription response notifications
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SubscriptionRespHandler(resp *clientmodel.SubscriptionResponse) {
+       if tc.subscriptionId == *resp.SubscriptionID {
+               tc.Info("REST notification received SubscriptionID=%s, InstanceID=%v, RequestorID=%v (%v)",
+                       *resp.SubscriptionID, *resp.SubscriptionInstances[0].InstanceID, *resp.SubscriptionInstances[0].RequestorID, tc)
+               tc.CallBackNotification <- *resp.SubscriptionInstances[0].InstanceID
+       } else {
+               tc.Info("MISMATCHING REST notification received SubscriptionID=%s<>%s, InstanceID=%v, RequestorID=%v (%v)",
+                       tc.subscriptionId, *resp.SubscriptionID, *resp.SubscriptionInstances[0].InstanceID, *resp.SubscriptionInstances[0].RequestorID, tc)
+       }
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) ExpectRESTNotification(t *testing.T, restSubsId string) {
+
+       tc.Info("### Started to wait REST notification for %v on port %v f(RMR port %v), %v responses expected", restSubsId, *tc.clientEndpoint.HTTPPort, *tc.clientEndpoint.RMRPort, tc.requestCount)
+       tc.restSubsIdList = []string{restSubsId}
+       xapp.Subscription.SetResponseCB(tc.ListedRestNotifHandler)
+       if tc.requestCount == 0 {
+               tc.TestError(t, "### NO REST notifications SET received for endpoint=%s, request zount ZERO! (%v)", tc.clientEndpoint, tc)
+       }
+       go func() {
+               select {
+               case e2Ids := <-tc.CallBackListedNotifications:
+                       if tc.requestCount == 0 {
+                               tc.TestError(t, "### REST notification count unexpectedly ZERO for %s (%v)", restSubsId, tc)
+                       } else if e2Ids.RestSubsId != restSubsId {
+                               tc.TestError(t, "### Unexpected REST notifications received |%s:%s| (%v)", e2Ids.RestSubsId, restSubsId, tc)
+                       } else {
+                               tc.requestCount--
+                               if tc.requestCount == 0 {
+                                       tc.Info("### All expected REST notifications received for %s (%v)", e2Ids.RestSubsId, tc)
+                               } else {
+                                       tc.Info("### Expected REST notifications received for %s, (%v)", e2Ids.RestSubsId, tc)
+                               }
+                               tc.Info("### REST Notification received Notif for %s : %v", e2Ids.RestSubsId, e2Ids.E2SubsId)
+                               tc.ListedRESTNotifications <- e2Ids
+                       }
+               case <-time.After(15 * time.Second):
+                       err := fmt.Errorf("### Timeout 15s expired while expecting REST notification for subsId: %v", restSubsId)
+                       tc.TestError(t, "%s", err.Error())
+               }
+       }()
+}
+
+func (tc *E2Stub) WaitRESTNotification(t *testing.T, restSubsId string) uint32 {
+       select {
+       case e2SubsId := <-tc.ListedRESTNotifications:
+               if e2SubsId.RestSubsId == restSubsId {
+                       tc.Info("### Expected REST notifications received %s, e2SubsId %v for endpoint=%s, (%v)", e2SubsId.RestSubsId, e2SubsId.E2SubsId, tc.clientEndpoint, tc)
+                       return e2SubsId.E2SubsId
+               } else {
+                       tc.TestError(t, "### Unexpected REST notifications received %s, expected %s for endpoint=%s, (%v)", e2SubsId.RestSubsId, restSubsId, tc.clientEndpoint, tc)
+                       return 0
+               }
+       case <-time.After(15 * time.Second):
+               err := fmt.Errorf("### Timeout 15s expired while waiting REST notification for subsId: %v", restSubsId)
+               tc.TestError(t, "%s", err.Error())
+               panic("WaitRESTNotification - timeout error")
+       }
+       return 0
+}
+
+func (tc *E2Stub) WaitRESTNotificationForAnySubscriptionId(t *testing.T) {
+       go func() {
+               tc.Info("### REST notifications received for endpoint=%s, (%v)", tc.clientEndpoint, tc)
+               select {
+               case e2SubsId := <-tc.CallBackNotification:
+                       tc.Info("### REST notifications received e2SubsId %v for endpoint=%s, (%v)", e2SubsId, tc.clientEndpoint, tc)
+                       tc.RESTNotification <- (uint32)(e2SubsId)
+               case <-time.After(15 * time.Second):
+                       err := fmt.Errorf("### Timeout 15s expired while waiting REST notification")
+                       tc.TestError(t, "%s", err.Error())
+                       tc.RESTNotification <- 0
+               }
+       }()
+}
+
+func (tc *E2Stub) ListedRestNotifHandler(resp *clientmodel.SubscriptionResponse) {
+
+       if len(tc.restSubsIdList) == 0 {
+               tc.Error("Unexpected listed REST notifications received for endpoint=%s, expected restSubsId list size was ZERO!", tc.clientEndpoint)
+       } else {
+               for i, subsId := range tc.restSubsIdList {
+                       if *resp.SubscriptionID == subsId {
+                               //tc.Info("Listed REST notifications received SubscriptionID=%s, InstanceID=%v, RequestorID=%v",
+                               //      *resp.SubscriptionID, *resp.SubscriptionInstances[0].InstanceID, *resp.SubscriptionInstances[0].RequestorID)
+
+                               tc.restSubsIdList = append(tc.restSubsIdList[:i], tc.restSubsIdList[i+1:]...)
+                               //tc.Info("Removed %s from Listed REST notifications, %v entries left", *resp.SubscriptionID, len(tc.restSubsIdList))
+
+                               tc.CallBackListedNotifications <- E2RestIds{*resp.SubscriptionID, uint32(*resp.SubscriptionInstances[0].InstanceID)}
+
+                               if len(tc.restSubsIdList) == 0 {
+                                       //tc.Info("All listed REST notifications received for endpoint=%s", tc.clientEndpoint)
+                               }
+
+                               return
+                       }
+               }
+               tc.Error("UNKONWN REST notification received SubscriptionID=%s<>%s, InstanceID=%v, RequestorID=%v (%v)",
+                       tc.subscriptionId, *resp.SubscriptionID, *resp.SubscriptionInstances[0].InstanceID, *resp.SubscriptionInstances[0].RequestorID, tc)
+       }
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) WaitListedRestNotifications(t *testing.T, restSubsIds []string) {
+       tc.Info("Started to wait REST notifications %v on port %v f(RMR port %v)", restSubsIds, *tc.clientEndpoint.HTTPPort, *tc.clientEndpoint.RMRPort)
+
+       tc.restSubsIdList = restSubsIds
+       xapp.Subscription.SetResponseCB(tc.ListedRestNotifHandler)
+
+       for i := 0; i < len(restSubsIds); i++ {
+               go func() {
+                       select {
+                       case e2Ids := <-tc.CallBackListedNotifications:
+                               tc.Info("Listed Notification waiter received Notif for %s : %v", e2Ids.RestSubsId, e2Ids.E2SubsId)
+                               tc.ListedRESTNotifications <- e2Ids
+                       case <-time.After(15 * time.Second):
+                               err := fmt.Errorf("Timeout 15s expired while waiting Listed REST notification")
+                               tc.TestError(t, "%s", err.Error())
+                               tc.RESTNotification <- 0
+                       }
+               }()
+       }
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SendRESTSubsReq(t *testing.T, params *RESTSubsReqParams) string { // This need to be edited according to new specification
+       tc.Info("Posting REST Report subscriptions to Submgr")
+
+       if params == nil {
+               tc.Info("SendRESTReportSubsReq: params == nil")
+               return ""
+       }
+
+       resp, err := xapp.Subscription.Subscribe(&params.SubsReqParams)
+       if err != nil {
+               // Swagger generated code makes checks for the values that are inserted the subscription function
+               // If error cause is unknown and POST is not done, the problem is in the inserted values
+               tc.Error("REST report subscriptions failed %s", err.Error())
+       }
+       tc.subscriptionId = *resp.SubscriptionID
+       tc.Info("REST report subscriptions pushed successfully. SubscriptionID = %s, RequestCount = %v", *resp.SubscriptionID, tc.requestCount)
+       return *resp.SubscriptionID
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) GetRESTSubsReqReportParams(subReqCount int, parameterSet int, actionDefinitionPresent bool, actionParamCount int) *RESTSubsReqParams {
+
+       reportParams := RESTSubsReqParams{}
+       if parameterSet == 1 {
+               reportParams.GetRESTSubsReqReportParams1(subReqCount, actionDefinitionPresent, actionParamCount, &tc.clientEndpoint, &tc.meid)
+       } else if parameterSet == 2 {
+
+       } else {
+               tc.Error("Invalid parameterSet=%v", parameterSet)
+       }
+       tc.requestCount = subReqCount
+       return &reportParams
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) GetRESTSubsReqReportParams1(subReqCount int, actionDefinitionPresent bool, actionParamCount int) *RESTSubsReqParams {
+
+       reportParams := RESTSubsReqParams{}
+       reportParams.GetRESTSubsReqReportParams1(subReqCount, actionDefinitionPresent, actionParamCount, &tc.clientEndpoint, &tc.meid)
+       tc.requestCount = subReqCount
+       return &reportParams
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type RESTSubsReqParams struct {
+       SubsReqParams clientmodel.SubscriptionParams
+}
+
+func (p *RESTSubsReqParams) GetRESTSubsReqReportParams1(subReqCount int, actionDefinitionPresent bool, actionParamCount int, clientEndpoint *clientmodel.SubscriptionParamsClientEndpoint, meid *string) {
+
+       // E2SM-gNB-X2
+       p.SubsReqParams.ClientEndpoint = clientEndpoint
+       p.SubsReqParams.Meid = meid
+       var rANFunctionID int64 = 33
+       p.SubsReqParams.RANFunctionID = &rANFunctionID
+
+       //      reqId := int64(1)
+       //seqId := int64(1)
+       actionId := int64(1)
+       actionType := "report"
+       subsequestActioType := "continue"
+       timeToWait := "w10ms"
+
+       for requestCount := 0; requestCount < subReqCount; requestCount++ {
+               reqId := int64(requestCount) + 1
+               seqId := int64(requestCount) + 1
+               subscriptionDetail := &clientmodel.SubscriptionDetail{
+                       RequestorID: &reqId,
+                       InstanceID:  &seqId,
+                       EventTriggers: &clientmodel.EventTriggerDefinition{
+                               OctetString: "1234" + strconv.Itoa(requestCount),
+                       },
+                       ActionToBeSetupList: clientmodel.ActionsToBeSetup{
+                               &clientmodel.ActionToBeSetup{
+                                       ActionID:   &actionId,
+                                       ActionType: &actionType,
+                                       ActionDefinition: &clientmodel.ActionDefinition{
+                                               OctetString: "5678" + strconv.Itoa(requestCount),
+                                       },
+                                       SubsequentAction: &clientmodel.SubsequentAction{
+                                               SubsequentActionType: &subsequestActioType,
+                                               TimeToWait:           &timeToWait,
+                                       },
+                               },
+                       },
+               }
+               p.SubsReqParams.SubscriptionDetails = append(p.SubsReqParams.SubscriptionDetails, subscriptionDetail)
+       }
+
+}
+
+func (p *RESTSubsReqParams) SetMeid(MEID string) {
+       p.SubsReqParams.Meid = &MEID
+}
+
+func (p *RESTSubsReqParams) SetEndpoint(HTTP_port int64, RMR_port int64, host string) {
+       var endpoint clientmodel.SubscriptionParamsClientEndpoint
+       endpoint.HTTPPort = &HTTP_port
+       endpoint.RMRPort = &RMR_port
+       endpoint.Host = host
+       p.SubsReqParams.ClientEndpoint = &endpoint
+}
+
+func (p *RESTSubsReqParams) SetEndpointHost(host string) {
+
+       if p.SubsReqParams.ClientEndpoint.Host != "" {
+               if p.SubsReqParams.ClientEndpoint.Host != host {
+                       // Renaming toto, print something tc.Info("Posting REST subscription request to Submgr")
+                       err := fmt.Errorf("hostname change attempt: %s -> %s", p.SubsReqParams.ClientEndpoint.Host, host)
+                       panic(err)
+               }
+       }
+       p.SubsReqParams.ClientEndpoint.Host = host
+}
+
+func (p *RESTSubsReqParams) SetHTTPEndpoint(HTTP_port int64, host string) {
+
+       p.SubsReqParams.ClientEndpoint.HTTPPort = &HTTP_port
+
+       p.SetEndpointHost(host)
+
+       if p.SubsReqParams.ClientEndpoint.RMRPort == nil {
+               var RMR_port int64
+               p.SubsReqParams.ClientEndpoint.RMRPort = &RMR_port
+       }
+}
+
+func (p *RESTSubsReqParams) SetSubActionTypes(actionType string) {
+
+       for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
+               for _, action := range subDetail.ActionToBeSetupList {
+                       if action != nil {
+                               action.ActionType = &actionType
+                       }
+               }
+       }
+}
+
+func (p *RESTSubsReqParams) SetRMREndpoint(RMR_port int64, host string) {
+
+       p.SubsReqParams.ClientEndpoint.RMRPort = &RMR_port
+
+       p.SetEndpointHost(host)
+
+       if p.SubsReqParams.ClientEndpoint.HTTPPort == nil {
+               var HTTP_port int64
+               p.SubsReqParams.ClientEndpoint.HTTPPort = &HTTP_port
+       }
+}
+
+func (p *RESTSubsReqParams) SetTimeToWait(timeToWait string) {
+
+       for _, subDetail := range p.SubsReqParams.SubscriptionDetails {
+               for _, action := range subDetail.ActionToBeSetupList {
+                       if action != nil && action.SubsequentAction != nil {
+                               action.SubsequentAction.TimeToWait = &timeToWait
+                       }
+               }
+       }
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SendRESTSubsDelReq(t *testing.T, subscriptionID *string) {
+
+       if *subscriptionID == "" {
+               tc.Error("REST error in deleting subscriptions. Empty SubscriptionID = %s", *subscriptionID)
+       }
+       tc.Info("REST deleting E2 subscriptions. SubscriptionID = %s", *subscriptionID)
+
+       err := xapp.Subscription.Unsubscribe(*subscriptionID)
+       if err != nil {
+               tc.Error("REST Delete subscription failed %s", err.Error())
+       }
+       tc.Info("REST delete subscription pushed to submgr successfully. SubscriptionID = %s", *subscriptionID)
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) GetRESTSubsReqPolicyParams(subReqCount int, actionDefinitionPresent bool, policyParamCount int) *RESTSubsReqParams {
+
+       policyParams := RESTSubsReqParams{}
+       policyParams.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount, &tc.clientEndpoint, &tc.meid)
+       tc.requestCount = subReqCount
+       return &policyParams
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (p *RESTSubsReqParams) GetRESTSubsReqPolicyParams(subReqCount int, actionDefinitionPresent bool, policyParamCount int, clientEndpoint *clientmodel.SubscriptionParamsClientEndpoint, meid *string) {
+
+       p.SubsReqParams.ClientEndpoint = clientEndpoint
+       p.SubsReqParams.Meid = meid
+       var rANFunctionID int64 = 33
+       p.SubsReqParams.RANFunctionID = &rANFunctionID
+
+       //      reqId := int64(1)
+       //seqId := int64(1)
+       actionId := int64(1)
+       actionType := "policy"
+       subsequestActioType := "continue"
+       timeToWait := "w10ms"
+
+       for requestCount := 0; requestCount < subReqCount; requestCount++ {
+               reqId := int64(requestCount) + 1
+               seqId := int64(0)
+               subscriptionDetail := &clientmodel.SubscriptionDetail{
+                       RequestorID: &reqId,
+                       InstanceID:  &seqId,
+                       EventTriggers: &clientmodel.EventTriggerDefinition{
+                               OctetString: "1234" + strconv.Itoa(requestCount),
+                       },
+                       ActionToBeSetupList: clientmodel.ActionsToBeSetup{
+                               &clientmodel.ActionToBeSetup{
+                                       ActionID:   &actionId,
+                                       ActionType: &actionType,
+                                       ActionDefinition: &clientmodel.ActionDefinition{
+                                               OctetString: "5678" + strconv.Itoa(requestCount),
+                                       },
+                                       SubsequentAction: &clientmodel.SubsequentAction{
+                                               SubsequentActionType: &subsequestActioType,
+                                               TimeToWait:           &timeToWait,
+                                       },
+                               },
+                       },
+               }
+               p.SubsReqParams.SubscriptionDetails = append(p.SubsReqParams.SubscriptionDetails, subscriptionDetail)
+       }
+
+}