From: subhash kumar singh Date: Thu, 5 May 2022 17:25:33 +0000 (+0000) Subject: Add transaction ID support in RICServiceQuery X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=0333c25c019ab0843f507f46631839fbb313f2f1;p=ric-plt%2Fe2mgr.git Add transaction ID support in RICServiceQuery Added transaction ID support in RICServiceQuery message. Signed-off-by: subhash kumar singh Change-Id: I52a1849e421a7c0c372f8dea9ca62c12b7114c6e --- diff --git a/E2Manager/models/constants.go b/E2Manager/models/constants.go index 1a33212..246329b 100644 --- a/E2Manager/models/constants.go +++ b/E2Manager/models/constants.go @@ -26,4 +26,5 @@ const ( const ( SuccessfulOutcome_value_PR_RICserviceUpdateAcknowledge = "3" + InitiatingMessage_value_PR_RICserviceQuery = "10" ) diff --git a/E2Manager/models/ric_service_query_message.go b/E2Manager/models/ric_service_query_message.go index dc6d315..214646d 100644 --- a/E2Manager/models/ric_service_query_message.go +++ b/E2Manager/models/ric_service_query_message.go @@ -20,13 +20,17 @@ package models import ( "encoding/xml" + "math/rand" + "strconv" + "time" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" ) type RanFunctionIdItem struct { - Text string `xml:",chardata"` - RanFunctionId uint32 `xml:"ranFunctionID"` - RanFunctionRevision uint32 `xml:"ranFunctionRevision"` + Text string `xml:",chardata"` + RanFunctionId uint32 `xml:"ranFunctionID"` + RanFunctionRevision uint32 `xml:"ranFunctionRevision"` } type RicServiceQueryProtocolIESingleContainer struct { @@ -37,8 +41,8 @@ type RicServiceQueryProtocolIESingleContainer struct { Reject string `xml:"reject"` } `xml:"criticality"` Value struct { - Text string `xml:",chardata"` - RanFunctionIdItem RanFunctionIdItem `xml:"RANfunctionID-Item"` + Text string `xml:",chardata"` + RanFunctionIdItem RanFunctionIdItem `xml:"RANfunctionID-Item"` } `xml:"value"` } @@ -49,19 +53,25 @@ type RICServiceQueryIEs struct { Text string `xml:",chardata"` Reject string `xml:"reject"` } `xml:"criticality"` - Value struct { - Text string `xml:",chardata"` - RANFunctionIdList struct { - Text string `xml:",chardata"` - ProtocolIESingleContainer []RicServiceQueryProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"` - } `xml:"RANfunctionsID-List"` - } `xml:"value"` + Value interface{} `xml:"value"` +} + +type RICServiceQueryRANFunctionIdList struct { + Text string `xml:",chardata"` + RANFunctionIdList struct { + Text string `xml:",chardata"` + ProtocolIESingleContainer []RicServiceQueryProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"` + } `xml:"RANfunctionsID-List"` +} +type RICServiceQueryTransactionID struct { + Text string `xml:",chardata"` + TransactionID string `xml:"TransactionID"` } type RICServiceQuery struct { - Text string `xml:",chardata"` + Text string `xml:",chardata"` ProtocolIEs struct { - Text string `xml:",chardata"` + Text string `xml:",chardata"` RICServiceQueryIEs []RICServiceQueryIEs `xml:"RICserviceQuery-IEs"` } `xml:"protocolIEs"` } @@ -74,38 +84,68 @@ type InitiatingMessage struct { Ignore string `xml:"ignore"` } `xml:"criticality"` Value struct { - Text string `xml:",chardata"` + Text string `xml:",chardata"` RICServiceQuery RICServiceQuery `xml:"RICserviceQuery"` } `xml:"value"` } type RicServiceQueryE2APPDU struct { - XMLName xml.Name `xml:"E2AP-PDU"` - Text string `xml:",chardata"` + XMLName xml.Name `xml:"E2AP-PDU"` + Text string `xml:",chardata"` InitiatingMessage InitiatingMessage `xml:"initiatingMessage"` } - -type RICServiceQueryMessage struct{ - XMLName xml.Name `xml:"RICserviceQueryMessage"` - Text string `xml:",chardata"` - E2APPDU RicServiceQueryE2APPDU `xml:"E2AP-PDU"` +type RICServiceQueryMessage struct { + XMLName xml.Name `xml:"RICserviceQueryMessage"` + Text string `xml:",chardata"` + E2APPDU RicServiceQueryE2APPDU `xml:"E2AP-PDU"` } func NewRicServiceQueryMessage(ranFunctions []*entities.RanFunction) RICServiceQueryMessage { - initiatingMessage := InitiatingMessage{} - initiatingMessage.ProcedureCode = "6" - initiatingMessage.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs = make([]RICServiceQueryIEs,1) - initiatingMessage.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Id = "9" - protocolIESingleContainer := make([]RicServiceQueryProtocolIESingleContainer,len(ranFunctions)) + rand.Seed(time.Now().Unix()) + + txIE := RICServiceQueryIEs{ + Id: ProtocolIE_ID_id_TransactionID, + Value: RICServiceQueryTransactionID{ + TransactionID: strconv.FormatUint(rand.Uint64(), 10), + }, + } + + protocolIESingleContainer := make([]RicServiceQueryProtocolIESingleContainer, len(ranFunctions)) for i := 0; i < len(ranFunctions); i++ { - protocolIESingleContainer[i].Id = "6" + protocolIESingleContainer[i].Id = ProtocolIE_ID_id_RANfunctionID_Item protocolIESingleContainer[i].Value.RanFunctionIdItem.RanFunctionId = ranFunctions[i].RanFunctionId protocolIESingleContainer[i].Value.RanFunctionIdItem.RanFunctionRevision = ranFunctions[i].RanFunctionRevision } - initiatingMessage.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Value.RANFunctionIdList.ProtocolIESingleContainer = protocolIESingleContainer - return RICServiceQueryMessage{E2APPDU:RicServiceQueryE2APPDU{InitiatingMessage:initiatingMessage}} -} + funcListIE := RICServiceQueryIEs{ + Id: ProtocolIE_ID_id_RANfunctionsAccepted, + Value: RICServiceQueryRANFunctionIdList{ + RANFunctionIdList: struct { + Text string `xml:",chardata"` + ProtocolIESingleContainer []RicServiceQueryProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"` + }{ + ProtocolIESingleContainer: protocolIESingleContainer, + }, + }, + } + initiatingMessage := InitiatingMessage{ + ProcedureCode: InitiatingMessage_value_PR_RICserviceQuery, + Value: struct { + Text string `xml:",chardata"` + RICServiceQuery RICServiceQuery `xml:"RICserviceQuery"` + }{ + RICServiceQuery: RICServiceQuery{ + ProtocolIEs: struct { + Text string `xml:",chardata"` + RICServiceQueryIEs []RICServiceQueryIEs `xml:"RICserviceQuery-IEs"` + }{ + RICServiceQueryIEs: []RICServiceQueryIEs{txIE, funcListIE}, + }, + }, + }, + } + return RICServiceQueryMessage{E2APPDU: RicServiceQueryE2APPDU{InitiatingMessage: initiatingMessage}} +} diff --git a/E2Manager/models/ric_service_query_message_test.go b/E2Manager/models/ric_service_query_message_test.go index 3ed2fbc..9da1b6d 100644 --- a/E2Manager/models/ric_service_query_message_test.go +++ b/E2Manager/models/ric_service_query_message_test.go @@ -23,9 +23,10 @@ import ( "e2mgr/models" "e2mgr/utils" "encoding/xml" + "testing" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" "github.com/stretchr/testify/assert" - "testing" ) func getTestRicServiceQueryRanFunctions(t *testing.T) []*entities.RanFunction { @@ -47,7 +48,15 @@ func TestRicServiceQueryMessageSuccess(t *testing.T) { serviceQuery := models.NewRicServiceQueryMessage(ranFunctionList) initMsg := serviceQuery.E2APPDU.InitiatingMessage - assert.Equal(t, "6", initMsg.ProcedureCode) - assert.Equal(t, "9", initMsg.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Id) - assert.Equal(t, 3, len(initMsg.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Value.RANFunctionIdList.ProtocolIESingleContainer)) + assert.Equal(t, models.InitiatingMessage_value_PR_RICserviceQuery, initMsg.ProcedureCode) + assert.Equal(t, models.ProtocolIE_ID_id_TransactionID, initMsg.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Id) + assert.Equal(t, models.ProtocolIE_ID_id_RANfunctionsAccepted, initMsg.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[1].Id) + assert.Equal(t, 3, len(initMsg.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[1].Value.(models.RICServiceQueryRANFunctionIdList).RANFunctionIdList.ProtocolIESingleContainer)) +} + +func TestTransactionIdServiceQuery(t *testing.T) { + ranFunctionList := getTestRicServiceQueryRanFunctions(t) + serviceQuery := models.NewRicServiceQueryMessage(ranFunctionList) + txIE := serviceQuery.E2APPDU.InitiatingMessage.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Value.(models.RICServiceQueryTransactionID) + assert.NotEmpty(t, txIE.TransactionID, "transaction ID should not be empty") }