RIC-1024: ErrorIndication handling at Submgr 71/12571/7
authoraditverm <aditya.3.verma@nokia.com>
Mon, 26 Feb 2024 09:53:27 +0000 (11:53 +0200)
committeraditverm <aditya.3.verma@nokia.com>
Mon, 26 Feb 2024 13:14:51 +0000 (15:14 +0200)
Change-Id: Iea2e0d899e3ed79d3bb5305440d535504e4c2440
Signed-off-by: aditverm <aditya.3.verma@nokia.com>
17 files changed:
Dockerfile
e2ap/go.mod
e2ap/libe2ap_wrapper/E2AP_if.c
e2ap/libe2ap_wrapper/E2AP_if.h
e2ap/pkg/e2ap/e2ap_packerif.go
e2ap/pkg/e2ap/msg_e2ap.go
e2ap/pkg/e2ap/msg_e2ap_subscription.go
e2ap/pkg/e2ap_wrapper/packer_e2ap.go
e2ap/pkg/e2ap_wrapper/ut_packer_e2ap.go
go.mod
pkg/control/control.go
pkg/control/e2ap.go
pkg/control/metrics.go
pkg/control/metrics_test.go
pkg/control/ut_messaging_test.go
pkg/control/ut_test.go
pkg/teststube2ap/stubE2.go

index d51ab1d..d380663 100644 (file)
@@ -25,7 +25,7 @@
 ###########################################################
 FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-ubuntu20-c-go:1.0.0 as submgrcore
 
-ARG GOVERSION="1.18.5"
+ARG GOVERSION="1.21.6"
 RUN wget -nv https://dl.google.com/go/go${GOVERSION}.linux-amd64.tar.gz \
      && tar -xf go${GOVERSION}.linux-amd64.tar.gz \
      && mv go /opt/go/${GOVERSION} \
@@ -65,7 +65,7 @@ RUN export GOBIN=/usr/local/bin/ ; \
 #
 # RMR
 #
-ARG RMRVERSION=4.9.4
+ARG RMRVERSION=4.9.0
 ARG RMRLIBURL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb
 ARG RMRDEVURL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb
 RUN wget --content-disposition ${RMRLIBURL} && dpkg -i rmr_${RMRVERSION}_amd64.deb
@@ -115,11 +115,9 @@ RUN cd e2ap && go test -v ./pkg/conv
 RUN cd e2ap && go test -v ./pkg/e2ap_wrapper
 
 # test formating (not important)
