From: subhash kumar singh Date: Mon, 9 May 2022 20:37:12 +0000 (+0000) Subject: Handle received removal List NodeConfig X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=92a4d4ec0ad5fc243a19aee42b5ee2e4b99b510b;p=ric-plt%2Fe2mgr.git Handle received removal List NodeConfig Implemented handling of e2nodebconfig for receieved IEs in removal list. Each IEs is converted to respective entities updated to store inside NodebInfo. Signed-off-by: subhash kumar singh Change-Id: I99fdbba24352bc5e68732aff9ae05c6b020db556 --- diff --git a/E2Manager/handlers/rmrmsghandlers/e2_node_config_update_notification_handler.go b/E2Manager/handlers/rmrmsghandlers/e2_node_config_update_notification_handler.go index b9f25df..6bd9173 100644 --- a/E2Manager/handlers/rmrmsghandlers/e2_node_config_update_notification_handler.go +++ b/E2Manager/handlers/rmrmsghandlers/e2_node_config_update_notification_handler.go @@ -74,6 +74,7 @@ func (e *E2nodeConfigUpdateNotificationHandler) Handle(request *models.Notificat func (e *E2nodeConfigUpdateNotificationHandler) updateE2nodeConfig(e2nodeConfig *models.E2nodeConfigurationUpdateMessage, nodebInfo *entities.NodebInfo) { e.handleAddConfig(e2nodeConfig, nodebInfo) e.handleUpdateConfig(e2nodeConfig, nodebInfo) + e.handleDeleteConfig(e2nodeConfig, nodebInfo) e.rNibDataService.UpdateNodebInfoAndPublish(nodebInfo) } @@ -157,6 +158,37 @@ func (e *E2nodeConfigUpdateNotificationHandler) handleUpdateConfig(e2nodeConfig } } +func (e *E2nodeConfigUpdateNotificationHandler) handleDeleteConfig(e2nodeConfig *models.E2nodeConfigurationUpdateMessage, nodebInfo *entities.NodebInfo) { + deleteList := e2nodeConfig.ExtractConfigDeletionList() + + for _, u := range deleteList { + if nodebInfo.GetNodeType() == entities.Node_ENB { + for i, v := range nodebInfo.GetEnb().NodeConfigs { + if e.compareConfigIDs(u, *v) { + nodebInfo.GetEnb().NodeConfigs = removeIndex(nodebInfo.GetEnb().GetNodeConfigs(), i) + break + } + } + } + + if nodebInfo.GetNodeType() == entities.Node_GNB { + for i, v := range nodebInfo.GetGnb().NodeConfigs { + if e.compareConfigIDs(u, *v) { + nodebInfo.GetGnb().NodeConfigs = removeIndex(nodebInfo.GetGnb().GetNodeConfigs(), i) + break + } + } + } + } +} + +func removeIndex(s []*entities.E2NodeComponentConfig, index int) []*entities.E2NodeComponentConfig { + if index < len(s) { + return append(s[:index], s[index+1:]...) + } + return s +} + func (e *E2nodeConfigUpdateNotificationHandler) parseE2NodeConfigurationUpdate(payload []byte) (*models.E2nodeConfigurationUpdateMessage, error) { e2nodeConfig := models.E2nodeConfigurationUpdateMessage{} err := xml.Unmarshal(utils.NormalizeXml(payload), &(e2nodeConfig.E2APPDU)) diff --git a/E2Manager/handlers/rmrmsghandlers/e2_node_config_update_notification_handler_test.go b/E2Manager/handlers/rmrmsghandlers/e2_node_config_update_notification_handler_test.go index 2eeb546..3692fae 100644 --- a/E2Manager/handlers/rmrmsghandlers/e2_node_config_update_notification_handler_test.go +++ b/E2Manager/handlers/rmrmsghandlers/e2_node_config_update_notification_handler_test.go @@ -33,8 +33,9 @@ import ( ) const ( - E2nodeConfigUpdateXmlPath = "../../tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml" - E2nodeConfigUpdateOnlyAdditionXmlPath = "../../tests/resources/configurationUpdate/e2NodeConfigurationUpdateOnlyAddition.xml" + E2nodeConfigUpdateXmlPath = "../../tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml" + E2nodeConfigUpdateOnlyAdditionXmlPath = "../../tests/resources/configurationUpdate/e2NodeConfigurationUpdateOnlyAddition.xml" + E2nodeConfigUpdateOnlyAdditionAndUpdateXmlPath = "../../tests/resources/configurationUpdate/e2NodeConfigurationUpdateAdditionAndUpdateOnly.xml" ) func initE2nodeConfigMocks(t *testing.T) (*E2nodeConfigUpdateNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.RmrMessengerMock) { @@ -89,8 +90,8 @@ func TestE2nodeConfigUpdatetParseFail(t *testing.T) { assert.NotNil(t, err) } -func TestHandleAddConfig(t *testing.T) { - e2NodeConfigUpdateXml := utils.ReadXmlFile(t, E2nodeConfigUpdateXmlPath) +func TestHandleAddAndUpdateConfig(t *testing.T) { + e2NodeConfigUpdateXml := utils.ReadXmlFile(t, E2nodeConfigUpdateOnlyAdditionAndUpdateXmlPath) handler, readerMock, writerMock, _ := initE2nodeConfigMocks(t) var nodebInfo = &entities.NodebInfo{ @@ -119,3 +120,31 @@ func TestHandleAddConfig(t *testing.T) { writerMock.AssertExpectations(t) readerMock.AssertExpectations(t) } + +func TestHandleAddandDeleteConfig(t *testing.T) { + e2NodeConfigUpdateXml := utils.ReadXmlFile(t, E2nodeConfigUpdateXmlPath) + + handler, readerMock, writerMock, _ := initE2nodeConfigMocks(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(""), e2NodeConfigUpdateXml...)} + + handler.Handle(notificationRequest) + + t.Logf("len of nodeconfig : %d", len(nodebInfo.GetGnb().NodeConfigs)) + + assert.Equal(t, 0, len(nodebInfo.GetGnb().NodeConfigs)) + + writerMock.AssertExpectations(t) + readerMock.AssertExpectations(t) +} diff --git a/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml b/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml index 2dc0276..a86f941 100644 --- a/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml +++ b/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdate.xml @@ -337,7 +337,7 @@ - 1234 + 100 @@ -351,7 +351,7 @@ - 2345 + 100 @@ -365,7 +365,7 @@ - 3456 + 121 diff --git a/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdateAdditionAndUpdateOnly.xml b/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdateAdditionAndUpdateOnly.xml new file mode 100644 index 0000000..1d8ca8c --- /dev/null +++ b/E2Manager/tests/resources/configurationUpdate/e2NodeConfigurationUpdateAdditionAndUpdateOnly.xml @@ -0,0 +1,303 @@ + + + 6 + + + + + + 49 + + + 1234 + + + + 50 + + + + + 51 + + + + + + + nginterf + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 51 + + + + + + + + + + 67 6E 62 3A 31 32 33 34 35 36 37 38 39 73 64 66 + 67 31 31 31 + + + + 0011000100110010001100110011010000110101001100010011001000110011 + 0011010000110101001100010011001000110011001101000011001000110010 + 00110010001100100011001000110010 + + + + + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 51 + + + + + + + 100 + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 51 + + + + + + + 100 + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 51 + + + + + + + 121 + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 51 + + + + + + + s1interf + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 51 + + + + + + + x2interf + x2interf + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + + + + 33 + + + + + 34 + + + + + + + nginterf + + + + 72 65 71 70 61 72 73 + 72 65 73 70 61 72 73 + + + + + + 34 + + + + + + + xninterf + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 34 + + + + + + + 1234 + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 34 + + + + + + + 2345 + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 34 + + + + + + + 3456 + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 34 + + + + + + + s1interf + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + 34 + + + + + + + x2interf + x2interf + + + + 72 65 71 70 61 72 74 + 72 65 73 70 61 72 74 + + + + + + + + + + + + \ No newline at end of file