From 04ff63f1708020673dd9be975476e0f76f179a81 Mon Sep 17 00:00:00 2001 From: "naman.gupta" Date: Fri, 24 Feb 2023 14:56:41 +0530 Subject: [PATCH] Handling e2 reset request & change status to reset Changing connection status to under reset on e2 reset request Signed-off-by: naman.gupta Change-Id: Ic2486d67c94f44a0376605de4fd934d7e64dffe3 --- E2Manager/go.mod | 2 +- E2Manager/go.sum | 2 + .../rmrmsghandlers/e2_reset_request_handler.go | 79 ++++++++++++++++++++++ .../e2_reset_request_handler_test.go | 70 +++++++++++++++++++ .../notification_handler_provider.go | 2 + E2Manager/rmrCgo/rmrCgoTypes.go | 1 + 6 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go create mode 100644 E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go diff --git a/E2Manager/go.mod b/E2Manager/go.mod index 3be71b5..4d4899f 100644 --- a/E2Manager/go.mod +++ b/E2Manager/go.mod @@ -2,7 +2,7 @@ module e2mgr require ( gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1 - gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.5 + gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.8 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1 gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.8.0 github.com/golang/protobuf v1.4.2 diff --git a/E2Manager/go.sum b/E2Manager/go.sum index 15be563..8dbfcaa 100644 --- a/E2Manager/go.sum +++ b/E2Manager/go.sum @@ -5,6 +5,8 @@ gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1 h1:8Z60JRsPgcS1Ona4 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1/go.mod h1:YaQ+XEI4PcAoISxp9wUpUr2TP0J7JihpQTD0G1Lpd4A= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.5 h1:RgbLxLgJcMQsm84NJI5q81PKRtgPk3j1VvMTWO5U9os= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.5/go.mod h1:YaQ+XEI4PcAoISxp9wUpUr2TP0J7JihpQTD0G1Lpd4A= +gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.8 h1:9KLAcDI20l0lYsIbfzlVRMwWLU6iflJkgqG1FxmvcPM= +gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.8/go.mod h1:8NTND7RCHfHPQtx1xk9oclqF/7usqDAX9aYBzt3Hynk= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1 h1:BG3kste8PLVTG0m8CRB/VP2tAV5JImKueBGuOsUNcR8= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1/go.mod h1:zX8rW6YEsagHrRGVW5YO50Ku/Csrpzsuvblhr4DbYi4= gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.8.0 h1:H7GtCRC+pGn6oOxYalUZr7LinQX5jQCVa+ConX7PB5Q= diff --git a/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go new file mode 100644 index 0000000..a800fef --- /dev/null +++ b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go @@ -0,0 +1,79 @@ +// +// Copyright (c) 2023 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 rmrmsghandlers + +import ( + "e2mgr/logger" + "e2mgr/models" + "e2mgr/services" + "e2mgr/utils" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" +) + +const E2ResetRequestLogInfoElapsedTime = "#E2ResetRequestNotificationHandler.Handle - Summary: elapsed time for receiving and handling reset request message from E2 terminator: %f ms" + +type E2ResetRequestNotificationHandler struct { + logger *logger.Logger + rnibDataService services.RNibDataService +} + +func NewE2ResetRequestNotificationHandler(logger *logger.Logger, rnibDataService services.RNibDataService) *E2ResetRequestNotificationHandler { + return &E2ResetRequestNotificationHandler{ + logger: logger, + rnibDataService: rnibDataService, + } +} + +func (e *E2ResetRequestNotificationHandler) Handle(request *models.NotificationRequest) { + + e.logger.Infof("#E2ResetRequestNotificationHandler.Handle - RAN name: %s - received E2_Reset. Payload: %x", request.RanName, request.Payload) + + e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - RIC_E2_Node_Reset parsed successfully ") + + nodebInfo, err := e.getNodebInfo(request.RanName) + if err != nil { + e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to retrieve nodeB entity. RanName: %s. Error: %s", request.RanName, err.Error()) + e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime)) + return + } + + e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity retrieved. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus) + + nodebInfo.ConnectionStatus = entities.ConnectionStatus_UNDER_RESET + + err = e.rnibDataService.UpdateNodebInfoAndPublish(nodebInfo) + + if err != nil { + e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to update connection status of nodeB entity. RanName: %s. Error: %s", request.RanName, err.Error()) + } + + e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity under reset state. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus) + + e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime)) +} + +func (e *E2ResetRequestNotificationHandler) getNodebInfo(ranName string) (*entities.NodebInfo, error) { + + nodebInfo, err := e.rnibDataService.GetNodeb(ranName) + if err != nil { + e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to retrieve nodeB entity. RanName: %s. Error: %s", ranName, err.Error()) + return nil, err + } + return nodebInfo, err +} diff --git a/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go new file mode 100644 index 0000000..8b15865 --- /dev/null +++ b/E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go @@ -0,0 +1,70 @@ +// +// Copyright (c) 2023 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 rmrmsghandlers + +import ( + "e2mgr/configuration" + "e2mgr/mocks" + "e2mgr/models" + "e2mgr/services" + "e2mgr/tests" + "e2mgr/utils" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" + "github.com/stretchr/testify/mock" + "testing" +) + +const ( + E2ResetXmlPath = "../../tests/resources/reset/reset-request.xml" +) + +func initE2ResetMocks(t *testing.T) (*E2ResetRequestNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock) { + logger := tests.InitLog(t) + config := &configuration.Configuration{ + RnibRetryIntervalMs: 10, + MaxRnibConnectionAttempts: 3, + RnibWriter: configuration.RnibWriterConfig{ + StateChangeMessageChannel: StateChangeMessageChannel, + }} + readerMock := &mocks.RnibReaderMock{} + writerMock := &mocks.RnibWriterMock{} + rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock) + handler := NewE2ResetRequestNotificationHandler(logger, rnibDataService) + return handler, readerMock, writerMock +} + +func TestE2ResetRequestHandler(t *testing.T) { + e2ResetXml := utils.ReadXmlFile(t, E2ResetXmlPath) + handler, readerMock, writerMock := initE2ResetMocks(t) + var nodebInfo = &entities.NodebInfo{ + RanName: gnbNodebRanName, + AssociatedE2TInstanceAddress: e2tInstanceFullAddress, + ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, + NodeType: entities.Node_GNB, + Configuration: &entities.NodebInfo_Gnb{ + Gnb: &entities.Gnb{}, + }, + } + readerMock.On("GetNodeb", gnbNodebRanName).Return(nodebInfo, nil) + writerMock.On("UpdateNodebInfoAndPublish", mock.Anything).Return(nil) + notificationRequest := &models.NotificationRequest{RanName: gnbNodebRanName, Payload: append([]byte(""), e2ResetXml...)} + handler.Handle(notificationRequest) + readerMock.AssertExpectations(t) + writerMock.AssertExpectations(t) +} diff --git a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go index 5f02168..82db437 100644 --- a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go +++ b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go @@ -95,6 +95,7 @@ func (provider *NotificationHandlerProvider) Init(logger *logger.Logger, config e2SetupRequestNotificationHandler := rmrmsghandlers.NewE2SetupRequestNotificationHandler(logger, config, e2tInstancesManager, rmrSender, rnibDataService, e2tAssociationManager, ranConnectStatusChangeManager, ranListManager) ricServiceUpdateHandler := rmrmsghandlers.NewRicServiceUpdateHandler(logger, rmrSender, rnibDataService, ranListManager) ricE2nodeConfigUpdateHandler := rmrmsghandlers.NewE2nodeConfigUpdateNotificationHandler(logger, rnibDataService, rmrSender) + e2ResetRequestNotificationHandler := rmrmsghandlers.NewE2ResetRequestNotificationHandler(logger, rnibDataService) provider.Register(rmrCgo.RIC_X2_SETUP_RESP, x2SetupResponseHandler) provider.Register(rmrCgo.RIC_X2_SETUP_FAILURE, x2SetupFailureResponseHandler) @@ -111,4 +112,5 @@ func (provider *NotificationHandlerProvider) Init(logger *logger.Logger, config provider.Register(rmrCgo.RIC_E2_SETUP_REQ, e2SetupRequestNotificationHandler) provider.Register(rmrCgo.RIC_SERVICE_UPDATE, ricServiceUpdateHandler) provider.Register(rmrCgo.RIC_E2NODE_CONFIG_UPDATE, ricE2nodeConfigUpdateHandler) + provider.Register(rmrCgo.RIC_E2_RESET_REQ, e2ResetRequestNotificationHandler) } diff --git a/E2Manager/rmrCgo/rmrCgoTypes.go b/E2Manager/rmrCgo/rmrCgoTypes.go index 0cab4da..31292ca 100644 --- a/E2Manager/rmrCgo/rmrCgoTypes.go +++ b/E2Manager/rmrCgo/rmrCgoTypes.go @@ -87,6 +87,7 @@ const ( RIC_E2NODE_CONFIG_UPDATE = C.RIC_E2NODE_CONFIG_UPDATE RIC_E2NODE_CONFIG_UPDATE_ACK = C.RIC_E2NODE_CONFIG_UPDATE_ACK RIC_E2NODE_CONFIG_UPDATE_FAILURE = C.RIC_E2NODE_CONFIG_UPDATE_FAILURE + RIC_E2_RESET_REQ = C.RIC_E2_RESET_REQ ) const ( -- 2.16.6