-RUN cd e2ap && test -z "$(gofmt -l pkg/conv/*.go)"
-RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap_wrapper/*.go)"
-RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/*.go)"
-RUN cd e2ap && test -z "$(gofmt -l pkg/e2ap/e2ap_tests/*.go)"
-
+RUN cd e2ap
+RUN test -z "$(gofmt -l pkg/conv/*.go)" && test -z "$(gofmt -l pkg/e2ap_wrapper/*.go)" \
+    && test -z "$(gofmt -l pkg/e2ap/*.go)" && test -z "$(gofmt -l pkg/e2ap/e2ap_tests/*.go)"
 
 ###########################################################
 #
@@ -182,19 +180,15 @@ ENV RMR_SEED_RT=/opt/submgr/test/uta_rtg.rt
 #RUN RMR_VCTL_FILE=/opt/submgr/level go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control 
 
 #
-# go tests. comment out ipv6 localhost if exist when tests are executed.
+# go tests.
 #
-RUN sed -r  "s/^(::1.*)/#\1/" /etc/hosts  > /etc/hosts.new \
-    && cat /etc/hosts.new > /etc/hosts \
-    && cat /etc/hosts  \
-    && go test -failfast -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control \
-    && go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html    
+RUN go test -failfast -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control \
+    && go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html
 
 # test formating (not important)
-RUN test -z "$(gofmt -l pkg/control/*.go)"
-RUN test -z "$(gofmt -l pkg/teststub/*.go)"
-RUN test -z "$(gofmt -l pkg/teststubdummy/*.go)"
-RUN test -z "$(gofmt -l pkg/teststube2ap/*.go)"
+RUN cd pkg
+RUN test -z "$(gofmt -l control/*.go)" && test -z "$(gofmt -l teststub/*.go)" \
+    && test -z "$(gofmt -l teststubdummy/*.go)" && test -z "$(gofmt -l teststube2ap/*.go)"
 
 
 ###########################################################
index 6143b08..c4eafed 100644 (file)
@@ -1,4 +1,4 @@
-go 1.12
+go 1.21
 
 module gerrit.o-ran-sc.org/r/ric-plt/e2ap
 
index 64bb5bc..c17373f 100644 (file)
@@ -61,6 +61,7 @@ const uint64_t cE2UnsuccessfulOutcome = 3;
 const uint64_t cRICSubscriptionRequest = 1;
 const uint64_t cRICSubscriptionDeleteRequest = 2;
 const uint64_t cRICSubscriptionDeleteRequired = 3;
+const uint64_t cRICE2RanErrorIndication = 4;
 
 // Successful outcome
 const uint64_t cRICSubscriptionResponse = 1;
@@ -723,6 +724,17 @@ e2ap_pdu_ptr_t* unpackE2AP_pdu(const size_t dataBufferSize, const byte* dataBuff
                                     pE2AP_PDU->choice.initiatingMessage.value.present);
                             return 0;
                         }
+            }else if (pE2AP_PDU->choice.initiatingMessage.procedureCode == ProcedureCode_id_ErrorIndication) {
+                printf("ProcedureCode is ProcedureCode_id_ErrorIndication present\n");
+                if (pE2AP_PDU->choice.initiatingMessage.value.present == InitiatingMessage__value_PR_ErrorIndication) {
+                    pMessageInfo->messageType = cE2InitiatingMessage;
+                    pMessageInfo->messageId = cRICE2RanErrorIndication;
+                    return (e2ap_pdu_ptr_t*)pE2AP_PDU;
+                }
+                else {
+                    sprintf(pLogBuffer,"Error. Not supported initiatingMessage MessageId = %u",pE2AP_PDU->choice.initiatingMessage.value.present);
+                    return 0;
+                }
             }
             else {
                 sprintf(pLogBuffer,"Error. Procedure not supported. ProcedureCode = %li",pE2AP_PDU->choice.initiatingMessage.procedureCode);
@@ -1439,3 +1451,163 @@ uint64_t getRICSubscriptionDeleteRequiredData(e2ap_pdu_ptr_t *pE2AP_PDU_pointer,
         return e2err_OK;
     }
 
+    //////////////////////////////////////////////////////////////////////
+uint64_t packRICE2RanErrorIndication(size_t* pDataBufferSize, byte* pDataBuffer, char* pLogBuffer, RICErrorIndication_t* pRICE2RanErrorIndication) {
+    E2AP_PDU_t* pE2AP_PDU = calloc(1, sizeof(E2AP_PDU_t));
+    if(pE2AP_PDU)
+       {
+        pE2AP_PDU->present = E2AP_PDU_PR_initiatingMessage;
+        pE2AP_PDU->choice.initiatingMessage.procedureCode = ProcedureCode_id_ErrorIndication;
+        pE2AP_PDU->choice.initiatingMessage.criticality = Criticality_reject;
+        pE2AP_PDU->choice.initiatingMessage.value.present = InitiatingMessage__value_PR_ErrorIndication;
+
+        // RICrequestID
+        ErrorIndication_IEs_t* pRICE2RanErrorIndication_IEs = calloc(1, sizeof(ErrorIndication_IEs_t));
+        printf("pRICE2RanErrorIndication->isRicRequestIdPresent is %s\n", pRICE2RanErrorIndication->isRicRequestIdPresent == true ? "true" : "false");
+        if (pRICE2RanErrorIndication->isRicRequestIdPresent == true) {
+
+        if (pRICE2RanErrorIndication_IEs) {
+            pRICE2RanErrorIndication_IEs->id = ProtocolIE_ID_id_RICrequestID;
+                printf("Inside RicRequestID ProtocolID\n");
+                pRICE2RanErrorIndication_IEs->criticality = Criticality_reject;
+                pRICE2RanErrorIndication_IEs->value.present = ErrorIndication_IEs__value_PR_RICrequestID;
+                pRICE2RanErrorIndication_IEs->value.choice.RICrequestID.ricRequestorID = pRICE2RanErrorIndication->ricRequestID.ricRequestorID;
+                pRICE2RanErrorIndication_IEs->value.choice.RICrequestID.ricInstanceID = pRICE2RanErrorIndication->ricRequestID.ricInstanceID;
+                printf("After Assigning to pRICE2RanErrorIndication_IEs->value.choice.RICrequestID.ricRequestorID: %ld\n", pRICE2RanErrorIndication_IEs->value.choice.RICrequestID.ricRequestorID);
+                printf("After Assigning to pRICE2RanErrorIndication_IEs->value.choice.RICrequestID.ricInstanceID: %ld\n", pRICE2RanErrorIndication_IEs->value.choice.RICrequestID.ricInstanceID);
+                
+                ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.ErrorIndication.protocolIEs.list, pRICE2RanErrorIndication_IEs);
+            }
+        }
+        // RANfunctionID
+        printf("pRICE2RanErrorIndication->isRanFunctionIdPresent is %s\n", pRICE2RanErrorIndication->isRanFunctionIdPresent == true ? "true" : "false");
+        if (pRICE2RanErrorIndication->isRanFunctionIdPresent == true) {
+        pRICE2RanErrorIndication_IEs = calloc(1, sizeof(ErrorIndication_IEs_t));
+        if (pRICE2RanErrorIndication_IEs) {
+            pRICE2RanErrorIndication_IEs->id = ProtocolIE_ID_id_RANfunctionID;
+                pRICE2RanErrorIndication_IEs->criticality = Criticality_reject;
+                pRICE2RanErrorIndication_IEs->value.present = ErrorIndication_IEs__value_PR_RANfunctionID;
+                pRICE2RanErrorIndication_IEs->value.choice.RANfunctionID = pRICE2RanErrorIndication->ranFunctionID;
+                ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.ErrorIndication.protocolIEs.list, pRICE2RanErrorIndication_IEs);
+            }
+        }
+        // Cause
+        printf("pRICE2RanErrorIndication->isCausePresent is %s\n", pRICE2RanErrorIndication->isCausePresent == true ? "true" : "false");
+        if (pRICE2RanErrorIndication->isCausePresent == true) {
+        pRICE2RanErrorIndication_IEs = calloc(1, sizeof(RICsubscriptionFailure_IEs_t));
+        if (pRICE2RanErrorIndication_IEs) {
+            pRICE2RanErrorIndication_IEs->id = ProtocolIE_ID_id_Cause;
+                printf("Inside Cause ProtocolID\n");
+                pRICE2RanErrorIndication_IEs->criticality = Criticality_reject;
+                pRICE2RanErrorIndication_IEs->value.present = ErrorIndication_IEs__value_PR_Cause;
+                if (pRICE2RanErrorIndication->cause.content == Cause_PR_ricRequest) {
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.present = Cause_PR_ricRequest;
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.ricRequest =
+                    pRICE2RanErrorIndication->cause.causeVal;
+                }
+                else if (pRICE2RanErrorIndication->cause.content == Cause_PR_ricService) {
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.present = Cause_PR_ricService;
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.ricService =
+                    pRICE2RanErrorIndication->cause.causeVal;
+                }
+                else if (pRICE2RanErrorIndication->cause.content == Cause_PR_e2Node) {
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.present = Cause_PR_e2Node;
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.e2Node =
+                    pRICE2RanErrorIndication->cause.causeVal;
+                }
+                else if (pRICE2RanErrorIndication->cause.content == Cause_PR_transport) {
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.present = Cause_PR_transport;
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.transport =
+                    pRICE2RanErrorIndication->cause.causeVal;
+                }
+                else if (pRICE2RanErrorIndication->cause.content == Cause_PR_protocol) {
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.present = Cause_PR_protocol;
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.protocol =
+                    pRICE2RanErrorIndication->cause.causeVal;
+                }
+                else if (pRICE2RanErrorIndication->cause.content == Cause_PR_misc) {
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.present = Cause_PR_misc;
+                    pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.misc =
+                    pRICE2RanErrorIndication->cause.causeVal;
+                }
+                ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.initiatingMessage.value.choice.ErrorIndication.protocolIEs.list, pRICE2RanErrorIndication_IEs);
+            }
+        }
+        // CriticalityDiagnostics, OPTIONAL. Not used in RIC
+
+        
+        if (E2encode(pE2AP_PDU, pDataBufferSize, pDataBuffer, pLogBuffer))
+            return e2err_OK;
+        else
+            return e2err_RICE2RanErrorIndicationEncodeFail;
+
+    }
+    else
+        return e2err_RICE2RanErrorIndicationAllocE2AP_PDUFail;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+uint64_t getRICE2RanErrorIndicationData(e2ap_pdu_ptr_t* pE2AP_PDU_pointer, RICErrorIndication_t* pRICE2RanErrorIndication) {
+    E2AP_PDU_t* pE2AP_PDU = (E2AP_PDU_t*)pE2AP_PDU_pointer;
+
+    ErrorIndication_t *asnRicE2RanErrorIndication = &pE2AP_PDU->choice.initiatingMessage.value.choice.ErrorIndication;
+    ErrorIndication_IEs_t* pRICE2RanErrorIndication_IEs;
+
+    for (int i = 0; i < asnRicE2RanErrorIndication->protocolIEs.list.count; i++) {
+
+        pRICE2RanErrorIndication_IEs = asnRicE2RanErrorIndication->protocolIEs.list.array[i];
+        if (asnRicE2RanErrorIndication->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID) {
+
+            if (pRICE2RanErrorIndication_IEs->value.present == ErrorIndication_IEs__value_PR_RICrequestID) {
+                printf("Inside ErrorIndication_IEs__value_PR_RICrequestID\n");
+                pRICE2RanErrorIndication->isRicRequestIdPresent = true;
+                pRICE2RanErrorIndication->ricRequestID.ricRequestorID = pRICE2RanErrorIndication_IEs->value.choice.RICrequestID.ricRequestorID;
+                pRICE2RanErrorIndication->ricRequestID.ricInstanceID = pRICE2RanErrorIndication_IEs->value.choice.RICrequestID.ricInstanceID;
+            }
+            else {
+                printf("ErrorIndication_IEs__value_PR_RICrequestID is not present\n");
+                pRICE2RanErrorIndication->isRicRequestIdPresent = false;
+            }
+        }
+
+        if (asnRicE2RanErrorIndication->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_Cause) {
+            printf("Inside ProtocolIE_ID_id_Cause\n");
+            if (pRICE2RanErrorIndication_IEs->value.present == ErrorIndication_IEs__value_PR_Cause) {
+                pRICE2RanErrorIndication->isCausePresent = true;
+                if (pRICE2RanErrorIndication_IEs->value.choice.Cause.present == Cause_PR_ricRequest) {
+                    pRICE2RanErrorIndication->cause.content = Cause_PR_ricRequest;
+                    pRICE2RanErrorIndication->cause.causeVal = pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.ricRequest;
+                }
+                else if (pRICE2RanErrorIndication_IEs->value.choice.Cause.present == Cause_PR_ricService) {
+                    pRICE2RanErrorIndication->cause.content = Cause_PR_ricService;
+                    pRICE2RanErrorIndication->cause.causeVal = pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.ricService;
+                }
+                else if (pRICE2RanErrorIndication_IEs->value.choice.Cause.present == Cause_PR_e2Node) {
+                    pRICE2RanErrorIndication->cause.content = Cause_PR_e2Node;
+                    pRICE2RanErrorIndication->cause.causeVal = pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.e2Node;
+                }
+                else if (pRICE2RanErrorIndication_IEs->value.choice.Cause.present == Cause_PR_transport) {
+                    pRICE2RanErrorIndication->cause.content = Cause_PR_transport;
+                    pRICE2RanErrorIndication->cause.causeVal = pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.transport;
+                }
+                else if (pRICE2RanErrorIndication_IEs->value.choice.Cause.present == Cause_PR_protocol) {
+                    pRICE2RanErrorIndication->cause.content = Cause_PR_protocol;
+                    pRICE2RanErrorIndication->cause.causeVal = pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.protocol;
+                }
+                else if(pRICE2RanErrorIndication_IEs->value.choice.Cause.present == Cause_PR_misc) {
+                    pRICE2RanErrorIndication->cause.content = Cause_PR_misc;
+                    pRICE2RanErrorIndication->cause.causeVal = pRICE2RanErrorIndication_IEs->value.choice.Cause.choice.misc;
+                }
+            }
+            else {
+                printf("ErrorIndication_IEs__value_PR_Cause is not present\n");
+                pRICE2RanErrorIndication->isCausePresent = false;
+            }
+        }
+    }
+
+    ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
+    return e2err_OK;
+}
+
index a98570c..ee68b0e 100644 (file)
@@ -61,6 +61,8 @@ typedef uint16_t RANFunctionID_t; // 0..4095
 
 typedef uint64_t RICActionID_t; // 0..255
 
+typedef long TransactionID_t;
+
 enum RICActionType_t {
      RICActionType_report,
      RICActionType_insert,
@@ -299,7 +301,9 @@ enum e2err {
     e2err_RICsubscriptionDeleteResponseRANfunctionIDWrongOrder,
     e2err_RICsubscriptionDeleteFailureRICrequestIDWrongOrder,
     e2err_RICsubscriptionDeleteFailureRANfunctionIDWrongOrder,
-    e2err_RICsubscriptionDeleteFailureRICcauseWrongOrder
+    e2err_RICsubscriptionDeleteFailureRICcauseWrongOrder,
+    e2err_RICE2RanErrorIndicationEncodeFail,
+    e2err_RICE2RanErrorIndicationAllocE2AP_PDUFail
 };
 
 static const char* const E2ErrorStrings[] = {
@@ -368,6 +372,8 @@ static const char* const E2ErrorStrings[] = {
     "e2err_RICsubscriptionFailureRICrequestIDWrongOrder",
     "e2err_RICsubscriptionFailureRANfunctionIDWrongOrder",
     "e2err_RICsubscriptionFailureCauseWrongOrder",
+    "e2err_RICE2RanErrorIndicationEncodeFail",
+    "e2err_RICE2RanErrorIndicationAllocE2AP_PDUFail",
 };
 
 typedef struct {
@@ -389,6 +395,7 @@ extern const uint64_t cE2UnsuccessfulOutcome;
 extern const uint64_t cRICSubscriptionRequest;
 extern const uint64_t cRICSubscriptionDeleteRequest;
 extern const uint64_t cRICSubscriptionDeleteRequired;
+extern const uint64_t cRICE2RanErrorIndication;
 
 // Successful outcome
 extern const uint64_t cRICSubscriptionResponse;
@@ -450,6 +457,19 @@ typedef struct {
 
 } RICSubsDeleteRequired_t;
 
+typedef struct {
+    bool isTransactionIdPresent;
+    TransactionID_t transactionId;
+    bool isRicRequestIdPresent;
+    RICRequestID_t ricRequestID;
+    bool isRanFunctionIdPresent;
+    RANFunctionID_t ranFunctionID;
+    bool isCausePresent;
+    RICCause_t cause;
+    bool criticalityDiagnosticsPresent;
+    CriticalityDiagnostics__t criticalityDiagnostics;
+} RICErrorIndication_t;
+
 //////////////////////////////////////////////////////////////////////
 // Function declarations
 
@@ -468,6 +488,7 @@ uint64_t packRICSubscriptionDeleteRequest(size_t*, byte*, char*,RICSubscriptionD
 uint64_t packRICSubscriptionDeleteResponse(size_t*, byte*, char*,RICSubscriptionDeleteResponse_t*);
 uint64_t packRICSubscriptionDeleteFailure(size_t*, byte*, char*,RICSubscriptionDeleteFailure_t*);
 uint64_t packRICSubscriptionDeleteRequired(size_t*, byte*, char*,RICSubsDeleteRequired_t*);
+uint64_t packRICE2RanErrorIndication(size_t*, byte*, char*,RICErrorIndication_t*);
 
 e2ap_pdu_ptr_t* unpackE2AP_pdu(const size_t, const byte*, char*, E2MessageInfo_t*);
 uint64_t getRICSubscriptionRequestData(e2ap_pdu_ptr_t*, RICSubscriptionRequest_t*);
@@ -477,6 +498,7 @@ uint64_t getRICSubscriptionDeleteRequestData(e2ap_pdu_ptr_t*, RICSubscriptionDel
 uint64_t getRICSubscriptionDeleteResponseData(e2ap_pdu_ptr_t*, RICSubscriptionDeleteResponse_t*);
 uint64_t getRICSubscriptionDeleteFailureData(e2ap_pdu_ptr_t*, RICSubscriptionDeleteFailure_t*);
 uint64_t getRICSubscriptionDeleteRequiredData(e2ap_pdu_ptr_t*, RICSubsDeleteRequired_t*);
+uint64_t getRICE2RanErrorIndicationData(e2ap_pdu_ptr_t*, RICErrorIndication_t*);
 
 #if DEBUG
 bool TestRICSubscriptionRequest();
index 5e327d5..0e39573 100644 (file)
@@ -82,6 +82,15 @@ type E2APMsgPackerSubscriptionDeleteRequiredIf interface {
        String() string
 }
 
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type E2APMsgPackerErrorIndicationIf interface {
+       Pack(*E2APErrorIndication) (error, *PackedData)
+       UnPack(msg *PackedData) (error, *E2APErrorIndication)
+       String() string
+}
+
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
@@ -93,6 +102,7 @@ type E2APPackerIf interface {
        NewPackerSubscriptionDeleteResponse() E2APMsgPackerSubscriptionDeleteResponseIf
        NewPackerSubscriptionDeleteFailure() E2APMsgPackerSubscriptionDeleteFailureIf
        NewPackerSubscriptionDeleteRequired() E2APMsgPackerSubscriptionDeleteRequiredIf
+       NewPackerErrorIndication() E2APMsgPackerErrorIndicationIf
        //UnPack(*PackedData) (error, interface{})
        //Pack(interface{}, *PackedData) (error, *PackedData)
 }
index 35711a6..507a15a 100644 (file)
@@ -20,8 +20,9 @@
 package e2ap
 
 import (
-       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/conv"
        "strconv"
+
+       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/conv"
 )
 
 //-----------------------------------------------------------------------------
@@ -132,6 +133,22 @@ func (rid *RequestId) String() string {
 //-----------------------------------------------------------------------------
 type FunctionId uint16
 
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type RanFunctionID struct {
+       isRanFuncIdPresent bool
+       FunctionId         uint16
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type TransactionId struct {
+       transactionIdPresent bool
+       transactionID        uint32
+}
+
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
@@ -334,6 +351,43 @@ const (
        E2AP_CauseValue_RICrequest_unspecified                                    uint8 = 13
 )
 
+// CauseRICservice ENUMERATED, E2AP-v02.00
+const (
+       E2AP_CauseValue_RICservice_ran_function_not_supported uint8 = 0
+       E2AP_CauseValue_RICservice_excessive_functions        uint8 = 1
+       E2AP_CauseValue_RICservice_ric_resource_limit         uint8 = 2
+)
+
+// CauseE2node ENUMERATED, E2AP-v02.00
+const (
+       E2AP_CauseValue_CauseE2node_e2node_component_unknown uint8 = 0
+)
+
+// CauseTransport ENUMERATED, E2AP-v02.00
+const (
+       E2AP_CauseValue_CauseTransport_unspecified                    uint8 = 0
+       E2AP_CauseValue_CauseTransport_transport_resource_unavailable uint8 = 1
+)
+
+// CauseProtocol ENUMERATED, E2AP-v02.00
+const (
+       E2AP_CauseValue_CauseProtocol_transfer_syntax_error                             uint8 = 0
+       E2AP_CauseValue_CauseProtocol_abstract_syntax_error_reject                      uint8 = 1
+       E2AP_CauseValue_CauseProtocol_abstract_syntax_error_ignore_and_notify           uint8 = 2
+       E2AP_CauseValue_CauseProtocol_message_not_compatible_with_receiver_state        uint8 = 3
+       E2AP_CauseValue_CauseProtocol_semantic_error                                    uint8 = 4
+       E2AP_CauseValue_CauseProtocol_abstract_syntax_error_falsely_constructed_message uint8 = 5
+       E2AP_CauseValue_CauseProtocol_unspecified                                       uint8 = 6
+)
+
+// CauseMisc ENUMERATED, E2AP-v02.00
+const (
+       E2AP_CauseValue_CauseMisc_control_processing_overload uint8 = 0
+       E2AP_CauseValue_CauseMisc_hardware_failure            uint8 = 1
+       E2AP_CauseValue_CauseMisc_om_intervention             uint8 = 2
+       E2AP_CauseValue_CauseMisc_unspecified                 uint8 = 3
+)
+
 type Cause struct {
        Content uint8
        Value   uint8
@@ -401,5 +455,7 @@ type CriticalityDiagnostics struct {
        TrigMsg         uint64
        ProcCritPresent bool
        ProcCrit        uint8 //Crit
+       IsRicReqPresent bool
+       RequestId
        CriticalityDiagnosticsIEList
 }
index 7073831..2a5f237 100644 (file)
@@ -55,3 +55,16 @@ type E2APSubscriptionFailure struct {
        Cause
        CriticalityDiagnostics
 }
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type E2APErrorIndication struct {
+       TransactionId
+       IsReqIdPresent bool
+       RequestId
+       RanFunctionID
+       IsCausePresent bool
+       Cause
+       CriticalityDiagnostics
+}
index bceb66f..bcd6bfb 100644 (file)
@@ -46,6 +46,9 @@ package e2ap_wrapper
 // void initSubsDeleteRequired(RICSubsDeleteRequired_t *data){
 //      bzero(data,sizeof(RICSubsDeleteRequired_t));
 // }
+// void initRicE2RanErrorIndication(RICErrorIndication_t *data){
+//   bzero(data,sizeof(RICErrorIndication_t));
+// }
 //
 import "C"
 
@@ -465,6 +468,10 @@ func (item *e2apEntryCriticalityDiagnostic) get(data *e2ap.CriticalityDiagnostic
        data.ProcCritPresent = (bool)(item.entry.procedureCriticalityPresent)
        data.ProcCrit = (uint8)(item.entry.procedureCriticality)
 
+       data.IsRicReqPresent = (bool)(item.entry.ricRequestorIDPresent)
+       data.RequestId.Id = (uint32)(item.entry.ricRequestorID.ricRequestorID)
+       data.RequestId.InstanceId = (uint32)(item.entry.ricRequestorID.ricInstanceID)
+
        if item.entry.iEsCriticalityDiagnosticsPresent == true {
                conlen := (int)(item.entry.criticalityDiagnosticsIELength)
                data.CriticalityDiagnosticsIEList.Items = make([]e2ap.CriticalityDiagnosticsIEListItem, conlen)
@@ -477,6 +484,52 @@ func (item *e2apEntryCriticalityDiagnostic) get(data *e2ap.CriticalityDiagnostic
        return nil
 }
 
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type e2apEntryCause struct {
+       entry *C.RICCause_t
+}
+
+func (item *e2apEntryCause) set(data *e2ap.Cause) error {
+
+       item.entry.content = (C.uchar)(data.Content)
+       item.entry.causeVal = (C.uchar)(data.Value)
+
+       return nil
+}
+
+func (item *e2apEntryCause) get(data *e2ap.Cause) error {
+
+       data.Content = (uint8)(item.entry.content)
+       data.Value = (uint8)(item.entry.causeVal)
+
+       return nil
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type e2apEntryRicRequestId struct {
+       entry *C.RICRequestID_t
+}
+
+func (item *e2apEntryRicRequestId) set(data *e2ap.RequestId) error {
+
+       item.entry.ricRequestorID = (C.uint32_t)(data.Id)
+       item.entry.ricInstanceID = (C.uint32_t)(data.InstanceId)
+
+       return nil
+}
+
+func (item *e2apEntryRicRequestId) get(data *e2ap.RequestId) error {
+
+       data.Id = (uint32)(item.entry.ricRequestorID)
+       data.InstanceId = (uint32)(item.entry.ricInstanceID)
+
+       return nil
+}
+
 /*
 //-----------------------------------------------------------------------------
 //
@@ -1202,6 +1255,141 @@ func (e2apMsg *e2apMsgPackerSubscriptionDeleteRequired) String() string {
        return b.String()
 }
 
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type e2apMsgPackerErrorIndication struct {
+       e2apMessagePacker
+       msgC *C.RICErrorIndication_t
+       msgG *e2ap.E2APErrorIndication
+}
+
+func (e2apMsg *e2apMsgPackerErrorIndication) init() {
+       e2apMsg.e2apMessagePacker.init(C.E2MessageInfo_t{C.cE2InitiatingMessage, C.cRICE2RanErrorIndication})
+       e2apMsg.msgC = &C.RICErrorIndication_t{}
+       e2apMsg.msgG = &e2ap.E2APErrorIndication{}
+       C.initRicE2RanErrorIndication(e2apMsg.msgC)
+}
+
+func (e2apMsg *e2apMsgPackerErrorIndication) Pack(data *e2ap.E2APErrorIndication) (error, *e2ap.PackedData) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+       e2apMsg.msgG = data
+
+       e2apMsg.msgC.isRicRequestIdPresent = false
+       if e2apMsg.msgG.IsReqIdPresent {
+               e2apMsg.msgC.isRicRequestIdPresent = true
+               if err := (&e2apEntryRicRequestId{entry: &e2apMsg.msgC.ricRequestID}).set(&e2apMsg.msgG.RequestId); err != nil {
+                       return err, nil
+               }
+       }
+
+       e2apMsg.msgC.isCausePresent = false
+       if e2apMsg.msgG.IsCausePresent {
+               e2apMsg.msgC.isCausePresent = true
+               if err := (&e2apEntryCause{entry: &e2apMsg.msgC.cause}).set(&e2apMsg.msgG.Cause); err != nil {
+                       return err, nil
+               }
+       }
+
+       e2apMsg.msgC.criticalityDiagnosticsPresent = false
+       if e2apMsg.msgG.CriticalityDiagnostics.Present {
+               e2apMsg.msgC.criticalityDiagnosticsPresent = true
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).set(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
+                       return err, nil
+               }
+       }
+
+       errorNro := C.packRICE2RanErrorIndication(&e2apMsg.plen, (*C.uchar)(e2apMsg.p), (*C.char)(unsafe.Pointer(&e2apMsg.lb[0])), e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, nil
+       }
+
+       fmt.Printf("After Completed packRICE2RanErrorIndication\n")
+       fmt.Printf("e2apMsg.msgC.isRicRequestIdPresent is %t\n", e2apMsg.msgC.isRicRequestIdPresent)
+
+       return nil, e2apMsg.packeddata()
+}
+
+func (e2apMsg *e2apMsgPackerErrorIndication) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APErrorIndication) {
+       e2apMsg.init()
+       defer e2apMsg.fini()
+
+       if err := e2apMsg.e2apMessagePacker.unpacktopdu(msg); err != nil {
+               return err, e2apMsg.msgG
+       }
+
+       errorNro := C.getRICE2RanErrorIndicationData(e2apMsg.e2apMessagePacker.pdu, e2apMsg.msgC)
+       if err := e2apMsg.checkerr(errorNro); err != nil {
+               return err, e2apMsg.msgG
+       }
+
+       fmt.Println("Completed getRICE2RanErrorIndicationData")
+
+       fmt.Printf("e2apMsg.msgC.isRicRequestIdPresent = %t\n", e2apMsg.msgC.isRicRequestIdPresent)
+
+       if e2apMsg.msgC.isRicRequestIdPresent == true {
+               e2apMsg.msgG.IsReqIdPresent = true
+               if err := (&e2apEntryRicRequestId{entry: &e2apMsg.msgC.ricRequestID}).get(&e2apMsg.msgG.RequestId); err != nil {
+                       return err, e2apMsg.msgG
+               }
+       }
+
+       fmt.Printf("e2apMsg.msgC.isCausePresent = %t\n", e2apMsg.msgC.isCausePresent)
+
+       if e2apMsg.msgC.isCausePresent == true {
+               e2apMsg.msgG.IsCausePresent = true
+               if err := (&e2apEntryCause{entry: &e2apMsg.msgC.cause}).get(&e2apMsg.msgG.Cause); err != nil {
+                       return err, e2apMsg.msgG
+               }
+       }
+
+       if e2apMsg.msgC.criticalityDiagnosticsPresent == true {
+               e2apMsg.msgG.CriticalityDiagnostics.Present = true
+               if err := (&e2apEntryCriticalityDiagnostic{entry: &e2apMsg.msgC.criticalityDiagnostics}).get(&e2apMsg.msgG.CriticalityDiagnostics); err != nil {
+                       return err, e2apMsg.msgG
+               }
+       }
+
+       return nil, e2apMsg.msgG
+}
+
+func (e2apMsg *e2apMsgPackerErrorIndication) String() string {
+       var b bytes.Buffer
+       fmt.Fprintln(&b, "ricE2RanErrorIndication.")
+       fmt.Fprintln(&b, "  ricRequestID.")
+       fmt.Fprintln(&b, "    ricRequestorID =", e2apMsg.msgC.ricRequestID.ricRequestorID)
+       fmt.Fprintln(&b, "    ricInstanceID =", e2apMsg.msgC.ricRequestID.ricInstanceID)
+       fmt.Fprintln(&b, "  ranFunctionID =", e2apMsg.msgC.ranFunctionID)
+       //fmt.Fprintln(&b, "  ricActionNotAdmittedList.")
+       fmt.Fprintln(&b, "    cause.content =", e2apMsg.msgC.cause.content)
+       fmt.Fprintln(&b, "    cause.causeVal =", e2apMsg.msgC.cause.causeVal)
+
+       /* NOT SUPPORTED
+       if e2apMsg.msgC.criticalityDiagnosticsPresent {
+               fmt.Fprintln(&b, "  criticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnosticsPresent)
+               fmt.Fprintln(&b, "    criticalityDiagnostics.")
+               fmt.Fprintln(&b, "    procedureCodePresent =", e2apMsg.msgC.criticalityDiagnostics.procedureCodePresent)
+               fmt.Fprintln(&b, "      procedureCode =", e2apMsg.msgC.criticalityDiagnostics.procedureCode)
+               fmt.Fprintln(&b, "    triggeringMessagePresent =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessagePresent)
+               fmt.Fprintln(&b, "      triggeringMessage =", e2apMsg.msgC.criticalityDiagnostics.triggeringMessage)
+               fmt.Fprintln(&b, "    procedureCriticalityPresent=", e2apMsg.msgC.criticalityDiagnostics.procedureCriticalityPresent)
+               fmt.Fprintln(&b, "      procedureCriticality =", e2apMsg.msgC.criticalityDiagnostics.procedureCriticality)
+               fmt.Fprintln(&b, "    iEsCriticalityDiagnosticsPresent =", e2apMsg.msgC.criticalityDiagnostics.iEsCriticalityDiagnosticsPresent)
+               fmt.Fprintln(&b, "      criticalityDiagnosticsIELength =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength)
+               var index2 uint16
+               index2 = 0
+               for (C.ushort)(index2) < e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIELength {
+                       fmt.Fprintln(&b, "      criticalityDiagnosticsIEListItem[index2].iECriticality =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iECriticality)
+                       fmt.Fprintln(&b, "      criticalityDiagnosticsIEListItem[index2].iE_ID =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].iE_ID)
+                       fmt.Fprintln(&b, "      criticalityDiagnosticsIEListItem[index2].typeOfError =", e2apMsg.msgC.criticalityDiagnostics.criticalityDiagnosticsIEListItem[index2].typeOfError)
+                       index2++
+               }
+       }
+       */
+       return b.String()
+}
+
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
@@ -1257,6 +1445,12 @@ func (*cppasn1E2APPacker) NewPackerSubscriptionDeleteRequired() e2ap.E2APMsgPack
        return &e2apMsgPackerSubscriptionDeleteRequired{}
 }
 
