Fix for RequestorId returned to xApp 32/5632/1
authorAnssi Mannila <anssi.mannila@nokia.com>
Thu, 11 Feb 2021 10:50:48 +0000 (12:50 +0200)
committerAnssi Mannila <anssi.mannila@nokia.com>
Thu, 11 Feb 2021 10:50:55 +0000 (12:50 +0200)
Change-Id: Ib4f784472e0b940d52181b6cb777bf56eb71bf82
Signed-off-by: Anssi Mannila <anssi.mannila@nokia.com>
container-tag.yaml
e2ap/pkg/e2ap/msg_e2ap.go
pkg/control/control.go
pkg/control/sdl_test.go
pkg/control/tracker.go
pkg/control/transaction.go

index 6c9085d..8420c21 100644 (file)
@@ -2,4 +2,4 @@
 # By default this file is in the docker build directory,
 # but the location can configured in the JJB template.
 ---
-tag: "0.6.2"
+tag: "0.6.3"
index 96ef099..f4ca81a 100644 (file)
@@ -119,8 +119,8 @@ func (msgInfo *MessageInfo) String() string {
 //
 //-----------------------------------------------------------------------------
 type RequestId struct {
-       Id         uint32
-       InstanceId uint32
+       Id         uint32 //RequestorId
+       InstanceId uint32 //Same as SubId in many place in the code. Name changed in E2 spec SubId -> InstanceId
 }
 
 func (rid *RequestId) String() string {
index eff14ee..6111c63 100755 (executable)
@@ -231,11 +231,12 @@ func (c *Control) SubscriptionDeleteHandler(s string) error {
 }
 
 func (c *Control) QueryHandler() (models.SubscriptionList, error) {
+       xapp.Logger.Info("QueryHandler() called")
+
        return c.registry.QueryHandler()
 }
 
 func (c *Control) TestRestHandler(w http.ResponseWriter, r *http.Request) {
-
        xapp.Logger.Info("TestRestHandler() called")
 
        pathParams := mux.Vars(r)
@@ -352,7 +353,7 @@ func (c *Control) handleXAPPSubscriptionRequest(params *xapp.RMRParams) {
                return
        }
 
-       trans := c.tracker.NewXappTransaction(xapp.NewRmrEndpoint(params.Src), params.Xid, subReqMsg.RequestId.InstanceId, params.Meid)
+       trans := c.tracker.NewXappTransaction(xapp.NewRmrEndpoint(params.Src), params.Xid, subReqMsg.RequestId, params.Meid)
        if trans == nil {
                xapp.Logger.Error("XAPP-SubReq: %s", idstring(fmt.Errorf("transaction not created"), params))
                return
@@ -381,6 +382,7 @@ func (c *Control) handleXAPPSubscriptionRequest(params *xapp.RMRParams) {
        if event != nil {
                switch themsg := event.(type) {
                case *e2ap.E2APSubscriptionResponse:
+                       themsg.RequestId.Id = trans.RequestId.Id
                        trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionResponse(themsg)
                        if err == nil {
                                trans.Release()
@@ -389,6 +391,7 @@ func (c *Control) handleXAPPSubscriptionRequest(params *xapp.RMRParams) {
                                return
                        }
                case *e2ap.E2APSubscriptionFailure:
+                       themsg.RequestId.Id = trans.RequestId.Id
                        trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionFailure(themsg)
                        if err == nil {
                                c.UpdateCounter(cSubFailToXapp)
@@ -415,7 +418,7 @@ func (c *Control) handleXAPPSubscriptionDeleteRequest(params *xapp.RMRParams) {
                return
        }
 
-       trans := c.tracker.NewXappTransaction(xapp.NewRmrEndpoint(params.Src), params.Xid, subDelReqMsg.RequestId.InstanceId, params.Meid)
+       trans := c.tracker.NewXappTransaction(xapp.NewRmrEndpoint(params.Src), params.Xid, subDelReqMsg.RequestId, params.Meid)
        if trans == nil {
                xapp.Logger.Error("XAPP-SubDelReq: %s", idstring(fmt.Errorf("transaction not created"), params))
                return
@@ -449,7 +452,8 @@ func (c *Control) handleXAPPSubscriptionDeleteRequest(params *xapp.RMRParams) {
 
        // Whatever is received success, fail or timeout, send successful delete response
        subDelRespMsg := &e2ap.E2APSubscriptionDeleteResponse{}
-       subDelRespMsg.RequestId = subs.GetReqId().RequestId
+       subDelRespMsg.RequestId.Id = trans.RequestId.Id
+       subDelRespMsg.RequestId.InstanceId = subs.GetReqId().RequestId.InstanceId
        subDelRespMsg.FunctionId = subs.SubReqMsg.FunctionId
        trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionDeleteResponse(subDelRespMsg)
        if err == nil {
index 9198e5c..9e27ebc 100644 (file)
@@ -91,7 +91,7 @@ func GetSubscription(t *testing.T, e2SubId uint32, responseType int, srcEndPoint
        params.Meid = &meid
 
        // Create xApp transaction
-       trans := mainCtrl.c.tracker.NewXappTransaction(xapp.NewRmrEndpoint(params.Src), params.Xid, subReqParams.Req.RequestId.InstanceId, params.Meid)
+       trans := mainCtrl.c.tracker.NewXappTransaction(xapp.NewRmrEndpoint(params.Src), params.Xid, subReqParams.Req.RequestId, params.Meid)
        if trans == nil {
                t.Errorf("TEST: %s", idstring(fmt.Errorf("transaction not created"), params))
                return nil
index 46971d9..d837ac8 100644 (file)
@@ -21,6 +21,7 @@ package control
 
 import (
        "fmt"
+       "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "sync"
 )
@@ -58,13 +59,13 @@ func (t *Tracker) NewSubsTransaction(subs *Subscription) *TransactionSubs {
 func (t *Tracker) NewXappTransaction(
        endpoint *xapp.RmrEndpoint,
        xid string,
-       subid uint32,
+       requestId e2ap.RequestId,
        meid *xapp.RMRMeid) *TransactionXapp {
 
        trans := &TransactionXapp{}
        trans.XappKey = &TransactionXappKey{*endpoint, xid}
        trans.Meid = meid
-       trans.SubId = subid
+       trans.RequestId = requestId
        t.initTransaction(&trans.Transaction)
        xapp.Logger.Debug("CREATE %s", trans.String())
        return trans
index f722d11..c7ca812 100644 (file)
@@ -142,8 +142,8 @@ func (key *TransactionXappKey) String() string {
 //-----------------------------------------------------------------------------
 type TransactionXapp struct {
        Transaction
-       XappKey *TransactionXappKey
-       SubId   uint32
+       XappKey   *TransactionXappKey
+       RequestId e2ap.RequestId
 }
 
 func (t *TransactionXapp) String() string {
@@ -151,7 +151,7 @@ func (t *TransactionXapp) String() string {
        if t.XappKey != nil {
                transkey = t.XappKey.String()
        }
-       return "transxapp(" + t.Transaction.String() + "/" + transkey + "/" + strconv.FormatUint(uint64(t.SubId), 10) + ")"
+       return "transxapp(" + t.Transaction.String() + "/" + transkey + "/" + strconv.FormatUint(uint64(t.RequestId.InstanceId), 10) + ")"
 }
 
 func (t *TransactionXapp) GetEndpoint() *xapp.RmrEndpoint {
@@ -184,7 +184,7 @@ func (t *TransactionXapp) GetSrc() string {
 func (t *TransactionXapp) GetSubId() uint32 {
        t.mutex.Lock()
        defer t.mutex.Unlock()
-       return t.SubId
+       return t.RequestId.InstanceId
 }
 
 func (t *TransactionXapp) Release() {