X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fhandlers%2Frmrmsghandlers%2Fe2_setup_request_notification_handler_test.go;h=41ddccad5f5a540e465c3231534942ea3878a76a;hb=5de9b208a878150d4f991816d2283720fea36a1c;hp=a824e0cec528fcfd54417e5cf66006a244e81700;hpb=13ced50827996f6d49f5af7a64247466cda046e2;p=ric-plt%2Fe2mgr.git
diff --git a/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler_test.go b/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler_test.go
index a824e0c..41ddcca 100644
--- a/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler_test.go
+++ b/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler_test.go
@@ -20,6 +20,7 @@
package rmrmsghandlers
import (
+ "bytes"
"e2mgr/configuration"
"e2mgr/managers"
"e2mgr/mocks"
@@ -27,9 +28,11 @@ import (
"e2mgr/rmrCgo"
"e2mgr/services"
"e2mgr/tests"
+ "encoding/xml"
"errors"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/golang/protobuf/ptypes/wrappers"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"io/ioutil"
@@ -38,13 +41,16 @@ import (
)
const (
- prefix = "10.0.2.15:9999|"
- e2tInstanceFullAddress = "10.0.2.15:9999"
- nodebRanName = "gnb:310-410-b5c67788"
- GnbSetupRequestXmlPath = "../../tests/resources/setupRequest_gnb.xml"
- EnGnbSetupRequestXmlPath = "../../tests/resources/setupRequest_en-gNB.xml"
- NgEnbSetupRequestXmlPath = "../../tests/resources/setupRequest_ng-eNB.xml"
- EnbSetupRequestXmlPath = "../../tests/resources/setupRequest_enb.xml"
+ prefix = "10.0.2.15:9999|"
+ e2tInstanceFullAddress = "10.0.2.15:9999"
+ nodebRanName = "gnb:310-410-b5c67788"
+ GnbSetupRequestXmlPath = "../../tests/resources/setupRequest_gnb.xml"
+ EnGnbSetupRequestXmlPath = "../../tests/resources/setupRequest_en-gNB.xml"
+ NgEnbSetupRequestXmlPath = "../../tests/resources/setupRequest_ng-eNB.xml"
+ EnbSetupRequestXmlPath = "../../tests/resources/setupRequest_enb.xml"
+ GnbWithoutFunctionsSetupRequestXmlPath = "../../tests/resources/setupRequest_gnb_without_functions.xml"
+ E2SetupFailureResponseWithMiscCause = "1131"
+ E2SetupFailureResponseWithTransportCause = "1131"
)
func readXmlFile(t *testing.T, xmlPath string) []byte {
@@ -119,16 +125,68 @@ func TestParseSetupRequest_UnmarshalFailure(t *testing.T) {
assert.EqualError(t, err, "#E2SetupRequestNotificationHandler.parseSetupRequest - Error unmarshalling E2 Setup Request payload: 31302e302e322e31353a393939397c010203")
}
+func TestE2SetupRequestNotificationHandler_GetGeneralConfigurationFailure(t *testing.T) {
+ xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
+ handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{}, common.NewInternalError(errors.New("some error")))
+ notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), xmlGnb...)}
+ handler.Handle(notificationRequest)
+ rmrMessengerMock.AssertNotCalled(t, "SendMsg")
+ e2tInstancesManagerMock.AssertNotCalled(t, "GetE2TInstance")
+ routingManagerClientMock.AssertNotCalled(t, "AssociateRanToE2TInstance")
+ readerMock.AssertNotCalled(t, "GetNodeb")
+ writerMock.AssertNotCalled(t, "SaveNodeb")
+}
+
+func getMbuf(msgType int, payloadStr string, request *models.NotificationRequest) *rmrCgo.MBuf {
+ payload := []byte(payloadStr)
+ mbuf := rmrCgo.NewMBuf(msgType, len(payload), nodebRanName,&payload,&request.TransactionId, request.GetMsgSrc() )
+ return mbuf
+}
+
+func TestE2SetupRequestNotificationHandler_EnableRicFalse(t *testing.T) {
+ xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
+ handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: false}, nil)
+ notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), xmlGnb...)}
+ mbuf := getMbuf(rmrCgo.RIC_E2_SETUP_FAILURE, E2SetupFailureResponseWithMiscCause, notificationRequest)
+ rmrMessengerMock.On("WhSendMsg", mbuf, true).Return(&rmrCgo.MBuf{}, nil)
+ handler.Handle(notificationRequest)
+ rmrMessengerMock.AssertCalled(t, "WhSendMsg", mbuf,true )
+ e2tInstancesManagerMock.AssertNotCalled(t, "GetE2TInstance")
+ routingManagerClientMock.AssertNotCalled(t, "AssociateRanToE2TInstance")
+ readerMock.AssertNotCalled(t, "GetNodeb")
+ writerMock.AssertNotCalled(t, "SaveNodeb")
+}
+
func TestE2SetupRequestNotificationHandler_HandleNewGnbSuccess(t *testing.T) {
xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
- var e2tInstance = &entities.E2TInstance{}
- e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, nil)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
+ var gnb *entities.NodebInfo
+ readerMock.On("GetNodeb", mock.Anything).Return(gnb, common.NewResourceNotFoundError("Not found"))
+ notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), xmlGnb...)}
+ nodebInfo := getExpectedNodebWithFunctionsForNewRan(notificationRequest.Payload)
+ writerMock.On("SaveNodeb", mock.Anything, nodebInfo).Return(nil)
+ routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(nil)
+ writerMock.On("UpdateNodebInfo", mock.Anything).Return(nil)
+ e2tInstancesManagerMock.On("AddRansToInstance", mock.Anything, mock.Anything).Return(nil)
+ rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(&rmrCgo.MBuf{}, nil)
+ handler.Handle(notificationRequest)
+ writerMock.AssertCalled(t, "SaveNodeb", mock.Anything, nodebInfo)
+ assertNewNodebSuccessCalls(readerMock, t, e2tInstancesManagerMock, writerMock, routingManagerClientMock, rmrMessengerMock)
+}
+
+func TestE2SetupRequestNotificationHandler_HandleNewGnbWithoutFunctionsSuccess(t *testing.T) {
+ xmlGnb := readXmlFile(t, GnbWithoutFunctionsSetupRequestXmlPath)
+ handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
var gnb *entities.NodebInfo
readerMock.On("GetNodeb", mock.Anything).Return(gnb, common.NewResourceNotFoundError("Not found"))
notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), xmlGnb...)}
- setupRequest, e2tIpAddress, _ := handler.parseSetupRequest(notificationRequest.Payload)
- nodebInfo, _ := handler.buildNodebInfo(nodebRanName, e2tIpAddress, setupRequest)
+ nodebInfo := getExpectedNodebWithFunctionsForNewRan(notificationRequest.Payload)
writerMock.On("SaveNodeb", mock.Anything, nodebInfo).Return(nil)
routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(nil)
writerMock.On("UpdateNodebInfo", mock.Anything).Return(nil)
@@ -144,8 +202,8 @@ func TestE2SetupRequestNotificationHandler_HandleNewGnbSuccess(t *testing.T) {
func TestE2SetupRequestNotificationHandler_HandleNewEnGnbSuccess(t *testing.T) {
xmlEnGnb := readXmlFile(t, EnGnbSetupRequestXmlPath)
handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
- var e2tInstance = &entities.E2TInstance{}
- e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, nil)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
var gnb *entities.NodebInfo
readerMock.On("GetNodeb", mock.Anything).Return(gnb, common.NewResourceNotFoundError("Not found"))
writerMock.On("SaveNodeb", mock.Anything, mock.Anything).Return(nil)
@@ -164,8 +222,8 @@ func TestE2SetupRequestNotificationHandler_HandleNewEnGnbSuccess(t *testing.T) {
func TestE2SetupRequestNotificationHandler_HandleNewNgEnbSuccess(t *testing.T) {
xmlNgEnb := readXmlFile(t, NgEnbSetupRequestXmlPath)
handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
- var e2tInstance = &entities.E2TInstance{}
- e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, nil)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
var gnb *entities.NodebInfo
readerMock.On("GetNodeb", mock.Anything).Return(gnb, common.NewResourceNotFoundError("Not found"))
writerMock.On("SaveNodeb", mock.Anything, mock.Anything).Return(nil)
@@ -185,8 +243,8 @@ func TestE2SetupRequestNotificationHandler_HandleExistingGnbSuccess(t *testing.T
xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
- var e2tInstance = &entities.E2TInstance{}
- e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, nil)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
var gnb = &entities.NodebInfo{
RanName: nodebRanName,
AssociatedE2TInstanceAddress: e2tInstanceFullAddress,
@@ -198,24 +256,86 @@ func TestE2SetupRequestNotificationHandler_HandleExistingGnbSuccess(t *testing.T
routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(nil)
notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), xmlGnb...)}
- setupRequest, _, _ := handler.parseSetupRequest(notificationRequest.Payload)
- _ = handler.setGnbFunctions(gnb, setupRequest)
+ gnbToUpdate := getExpectedNodebWithFunctionsForExistingRan(*gnb, notificationRequest.Payload)
+ writerMock.On("UpdateNodebInfo", gnbToUpdate).Return(nil)
+ e2tInstancesManagerMock.On("AddRansToInstance", mock.Anything, mock.Anything).Return(nil)
+ var errEmpty error
+ rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(&rmrCgo.MBuf{}, errEmpty)
+ handler.Handle(notificationRequest)
+ writerMock.AssertCalled(t, "UpdateNodebInfo", gnbToUpdate)
+ assertExistingNodebSuccessCalls(readerMock, t, e2tInstancesManagerMock, writerMock, routingManagerClientMock, rmrMessengerMock)
+}
+
+func TestE2SetupRequestNotificationHandler_HandleExistingGnbWithFunctionsSuccess(t *testing.T) {
+ xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
- writerMock.On("UpdateNodebInfo", gnb).Return(nil)
+ handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
+ var gnb = &entities.NodebInfo{
+ RanName: nodebRanName,
+ AssociatedE2TInstanceAddress: e2tInstanceFullAddress,
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ NodeType: entities.Node_GNB,
+ Configuration: &entities.NodebInfo_Gnb{Gnb: &entities.Gnb{RanFunctions: []*entities.RanFunction{
+ {
+ RanFunctionId: &wrappers.UInt32Value{Value: 2},
+ RanFunctionRevision: &wrappers.UInt32Value{Value: 2},
+ },
+ }}},
+ }
+ readerMock.On("GetNodeb", mock.Anything).Return(gnb, nil)
+ routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(nil)
+
+ notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), xmlGnb...)}
+ gnbToUpdate := getExpectedNodebWithFunctionsForExistingRan(*gnb, notificationRequest.Payload)
+
+ writerMock.On("UpdateNodebInfo", gnbToUpdate).Return(nil)
e2tInstancesManagerMock.On("AddRansToInstance", mock.Anything, mock.Anything).Return(nil)
var errEmpty error
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(&rmrCgo.MBuf{}, errEmpty)
handler.Handle(notificationRequest)
- writerMock.AssertCalled(t, "UpdateNodebInfo", gnb)
+ writerMock.AssertCalled(t, "UpdateNodebInfo", gnbToUpdate)
assertExistingNodebSuccessCalls(readerMock, t, e2tInstancesManagerMock, writerMock, routingManagerClientMock, rmrMessengerMock)
}
+func getExpectedNodebWithFunctionsForExistingRan(nodeb entities.NodebInfo, payload []byte) *entities.NodebInfo {
+ pipInd := bytes.IndexByte(payload, '|')
+ setupRequest := &models.E2SetupRequestMessage{}
+ _ = xml.Unmarshal(normalizeXml(payload[pipInd+1:]), &setupRequest.E2APPDU)
+ nodeb.GetGnb().RanFunctions = setupRequest.ExtractRanFunctionsList()
+ return &nodeb
+}
+
+func getExpectedNodebWithFunctionsForNewRan(payload []byte) *entities.NodebInfo {
+ pipInd := bytes.IndexByte(payload, '|')
+ setupRequest := &models.E2SetupRequestMessage{}
+ _ = xml.Unmarshal(normalizeXml(payload[pipInd+1:]), &setupRequest.E2APPDU)
+
+ nodeb := &entities.NodebInfo{
+ AssociatedE2TInstanceAddress: e2tInstanceFullAddress,
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ RanName: nodebRanName,
+ NodeType: entities.Node_GNB,
+ Configuration: &entities.NodebInfo_Gnb{
+ Gnb: &entities.Gnb{
+ RanFunctions: setupRequest.ExtractRanFunctionsList(),
+ },
+ },
+ GlobalNbId: &entities.GlobalNbId{
+ PlmnId: setupRequest.GetPlmnId(),
+ NbId: setupRequest.GetNbId(),
+ },
+ }
+
+ return nodeb
+}
+
func TestE2SetupRequestNotificationHandler_HandleParseError(t *testing.T) {
xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
-
handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
- prefBytes := []byte("invalid_prefix")
- notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append(prefBytes, xmlGnb...)}
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte("invalid_prefix"), xmlGnb...)}
handler.Handle(notificationRequest)
readerMock.AssertNotCalled(t, "GetNodeb", mock.Anything)
writerMock.AssertNotCalled(t, "SaveNodeb", mock.Anything, mock.Anything)
@@ -227,8 +347,8 @@ func TestE2SetupRequestNotificationHandler_HandleParseError(t *testing.T) {
func TestE2SetupRequestNotificationHandler_HandleUnmarshalError(t *testing.T) {
handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
- prefBytes := []byte(prefix)
- notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append(prefBytes, "xmlGnb"...)}
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), "xmlGnb"...)}
handler.Handle(notificationRequest)
readerMock.AssertNotCalled(t, "GetNodeb", mock.Anything)
writerMock.AssertNotCalled(t, "SaveNodeb", mock.Anything, mock.Anything)
@@ -241,8 +361,8 @@ func TestE2SetupRequestNotificationHandler_HandleUnmarshalError(t *testing.T) {
func TestE2SetupRequestNotificationHandler_HandleGetE2TInstanceError(t *testing.T) {
xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
- var e2tInstance *entities.E2TInstance
- e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, common.NewResourceNotFoundError("Not found"))
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, common.NewResourceNotFoundError("Not found"))
prefBytes := []byte(prefix)
notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append(prefBytes, xmlGnb...)}
handler.Handle(notificationRequest)
@@ -257,14 +377,12 @@ func TestE2SetupRequestNotificationHandler_HandleGetE2TInstanceError(t *testing.
func TestE2SetupRequestNotificationHandler_HandleGetNodebError(t *testing.T) {
xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
-
handler, readerMock, writerMock, routingManagerClientMock, e2tInstancesManagerMock, rmrMessengerMock := initMocks(t)
- var e2tInstance = &entities.E2TInstance{}
- e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, nil)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
var gnb *entities.NodebInfo
readerMock.On("GetNodeb", mock.Anything).Return(gnb, common.NewInternalError(errors.New("some error")))
- prefBytes := []byte(prefix)
- notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append(prefBytes, xmlGnb...)}
+ notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), xmlGnb...)}
handler.Handle(notificationRequest)
e2tInstancesManagerMock.AssertCalled(t, "GetE2TInstance", e2tInstanceFullAddress)
readerMock.AssertCalled(t, "GetNodeb", mock.Anything)
@@ -279,8 +397,8 @@ func TestE2SetupRequestNotificationHandler_HandleAssociationError(t *testing.T)
xmlGnb := readXmlFile(t, GnbSetupRequestXmlPath)
handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
- var e2tInstance = &entities.E2TInstance{}
- e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, nil)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
var gnb *entities.NodebInfo
readerMock.On("GetNodeb", mock.Anything).Return(gnb, common.NewResourceNotFoundError("Not found"))
writerMock.On("SaveNodeb", mock.Anything, mock.Anything).Return(nil)
@@ -288,11 +406,9 @@ func TestE2SetupRequestNotificationHandler_HandleAssociationError(t *testing.T)
e2tInstancesManagerMock.On("AddRansToInstance", mock.Anything, mock.Anything).Return(nil)
routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(errors.New("association error"))
var errEmpty error
- rmrMessage := &rmrCgo.MBuf{}
- rmrMessengerMock.On("WhSendMsg", mock.Anything, mock.Anything).Return(rmrMessage, errEmpty)
-
- prefBytes := []byte(prefix)
- notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append(prefBytes, xmlGnb...)}
+ notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append([]byte(prefix), xmlGnb...)}
+ mbuf := getMbuf(rmrCgo.RIC_E2_SETUP_FAILURE, E2SetupFailureResponseWithTransportCause, notificationRequest)
+ rmrMessengerMock.On("WhSendMsg", mbuf, true).Return(&rmrCgo.MBuf{}, errEmpty)
handler.Handle(notificationRequest)
readerMock.AssertCalled(t, "GetNodeb", mock.Anything)
e2tInstancesManagerMock.AssertCalled(t, "GetE2TInstance", e2tInstanceFullAddress)
@@ -300,7 +416,7 @@ func TestE2SetupRequestNotificationHandler_HandleAssociationError(t *testing.T)
routingManagerClientMock.AssertCalled(t, "AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything)
writerMock.AssertCalled(t, "UpdateNodebInfo", mock.Anything)
e2tInstancesManagerMock.AssertNotCalled(t, "AddRansToInstance", mock.Anything, mock.Anything)
- rmrMessengerMock.AssertCalled(t, "WhSendMsg", mock.Anything, mock.Anything)
+ rmrMessengerMock.AssertCalled(t, "WhSendMsg", mbuf, true)
}
func TestE2SetupRequestNotificationHandler_ConvertTo20BitStringError(t *testing.T) {
@@ -310,7 +426,7 @@ func TestE2SetupRequestNotificationHandler_ConvertTo20BitStringError(t *testing.
RicId string
Mcc string
Mnc string
- }{Mcc: "327", Mnc: "94" ,RicId: "10011001101010101011"}}
+ }{Mcc: "327", Mnc: "94", RicId: "10011001101010101011"}}
rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrSender := tests.InitRmrSender(rmrMessengerMock, logger)
readerMock := &mocks.RnibReaderMock{}
@@ -320,9 +436,8 @@ func TestE2SetupRequestNotificationHandler_ConvertTo20BitStringError(t *testing.
e2tInstancesManagerMock := &mocks.E2TInstancesManagerMock{}
e2tAssociationManager := managers.NewE2TAssociationManager(logger, rnibDataService, e2tInstancesManagerMock, routingManagerClientMock)
handler := NewE2SetupRequestNotificationHandler(logger, config, e2tInstancesManagerMock, rmrSender, rnibDataService, e2tAssociationManager)
-
- var e2tInstance = &entities.E2TInstance{}
- e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, nil)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
var gnb *entities.NodebInfo
readerMock.On("GetNodeb", mock.Anything).Return(gnb, common.NewResourceNotFoundError("Not found"))
writerMock.On("SaveNodeb", mock.Anything, mock.Anything).Return(nil)
@@ -349,8 +464,8 @@ func TestE2SetupRequestNotificationHandler_HandleExistingGnbInvalidStatusError(t
handler, readerMock, writerMock, routingManagerClientMock, e2tInstancesManagerMock, rmrMessengerMock := initMocks(t)
var gnb = &entities.NodebInfo{RanName: nodebRanName, ConnectionStatus: entities.ConnectionStatus_SHUTTING_DOWN}
readerMock.On("GetNodeb", mock.Anything).Return(gnb, nil)
- var e2tInstance = &entities.E2TInstance{}
- e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(e2tInstance, nil)
+ readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
+ e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
prefBytes := []byte(prefix)
notificationRequest := &models.NotificationRequest{RanName: nodebRanName, Payload: append(prefBytes, xmlGnb...)}
handler.Handle(notificationRequest)
@@ -363,13 +478,13 @@ func TestE2SetupRequestNotificationHandler_HandleExistingGnbInvalidStatusError(t
rmrMessengerMock.AssertNotCalled(t, "SendMsg", mock.Anything, mock.Anything)
}
-func initMocks(t *testing.T) (E2SetupRequestNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.RmrMessengerMock, *mocks.E2TInstancesManagerMock, *mocks.RoutingManagerClientMock) {
+func initMocks(t *testing.T) (*E2SetupRequestNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.RmrMessengerMock, *mocks.E2TInstancesManagerMock, *mocks.RoutingManagerClientMock) {
logger := tests.InitLog(t)
config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3, GlobalRicId: struct {
RicId string
Mcc string
Mnc string
- }{Mcc: "327", Mnc: "94" ,RicId: "AACCE"}}
+ }{Mcc: "327", Mnc: "94", RicId: "AACCE"}}
rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrSender := tests.InitRmrSender(rmrMessengerMock, logger)
readerMock := &mocks.RnibReaderMock{}