+// Changes to support "RIC_E2_RAN_ERROR_INDICATION"
+func (*cppasn1E2APPacker) NewPackerErrorIndication() e2ap.E2APMsgPackerErrorIndicationIf {
+       fmt.Println("Inside NewPackerErrorIndication")
+       return &e2apMsgPackerErrorIndication{}
+}
+
 func NewAsn1E2Packer() e2ap.E2APPackerIf {
        return &cppasn1E2APPacker{}
 }
index fd2439b..228d722 100644 (file)
@@ -25,12 +25,13 @@ import (
 )
 
 const (
-       SUB_REQ         int = 1
-       SUB_RESP        int = 2
-       SUB_FAILURE     int = 3
-       SUB_DEL_REQ     int = 4
-       SUB_DEL_RESP    int = 5
-       SUB_DEL_FAILURE int = 6
+       SUB_REQ                     int = 1
+       SUB_RESP                    int = 2
+       SUB_FAILURE                 int = 3
+       SUB_DEL_REQ                 int = 4
+       SUB_DEL_RESP                int = 5
+       SUB_DEL_FAILURE             int = 6
+       RIC_E2_RAN_ERROR_INDICATION int = 7
 )
 
 //-----------------------------------------------------------------------------
@@ -40,12 +41,13 @@ const (
 var origPackerif e2ap.E2APPackerIf = NewAsn1E2Packer()
 
 var allowAction = map[int]bool{
-       SUB_REQ:         true,
-       SUB_RESP:        true,
-       SUB_FAILURE:     true,
-       SUB_DEL_REQ:     true,
-       SUB_DEL_RESP:    true,
-       SUB_DEL_FAILURE: true,
+       SUB_REQ:                     true,
+       SUB_RESP:                    true,
+       SUB_FAILURE:                 true,
+       SUB_DEL_REQ:                 true,
+       SUB_DEL_RESP:                true,
+       SUB_DEL_FAILURE:             true,
+       RIC_E2_RAN_ERROR_INDICATION: true,
 }
 
 func AllowE2apToProcess(mtype int, actionFail bool) {
@@ -256,6 +258,24 @@ func (e2apMsg *utMsgPackerSubscriptionDeleteRequired) UnPack(msg *e2ap.PackedDat
        return fmt.Errorf("Error: Set to be fail by UT"), nil
 }
 
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type utMsgPackerRicE2RanErrorIndication struct {
+       e2apMsgPackerErrorIndication
+}
+
+func (e2apMsg *utMsgPackerRicE2RanErrorIndication) init() {
+}
+
+func (e2apMsg *utMsgPackerRicE2RanErrorIndication) UnPack(msg *e2ap.PackedData) (error, *e2ap.E2APErrorIndication) {
+       if allowAction[RIC_E2_RAN_ERROR_INDICATION] {
+               errIndication := origPackerif.NewPackerErrorIndication()
+               return errIndication.UnPack(msg)
+       }
+       return fmt.Errorf("Error: Set to be fail by UT"), nil
+}
+
 //-----------------------------------------------------------------------------
 // Public E2AP packer creators
 //-----------------------------------------------------------------------------
@@ -290,6 +310,10 @@ func (p *utAsn1E2APPacker) NewPackerSubscriptionDeleteRequired() e2ap.E2APMsgPac
        return &utMsgPackerSubscriptionDeleteRequired{}
 }
 
+func (*utAsn1E2APPacker) NewPackerErrorIndication() e2ap.E2APMsgPackerErrorIndicationIf {
+       return &utMsgPackerRicE2RanErrorIndication{}
+}
+
 func NewUtAsn1E2APPacker() e2ap.E2APPackerIf {
        return &utAsn1E2APPacker{}
 }
diff --git a/go.mod b/go.mod
index 432ba85..5d6d89c 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -1,10 +1,10 @@
 module gerrit.o-ran-sc.org/r/ric-plt/submgr
 
-go 1.18
+go 1.21
 
 replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.8.0
 
-replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.9.16
+replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.9.22
 
 replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.2
 
@@ -22,3 +22,7 @@ require (
        github.com/spf13/viper v1.4.0
        github.com/stretchr/testify v1.5.1
 )
+
+require (
+    gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1 // indirect
+)
index 1f769e1..b106ab0 100755 (executable)
@@ -671,6 +671,9 @@ func (c *Control) handleSubscriptionRequest(trans *TransactionXapp, subReqMsg *e
                case *e2ap.E2APSubscriptionFailure:
                        err = fmt.Errorf("RICSubscriptionFailure. E2NodeCause: (Cause:%v, Value %v)", themsg.Cause.Content, themsg.Cause.Value)
                        errorInfo.SetInfo(err.Error(), models.SubscriptionInstanceErrorSourceE2Node, "")
+               case *e2ap.E2APErrorIndication:
+                       err = fmt.Errorf("RICE2RanErrorIndication. E2NodeCause: (Cause:%v, Value %v)", themsg.Cause.Content, themsg.Cause.Value)
+                       errorInfo.SetInfo(err.Error(), models.SubscriptionInstanceErrorSourceE2Node, "")
                case *PackSubscriptionRequestErrortEvent:
                        err = fmt.Errorf("E2 RICSubscriptionRequest pack failure")
                        errorInfo = themsg.ErrorInfo
@@ -960,6 +963,8 @@ func (c *Control) Consume(msg *xapp.RMRParams) (err error) {
                go c.handleE2TSubscriptionDeleteFailure(msg)
        case xapp.RIC_SUB_DEL_REQUIRED:
                go c.handleE2TSubscriptionDeleteRequired(msg)
+       case xapp.RIC_E2_RAN_ERROR_INDICATION:
+               go c.handleE2RanErrorIndication(msg)
        default:
                xapp.Logger.Debug("Unknown Message Type '%d', discarding", msg.Mtype)
        }
@@ -1144,6 +1149,8 @@ func (c *Control) handleSubscriptionCreate(subs *Subscription, parentTrans *Tran
                                subRfMsg, valid = subs.SetCachedResponse(event, true)
                        }
                        xapp.Logger.Debug("SUBS-SubReq: internal delete due failure event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
+               case *e2ap.E2APErrorIndication:
+                       subRfMsg, valid = subs.SetCachedResponse(event, false)
                case *SubmgrRestartTestEvent:
                        // This is used to simulate that no response has been received and after restart, subscriptions are restored from db
                        xapp.Logger.Debug("Test restart flag is active. Dropping this transaction to test restart case")
@@ -1463,6 +1470,8 @@ func typeofSubsMessage(v interface{}) string {
                return "SubDelResp"
        case *e2ap.E2APSubscriptionDeleteFailure:
                return "SubDelFail"
+       case *e2ap.E2APErrorIndication:
+               return "RicE2RanErrorIndication"
        default:
                return "Unknown"
        }
@@ -1694,6 +1703,59 @@ func (c *Control) handleE2TSubscriptionDeleteRequired(params *xapp.RMRParams) {
        }
 }
 
+//-------------------------------------------------------------------
+// handle from E2T Error Indication
+//-------------------------------------------------------------------
+func (c *Control) handleE2RanErrorIndication(params *xapp.RMRParams) {
+       xapp.Logger.Debug("Received ErrorIndication from E2T")
+       xapp.Logger.Error("MSG from E2T: %s", params.String())
+
+       c.UpdateCounter(cErrorIndicationFromE2Node)
+
+       errorIndication, err := c.e2ap.UnpackErrorIndicationFromE2Node(params.Payload)
+       if err != nil {
+               xapp.Logger.Error("MSG-ErrorIndication From E2Node %s", idstring(err, params))
+               return
+       }
+
+       subs, err := c.registry.GetSubscriptionFirstMatch([]uint32{errorIndication.RequestId.InstanceId})
+       if err != nil {
+               xapp.Logger.Error("Unknown/Invalid InstanceId from E2Node. Dropping ErrorIndication from E2Node.")
+               xapp.Logger.Error("MSG-ErrorIndication From E2Node: %s", idstring(err, params))
+               if errorIndication.IsCausePresent == true {
+                       xapp.Logger.Debug("Cause is present in received ErrorIndication Message - Content: %v, Value: %v", errorIndication.Cause.Content, errorIndication.Cause.Value)
+               }
+               return
+       }
+
+       trans := subs.GetTransaction()
+       if trans == nil {
+               err = fmt.Errorf("Ongoing transaction not found")
+               xapp.Logger.Error("MSG-SubFail: %s", idstring(err, params, subs))
+               if errorIndication.IsCausePresent == true {
+                       xapp.Logger.Debug("Cause is present in received ErrorIndication Message - Content: %v, Value: %v", errorIndication.Cause.Content, errorIndication.Cause.Value)
+               }
+               return
+       }
+
+       if errorIndication.IsCausePresent == true {
+               xapp.Logger.Debug("Cause present in ErrorIndication is: Content: %v, Value: %v", errorIndication.Cause.Content, errorIndication.Cause.Value)
+               if (errorIndication.Cause.Content == e2ap.E2AP_CauseContent_Misc && (errorIndication.Cause.Value == e2ap.E2AP_CauseValue_CauseMisc_hardware_failure ||
+                       errorIndication.Cause.Value == e2ap.E2AP_CauseValue_CauseMisc_om_intervention)) ||
+                       (errorIndication.Cause.Content == e2ap.E2AP_CauseContent_E2node && errorIndication.Cause.Value == e2ap.E2AP_CauseValue_CauseE2node_e2node_component_unknown) {
+
+                       sendOk, timedOut := trans.SendEvent(errorIndication, e2tRecvMsgTimeout)
+                       if sendOk == false {
+                               err = fmt.Errorf("Passing event to transaction failed: sendOk(%t) timedOut(%t)", sendOk, timedOut)
+                               xapp.Logger.Error("MSG-ErrorIndication: %s", idstring(err, trans, subs))
+                       }
+               } else {
+                       xapp.Logger.Debug("Cause present in ErrorIndication is not serious problem. Retrying SubReq Procedure")
+               }
+       }
+       return
+}
+
 //-----------------------------------------------------------------
 // Initiate RIC Subscription Delete Request after receiving
 // RIC Subscription Delete Required from E2T
index f233bc4..4b92804 100644 (file)
@@ -291,3 +291,16 @@ func (c *E2ap) PackSubscriptionDeleteRequired(req *e2ap.SubscriptionDeleteRequir
        }
        return xapp.RIC_SUB_DEL_REQUIRED, packedData, nil
 }
+
+//-----------------------------------------------------------------------------
+// Changes to support "RIC_E2_RAN_ERROR_INDICATION"
+//-----------------------------------------------------------------------------
+func (e *E2ap) UnpackErrorIndicationFromE2Node(payload []byte) (*e2ap.E2APErrorIndication, error) {
+       fmt.Println("Inside UnpackErrorIndicationFromE2Node")
+       e2RanErrorIndication := packerif.NewPackerErrorIndication()
+       err, errorIndication := e2RanErrorIndication.UnPack(&e2ap.PackedData{payload})
+       if err != nil {
+               return nil, fmt.Errorf("%s buf[%s]", err.Error(), hex.EncodeToString(payload))
+       }
+       return errorIndication, nil
+}
index 3c875ca..11fe729 100644 (file)
@@ -5,45 +5,46 @@ import (
 )
 
 const (
-       cSubReqFromXapp         string = "SubReqFromXapp"
-       cRestSubReqFromXapp     string = "RestSubReqFromXapp"
-       cSubFailToXapp          string = "SubFailToXapp"
-       cSubRespToXapp          string = "SubRespToXapp"
-       cRestSubRespToXapp      string = "RestSubRespToXapp"
-       cRestSubFailToXapp      string = "RestSubFailToXapp"
-       cRestReqRejDueE2Down    string = "RestReqRejDueE2Down"
-       cRestSubNotifToXapp     string = "RestSubNotifToXapp"
-       cRestSubFailNotifToXapp string = "RestSubFailNotifToXapp"
-       cSubReqToE2             string = "SubReqToE2"
-       cSubReReqToE2           string = "SubReReqToE2"
-       cSubRespFromE2          string = "SubRespFromE2"
-       cPartialSubRespFromE2   string = "PartialSubRespFromE2"
-       cSubFailFromE2          string = "SubFailFromE2"
-       cSubReqTimerExpiry      string = "SubReqTimerExpiry"
-       cRouteCreateFail        string = "RouteCreateFail"
-       cRouteCreateUpdateFail  string = "RouteCreateUpdateFail"
-       cMergedSubscriptions    string = "MergedSubscriptions"
-       cDuplicateE2SubReq      string = "DuplicateE2SubReq"
-       cSubDelReqFromXapp      string = "SubDelReqFromXapp"
-       cSubDelRespToXapp       string = "SubDelRespToXapp"
-       cRestSubDelReqFromXapp  string = "RestSubDelReqFromXapp"
-       cRestSubDelRespToXapp   string = "RestSubDelRespToXapp"
-       cRestSubDelFailToXapp   string = "RestSubDelFailToXapp"
-       cSubDelReqToE2          string = "SubDelReqToE2"
-       cSubDelReReqToE2        string = "SubDelReReqToE2"
-       cSubDelRespFromE2       string = "SubDelRespFromE2"
-       cSubDelFailFromE2       string = "SubDelFailFromE2"
-       cSubDelReqTimerExpiry   string = "SubDelReqTimerExpiry"
-       cSubDelRequFromE2       string = "SubDelRequiredFromE2"
-       cRouteDeleteFail        string = "RouteDeleteFail"
-       cRouteDeleteUpdateFail  string = "RouteDeleteUpdateFail"
-       cUnmergedSubscriptions  string = "UnmergedSubscriptions"
-       cSDLWriteFailure        string = "SDLWriteFailure"
-       cSDLReadFailure         string = "SDLReadFailure"
-       cSDLRemoveFailure       string = "SDLRemoveFailure"
-       cE2StateChangedToUp     string = "E2StateChangedToUp"
-       cE2StateChangedToDown   string = "E2StateChangedToDown"
-       cE2StateUnderReset      string = "E2StateChangedToUnderReset"
+       cSubReqFromXapp            string = "SubReqFromXapp"
+       cRestSubReqFromXapp        string = "RestSubReqFromXapp"
+       cSubFailToXapp             string = "SubFailToXapp"
+       cSubRespToXapp             string = "SubRespToXapp"
+       cRestSubRespToXapp         string = "RestSubRespToXapp"
+       cRestSubFailToXapp         string = "RestSubFailToXapp"
+       cRestReqRejDueE2Down       string = "RestReqRejDueE2Down"
+       cRestSubNotifToXapp        string = "RestSubNotifToXapp"
+       cRestSubFailNotifToXapp    string = "RestSubFailNotifToXapp"
+       cSubReqToE2                string = "SubReqToE2"
+       cSubReReqToE2              string = "SubReReqToE2"
+       cSubRespFromE2             string = "SubRespFromE2"
+       cPartialSubRespFromE2      string = "PartialSubRespFromE2"
+       cSubFailFromE2             string = "SubFailFromE2"
+       cSubReqTimerExpiry         string = "SubReqTimerExpiry"
+       cRouteCreateFail           string = "RouteCreateFail"
+       cRouteCreateUpdateFail     string = "RouteCreateUpdateFail"
+       cMergedSubscriptions       string = "MergedSubscriptions"
+       cDuplicateE2SubReq         string = "DuplicateE2SubReq"
+       cSubDelReqFromXapp         string = "SubDelReqFromXapp"
+       cSubDelRespToXapp          string = "SubDelRespToXapp"
+       cRestSubDelReqFromXapp     string = "RestSubDelReqFromXapp"
+       cRestSubDelRespToXapp      string = "RestSubDelRespToXapp"
+       cRestSubDelFailToXapp      string = "RestSubDelFailToXapp"
+       cSubDelReqToE2             string = "SubDelReqToE2"
+       cSubDelReReqToE2           string = "SubDelReReqToE2"
+       cSubDelRespFromE2          string = "SubDelRespFromE2"
+       cSubDelFailFromE2          string = "SubDelFailFromE2"
+       cSubDelReqTimerExpiry      string = "SubDelReqTimerExpiry"
+       cSubDelRequFromE2          string = "SubDelRequiredFromE2"
+       cRouteDeleteFail           string = "RouteDeleteFail"
+       cRouteDeleteUpdateFail     string = "RouteDeleteUpdateFail"
+       cUnmergedSubscriptions     string = "UnmergedSubscriptions"
+       cSDLWriteFailure           string = "SDLWriteFailure"
+       cSDLReadFailure            string = "SDLReadFailure"
+       cSDLRemoveFailure          string = "SDLRemoveFailure"
+       cE2StateChangedToUp        string = "E2StateChangedToUp"
+       cE2StateChangedToDown      string = "E2StateChangedToDown"
+       cE2StateUnderReset         string = "E2StateChangedToUnderReset"
+       cErrorIndicationFromE2Node string = "ErrorIndicationFromE2Node"
 )
 
 func GetMetricsOpts() []xapp.CounterOpts {
@@ -95,6 +96,9 @@ func GetMetricsOpts() []xapp.CounterOpts {
                {Name: cE2StateChangedToUp, Help: "The total number of E2 interface change connected state"},
                {Name: cE2StateChangedToDown, Help: "The total number of E2 interface change disconnected state"},
                {Name: cE2StateUnderReset, Help: "The total number of E2 interface change under reset state"},
+
+               // ErrorIndication From E2Node counter
+               {Name: cErrorIndicationFromE2Node, Help: "The total number of ErrorIndication from E2Node"},
        }
 }
 
index 485f395..194cecb 100644 (file)
@@ -65,6 +65,7 @@ func TestAddAllCountersOnce(t *testing.T) {
                Counter{cE2StateChangedToUp, 1},
                Counter{cE2StateChangedToDown, 1},
                Counter{cE2StateUnderReset, 1},
+               Counter{cErrorIndicationFromE2Node, 1},
        })
 
        mainCtrl.c.UpdateCounter(cSubReqFromXapp)
