Handling e2 reset request & change status to reset 30/10530/1
authornaman.gupta <naman.gupta@samsung.com>
Fri, 24 Feb 2023 09:26:41 +0000 (14:56 +0530)
committernaman.gupta <naman.gupta@samsung.com>
Fri, 24 Feb 2023 09:26:41 +0000 (14:56 +0530)
Changing connection status to under reset on e2 reset request

Signed-off-by: naman.gupta <naman.gupta@samsung.com>
Change-Id: Ic2486d67c94f44a0376605de4fd934d7e64dffe3

E2Manager/go.mod
E2Manager/go.sum
E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go [new file with mode: 0644]
E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go [new file with mode: 0644]
E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go
E2Manager/rmrCgo/rmrCgoTypes.go

index 3be71b5..4d4899f 100644 (file)
@@ -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
index 15be563..8dbfcaa 100644 (file)
@@ -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 (file)
index 0000000..a800fef
--- /dev/null
@@ -0,0 +1,79 @@
+//\r
+// Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//      http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+//  This source code is part of the near-RT RIC (RAN Intelligent Controller)\r
+//  platform project (RICP).\r
+\r
+package rmrmsghandlers\r
+\r
+import (\r
+       "e2mgr/logger"\r
+       "e2mgr/models"\r
+       "e2mgr/services"\r
+       "e2mgr/utils"\r
+       "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"\r
+)\r
+\r
+const E2ResetRequestLogInfoElapsedTime = "#E2ResetRequestNotificationHandler.Handle - Summary: elapsed time for receiving and handling reset request message from E2 terminator: %f ms"\r
+\r
+type E2ResetRequestNotificationHandler struct {\r
+       logger          *logger.Logger\r
+       rnibDataService services.RNibDataService\r
+}\r
+\r
+func NewE2ResetRequestNotificationHandler(logger *logger.Logger, rnibDataService services.RNibDataService) *E2ResetRequestNotificationHandler {\r
+       return &E2ResetRequestNotificationHandler{\r
+               logger:          logger,\r
+               rnibDataService: rnibDataService,\r
+       }\r
+}\r
+\r
+func (e *E2ResetRequestNotificationHandler) Handle(request *models.NotificationRequest) {\r
+\r
+       e.logger.Infof("#E2ResetRequestNotificationHandler.Handle - RAN name: %s - received E2_Reset. Payload: %x", request.RanName, request.Payload)\r
+\r
+       e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - RIC_E2_Node_Reset parsed successfully ")\r
+\r
+       nodebInfo, err := e.getNodebInfo(request.RanName)\r
+       if err != nil {\r
+               e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to retrieve nodeB entity. RanName: %s. Error: %s", request.RanName, err.Error())\r
+               e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime))\r
+               return\r
+       }\r
+\r
+       e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity retrieved. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus)\r
+\r
+       nodebInfo.ConnectionStatus = entities.ConnectionStatus_UNDER_RESET\r
+\r
+       err = e.rnibDataService.UpdateNodebInfoAndPublish(nodebInfo)\r
+\r
+       if err != nil {\r
+               e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to update connection status of nodeB entity. RanName: %s. Error: %s", request.RanName, err.Error())\r
+       }\r
+\r
+       e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity under reset state. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus)\r
+\r
+       e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime))\r
+}\r
+\r
+func (e *E2ResetRequestNotificationHandler) getNodebInfo(ranName string) (*entities.NodebInfo, error) {\r
+\r
+       nodebInfo, err := e.rnibDataService.GetNodeb(ranName)\r
+       if err != nil {\r
+               e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to retrieve nodeB entity. RanName: %s. Error: %s", ranName, err.Error())\r
+               return nil, err\r
+       }\r
+       return nodebInfo, err\r
+}\r
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 (file)
index 0000000..8b15865
--- /dev/null
@@ -0,0 +1,70 @@
+//\r
+// Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//      http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+//  This source code is part of the near-RT RIC (RAN Intelligent Controller)\r
+//  platform project (RICP).\r
+\r
+package rmrmsghandlers\r
+\r
+import (\r
+       "e2mgr/configuration"\r
+       "e2mgr/mocks"\r
+       "e2mgr/models"\r
+       "e2mgr/services"\r
+       "e2mgr/tests"\r
+       "e2mgr/utils"\r
+       "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"\r
+       "github.com/stretchr/testify/mock"\r
+       "testing"\r
+)\r
+\r
+const (\r
+       E2ResetXmlPath = "../../tests/resources/reset/reset-request.xml"\r
+)\r
+\r
+func initE2ResetMocks(t *testing.T) (*E2ResetRequestNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock) {\r
+       logger := tests.InitLog(t)\r
+       config := &configuration.Configuration{\r
+               RnibRetryIntervalMs:       10,\r
+               MaxRnibConnectionAttempts: 3,\r
+               RnibWriter: configuration.RnibWriterConfig{\r
+                       StateChangeMessageChannel: StateChangeMessageChannel,\r
+               }}\r
+       readerMock := &mocks.RnibReaderMock{}\r
+       writerMock := &mocks.RnibWriterMock{}\r
+       rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock)\r
+       handler := NewE2ResetRequestNotificationHandler(logger, rnibDataService)\r
+       return handler, readerMock, writerMock\r
+}\r
+\r
+func TestE2ResetRequestHandler(t *testing.T) {\r
+       e2ResetXml := utils.ReadXmlFile(t, E2ResetXmlPath)\r
+       handler, readerMock, writerMock := initE2ResetMocks(t)\r
+       var nodebInfo = &entities.NodebInfo{\r
+               RanName:                      gnbNodebRanName,\r
+               AssociatedE2TInstanceAddress: e2tInstanceFullAddress,\r
+               ConnectionStatus:             entities.ConnectionStatus_DISCONNECTED,\r
+               NodeType:                     entities.Node_GNB,\r
+               Configuration: &entities.NodebInfo_Gnb{\r
+                       Gnb: &entities.Gnb{},\r
+               },\r
+       }\r
+       readerMock.On("GetNodeb", gnbNodebRanName).Return(nodebInfo, nil)\r
+       writerMock.On("UpdateNodebInfoAndPublish", mock.Anything).Return(nil)\r
+       notificationRequest := &models.NotificationRequest{RanName: gnbNodebRanName, Payload: append([]byte(""), e2ResetXml...)}\r
+       handler.Handle(notificationRequest)\r
+       readerMock.AssertExpectations(t)\r
+       writerMock.AssertExpectations(t)\r
+}\r
index 5f02168..82db437 100644 (file)
@@ -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)
 }
index 0cab4da..31292ca 100644 (file)
@@ -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 (