Support Transaction ID in ServiceUpdateAck 85/8185/1
authorsubhash kumar singh <subh.singh@samsung.com>
Fri, 6 May 2022 20:32:50 +0000 (20:32 +0000)
committersubhash kumar singh <subh.singh@samsung.com>
Fri, 6 May 2022 21:08:32 +0000 (02:38 +0530)
Support transaction ID in ServiceUpdateAck message.

Signed-off-by: subhash kumar singh <subh.singh@samsung.com>
Change-Id: I2a5b445bf3c032eee9882d14036e2662b46711f3

E2Manager/handlers/rmrmsghandlers/ric_service_update_handler.go
E2Manager/models/constants.go [new file with mode: 0644]
E2Manager/models/ric_service_update_ack_message.go
E2Manager/models/ric_service_update_ack_message_test.go

index 94f9272..15f89a8 100644 (file)
@@ -104,7 +104,7 @@ func (h *RicServiceUpdateHandler) Handle(request *models.NotificationRequest) {
                return
        }
 
-       updateAck := models.NewServiceUpdateAck(ackFunctionIds)
+       updateAck := models.NewServiceUpdateAck(ackFunctionIds, ricServiceUpdate.E2APPDU.InitiatingMessage.Value.RICServiceUpdate.ProtocolIEs.RICServiceUpdateIEs[0].Value.TransactionID)
        err = h.sendUpdateAck(updateAck, nodebInfo, request)
        if err != nil {
                h.logger.Errorf("#RicServiceUpdate.Handle - failed to send RIC_SERVICE_UPDATE_ACK message to RMR: %s", err)
diff --git a/E2Manager/models/constants.go b/E2Manager/models/constants.go
new file mode 100644 (file)
index 0000000..1a33212
--- /dev/null
@@ -0,0 +1,29 @@
+//
+// Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//  This source code is part of the near-RT RIC (RAN Intelligent Controller)
+//  platform project (RICP).
+
+package models
+
+const (
+       ProtocolIE_ID_id_RANfunctionID_Item   = "6"
+       ProtocolIE_ID_id_RANfunctionsAccepted = "9"
+       ProtocolIE_ID_id_TransactionID        = "49"
+)
+
+const (
+       SuccessfulOutcome_value_PR_RICserviceUpdateAcknowledge = "3"
+)
index 1388f14..81cc12c 100644 (file)
 package models
 
 import (
-        "encoding/xml"
+       "encoding/xml"
 )
 
 type RicServiceAckRANFunctionIDItem struct {
        Text                string `xml:",chardata"`
-        RanFunctionID       uint32 `xml:"ranFunctionID"`
-        RanFunctionRevision uint32 `xml:"ranFunctionRevision"`
+       RanFunctionID       uint32 `xml:"ranFunctionID"`
+       RanFunctionRevision uint32 `xml:"ranFunctionRevision"`
 }
 
 type RICserviceUpdateAcknowledgeProtocolIESingleContainer struct {
-               Text        string `xml:",chardata"`
-               Id          string `xml:"id"`
-               Criticality struct {
-                               Text   string `xml:",chardata"`
-                               //Ignore string `xml:"ignore"`
-                               Reject string `xml:"reject"`
-               } `xml:"criticality"`
-               Value struct {
-                               Text              string `xml:",chardata"`
-                               RANfunctionIDItem RicServiceAckRANFunctionIDItem `xml:"RANfunctionID-Item"`
-               } `xml:"value"`
+       Text        string `xml:",chardata"`
+       Id          string `xml:"id"`
+       Criticality struct {
+               Text string `xml:",chardata"`
+               //Ignore string `xml:"ignore"`
+               Reject string `xml:"reject"`
+       } `xml:"criticality"`
+       Value struct {
+               Text              string                         `xml:",chardata"`
+               RANfunctionIDItem RicServiceAckRANFunctionIDItem `xml:"RANfunctionID-Item"`
+       } `xml:"value"`
 }
 
 type RICserviceUpdateAcknowledgeIEs struct {
        Text        string `xml:",chardata"`
-        ID          string `xml:"id"`
-        Criticality struct {
-                Text   string `xml:",chardata"`
-                Reject string `xml:"reject"`
-        } `xml:"criticality"`
-        Value struct {
+       ID          string `xml:"id"`
+       Criticality struct {
                Text   string `xml:",chardata"`
-               RANfunctionsIDList struct {
-                       Text   string `xml:",chardata"`
-                       ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
-               } `xml:"RANfunctionsID-List"`
-       }`xml:"value"`
+               Reject string `xml:"reject"`
+       } `xml:"criticality"`
+       Value interface{} `xml:"value"`
 }
 
+type RICserviceUpdateAcknowledgeTransactionID struct {
+       Text          string `xml:",chardata"`
+       TransactionID string `xml:"TransactionID"`
+}
+
+type RICserviceUpdateAcknowledgeRANfunctionsList struct {
+       Text               string `xml:",chardata"`
+       RANfunctionsIDList struct {
+               Text                      string                                                 `xml:",chardata"`
+               ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
+       } `xml:"RANfunctionsID-List"`
+}
 type RicServiceUpdateAckSuccessfulOutcome struct {
-       XMLName xml.Name        `xml:"successfulOutcome"`
-        Text          string `xml:",chardata"`
-        ProcedureCode string `xml:"procedureCode"`
-        Criticality   struct {
-                Text   string `xml:",chardata"`
-                Reject string `xml:"reject"`
-        } `xml:"criticality"`
+       XMLName       xml.Name `xml:"successfulOutcome"`
+       Text          string   `xml:",chardata"`
+       ProcedureCode string   `xml:"procedureCode"`
+       Criticality   struct {
+               Text   string `xml:",chardata"`
+               Reject string `xml:"reject"`
+       } `xml:"criticality"`
        Value struct {
-               Text            string `xml:",chardata"`
-               RICserviceUpdateAcknowledge  RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"`
+               Text                        string                      `xml:",chardata"`
+               RICserviceUpdateAcknowledge RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"`
        } `xml:"value"`
 }
 
 type RICserviceUpdateAcknowledge struct {
        Text        string `xml:",chardata"`
        ProtocolIEs struct {
-               Text               string `xml:",chardata"`
+               Text                           string                           `xml:",chardata"`
                RICserviceUpdateAcknowledgeIEs []RICserviceUpdateAcknowledgeIEs `xml:"RICserviceUpdateAcknowledge-IEs"`
        } `xml:"protocolIEs"`
 }
 
 type RicServiceUpdateAckE2APPDU struct {
-        XMLName xml.Name `xml:"E2AP-PDU"`
-        Text    string `xml:",chardata"`
-        InitiatingMessage interface{}
+       XMLName           xml.Name `xml:"E2AP-PDU"`
+       Text              string   `xml:",chardata"`
+       SuccessfulOutcome interface{}
 }
 
-func NewServiceUpdateAck(ricServiceUpdate []RicServiceAckRANFunctionIDItem) RicServiceUpdateAckE2APPDU {
-       successfulOutcome := RicServiceUpdateAckSuccessfulOutcome{}
-       successfulOutcome.ProcedureCode = "7"
-       if len(ricServiceUpdate) == 0 {
-               return RicServiceUpdateAckE2APPDU{InitiatingMessage:successfulOutcome}
+func NewServiceUpdateAck(ricServiceUpdate []RicServiceAckRANFunctionIDItem, txId string) RicServiceUpdateAckE2APPDU {
+
+       txIE := RICserviceUpdateAcknowledgeIEs{
+               ID: ProtocolIE_ID_id_TransactionID,
+               Value: RICserviceUpdateAcknowledgeTransactionID{
+                       TransactionID: txId,
+               },
        }
 
-       ricServiceUpdateAcknowledgeIEs := make([]RICserviceUpdateAcknowledgeIEs, 1)
-       ricServiceUpdateAcknowledgeIEs[0].ID = "9"
        protocolIESingleContainer := make([]RICserviceUpdateAcknowledgeProtocolIESingleContainer, len(ricServiceUpdate))
        for i := 0; i < len(ricServiceUpdate); i++ {
                protocolIESingleContainer[i].Value.RANfunctionIDItem = ricServiceUpdate[i]
-               protocolIESingleContainer[i].Id = "6"
+               protocolIESingleContainer[i].Id = ProtocolIE_ID_id_RANfunctionID_Item
+       }
+
+       // mandatory RANFunctionsAccepted
+       functionListIE := RICserviceUpdateAcknowledgeIEs{
+               ID: ProtocolIE_ID_id_RANfunctionsAccepted,
+               Value: RICserviceUpdateAcknowledgeRANfunctionsList{
+                       RANfunctionsIDList: struct {
+                               Text                      string                                                 `xml:",chardata"`
+                               ProtocolIESingleContainer []RICserviceUpdateAcknowledgeProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
+                       }{
+                               ProtocolIESingleContainer: protocolIESingleContainer,
+                       },
+               },
        }
-       ricServiceUpdateAcknowledgeIEs[0].Value.RANfunctionsIDList.ProtocolIESingleContainer = protocolIESingleContainer
-       successfulOutcome.Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs = ricServiceUpdateAcknowledgeIEs
-       return RicServiceUpdateAckE2APPDU{InitiatingMessage:successfulOutcome}
-}
 
+       successfulOutcome := RicServiceUpdateAckSuccessfulOutcome{
+               ProcedureCode: SuccessfulOutcome_value_PR_RICserviceUpdateAcknowledge,
+               Value: struct {
+                       Text                        string                      `xml:",chardata"`
+                       RICserviceUpdateAcknowledge RICserviceUpdateAcknowledge `xml:"RICserviceUpdateAcknowledge"`
+               }{
+                       RICserviceUpdateAcknowledge: RICserviceUpdateAcknowledge{
+                               ProtocolIEs: struct {
+                                       Text                           string                           `xml:",chardata"`
+                                       RICserviceUpdateAcknowledgeIEs []RICserviceUpdateAcknowledgeIEs `xml:"RICserviceUpdateAcknowledge-IEs"`
+                               }{
+                                       RICserviceUpdateAcknowledgeIEs: []RICserviceUpdateAcknowledgeIEs{txIE, functionListIE},
+                               },
+                       },
+               },
+       }
+
+       return RicServiceUpdateAckE2APPDU{SuccessfulOutcome: successfulOutcome}
+}
index 8dfd4bb..85f2568 100644 (file)
@@ -21,8 +21,9 @@ package models_test
 
 import (
        "e2mgr/models"
-       "github.com/stretchr/testify/assert"
        "testing"
+
+       "github.com/stretchr/testify/assert"
 )
 
 func TestRicServiceUpdateAckMessageSuccess(t *testing.T) {
@@ -33,20 +34,20 @@ func TestRicServiceUpdateAckMessageSuccess(t *testing.T) {
                item2,
        }
 
-       serviceUpdateAck := models.NewServiceUpdateAck(serviceupdateAckFunctionIds)
-       ies := serviceUpdateAck.InitiatingMessage.(models.RicServiceUpdateAckSuccessfulOutcome).Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs
-       assert.Equal(t, "9", ies[0].ID)
-       assert.Equal(t, "6", ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[0].Id)
-       assert.Equal(t, "6", ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[1].Id)
-       assert.Equal(t, item1, ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[0].Value.RANfunctionIDItem)
-       assert.Equal(t, item2, ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[1].Value.RANfunctionIDItem)
+       serviceUpdateAck := models.NewServiceUpdateAck(serviceupdateAckFunctionIds, "1234")
+       ies := serviceUpdateAck.SuccessfulOutcome.(models.RicServiceUpdateAckSuccessfulOutcome).Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs
+       assert.Equal(t, models.ProtocolIE_ID_id_RANfunctionsAccepted, ies[1].ID)
+       assert.Equal(t, models.ProtocolIE_ID_id_RANfunctionID_Item, ies[1].Value.(models.RICserviceUpdateAcknowledgeRANfunctionsList).RANfunctionsIDList.ProtocolIESingleContainer[0].Id)
+       assert.Equal(t, models.ProtocolIE_ID_id_RANfunctionID_Item, ies[1].Value.(models.RICserviceUpdateAcknowledgeRANfunctionsList).RANfunctionsIDList.ProtocolIESingleContainer[1].Id)
+       assert.Equal(t, item1, ies[1].Value.(models.RICserviceUpdateAcknowledgeRANfunctionsList).RANfunctionsIDList.ProtocolIESingleContainer[0].Value.RANfunctionIDItem)
+       assert.Equal(t, item2, ies[1].Value.(models.RICserviceUpdateAcknowledgeRANfunctionsList).RANfunctionsIDList.ProtocolIESingleContainer[1].Value.RANfunctionIDItem)
+
+       txIE := serviceUpdateAck.SuccessfulOutcome.(models.RicServiceUpdateAckSuccessfulOutcome).Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs[0]
+       assert.Equal(t, models.ProtocolIE_ID_id_TransactionID, txIE.ID)
+       assert.Equal(t, "1234", txIE.Value.(models.RICserviceUpdateAcknowledgeTransactionID).TransactionID)
 }
 
 func TestRicServiceUpdateAckMessageNoRanFunctionIdItemsSuccess(t *testing.T) {
-       successfulOutcome := models.RicServiceUpdateAckSuccessfulOutcome{}
-       successfulOutcome.ProcedureCode = "7"
-
-       expectedAck := models.RicServiceUpdateAckE2APPDU{InitiatingMessage: successfulOutcome}
-       serviceUpdateAck := models.NewServiceUpdateAck(nil)
-       assert.Equal(t, expectedAck, serviceUpdateAck)
+       serviceUpdateAck := models.NewServiceUpdateAck(nil, "1234")
+       assert.Equal(t, 2, len(serviceUpdateAck.SuccessfulOutcome.(models.RicServiceUpdateAckSuccessfulOutcome).Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs), "Trasaction ID is mandatory IE")
 }