@@ -105,6 +106,7 @@ func TestAddAllCountersOnce(t *testing.T) {
        mainCtrl.c.UpdateCounter(cE2StateChangedToUp)
        mainCtrl.c.UpdateCounter(cE2StateChangedToDown)
        mainCtrl.c.UpdateCounter(cE2StateUnderReset)
+       mainCtrl.c.UpdateCounter(cErrorIndicationFromE2Node)
 
        mainCtrl.VerifyCounterValues(t)
 }
index 538e214..956faa7 100644 (file)
@@ -114,39 +114,764 @@ func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestRESTSubReqE2ConnBreak
 //
+//     stub                             stub
+//
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//
+//     |                 |              |
+//     | RESTSubReq      |              |
+//     |---------------->|              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |      SubResp |
+//     |                 |<-------------|
+//     |                 |              |
+//     |         [E2 Conn. DOWN]        |
+//     |        [Int. SUBS DELETE]      |
+//     |                 |              |
+//     |      RESTNotif(unsuccessful)   |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 |              |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqE2ConnBreak(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cSubRespFromE2, 1},
+               Counter{cRestSubFailNotifToXapp, 1},
+               Counter{cE2StateChangedToDown, 1},
+               Counter{cE2StateChangedToUp, 1},
+       })
+
+       // Req
+       const subReqCount int = 1
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       xappConn1.ExpectRESTNotification(t, restSubId)
+
+       // E2 disconnect after E2term has received response
+       mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
+
+       e2termConn1.SendSubsResp(t, crereq, cremsg)
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       <-time.After(time.Second * 1)
+       assert.Equal(t, 0, len(mainCtrl.c.registry.register))
+       assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
+
+       subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
+       if err != nil {
+               xapp.Logger.Error("%v", err)
+       } else {
+               assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
+               assert.Equal(t, 0, len(register))
+       }
+
+       restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
+       if err != nil {
+               xapp.Logger.Error("%v", err)
+       } else {
+               assert.Equal(t, 0, len(restSubscriptions))
+       }
+
+       // Restore E2 connection for following test cases
+       mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
+
+       // Wait that subs is cleaned
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+       mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestReportRESTSubReqE2NodeSendsErrorIndicationWithCauseHwFailure
+//
+//     stub                             stub
+//
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//
+//     |                 |                |
+//     | RESTSubReq      |                |
+//     |---------------->|                |
+//     |     RESTSubResp |                |
+//     |<----------------|                |
+//     |                 | SubReq         |
+//     |                 |--------------->|
+//     |                 | ErrorIndication|
+//     |                 |<---------------|
+//     |                 |                |
+//     |                 |                |
+//     |      RESTNotif(unsuccessful)     |
+//     |<----------------|                |
+//     |                 |                |
+//     |                 |                |
+//
+//-----------------------------------------------------------------------------
+func TestReportRESTSubReqE2NodeSendsErrorIndicationWithCauseHwFailure(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cErrorIndicationFromE2Node, 1},
+               Counter{cRestSubFailNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+       })
+
+       // Req
+       const subReqCount int = 1
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       xappConn1.ExpectRESTNotification(t, restSubId)
+
+       e2termConn1.SendErrorIndication(t, crereq, cremsg)
+
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       fmt.Printf("e2SubsId: %v\n", e2SubsId)
+
+       //For Cleanup. Next testcase should start freshly.
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+       mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestPolicyRESTSubReqE2NodeSendsErrorIndicationWithCauseHwFailure
+//
+//     stub                             stub
+//
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//
+//     |                 |                |
+//     | RESTSubReq      |                |
+//     |---------------->|                |
+//     |     RESTSubResp |                |
+//     |<----------------|                |
+//     |                 | SubReq         |
+//     |                 |--------------->|
+//     |                 | ErrorIndication|
+//     |                 |<---------------|
+//     |                 |                |
+//     |                 |                |
+//     |      RESTNotif(unsuccessful)     |
+//     |<----------------|                |
+//     |                 |                |
+//     |                 |                |
+//
+//-----------------------------------------------------------------------------
+func TestPolicyRESTSubReqE2NodeSendsErrorIndicationWithCauseHwFailure(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cErrorIndicationFromE2Node, 1},
+               Counter{cRestSubFailNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+       })
+
+       // Req
+       const subReqCount int = 1
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       xappConn1.ExpectRESTNotification(t, restSubId)
+
+       //e2termConn1.SendSubsResp(t, crereq, cremsg)
+       e2termConn1.SendErrorIndication(t, crereq, cremsg)
+
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       fmt.Printf("e2SubsId: %v\n", e2SubsId)
+
+       //For Cleanup. Next testcase should start freshly.
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+       mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestReportRESTSubReqE2NodeSendsErrorIndicationWithInvalidInstanceId
+//
+//     stub                             stub
+//
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//
+//                     |                 |                |
+//                     | RESTSubReq      |                |
+//                     |---------------->|                |
+//                     |     RESTSubResp |                |
+//                     |<----------------|                |
+//                     |                 | SubReq         |
+//                     |                 |--------------->|
+//                     |                 | ErrorIndication|
+//                     |                 |<---------------|
+//                     |                 |                |
+//                     |                 |                |
+//                     |      ErrorIndication Dropped     |
+//                     |                 |                |
+//                     |                 |                |
+//                     |                 | SubReq         |
+//                     |                 |--------------->|
+//                     |                 | SubResp        |
+//                     |                 |<---------------|
+//                 | RestNotifToXapp |                |
+//             |<----------------|                |
+//                 |                 |                |
+//                 |                 |                |
+//                 | RESTSubDelReq   |                |
+//                 |---------------->|                |
+//                 |                 |                |
+//                 |  RESTSubDelResp |                |
+//                 |<----------------|                |
+//                 |                 | SubDelReq      |
+//                 |                 | -------------->|
+//                     |                 |                |
+//             |                 | SubDelResp     |
+//             |                 |<---------------|
+//
+//-----------------------------------------------------------------------------
+func TestReportRESTSubReqE2NodeSendsErrorIndicationWithInvalidInstanceId(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cErrorIndicationFromE2Node, 1},
+               Counter{cSubReqTimerExpiry, 1},
+               Counter{cSubReReqToE2, 1},
+               Counter{cSubRespFromE2, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelRespFromE2, 1},
+       })
+
+       // Req
+       const subReqCount int = 1
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       xappConn1.ExpectRESTNotification(t, restSubId)
+
+       e2termConn1.SendErrorIndicationWithInvalidInstanceId(t, crereq, cremsg)
+
+       crereq, cremsg = e2termConn1.RecvSubsReq(t)
+       e2termConn1.SendSubsResp(t, crereq, cremsg)
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+
+       mainCtrl.wait_registry_empty(t, 10)
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+       mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestPolicyRESTSubReqE2NodeSendsErrorIndicationWithInvalidInstanceId
+//
+//     stub                             stub
+//
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//
+//                     |                 |                |
+//                     | RESTSubReq      |                |
+//                     |---------------->|                |
+//                     |     RESTSubResp |                |
+//                     |<----------------|                |
+//                     |                 | SubReq         |
+//                     |                 |--------------->|
+//                     |                 | ErrorIndication|
+//                     |                 |<---------------|
+//                     |                 |                |
+//                     |                 |                |
+//                     |      ErrorIndication Dropped     |
+//                     |                 |                |
+//                     |                 |                |
+//                     |                 | SubReq         |
+//                     |                 |--------------->|
+//                     |                 | SubResp        |
+//                     |                 |<---------------|
+//                 | RestNotifToXapp |                |
+//             |<----------------|                |
+//                 |                 |                |
+//                 |                 |                |
+//                 | RESTSubDelReq   |                |
+//                 |---------------->|                |
+//                 |                 |                |
+//                 |  RESTSubDelResp |                |
+//                 |<----------------|                |
+//                 |                 | SubDelReq      |
+//                 |                 | -------------->|
+//                     |                 |                |
+//             |                 | SubDelResp     |
+//             |                 |<---------------|
+//
+//-----------------------------------------------------------------------------
+func TestPolicyRESTSubReqE2NodeSendsErrorIndicationWithInvalidInstanceId(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cErrorIndicationFromE2Node, 1},
+               Counter{cSubReqTimerExpiry, 1},
+               Counter{cSubReReqToE2, 1},
+               Counter{cSubRespFromE2, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelRespFromE2, 1},
+       })
+
+       // Req
+       const subReqCount int = 1
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       xappConn1.ExpectRESTNotification(t, restSubId)
+
+       e2termConn1.SendErrorIndicationWithInvalidInstanceId(t, crereq, cremsg)
+
+       crereq, cremsg = e2termConn1.RecvSubsReq(t)
+       e2termConn1.SendSubsResp(t, crereq, cremsg)
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+
+       mainCtrl.wait_registry_empty(t, 10)
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+       mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestReportRESTSubReqE2NodeSendsErrorIndicationWithValidInstanceIdButCauseIsNeitherUnspecifiedOrHWFailure
+//
+//     stub                             stub
+//
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//
+//                     |                 |                |
+//                     | RESTSubReq      |                |
+//                     |---------------->|                |
+//                     |     RESTSubResp |                |
+//                     |<----------------|                |
+//                     |                 | SubReq         |
+//                     |                 |--------------->|
+//                     |                 | ErrorIndication|
+//                     |                 |<---------------|
+//                     |                 |                |
+//                     |                 |                |
+//     ErrorIndication Dropped With Diff Cause    | Cause = excessive_actions
+//                     |                 |                |
+//                     |                 |                |
+//                     |                 | SubReq         |
+//                     |                 |--------------->|
+//                     |                 | SubResp        |
+//                     |                 |<---------------|
+//                 | RestNotifToXapp |                |
+//             |<----------------|                |
+//                 |                 |                |
+//                 |                 |                |
+//                 | RESTSubDelReq   |                |
+//                 |---------------->|                |
+//                 |                 |                |
+//                 |  RESTSubDelResp |                |
+//                 |<----------------|                |
+//                 |                 | SubDelReq      |
+//                 |                 | -------------->|
+//                     |                 |                |
+//             |                 | SubDelResp     |
+//             |                 |<---------------|
+//
+//-----------------------------------------------------------------------------
+func TestReportRESTSubReqE2NodeSendsErrorIndicationWithValidInstanceIdButCauseIsNeitherUnspecifiedOrHWFailure(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cErrorIndicationFromE2Node, 1},
+               Counter{cSubReqTimerExpiry, 1},
+               Counter{cSubReReqToE2, 1},
+               Counter{cSubRespFromE2, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelRespFromE2, 1},
+       })
+
+       // Req
+       const subReqCount int = 1
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       xappConn1.ExpectRESTNotification(t, restSubId)
+
+       e2termConn1.SendErrorIndicationWithDiffCause(t, crereq, cremsg)
+
+       crereq, cremsg = e2termConn1.RecvSubsReq(t)
+       e2termConn1.SendSubsResp(t, crereq, cremsg)
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+
+       mainCtrl.wait_registry_empty(t, 10)
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+       mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestPolicyRESTSubReqE2NodeSendsErrorIndicationWithValidInstanceIdButCauseIsNeitherUnspecifiedOrHWFailure
+//
+//     stub                             stub
+//
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//
+//                     |                 |                |
+//                     | RESTSubReq      |                |
+//                     |---------------->|                |
+//                     |     RESTSubResp |                |
+//                     |<----------------|                |
+//                     |                 | SubReq         |
+//                     |                 |--------------->|
+//                     |                 | ErrorIndication|
+//                     |                 |<---------------|
+//                     |                 |                |
+//                     |                 |                |
+//     ErrorIndication Dropped With Diff Cause    | Cause = excessive_actions
+//                     |                 |                |
+//                     |                 |                |
+//                     |                 | SubReq         |
+//                     |                 |--------------->|
+//                     |                 | SubResp        |
+//                     |                 |<---------------|
+//                 | RestNotifToXapp |                |
+//             |<----------------|                |
+//                 |                 |                |
+//                 |                 |                |
+//                 | RESTSubDelReq   |                |
+//                 |---------------->|                |
+//                 |                 |                |
+//                 |  RESTSubDelResp |                |
+//                 |<----------------|                |
+//                 |                 | SubDelReq      |
+//                 |                 | -------------->|
+//                     |                 |                |
+//             |                 | SubDelResp     |
+//             |                 |<---------------|
+//
+//-----------------------------------------------------------------------------
+func TestPolicyRESTSubReqE2NodeSendsErrorIndicationWithValidInstanceIdButCauseIsNeitherUnspecifiedOrHWFailure(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cErrorIndicationFromE2Node, 1},
+               Counter{cSubReqTimerExpiry, 1},
+               Counter{cSubReReqToE2, 1},
+               Counter{cSubRespFromE2, 1},
+               Counter{cRestSubNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelRespFromE2, 1},
+       })
+
+       // Req
+       const subReqCount int = 1
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       xappConn1.ExpectRESTNotification(t, restSubId)
+
+       e2termConn1.SendErrorIndicationWithDiffCause(t, crereq, cremsg)
+
+       crereq, cremsg = e2termConn1.RecvSubsReq(t)
+       e2termConn1.SendSubsResp(t, crereq, cremsg)
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // Wait that subs is cleaned
+
+       mainCtrl.wait_registry_empty(t, 10)
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+       mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTReportSubReqUnpackErrorIndicationDecodeFail
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |ErrorIndication | ASN.1 decode fails
+//     |                 |<-------------| Decode failed. More data needed. This will result timer expiry and resending
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |ErrorIndication | Valid InstanceId and Cause
+//     |                 |<-------------|
+//     | RESTNotif (fail)|              |
+//     |<----------------|              |
+//     |                 |              |
+//     |           [SUBS DELETE]        |
+//     |                 |              |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTReportSubReqUnpackErrorIndicationDecodeFail(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cSubReqTimerExpiry, 1},
+               Counter{cSubReReqToE2, 1},
+               Counter{cErrorIndicationFromE2Node, 2},
+               Counter{cRestSubFailNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+       })
+
+       const subReqCount int = 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       // Decode of this response fails which will result resending original request
+       e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_E2_RAN_ERROR_INDICATION)
+
+       crereq, cremsg = e2termConn1.RecvSubsReq(t)
+
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+       e2termConn1.SendErrorIndication(t, crereq, cremsg)
+
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
+
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+       mainCtrl.VerifyAllClean(t)
+       mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTPolicySubReqUnpackErrorIndicationDecodeFail
+//
+//   stub                             stub
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//     |                 |              |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |ErrorIndication | ASN.1 decode fails
+//     |                 |<-------------| Decode failed. More data needed. This will result timer expiry and resending
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |ErrorIndication | Valid InstanceId and Cause
+//     |                 |<-------------|
+//     | RESTNotif (fail)|              |
+//     |<----------------|              |
+//     |                 |              |
+//     |           [SUBS DELETE]        |
+//     |                 |              |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTPolicySubReqUnpackErrorIndicationDecodeFail(t *testing.T) {
+
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cSubReqTimerExpiry, 1},
+               Counter{cSubReReqToE2, 1},
+               Counter{cErrorIndicationFromE2Node, 2},
+               Counter{cRestSubFailNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+       })
+
+       const subReqCount int = 1
+
+       // Req
+       params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       // Decode of this response fails which will result resending original request
+       e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_E2_RAN_ERROR_INDICATION)
+
+       crereq, cremsg = e2termConn1.RecvSubsReq(t)
+
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+       e2termConn1.SendErrorIndication(t, crereq, cremsg)
+
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
+
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       // Wait that subs is cleaned
+       mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
+
+       xappConn1.TestMsgChanEmpty(t)
+       e2termConn1.TestMsgChanEmpty(t)
+       mainCtrl.wait_registry_empty(t, 10)
+       mainCtrl.VerifyAllClean(t)
+       mainCtrl.VerifyCounterValues(t)
+}
+
+/*
+
+// This testcase is working as expected, but breaking TestRESTSubscriptionDeleteAfterE2ConnectionBreak with Unexpected Rest Notification received. Commenting this case for now.
+
+
+//-----------------------------------------------------------------------------
+// TestTimeoutForRESTReportSubReqE2NodeSendsErrorIndicationWithReqIdAndCause
+//
 //   stub                             stub
 // +-------+        +---------+    +---------+
 // | xapp  |        | submgr  |    | e2term  |
 // +-------+        +---------+    +---------+
 //     |                 |              |
-//     | RESTSubReq      |              |
+//     | RestSubReq      |              |
 //     |---------------->|              |
+//     |                 |              |
 //     |     RESTSubResp |              |
 //     |<----------------|              |
+//     |                 |              |
 //     |                 | SubReq       |
 //     |                 |------------->|
-//     |                 |      SubResp |
+//     |                 |              |
+//     |                 |ErrorIndication | RequestId Present and Cause is Trivial.
 //     |                 |<-------------|
 //     |                 |              |
-//     |         [E2 Conn. DOWN]        |
-//     |        [Int. SUBS DELETE]      |
 //     |                 |              |
-//     |      RESTNotif(unsuccessful)   |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |ErrorIndication | RequestId Present and Cause is Trivial.
+//     |                 |<-------------|
+//     |       RESTNotif |              |
+//     |       unsuccess |              |
 //     |<----------------|              |
 //     |                 |              |
+//     |            [SUBS DELETE]       |
 //     |                 |              |
-//
-//-----------------------------------------------------------------------------
-func TestRESTSubReqE2ConnBreak(t *testing.T) {
+func TestTimeoutForRESTReportSubReqE2NodeSendsErrorIndicationWithReqIdAndCause(t *testing.T) {
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
                Counter{cRestSubReqFromXapp, 1},
                Counter{cRestSubRespToXapp, 1},
                Counter{cSubReqToE2, 1},
-               Counter{cSubRespFromE2, 1},
+               Counter{cErrorIndicationFromE2Node, 2},
+               Counter{cSubReqTimerExpiry, 2},
+               Counter{cSubReReqToE2, 1},
+               Counter{cSubDelReqToE2, 1},
+               Counter{cSubDelRespFromE2, 1},
                Counter{cRestSubFailNotifToXapp, 1},
-               Counter{cE2StateChangedToDown, 1},
-               Counter{cE2StateChangedToUp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
        })
 
        // Req
@@ -156,61 +881,123 @@ func TestRESTSubReqE2ConnBreak(t *testing.T) {
 
        crereq, cremsg := e2termConn1.RecvSubsReq(t)
        xappConn1.ExpectRESTNotification(t, restSubId)
+       e2termConn1.SendErrorIndicationWithDiffCause(t, crereq, cremsg)
 
-       // E2 disconnect after E2term has received response
-       mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
-
-       e2termConn1.SendSubsResp(t, crereq, cremsg)
-       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
-
-       <-time.After(time.Second * 1)
-       assert.Equal(t, 0, len(mainCtrl.c.registry.register))
-       assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
+       crereq, cremsg = e2termConn1.RecvSubsReq(t)
+       e2termConn1.SendErrorIndicationWithDiffCause(t, crereq, cremsg)
 
-       subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
-       if err != nil {
-               xapp.Logger.Error("%v", err)
-       } else {
-               assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
-               assert.Equal(t, 0, len(register))
-       }
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+       xappConn1.WaitRESTNotification(t, restSubId)
 
-       restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
-       if err != nil {
-               xapp.Logger.Error("%v", err)
-       } else {
-               assert.Equal(t, 0, len(restSubscriptions))
-       }
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       // Wait that subs is cleaned
 
-       // Restore E2 connection for following test cases
-       mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
+       //xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       //delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
+       //e2termConn1.SendSubsDelResp(t, delreq, delmsg)
 
-       // Wait that subs is cleaned
-       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.wait_registry_empty(t, 10)
+       waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
+       //waitSubsCleanup(t, e2SubIds, 10)
        mainCtrl.VerifyCounterValues(t)
        mainCtrl.VerifyAllClean(t)
-}
+}*/
 
 //-----------------------------------------------------------------------------
-// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
+// TestRESTReportSubReqE2NodeSendsErrorIndicationAndNotifyToXapp
 //
 //   stub                             stub
 // +-------+        +---------+    +---------+
 // | xapp  |        | submgr  |    | e2term  |
 // +-------+        +---------+    +---------+
 //     |                 |              |
-//     |            [SUBS CREATE]       |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
 //     |                 |              |
-//     |           [E2 Conn. DOWN]      |
+//     |                 | SubReq       |
+//     |                 |------------->|
 //     |                 |              |
-//     | RESTSubDelReq   |              |
-//     |---------------->|              |
+//     |                 |ErrorIndication | RequestId Present and Cause is Trivial.
+//     |                 |<-------------|
 //     |                 |              |
-//     |  RESTSubDelResp |              |
+//     |                 |              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |ErrorIndication | RequestId Present and Cause is HW Failure.
+//     |                 |<-------------|
+//     |       RESTNotif |              |
+//     |       unsuccess |              |
 //     |<----------------|              |
 //     |                 |              |
-//     |  [No valid subscription found] |
+//     |            [SUBS DELETE]       |
 //     |                 |              |
+
+func TestRESTReportSubReqE2NodeSendsErrorIndicationAndNotifyToXapp(t *testing.T) {
+       mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+               Counter{cRestSubReqFromXapp, 1},
+               Counter{cRestSubRespToXapp, 1},
+               Counter{cSubReqToE2, 1},
+               Counter{cErrorIndicationFromE2Node, 2},
+               Counter{cSubReqTimerExpiry, 1},
+               Counter{cSubReReqToE2, 1},
+               Counter{cRestSubFailNotifToXapp, 1},
+               Counter{cRestSubDelReqFromXapp, 1},
+               Counter{cRestSubDelRespToXapp, 1},
+       })
+
+       // Req
+       const subReqCount int = 1
+       params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+       restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+       crereq, cremsg := e2termConn1.RecvSubsReq(t)
+       xappConn1.ExpectRESTNotification(t, restSubId)
+       e2termConn1.SendErrorIndicationWithDiffCause(t, crereq, cremsg)
+
+       crereq, cremsg = e2termConn1.RecvSubsReq(t)
+       e2termConn1.SendErrorIndication(t, crereq, cremsg)
+
+       e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+       fmt.Printf("e2SubsId: %v\n", e2SubsId)
+
+       //For Cleanup. Next testcase should start freshly.
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+       mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
+//
+//     stub                             stub
+//
+// +-------+        +---------+    +---------+
+// | xapp  |        | submgr  |    | e2term  |
+// +-------+        +---------+    +---------+
+//
+//     |                 |              |
+//     |            [SUBS CREATE]       |
+//     |                 |              |
+//     |           [E2 Conn. DOWN]      |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |  [No valid subscription found] |
+//     |                 |              |
 //
 //-----------------------------------------------------------------------------
 func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
@@ -274,20 +1061,22 @@ func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
 // TestRESTOtherE2ConnectionChanges
 //
 
-//   stub                             stub
+//     stub                             stub
+//
 // +-------+        +---------+    +---------+
 // | xapp  |        | submgr  |    | e2term  |
 // +-------+        +---------+    +---------+
-//     |                 |              |
-//     |            [SUBS CREATE]       |
-//     |                 |              |
-//     |  [E2 CONNECTED_SETUP_FAILED]   |
-//     |         [E2 CONNECTING]        |
-//     |        [E2 SHUTTING_DOWN]      |
-//     |          [E2 SHUT_DOWN]        |
-//     |                 |              |
-//     |            [SUBS DELETE]       |
-//     |                 |              |
+//
+//     |                 |              |
+//     |            [SUBS CREATE]       |
+//     |                 |              |
+//     |  [E2 CONNECTED_SETUP_FAILED]   |
+//     |         [E2 CONNECTING]        |
+//     |        [E2 SHUTTING_DOWN]      |
+//     |          [E2 SHUT_DOWN]        |
+//     |                 |              |
+//     |            [SUBS DELETE]       |
+//     |                 |              |
 //
 //-----------------------------------------------------------------------------
 func TestRESTOtherE2ConnectionChanges(t *testing.T) {
@@ -318,61 +1107,63 @@ func TestRESTOtherE2ConnectionChanges(t *testing.T) {
        // Submgr should not react to any other connection state changes than CONNECTED and DISCONNECTED
        mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
        mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
-       mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
-       mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
-
-       // Del
-       xappConn1.SendRESTSubsDelReq(t, &restSubId)
-       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
-       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
-
-       // Restore E2 connection for following test cases
-       mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
-
-       // Wait that subs is cleaned
-       waitSubsCleanup(t, e2SubsId, 10)
-       mainCtrl.VerifyCounterValues(t)
-       mainCtrl.VerifyAllClean(t)
-}
-
-//-----------------------------------------------------------------------------
-// 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 |             |
-//     |                 |<-------------|             |
-//     |                 |              |             |
-//     |                 |              |             |
+       mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
+       mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
+
+       // Del
+       xappConn1.SendRESTSubsDelReq(t, &restSubId)
+       delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+       e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+       // Restore E2 connection for following test cases
+       mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
+
+       // Wait that subs is cleaned
+       waitSubsCleanup(t, e2SubsId, 10)
+       mainCtrl.VerifyCounterValues(t)
+       mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// 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) {
@@ -388,36 +1179,38 @@ func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestRESTSubReqAndE1apDeleteReqPackingError
 //
-//   stub                             stub          stub
+//     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|              |             |
-//     |<----------------|              |             |
-//     |                 |              |             |
-//     |                 |              |             |
+//
+//     |                 |              |             |
+//     | 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) {
@@ -624,30 +1417,32 @@ func TestSubReqAndRouteUpdateNok(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubDelReqAndRouteDeleteNok
 //
-//   stub                          stub
+//     stub                          stub
+//
 // +-------+     +---------+    +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term  |    |  rtmgr  |
 // +-------+     +---------+    +---------+    +---------+
-//     |              |              |              |
-//     |         [SUBS CREATE]       |              |
-//     |              |              |              |
-//     |              |              |              |
-//     |              |              |              |
-//     | SubDelReq    |              |              |
-//     |------------->|              |              |
-//     |              |  SubDelReq   |              |
-//     |              |------------->|              |
-//     |              |  SubDelRsp   |              |
-//     |              |<-------------|              |
-//     |  SubDelRsp   |              |              |
-//     |<-------------|              |              |
-//     |              | RouteDelete  |              |
-//     |              |---------------------------->|
-//     |              |              |              |
-//     |              | RouteDelete  |              |
-//     |              |  status:400  |              |
-//     |              |<----------------------------|
-//     |              |              |              |
+//
+//     |              |              |              |
+//     |         [SUBS CREATE]       |              |
+//     |              |              |              |
+//     |              |              |              |
+//     |              |              |              |
+//     | SubDelReq    |              |              |
+//     |------------->|              |              |
+//     |              |  SubDelReq   |              |
+//     |              |------------->|              |
+//     |              |  SubDelRsp   |              |
+//     |              |<-------------|              |
+//     |  SubDelRsp   |              |              |
+//     |<-------------|              |              |
+//     |              | RouteDelete  |              |
+//     |              |---------------------------->|
+//     |              |              |              |
+//     |              | RouteDelete  |              |
+//     |              |  status:400  |              |
+//     |              |<----------------------------|
+//     |              |              |              |
 func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
        CaseBegin("TestSubDelReqAndRouteDeleteNok")
 
@@ -695,52 +1490,55 @@ func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
 
 //-----------------------------------------------------------------------------
 // TestSubMergeDelAndRouteUpdateNok
-//   stub                          stub
+//
+//     stub                          stub
+//
 // +-------+     +-------+     +---------+    +---------+
 // | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
 // +-------+     +-------+     +---------+    +---------+
-//     |             |              |              |
-//     |             |              |              |
-//     |             |              |              |
-//     |             | SubReq1      |              |
-//     |             |------------->|              |
-//     |             |              |              |
-//     |             |              | SubReq1      |
-//     |             |              |------------->|
-//     |             |              |    SubResp1  |
-//     |             |              |<-------------|
-//     |             |    SubResp1  |              |
-//     |             |<-------------|              |
-//     |             |              |              |
-//     |          SubReq2           |              |
-//     |--------------------------->|              |
-//     |             |              |              |
-//     |          SubResp2          |              |
-//     |<---------------------------|              |
-//     |             |              |              |
-//     |             | SubDelReq 1  |              |
-//     |             |------------->|              |
-//     |             |              | RouteUpdate  |
-//     |             |              |-----> rtmgr  |
-//     |             |              |              |
-//     |             |              | RouteUpdate  |
-//     |             |              |  status:400  |
-//     |             |              |<----- rtmgr  |
-//     |             |              |              |
-//     |             | SubDelResp 1 |              |
-//     |             |<-------------|              |
-//     |             |              |              |
-//     |         SubDelReq 2        |              |
-//     |--------------------------->|              |
-//     |             |              |              |
-//     |             |              | SubDelReq 2  |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |             |              | SubDelReq 2  |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |         SubDelResp 2       |              |
-//     |<---------------------------|              |
+//
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |             |              |    SubResp1  |
+//     |             |              |<-------------|
+//     |             |    SubResp1  |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |          SubReq2           |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |          SubResp2          |              |
+//     |<---------------------------|              |
+//     |             |              |              |
+//     |             | SubDelReq 1  |              |
+//     |             |------------->|              |
+//     |             |              | RouteUpdate  |
+//     |             |              |-----> rtmgr  |
+//     |             |              |              |
+//     |             |              | RouteUpdate  |
+//     |             |              |  status:400  |
+//     |             |              |<----- rtmgr  |
+//     |             |              |              |
+//     |             | SubDelResp 1 |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |         SubDelReq 2        |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |         SubDelResp 2       |              |
+//     |<---------------------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
@@ -808,35 +1606,37 @@ func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelOk
 //
-//   stub                          stub
+//     stub                          stub
+//
 // +-------+     +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term  |
 // +-------+     +---------+    +---------+
-//     |              |              |
-//     | SubReq       |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq       |
-//     |              |------------->|
-//     |              |              |
-//     |              |      SubResp |
-//     |              |<-------------|
-//     |              |              |
-//     |      SubResp |              |
-//     |<-------------|              |
-//     |              |              |
-//     |              |              |
-//     | SubDelReq    |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubDelReq    |
-//     |              |------------->|
-//     |              |              |
-//     |              |   SubDelResp |
-//     |              |<-------------|
-//     |              |              |
-//     |   SubDelResp |              |
-//     |<-------------|              |
+//
+//     |              |              |
+//     | SubReq       |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubReq       |
+//     |              |------------->|
+//     |              |              |
+//     |              |      SubResp |
+//     |              |<-------------|
+//     |              |              |
+//     |      SubResp |              |
+//     |<-------------|              |
+//     |              |              |
+//     |              |              |
+//     | SubDelReq    |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubDelReq    |
+//     |              |------------->|
+//     |              |              |
+//     |              |   SubDelResp |
+//     |              |<-------------|
+//     |              |              |
+//     |   SubDelResp |              |
+//     |<-------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOk(t *testing.T) {
@@ -976,29 +1776,31 @@ func TestSubReqAndSubDelOkOutofOrderIEs(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqRetransmission
 //
-//   stub                          stub
+//     stub                          stub
+//
 // +-------+     +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term  |
 // +-------+     +---------+    +---------+
-//     |              |              |
-//     |  SubReq      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq       |
-//     |              |------------->|
-//     |              |              |
-//     |  SubReq      |              |
-//     | (retrans)    |              |
-//     |------------->|              |
-//     |              |              |
-//     |              |      SubResp |
-//     |              |<-------------|
-//     |              |              |
-//     |      SubResp |              |
-//     |<-------------|              |
-//     |              |              |
-//     |         [SUBS DELETE]       |
-//     |              |              |
+//
+//     |              |              |
+//     |  SubReq      |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubReq       |
+//     |              |------------->|
+//     |              |              |
+//     |  SubReq      |              |
+//     | (retrans)    |              |
+//     |------------->|              |
+//     |              |              |
+//     |              |      SubResp |
+//     |              |<-------------|
+//     |              |              |
+//     |      SubResp |              |
+//     |<-------------|              |
+//     |              |              |
+//     |         [SUBS DELETE]       |
+//     |              |              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqRetransmission(t *testing.T) {
@@ -1037,30 +1839,32 @@ func TestSubReqRetransmission(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubDelReqRetransmission
 //
-//   stub                          stub
+//     stub                          stub
+//
 // +-------+     +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term  |
 // +-------+     +---------+    +---------+
-//     |              |              |
-//     |         [SUBS CREATE]       |
-//     |              |              |
-//     |              |              |
-//     | SubDelReq    |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubDelReq    |
-//     |              |------------->|
-//     |              |              |
-//     | SubDelReq    |              |
-//     | (same sub)   |              |
-//     | (same xid)   |              |
-//     |------------->|              |
-//     |              |              |
-//     |              |   SubDelResp |
-//     |              |<-------------|
-//     |              |              |
-//     |   SubDelResp |              |
-//     |<-------------|              |
+//
+//     |              |              |
+//     |         [SUBS CREATE]       |
+//     |              |              |
+//     |              |              |
+//     | SubDelReq    |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubDelReq    |
+//     |              |------------->|
+//     |              |              |
+//     | SubDelReq    |              |
+//     | (same sub)   |              |
+//     | (same xid)   |              |
+//     |------------->|              |
+//     |              |              |
+//     |              |   SubDelResp |
+//     |              |<-------------|
+//     |              |              |
+//     |   SubDelResp |              |
+//     |<-------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubDelReqRetransmission(t *testing.T) {
@@ -1263,41 +2067,43 @@ func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
 // TestSameSubsDiffRan
 // Same subscription to different RANs
 //
-//   stub                          stub
+//     stub                          stub
+//
 // +-------+     +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term  |
 // +-------+     +---------+    +---------+
-//     |              |              |
-//     |              |              |
-//     |              |              |
-//     | SubReq(r1)   |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq(r1)   |
-//     |              |------------->|
-//     |              |              |
-//     |              | SubResp(r1)  |
-//     |              |<-------------|
-//     |              |              |
-//     | SubResp(r1)  |              |
-//     |<-------------|              |
-//     |              |              |
-//     | SubReq(r2)   |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq(r2)   |
-//     |              |------------->|
-//     |              |              |
-//     |              | SubResp(r2)  |
-//     |              |<-------------|
-//     |              |              |
-//     | SubResp(r2)  |              |
-//     |<-------------|              |
-//     |              |              |
-//     |       [SUBS r1 DELETE]      |
-//     |              |              |
-//     |       [SUBS r2 DELETE]      |
-//     |              |              |
+//
+//     |              |              |
+//     |              |              |
+//     |              |              |
+//     | SubReq(r1)   |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubReq(r1)   |
+//     |              |------------->|
+//     |              |              |
+//     |              | SubResp(r1)  |
+//     |              |<-------------|
+//     |              |              |
+//     | SubResp(r1)  |              |
+//     |<-------------|              |
+//     |              |              |
+//     | SubReq(r2)   |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubReq(r2)   |
+//     |              |------------->|
+//     |              |              |
+//     |              | SubResp(r2)  |
+//     |              |<-------------|
+//     |              |              |
+//     | SubResp(r2)  |              |
+//     |<-------------|              |
+//     |              |              |
+//     |       [SUBS r1 DELETE]      |
+//     |              |              |
+//     |       [SUBS r2 DELETE]      |
+//     |              |              |
 //
 //-----------------------------------------------------------------------------
 func TestSameSubsDiffRan(t *testing.T) {
@@ -1419,27 +2225,29 @@ func TestSubReqRetryInSubmgr(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
 //
-//   stub                          stub
+//     stub                          stub
+//
 // +-------+     +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term  |
 // +-------+     +---------+    +---------+
-//     |              |              |
-//     |  SubReq      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq       |
-//     |              |------------->|
-//     |              |              |
-//     |              |              |
-//     |              | SubReq       |
-//     |              |------------->|
-//     |              |              |
-//     |              | SubDelReq    |
-//     |              |------------->|
-//     |              |              |
-//     |              |   SubDelResp |
-//     |              |<-------------|
-//     |              |              |
+//
+//     |              |              |
+//     |  SubReq      |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubReq       |
+//     |              |------------->|
+//     |              |              |
+//     |              |              |
+//     |              | SubReq       |
+//     |              |------------->|
+//     |              |              |
+//     |              | SubDelReq    |
+//     |              |------------->|
+//     |              |              |
+//     |              |   SubDelResp |
+//     |              |<-------------|
+//     |              |              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
@@ -1919,46 +2727,48 @@ func TestSubDelReqSubDelFailRespInSubmgrOutofOrderIEs(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelOkSameAction
 //
-//   stub                          stub
-// +-------+     +-------+     +---------+    +---------+
-// | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
+//     stub                          stub
+//
+// +-------+     +-------+     +---------+    +---------+
+// | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
 // +-------+     +-------+     +---------+    +---------+
-//     |             |              |              |
-//     |             |              |              |
-//     |             |              |              |
-//     |             | SubReq1      |              |
-//     |             |------------->|              |
-//     |             |              |              |
-//     |             |              | SubReq1      |
-//     |             |              |------------->|
-//     |             |              |    SubResp1  |
-//     |             |              |<-------------|
-//     |             |    SubResp1  |              |
-//     |             |<-------------|              |
-//     |             |              |              |
-//     |          SubReq2           |              |
-//     |--------------------------->|              |
-//     |             |              |              |
-//     |          SubResp2          |              |
-//     |<---------------------------|              |
-//     |             |              |              |
-//     |             | SubDelReq 1  |              |
-//     |             |------------->|              |
-//     |             |              |              |
-//     |             | SubDelResp 1 |              |
-//     |             |<-------------|              |
-//     |             |              |              |
-//     |         SubDelReq 2        |              |
-//     |--------------------------->|              |
-//     |             |              |              |
-//     |             |              | SubDelReq 2  |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |             |              | SubDelReq 2  |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |         SubDelResp 2       |              |
-//     |<---------------------------|              |
+//
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |             |              |    SubResp1  |
+//     |             |              |<-------------|
+//     |             |    SubResp1  |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |          SubReq2           |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |          SubResp2          |              |
+//     |<---------------------------|              |
+//     |             |              |              |
+//     |             | SubDelReq 1  |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             | SubDelResp 1 |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |         SubDelReq 2        |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |         SubDelResp 2       |              |
+//     |<---------------------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOkSameAction(t *testing.T) {
@@ -2020,45 +2830,47 @@ func TestSubReqAndSubDelOkSameAction(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelOkSameActionParallel
 //
-//   stub          stub                          stub
+//     stub          stub                          stub
+//
 // +-------+     +-------+     +---------+    +---------+
 // | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
 // +-------+     +-------+     +---------+    +---------+
-//     |             |              |              |
-//     |             |              |              |
-//     |             |              |              |
-//     |             | SubReq1      |              |
-//     |             |------------->|              |
-//     |             |              |              |
-//     |             |              | SubReq1      |
-//     |             |              |------------->|
-//     |          SubReq2           |              |
-//     |--------------------------->|              |
-//     |             |              |    SubResp1  |
-//     |             |              |<-------------|
-//     |             |    SubResp1  |              |
-//     |             |<-------------|              |
-//     |             |              |              |
-//     |          SubResp2          |              |
-//     |<---------------------------|              |
-//     |             |              |              |
-//     |             | SubDelReq 1  |              |
-//     |             |------------->|              |
-//     |             |              |              |
-//     |             | SubDelResp 1 |              |
-//     |             |<-------------|              |
-//     |             |              |              |
-//     |         SubDelReq 2        |              |
-//     |--------------------------->|              |
-//     |             |              |              |
-//     |             |              | SubDelReq 2  |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |             |              | SubDelReq 2  |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |         SubDelResp 2       |              |
-//     |<---------------------------|              |
+//
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |          SubReq2           |              |
+//     |--------------------------->|              |
+//     |             |              |    SubResp1  |
+//     |             |              |<-------------|
+//     |             |    SubResp1  |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |          SubResp2          |              |
+//     |<---------------------------|              |
+//     |             |              |              |
+//     |             | SubDelReq 1  |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             | SubDelResp 1 |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |         SubDelReq 2        |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |         SubDelResp 2       |              |
+//     |<---------------------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
@@ -2104,28 +2916,30 @@ func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelNokSameActionParallel
 //
-//   stub          stub                          stub
+//     stub          stub                          stub
+//
 // +-------+     +-------+     +---------+    +---------+
 // | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
 // +-------+     +-------+     +---------+    +---------+
-//     |             |              |              |
-//     |             |              |              |
-//     |             |              |              |
-//     |             | SubReq1      |              |
-//     |             |------------->|              |
-//     |             |              |              |
-//     |             |              | SubReq1      |
-//     |             |              |------------->|
-//     |          SubReq2           |              |
-//     |--------------------------->|              |
-//     |             |              |    SubFail1  |
-//     |             |              |<-------------|
-//     |             |              |              |
-//     |             |    SubFail1  |              |
-//     |             |<-------------|              |
-//     |             |              |              |
-//     |          SubFail2          |              |
-//     |<---------------------------|              |
+//
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |          SubReq2           |              |
+//     |--------------------------->|              |
+//     |             |              |    SubFail1  |
+//     |             |              |<-------------|
+//     |             |              |              |
+//     |             |    SubFail1  |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |          SubFail2          |              |
+//     |<---------------------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
@@ -2168,30 +2982,32 @@ func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelNoAnswerSameActionParallel
 //
-//   stub          stub                          stub
+//     stub          stub                          stub
+//
 // +-------+     +-------+     +---------+    +---------+
 // | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
 // +-------+     +-------+     +---------+    +---------+
-//     |             |              |              |
-//     |             |              |              |
-//     |             |              |              |
-//     |             | SubReq1      |              |
-//     |             |------------->|              |
-//     |             |              |              |
-//     |             |              | SubReq1      |
-//     |             |              |------------->|
-//     |             | SubReq2      |              |
-//     |--------------------------->|              |
-//     |             |              |              |
-//     |             |              | SubReq1      |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |             |              |              |
-//     |             |              | SubDelReq    |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |             |              |   SubDelResp |
-//     |             |              |<-------------|
+//
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |             | SubReq2      |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              | SubDelReq    |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              |   SubDelResp |
+//     |             |              |<-------------|
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
@@ -2230,35 +3046,37 @@ func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqPolicyAndSubDelOk
 //
-//   stub                          stub
+//     stub                          stub
+//
 // +-------+     +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term  |
 // +-------+     +---------+    +---------+
-//     |              |              |
-//     | SubReq       |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq       |
-//     |              |------------->|
-//     |              |              |
-//     |              |      SubResp |
-//     |              |<-------------|
-//     |              |              |
-//     |      SubResp |              |
-//     |<-------------|              |
-//     |              |              |
-//     |              |              |
-//     | SubDelReq    |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubDelReq    |
-//     |              |------------->|
-//     |              |              |
-//     |              |   SubDelResp |
-//     |              |<-------------|
-//     |              |              |
-//     |   SubDelResp |              |
-//     |<-------------|              |
+//
+//     |              |              |
+//     | SubReq       |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubReq       |
+//     |              |------------->|
+//     |              |              |
+//     |              |      SubResp |
+//     |              |<-------------|
+//     |              |              |
+//     |      SubResp |              |
+//     |<-------------|              |
+//     |              |              |
+//     |              |              |
+//     | SubDelReq    |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubDelReq    |
+//     |              |------------->|
+//     |              |              |
+//     |              |   SubDelResp |
+//     |              |<-------------|
+//     |              |              |
+//     |   SubDelResp |              |
+//     |<-------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqPolicyAndSubDelOk(t *testing.T) {
@@ -2371,38 +3189,40 @@ func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelOkTwoE2termParallel
 //
-//   stub                          stub           stub
+//     stub                          stub           stub
+//
 // +-------+     +---------+    +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term1 |    | e2term2 |
 // +-------+     +---------+    +---------+    +---------+
-//     |              |              |              |
-//     |              |              |              |
-//     |              |              |              |
-//     | SubReq1      |              |              |
-//     |------------->|              |              |
-//     |              |              |              |
-//     |              | SubReq1      |              |
-//     |              |------------->|              |
-//     |              |              |              |
-//     | SubReq2      |              |              |
-//     |------------->|              |              |
-//     |              |              |              |
-//     |              | SubReq2      |              |
-//     |              |---------------------------->|
-//     |              |              |              |
-//     |              |    SubResp1  |              |
-//     |              |<-------------|              |
-//     |    SubResp1  |              |              |
-//     |<-------------|              |              |
-//     |              |    SubResp2  |              |
-//     |              |<----------------------------|
-//     |    SubResp2  |              |              |
-//     |<-------------|              |              |
-//     |              |              |              |
-//     |        [SUBS 1 DELETE]      |              |
-//     |              |              |              |
-//     |        [SUBS 2 DELETE]      |              |
-//     |              |              |              |
+//
+//     |              |              |              |
+//     |              |              |              |
+//     |              |              |              |
+//     | SubReq1      |              |              |
+//     |------------->|              |              |
+//     |              |              |              |
+//     |              | SubReq1      |              |
+//     |              |------------->|              |
+//     |              |              |              |
+//     | SubReq2      |              |              |
+//     |------------->|              |              |
+//     |              |              |              |
+//     |              | SubReq2      |              |
+//     |              |---------------------------->|
+//     |              |              |              |
+//     |              |    SubResp1  |              |
+//     |              |<-------------|              |
+//     |    SubResp1  |              |              |
+//     |<-------------|              |              |
+//     |              |    SubResp2  |              |
+//     |              |<----------------------------|
+//     |    SubResp2  |              |              |
+//     |<-------------|              |              |
+//     |              |              |              |
+//     |        [SUBS 1 DELETE]      |              |
+//     |              |              |              |
+//     |        [SUBS 2 DELETE]      |              |
+//     |              |              |              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
@@ -2451,35 +3271,37 @@ func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqInsertAndSubDelOk
 //
-//   stub                          stub
+//     stub                          stub
+//
 // +-------+     +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term  |
 // +-------+     +---------+    +---------+
-//     |              |              |
-//     | SubReq       |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq       |
-//     |              |------------->|
-//     |              |              |
-//     |              |      SubResp |
-//     |              |<-------------|
-//     |              |              |
-//     |      SubResp |              |
-//     |<-------------|              |
-//     |              |              |
-//     |              |              |
-//     | SubDelReq    |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubDelReq    |
-//     |              |------------->|
-//     |              |              |
-//     |              |   SubDelResp |
-//     |              |<-------------|
-//     |              |              |
-//     |   SubDelResp |              |
-//     |<-------------|              |
+//
+//     |              |              |
+//     | SubReq       |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubReq       |
+//     |              |------------->|
+//     |              |              |
+//     |              |      SubResp |
+//     |              |<-------------|
+//     |              |              |
+//     |      SubResp |              |
+//     |<-------------|              |
+//     |              |              |
+//     |              |              |
+//     | SubDelReq    |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubDelReq    |
+//     |              |------------->|
+//     |              |              |
+//     |              |   SubDelResp |
+//     |              |<-------------|
+//     |              |              |
+//     |   SubDelResp |              |
+//     |<-------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqInsertAndSubDelOk(t *testing.T) {
@@ -2514,34 +3336,36 @@ func TestSubReqInsertAndSubDelOk(t *testing.T) {
 // This case simulates case where xApp restarts and starts sending same
 // subscription requests which have already subscribed successfully
 
-//   stub                          stub
+//     stub                          stub
+//
 // +-------+     +---------+    +---------+
 // | xapp  |     | submgr  |    | e2term  |
 // +-------+     +---------+    +---------+
-//     |              |              |
-//     |  SubReq      |              |
-//     |------------->|              |
-//     |              |              |
-//     |              | SubReq       |
-//     |              |------------->|
-//     |              |              |
-//     |              |      SubResp |
-//     |              |<-------------|
-//     |              |              |
-//     |      SubResp |              |
-//     |<-------------|              |
-//     |              |              |
-//     | xApp restart |              |
-//     |              |              |
-//     |  SubReq      |              |
-//     | (retrans with same xApp generated subid but diff xid)
-//     |------------->|              |
-//     |              |              |
-//     |      SubResp |              |
-//     |<-------------|              |
-//     |              |              |
-//     |         [SUBS DELETE]       |
-//     |              |              |
+//
+//     |              |              |
+//     |  SubReq      |              |
+//     |------------->|              |
+//     |              |              |
+//     |              | SubReq       |
+//     |              |------------->|
+//     |              |              |
+//     |              |      SubResp |
+//     |              |<-------------|
+//     |              |              |
+//     |      SubResp |              |
+//     |<-------------|              |
+//     |              |              |
+//     | xApp restart |              |
+//     |              |              |
+//     |  SubReq      |              |
+//     | (retrans with same xApp generated subid but diff xid)
+//     |------------->|              |
+//     |              |              |
+//     |      SubResp |              |
+//     |<-------------|              |
+//     |              |              |
+//     |         [SUBS DELETE]       |
+//     |              |              |
 //
 //-----------------------------------------------------------------------------
 func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
@@ -2841,16 +3665,18 @@ func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
 //-----------------------------------------------------------------------------
 // Test debug GET and POST requests
 //
-//   curl
+//     curl
+//
 // +-------+     +---------+
 // | user  |     | submgr  |
 // +-------+     +---------+
-//     |              |
-//     | GET/POST Req |
-//     |------------->|
-//     |         Resp |
-//     |<-------------|
-//     |              |
+//
+//     |              |
+//     | GET/POST Req |
+//     |------------->|
+//     |         Resp |
+//     |<-------------|
+//     |              |
 func TestGetSubscriptions(t *testing.T) {
 
        mainCtrl.SendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
@@ -3167,31 +3993,33 @@ func TestDelViaxAppSubsIf(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestRESTSubReqAndRouteNok
 //
-//   stub                             stub
+//     stub                             stub
+//
 // +-------+        +---------+    +---------+
 // | xapp  |        | submgr  |    | rtmgr   |
 // +-------+        +---------+    +---------+
-//     |                 |              |
-//     | RESTSubReq      |              |
-//     |---------------->|              |
-//     |                 |              |
-//     |     RESTSubResp |              |
-//     |<----------------|              |
-//     |                 | RouteCreate  |
-//     |                 |------------->|
-//     |                 | RouteCreate  |
-//     |                 |  status:400  |
-//     |                 |(Bad request) |
-//     |                 |<-------------|
-//     |       RESTNotif |              |
-//     |<----------------|              |
-//     |                 |              |
-//     |          [SUBS INT DELETE]     |
-//     |                 |              |
-//     | RESTSubDelReq   |              |
-//     |---------------->|              |
-//     |  RESTSubDelResp |              |
-//     |<----------------|              |
+//
+//     |                 |              |
+//     | RESTSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 | RouteCreate  |
+//     |                 |------------->|
+//     |                 | RouteCreate  |
+//     |                 |  status:400  |
+//     |                 |(Bad request) |
+//     |                 |<-------------|
+//     |       RESTNotif |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |          [SUBS INT DELETE]     |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
 //
 //-----------------------------------------------------------------------------
 func TestRESTSubReqAndRouteNok(t *testing.T) {
@@ -3233,48 +4061,50 @@ func TestRESTSubReqAndRouteNok(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestRESTSubReqAndRouteUpdateNok
 //
-//   stub        stub                         stub           stub
+//     stub        stub                         stub           stub
+//
 // +-------+   +-------+    +---------+    +---------+    +---------+
 // | xapp1 |   | xapp2 |    | submgr  |    | rtmgr   |    | e2term  |
 // +-------+   +-------+    +---------+    +---------+    +---------+
-//     |           |             |              |              |
-//     | RESTSubReq1             |              |              |
-//     |------------------------>|              |              |
-//     |     RESTSubResp2        |              |              |
-//     |<------------------------|              |              |
-//     |           |             |              |              |
-//     |           |             | RouteCreate  |              |
-//     |           |             |------------->|              |
-//     |           |             | CreateResp   |              |
-//     |           |             |<-------------|              |
-//     |           |             | SubReq       |              |
-//     |           |             |---------------------------->|
-//     |           |             |      SubResp |              |
-//     |           |             |<----------------------------|
-//     |      RESTNotif1         |              |              |
-//     |<------------------------|              |              |
-//     |           |             |              |              |
-//     |           | RESTSubReq2 |              |              |
-//     |           |------------>|              |              |
-//     |           | RESTSubResp2|              |              |
-//     |           |<------------|              |              |
-//     |           |             | RouteUpdate  |              |
-//     |           |             |------------->|              |
-//     |           |             | RouteUpdate  |              |
-//     |           |             |  status:400  |              |
-//     |           |             |(Bad request) |              |
-//     |           |             |<-------------|              |
-//     |           | RESTNotif2(unsuccessful)   |              |
-//     |           |<------------|              |              |
-//     |           |             |              |              |
-//     |          [SUBS INT DELETE]             |              |
-//     |           |             |              |              |
-//     | RESTSubDelReq1          |              |              |
-//     |------------------------>|              |              |
-//     |  RESTSubDelResp1        |              |              |
-//     |<------------------------|              |              |
-//     |           |             |              |              |
-//     |           |             |        [SUBS DELETE]        |
+//
+//     |           |             |              |              |
+//     | RESTSubReq1             |              |              |
+//     |------------------------>|              |              |
+//     |     RESTSubResp2        |              |              |
+//     |<------------------------|              |              |
+//     |           |             |              |              |
+//     |           |             | RouteCreate  |              |
+//     |           |             |------------->|              |
+//     |           |             | CreateResp   |              |
+//     |           |             |<-------------|              |
+//     |           |             | SubReq       |              |
+//     |           |             |---------------------------->|
+//     |           |             |      SubResp |              |
+//     |           |             |<----------------------------|
+//     |      RESTNotif1         |              |              |
+//     |<------------------------|              |              |
+//     |           |             |              |              |
+//     |           | RESTSubReq2 |              |              |
+//     |           |------------>|              |              |
+//     |           | RESTSubResp2|              |              |
+//     |           |<------------|              |              |
+//     |           |             | RouteUpdate  |              |
+//     |           |             |------------->|              |
+//     |           |             | RouteUpdate  |              |
+//     |           |             |  status:400  |              |
+//     |           |             |(Bad request) |              |
+//     |           |             |<-------------|              |
+//     |           | RESTNotif2(unsuccessful)   |              |
+//     |           |<------------|              |              |
+//     |           |             |              |              |
+//     |          [SUBS INT DELETE]             |              |
+//     |           |             |              |              |
+//     | RESTSubDelReq1          |              |              |
+//     |------------------------>|              |              |
+//     |  RESTSubDelResp1        |              |              |
+//     |<------------------------|              |              |
+//     |           |             |              |              |
+//     |           |             |        [SUBS DELETE]        |
 //
 //-----------------------------------------------------------------------------
 func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
@@ -3677,44 +4507,47 @@ func TestRESTSubReqRetransmissionV2(t *testing.T) {
 }
 
 //-----------------------------------------------------------------------------
-//   stub                             stub          stub
-// +-------+        +---------+    +---------+   +---------+
-// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
+//
+//     stub                             stub          stub
+//
+// +-------+        +---------+    +---------+   +---------+
+// | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
 // +-------+        +---------+    +---------+   +---------+
-//     |                 |              |             |
-//     | RESTSubReq      |              |             |
-//     |---------------->|              |             |
-//     |     RESTSubResp |              |             |
-//     |<----------------|              |             |
-//     |                 | RouteCreate  |             |
-//     |                 |--------------------------->|
-//     |                 | RouteResponse|             |
-//     |                 |<---------------------------|  // The order of these events may vary
-//     |                 | SubReq       |             |
-//     |                 |------------->|             |  // The order of these events may vary
-//     |                 |      SubResp |             |
-//     |                 |<-------------|             |
-//     |      RESTNotif1 |              |             |
-//     |<----------------|              |             |
-//     | RESTSubReq      |              |             |
-//     | [RETRANS, with RESTsubsId]     |             |
-//     |---------------->|              |             |
-//     |      RESTNotif1 |              |             |
-//     |<----------------|              |             |
-//     | RESTSubReq      |              |             |
-//     | [RETRANS, without RESTsubsId]  |             |
-//     |---------------->|              |             |
-//     |      RESTNotif1 |              |             |
-//     |<----------------|              |             |
-//     | RESTSubDelReq   |              |             |
-//     |---------------->|              |             |
-//     |                 | SubDelReq    |             |
-//     |                 |------------->|             |
-//     |   RESTSubDelResp|              |             |
-//     |<----------------|              |             |
-//     |                 |   SubDelResp |             |
-//     |                 |<-------------|             |
-//     |                 |              |             |
+//
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |     RESTSubResp |              |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|  // The order of these events may vary
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |  // The order of these events may vary
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [RETRANS, with RESTsubsId]     |             |
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [RETRANS, without RESTsubsId]  |             |
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 |              |             |
 //
 //-----------------------------------------------------------------------------
 func TestRESTSubReqRetransmissionV3(t *testing.T) {
@@ -4010,69 +4843,72 @@ func TestRESTSubReqRetransmissionV5(t *testing.T) {
 }
 
 //-----------------------------------------------------------------------------
-//   stub                             stub          stub
+//
+//     stub                             stub          stub
+//
 // +-------+        +---------+    +---------+   +---------+
 // | xapp  |        | submgr  |    | e2term  |   |  rtmgr  |
 // +-------+        +---------+    +---------+   +---------+
-//     |                 |              |             |
-//     | RESTSubReq      |              |             |
-//     |---------------->|              |             |
-//     |     RESTSubResp |              |             |
-//     |<----------------|              |             |
-//     |                 | RouteCreate  |             |
-//     |                 |--------------------------->|
-//     |                 | RouteResponse|             |
-//     |                 |<---------------------------|
-//     |                 | SubReq       |             |
-//     |                 |------------->|             |
-//     |                 |      SubResp |             |
-//     |                 |<-------------|             |
-//     |      RESTNotif1 |              |             |
-//     |<----------------|              |             |
-//     | RESTSubReq      |              |             |
-//     | [with RestSUbsId + one additional e2 subDetail]
-//     |---------------->|              |             |
-//     |      RESTNotif1 |              |             |
-//     | [for initial e2 subDetail]     |             |
-//     |<----------------|              |             |
-//     |                 | RouteCreate  |             |
-//     |                 |--------------------------->|
-//     |                 | RouteResponse|             |
-//     |                 |<---------------------------|
-//     |                 | SubReq       |             |
-//     |                 |------------->|             |
-//     |                 |      SubResp |             |
-//     |                 |<-------------|             |
-//     |      RESTNotif1 |              |             |
-//     |<----------------|              |             |
-//     | RESTSubDelReq   |              |             |
-//     |---------------->|              |             |
-//     |   RESTSubDelResp|              |             |
-//     |<----------------|              |             |
-//     |                 | SubDelReq    |             |
-//     |                 |------------->|             |
-//     |                 |   SubDelResp |             |
-//     |                 |<-------------|             |
-//     |                 | SubDelReq    |             |
-//     |                 |------------->|             |
-//     |                 |   SubDelResp |             |
-//     |                 |<-------------|             |
-//     | RESTSubReq      |              |             |
-//     | [with RESTsubsId initial request]            |
-//     |---------------->|              |             |
-//     |     RESTSubResp |              |             |
-//     |<----------------|              |             |
-//     |                 | RouteCreate  |             |
-//     |                 |--------------------------->|
-//     |                 | RouteResponse|             |
-//     |                 |<---------------------------|
-//     |                 | SubReq       |             |
-//     |                 |------------->|             |
-//     |                 |      SubResp |             |
-//     |                 |<-------------|             |
-//     |      RESTNotif1 |              |             |
-//     |<----------------|              |             |
-//     |                 |              |             |
+//
+//     |                 |              |             |
+//     | RESTSubReq      |              |             |
+//     |---------------->|              |             |
+//     |     RESTSubResp |              |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubReq      |              |             |
+//     | [with RestSUbsId + one additional e2 subDetail]
+//     |---------------->|              |             |
+//     |      RESTNotif1 |              |             |
+//     | [for initial e2 subDetail]     |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     | RESTSubDelReq   |              |             |
+//     |---------------->|              |             |
+//     |   RESTSubDelResp|              |             |
+//     |<----------------|              |             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     |                 | SubDelReq    |             |
+//     |                 |------------->|             |
+//     |                 |   SubDelResp |             |
+//     |                 |<-------------|             |
+//     | RESTSubReq      |              |             |
+//     | [with RESTsubsId initial request]            |
+//     |---------------->|              |             |
+//     |     RESTSubResp |              |             |
+//     |<----------------|              |             |
+//     |                 | RouteCreate  |             |
+//     |                 |--------------------------->|
+//     |                 | RouteResponse|             |
+//     |                 |<---------------------------|
+//     |                 | SubReq       |             |
+//     |                 |------------->|             |
+//     |                 |      SubResp |             |
+//     |                 |<-------------|             |
+//     |      RESTNotif1 |              |             |
+//     |<----------------|              |             |
+//     |                 |              |             |
 //
 //-----------------------------------------------------------------------------
 func TestRESTSubReqRetransmissionV6(t *testing.T) {
@@ -4215,30 +5051,32 @@ func TestRESTSubDelReqRetransmission(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestRESTSubReqDelReq
 //
-//   stub                             stub
+//     stub                             stub
+//
 // +-------+        +---------+    +---------+
 // | xapp  |        | submgr  |    | e2term  |
 // +-------+        +---------+    +---------+
-//     |                 |              |
-//     | RESTSubReq      |              |
-//     |---------------->|              |
-//     |                 |              |
-//     |     RESTSubResp |              |
-//     |<----------------|              |
-//     |                 | SubReq       |
-//     |                 |------------->|
-//     | RESTSubDelReq   |              |
-//     |---------------->|              |
-//     |  RESTSubDelResp |              |
-//     |     unsuccess   |              |
-//     |<----------------|              |
-//     |                 |      SubResp |
-//     |                 |<-------------|
-//     |      RESTNotif1 |              |
-//     |<----------------|              |
-//     |                 |              |
-//     |            [SUBS DELETE]       |
-//     |                 |              |
+//
+//     |                 |              |
+//     | RESTSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |  RESTSubDelResp |              |
+//     |     unsuccess   |              |
+//     |<----------------|              |
+//     |                 |      SubResp |
+//     |                 |<-------------|
+//     |      RESTNotif1 |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |            [SUBS DELETE]       |
+//     |                 |              |
 //
 //-----------------------------------------------------------------------------
 func TestRESTSubReqDelReq(t *testing.T) {
@@ -4689,39 +5527,41 @@ func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
 //
-//   stub                             stub
+//     stub                             stub
+//
 // +-------+        +---------+    +---------+
 // | xapp  |        | submgr  |    | e2term  |
 // +-------+        +---------+    +---------+
-//     |                 |              |
-//     | RESTSubReq      |              |
-//     |---------------->|              |
-//     |                 |              |
-//     |     RESTSubResp |              |
-//     |<----------------|              |
-//     |                 | SubReq       |
-//     |                 |------------->|
-//     |                 |              |
-//     |                 |              |
-//     |                 | SubReq       |
-//     |                 |------------->|
-//     |                 |              |
-//     |                 | SubDelReq    |
-//     |                 |------------->|
-//     |                 |              |
-//     |                 |              |
-//     |                 | SubDelReq    |
-//     |                 |------------->|
-//     |                 |              |
-//     |                 |              |
-//     |                 |   SubDelResp |
-//     |                 |<-------------|
-//     |       RESTNotif |              |
-//     |       unsuccess |              |
-//     |<----------------|              |
-//     |                 |              |
-//     |            [SUBS DELETE]       |
-//     |                 |              |
+//
+//     |                 |              |
+//     | RESTSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//     |       RESTNotif |              |
+//     |       unsuccess |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |            [SUBS DELETE]       |
+//     |                 |              |
 //
 //-----------------------------------------------------------------------------
 func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
@@ -4915,28 +5755,30 @@ func TestRESTSubReqPartialResp(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestRESTSubDelReqRetryInSubmgr
 //
-//   stub                             stub
+//     stub                             stub
+//
 // +-------+        +---------+    +---------+
 // | xapp  |        | submgr  |    | e2term  |
 // +-------+        +---------+    +---------+
-//     |                 |              |
-//     |            [SUBS CREATE]       |
-//     |                 |              |
-//     |                 |              |
-//     | RESTSubDelReq   |              |
-//     |---------------->|              |
-//     |                 |              |
-//     |  RESTSubDelResp |              |
-//     |<----------------|              |
-//     |                 | SubDelReq    |
-//     |                 |------------->|
-//     |                 |              |
-//     |                 | SubDelReq    |
-//     |                 |------------->|
-//     |                 |              |
-//     |                 |   SubDelResp |
-//     |                 |<-------------|
-//     |                 |              |
+//
+//     |                 |              |
+//     |            [SUBS CREATE]       |
+//     |                 |              |
+//     |                 |              |
+//     | RESTSubDelReq   |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |  RESTSubDelResp |              |
+//     |<----------------|              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//     |                 |              |
 //
 //-----------------------------------------------------------------------------
 func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
@@ -5199,50 +6041,51 @@ func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestSubReqAndSubDelOkSameActionParallel
 //
-//   stub          stub                          stub
+//     stub          stub                          stub
+//
 // +-------+     +-------+     +---------+    +---------+
 // | xapp2 |     | xapp1 |     | submgr  |    | e2term  |
 // +-------+     +-------+     +---------+    +---------+
-//     |             |              |              |
-//     |             |              |              |
-//     |             |              |              |
-//     |             | SubReq1      |              |
-//     |             |------------->|              |
-//     |             |              |              |
-//     |             |              | SubReq1      |
-//     |             |              |------------->|
-//     |          SubReq2           |              |
-//     |--------------------------->|              |
-//     |             |              |    SubResp1  |
-//     |             |              |<-------------|
-//     |             |    SubResp1  |              |
-//     |             |<-------------|              |
-//     |             |              | SubReq2      |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |             |              |    SubResp2  |
-//     |             |              |<-------------|
-//     |          SubResp2          |              |
-//     |<---------------------------|              |
-//     |             |              |              |
-//     |             | SubDelReq 1  |              |
-//     |             |------------->|              |
-//     |             |              |              |
-//     |             | SubDelResp 1 |              |
-//     |             |<-------------|              |
-//     |             |              |              |
-//     |         SubDelReq 2        |              |
-//     |--------------------------->|              |
-//     |             |              |              |
-//     |             |              | SubDelReq 2  |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |             |              | SubDelReq 2  |
-//     |             |              |------------->|
-//     |             |              |              |
-//     |         SubDelResp 2       |              |
-//     |<---------------------------|              |
 //
+//     |             |              |              |
+//     |             |              |              |
+//     |             |              |              |
+//     |             | SubReq1      |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             |              | SubReq1      |
+//     |             |              |------------->|
+//     |          SubReq2           |              |
+//     |--------------------------->|              |
+//     |             |              |    SubResp1  |
+//     |             |              |<-------------|
+//     |             |    SubResp1  |              |
+//     |             |<-------------|              |
+//     |             |              | SubReq2      |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              |    SubResp2  |
+//     |             |              |<-------------|
+//     |          SubResp2          |              |
+//     |<---------------------------|              |
+//     |             |              |              |
+//     |             | SubDelReq 1  |              |
+//     |             |------------->|              |
+//     |             |              |              |
+//     |             | SubDelResp 1 |              |
+//     |             |<-------------|              |
+//     |             |              |              |
+//     |         SubDelReq 2        |              |
+//     |--------------------------->|              |
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |             |              | SubDelReq 2  |
+//     |             |              |------------->|
+//     |             |              |              |
+//     |         SubDelResp 2       |              |
+//     |<---------------------------|              |
 func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
 
        mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
@@ -6199,55 +7042,57 @@ func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
 //
-//   stub                             stub
+//     stub                             stub
+//
 // +-------+     +-------+        +---------+    +---------+
 // | xapp2 |     | xapp1 |        | submgr  |    | e2term  |
 // +-------+     +-------+        +---------+    +---------+
-//     |             |                 |              |
-//     |             | RESTSubReq1     |              |
-//     |             |---------------->|              |
-//     |             |                 |              |
-//     |             |    RESTSubResp1 |              |
-//     |             |<----------------|              |
-//     |             |                 |              |
-//     |             |                 | SubReq1      |
-//     |             |                 |------------->|
-//     |             |                 |    SubResp1  |
-//     |             |                 |<-------------|
-//     |             |      RESTNotif1 |              |
-//     |             |<----------------|              |
-//     |             |                 |              |
-//     | RESTSubReq2                   |              |
-//     |------------------------------>|              |
-//     |             |                 |              |
-//     |                  RESTSubResp2 |              |
-//     |<------------------------------|              |
-//     |             |                 |              |
-//     |             |      RESTNotif2 |              |
-//     |<------------------------------|              |
-//     |             |                 |              |
-//     |             |           Submgr restart       |
-//     |             |                 |              |
-//     |             | RESTSubDelReq1  |              |
-//     |             |---------------->|              |
-//     |             |                 |              |
-//     |             | RESTSubDelResp1 |              |
-//     |             |<----------------|              |
-//     |             |                 |              |
-//     |             |           Submgr restart       |
-//     |             |                 |              |
-//     | RESTSubDelReq2                |              |
-//     |------------------------------>|              |
-//     |             |                 |              |
-//     |               RESTSubDelResp2 |              |
-//     |<------------------------------|              |
-//     |             |                 |              |
-//     |             |                 | SubDelReq2   |
-//     |             |                 |------------->|
-//     |             |                 |              |
-//     |             |                 |  SubDelResp2 |
-//     |             |                 |<-------------|
-//     |             |                 |              |
+//
+//     |             |                 |              |
+//     |             | RESTSubReq1     |              |
+//     |             |---------------->|              |
+//     |             |                 |              |
+//     |             |    RESTSubResp1 |              |
+//     |             |<----------------|              |
+//     |             |                 |              |
+//     |             |                 | SubReq1      |
+//     |             |                 |------------->|
+//     |             |                 |    SubResp1  |
+//     |             |                 |<-------------|
+//     |             |      RESTNotif1 |              |
+//     |             |<----------------|              |
+//     |             |                 |              |
+//     | RESTSubReq2                   |              |
+//     |------------------------------>|              |
+//     |             |                 |              |
+//     |                  RESTSubResp2 |              |
+//     |<------------------------------|              |
+//     |             |                 |              |
+//     |             |      RESTNotif2 |              |
+//     |<------------------------------|              |
+//     |             |                 |              |
+//     |             |           Submgr restart       |
+//     |             |                 |              |
+//     |             | RESTSubDelReq1  |              |
+//     |             |---------------->|              |
+//     |             |                 |              |
+//     |             | RESTSubDelResp1 |              |
+//     |             |<----------------|              |
+//     |             |                 |              |
+//     |             |           Submgr restart       |
+//     |             |                 |              |
+//     | RESTSubDelReq2                |              |
+//     |------------------------------>|              |
+//     |             |                 |              |
+//     |               RESTSubDelResp2 |              |
+//     |<------------------------------|              |
+//     |             |                 |              |
+//     |             |                 | SubDelReq2   |
+//     |             |                 |------------->|
+//     |             |                 |              |
+//     |             |                 |  SubDelResp2 |
+//     |             |                 |<-------------|
+//     |             |                 |              |
 //
 //-----------------------------------------------------------------------------
 func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
@@ -7892,38 +8737,40 @@ func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
 //-----------------------------------------------------------------------------
 // TestRESTUnpackSubscriptionResponseUnknownInstanceId
 //
-//   stub                             stub
+//     stub                             stub
+//
 // +-------+        +---------+    +---------+
 // | xapp  |        | submgr  |    | e2term  |
 // +-------+        +---------+    +---------+
-//     |                 |              |
-//     | RestSubReq      |              |
-//     |---------------->|              |
-//     |                 |              |
-//     |     RESTSubResp |              |
-//     |<----------------|              |
-//     |                 |              |
-//     |                 | SubReq       |
-//     |                 |------------->|
-//     |                 |              |
-//     |                 |      SubFail | Unknown instanceId
-//     |                 |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
-//     |                 |              |
-//     |                 | SubReq       |
-//     |                 |------------->|
-//     |                 |              |
-//     |                 |      SubFail | Duplicated action
-//     |                 |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
-//     | RESTNotif (fail)|              |
-//     |<----------------|              |
-//     |                 | SubDelReq    |
-//     |                 |------------->|
-//     |                 |              |
-//     |                 |   SubDelResp |
-//     |                 |<-------------|
-//     |                 |              |
-//     |           [SUBS DELETE]        |
-//     |                 |              |
+//
+//     |                 |              |
+//     | RestSubReq      |              |
+//     |---------------->|              |
+//     |                 |              |
+//     |     RESTSubResp |              |
+//     |<----------------|              |
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | Unknown instanceId
+//     |                 |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
+//     |                 |              |
+//     |                 | SubReq       |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |      SubFail | Duplicated action
+//     |                 |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
+//     | RESTNotif (fail)|              |
+//     |<----------------|              |
+//     |                 | SubDelReq    |
+//     |                 |------------->|
+//     |                 |              |
+//     |                 |   SubDelResp |
+//     |                 |<-------------|
+//     |                 |              |
+//     |           [SUBS DELETE]        |
+//     |                 |              |
 //
 //-----------------------------------------------------------------------------
 func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
@@ -8856,9 +9703,11 @@ func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
        mainCtrl.VerifyAllClean(t)
 }
 
-////////////////////////////////////////////////////////////////////////////////////
-//   Services for UT cases
-////////////////////////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////////////////////
+//
+//     Services for UT cases
+//
+// //////////////////////////////////////////////////////////////////////////////////
 const subReqCount int = 1
 const host string = "localhost"
 
index 8656d5d..7210194 100644 (file)
@@ -146,6 +146,7 @@ func ut_test_init() func() {
        rt.AddRoute(12022, e2term2src.String(), -1, mainsrc.String())
        rt.AddRoute(12021, mainsrc.String(), -1, xapp2src.String()+";"+xapp1src.String())
        rt.AddRoute(12022, mainsrc.String(), -1, xapp2src.String()+";"+xapp1src.String())
+       rt.AddRoute(12006, e2term1src.String(), -1, mainsrc.String())
        rt.AddRoute(teststubPortSeed, "", -1, xapp2src.String()+";"+xapp1src.String()+";"+e2term1src.String()+";"+e2term2src.String()+";"+dummysrc.String())
 
        rt.AddMeid(e2term1src.String(), []string{"RAN_NAME_1", "RAN_NAME_2"})
index fbb9065..712a5b1 100644 (file)
@@ -310,6 +310,165 @@ func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest,
        }
 }
 
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SendErrorIndication(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) {
+       tc.Debug("SendErrorIndication")
+       ricE2RanErrorIndication := e2asnpacker.NewPackerErrorIndication()
+
+       //---------------------------------
+       // e2term activity: Send Error Indication
+       //---------------------------------
+       resp := &e2ap.E2APErrorIndication{}
+
+       resp.IsReqIdPresent = true
+       resp.RequestId.Id = req.RequestId.Id
+       resp.RequestId.InstanceId = req.RequestId.InstanceId
+
+       fmt.Println("resp.RequestId.Id: %d\n", resp.RequestId.Id)
+       fmt.Println("resp.RequestId.InstanceId: %d\n", resp.RequestId.InstanceId)
+
+       //Cause is optional IE in ErrorIndication Message
+       resp.IsCausePresent = true
+       resp.Cause.Content = e2ap.E2AP_CauseContent_Misc
+       resp.Cause.Value = e2ap.E2AP_CauseValue_CauseMisc_hardware_failure
+
+       fmt.Println("resp.Cause.Content: %d\n", resp.Cause.Content)
+       fmt.Println("resp.Cause.Value: %d\n", resp.Cause.Value)
+
+       packerr, packedMsg := ricE2RanErrorIndication.Pack(resp)
+       if packerr != nil {
+               tc.TestError(t, "pack NOK %s", packerr.Error())
+       }
+
+       fmt.Println("packedMsg: %v", packedMsg)
+
+       tc.Debug("%s", ricE2RanErrorIndication.String())
+
+       params := &xapp.RMRParams{}
+       params.Mtype = xapp.RIC_E2_RAN_ERROR_INDICATION
+       //params.SubId = msg.SubId
+       params.SubId = -1
+       params.Payload = packedMsg.Buf
+       params.PayloadLen = len(packedMsg.Buf)
+       params.Meid = msg.Meid
+       //params.Xid = msg.Xid
+       params.Mbuf = nil
+
+       tc.Debug("SEND Error Indication to SubMgr: %s", params.String())
+       snderr := tc.SendWithRetry(params, false, 5)
+       if snderr != nil {
+               tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
+       }
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SendErrorIndicationWithInvalidInstanceId(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) {
+       tc.Debug("SendErrorIndicationWithInvalidInstanceId")
+       ricE2RanErrorIndication := e2asnpacker.NewPackerErrorIndication()
+
+       //---------------------------------
+       // e2term activity: Send Error Indication
+       //---------------------------------
+       resp := &e2ap.E2APErrorIndication{}
+
+       resp.IsReqIdPresent = true
+       resp.RequestId.Id = req.RequestId.Id
+       resp.RequestId.InstanceId = 10
+
+       fmt.Println("resp.RequestId.Id: %d\n", resp.RequestId.Id)
+       fmt.Println("resp.RequestId.InstanceId: %d\n", resp.RequestId.InstanceId)
+
+       //Cause is optional IE in ErrorIndication Message
+       resp.IsCausePresent = true
+       resp.Cause.Content = e2ap.E2AP_CauseContent_RICrequest
+       resp.Cause.Value = e2ap.E2AP_CauseValue_RICrequest_unspecified
+
+       fmt.Println("resp.Cause.Content: %d\n", resp.Cause.Content)
+       fmt.Println("resp.Cause.Value: %d\n", resp.Cause.Value)
+
+       packerr, packedMsg := ricE2RanErrorIndication.Pack(resp)
+       if packerr != nil {
+               tc.TestError(t, "pack NOK %s", packerr.Error())
+       }
+
+       fmt.Println("packedMsg: %v", packedMsg)
+
+       tc.Debug("%s", ricE2RanErrorIndication.String())
+
+       params := &xapp.RMRParams{}
+       params.Mtype = xapp.RIC_E2_RAN_ERROR_INDICATION
+       //params.SubId = msg.SubId
+       params.SubId = -1
+       params.Payload = packedMsg.Buf
+       params.PayloadLen = len(packedMsg.Buf)
+       params.Meid = msg.Meid
+       //params.Xid = msg.Xid
+       params.Mbuf = nil
+
+       tc.Debug("SEND Error Indication to SubMgr: %s", params.String())
+       snderr := tc.SendWithRetry(params, false, 5)
+       if snderr != nil {
+               tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
+       }
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (tc *E2Stub) SendErrorIndicationWithDiffCause(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) {
+       tc.Debug("SendErrorIndication")
+       ricE2RanErrorIndication := e2asnpacker.NewPackerErrorIndication()
+
+       //---------------------------------
+       // e2term activity: Send Error Indication
+       //---------------------------------
+       resp := &e2ap.E2APErrorIndication{}
+
+       resp.IsReqIdPresent = true
+       resp.RequestId.Id = req.RequestId.Id
+       resp.RequestId.InstanceId = req.RequestId.InstanceId
+
+       fmt.Println("resp.RequestId.Id: %d\n", resp.RequestId.Id)
+       fmt.Println("resp.RequestId.InstanceId: %d\n", resp.RequestId.InstanceId)
+
+       //Cause is optional IE in ErrorIndication Message
+       resp.IsCausePresent = true
+       resp.Cause.Content = e2ap.E2AP_CauseContent_RICrequest
+       resp.Cause.Value = e2ap.E2AP_CauseValue_RICrequest_excessive_actions
+
+       fmt.Println("resp.Cause.Content: %d\n", resp.Cause.Content)
+       fmt.Println("resp.Cause.Value: %d\n", resp.Cause.Value)
+
+       packerr, packedMsg := ricE2RanErrorIndication.Pack(resp)
+       if packerr != nil {
+               tc.TestError(t, "pack NOK %s", packerr.Error())
+       }
+
+       fmt.Println("packedMsg: %v", packedMsg)
+
+       tc.Debug("%s", ricE2RanErrorIndication.String())
+
+       params := &xapp.RMRParams{}
+       params.Mtype = xapp.RIC_E2_RAN_ERROR_INDICATION
+       //params.SubId = msg.SubId
+       params.SubId = -1
+       params.Payload = packedMsg.Buf
+       params.PayloadLen = len(packedMsg.Buf)
+       params.Meid = msg.Meid
+       //params.Xid = msg.Xid
+       params.Mbuf = nil
+
+       tc.Debug("SEND Error Indication to SubMgr: %s", params.String())
+       snderr := tc.SendWithRetry(params, false, 5)
+       if snderr != nil {
+               tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
+       }
+}
+
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------