From: Amichai Date: Tue, 16 Jun 2020 14:54:03 +0000 (+0300) Subject: [RIC-397] rename method to UpdateNodebInfoOnConnectionStatusInversion X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=5de9b208a878150d4f991816d2283720fea36a1c;p=ric-plt%2Fe2mgr.git [RIC-397] rename method to UpdateNodebInfoOnConnectionStatusInversion Change-Id: I696aedadf79dc43a0e4b64e725a0a7ad2be6b2ff Signed-off-by: Amichai --- diff --git a/E2Manager/managers/ran_connect_status_change_manager.go b/E2Manager/managers/ran_connect_status_change_manager.go index 8818399..26d12b2 100644 --- a/E2Manager/managers/ran_connect_status_change_manager.go +++ b/E2Manager/managers/ran_connect_status_change_manager.go @@ -62,7 +62,7 @@ func (m *RanConnectStatusChangeManager) ChangeStatus(nodebInfo *entities.NodebIn return err } } else { - err := m.updateNodebConnectivityState(nodebInfo, event) + err := m.updateNodebInfoOnConnectionStatusInversion(nodebInfo, event) if err != nil { return err } @@ -88,16 +88,16 @@ func (m *RanConnectStatusChangeManager) ChangeStatus(nodebInfo *entities.NodebIn return nil } -func (m *RanConnectStatusChangeManager) updateNodebConnectivityState(nodebInfo *entities.NodebInfo, event string) error { +func (m *RanConnectStatusChangeManager) updateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, event string) error { - err := m.rnibDataService.UpdateNodebConnectivityState(nodebInfo, event) + err := m.rnibDataService.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, event) if err != nil { - m.logger.Errorf("#RanConnectStatusChangeManager.updateNodebConnectivityState - RAN name: %s - Failed updating RAN's connection status in rNib. Error: %v", nodebInfo.RanName, err) + m.logger.Errorf("#RanConnectStatusChangeManager.updateNodebInfoOnConnectionStatusInversion - RAN name: %s - Failed updating RAN's connection status in rNib. Error: %v", nodebInfo.RanName, err) return err } - m.logger.Infof("#RanConnectStatusChangeManager.updateNodebConnectivityState - RAN name: %s - Successfully updated rNib.", nodebInfo.RanName) + m.logger.Infof("#RanConnectStatusChangeManager.updateNodebInfoOnConnectionStatusInversion - RAN name: %s - Successfully updated rNib.", nodebInfo.RanName) return nil } diff --git a/E2Manager/managers/ran_connect_status_change_manager_test.go b/E2Manager/managers/ran_connect_status_change_manager_test.go index 4dc77af..b9295e3 100644 --- a/E2Manager/managers/ran_connect_status_change_manager_test.go +++ b/E2Manager/managers/ran_connect_status_change_manager_test.go @@ -55,7 +55,7 @@ func TestChangeStatusSuccessNewRan(t *testing.T) { origNodebInfo := &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_UNKNOWN_CONNECTION_STATUS} updatedNodebInfo := *origNodebInfo updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED - writerMock.On("UpdateNodebConnectivityState", &updatedNodebInfo, EventChannelForTest, RanName + "_" + CONNECTED_RAW_EVENT).Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &updatedNodebInfo, EventChannelForTest, RanName + "_" + CONNECTED_RAW_EVENT).Return(nil) ranListManagerMock.On("UpdateRanState", &updatedNodebInfo).Return(nil) ranAlarmServiceMock.On("SetConnectivityChangeAlarm", &updatedNodebInfo).Return(nil) err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_CONNECTED) @@ -101,7 +101,7 @@ func TestChangeStatusSuccessEventConnected(t *testing.T) { origNodebInfo := &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED} updatedNodebInfo := *origNodebInfo updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED - writerMock.On("UpdateNodebConnectivityState", &updatedNodebInfo, EventChannelForTest, RanName + "_" + CONNECTED_RAW_EVENT).Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &updatedNodebInfo, EventChannelForTest, RanName + "_" + CONNECTED_RAW_EVENT).Return(nil) ranListManagerMock.On("UpdateRanState", &updatedNodebInfo).Return(nil) ranAlarmServiceMock.On("SetConnectivityChangeAlarm", &updatedNodebInfo).Return(nil) err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_CONNECTED) @@ -117,7 +117,7 @@ func TestChangeStatusSuccessEventDisconnected(t *testing.T) { origNodebInfo := &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_CONNECTED} updatedNodebInfo := *origNodebInfo updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebConnectivityState", &updatedNodebInfo, EventChannelForTest, RanName + "_" + DISCONNECTED_RAW_EVENT).Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &updatedNodebInfo, EventChannelForTest, RanName + "_" + DISCONNECTED_RAW_EVENT).Return(nil) ranListManagerMock.On("UpdateRanState", &updatedNodebInfo).Return(nil) ranAlarmServiceMock.On("SetConnectivityChangeAlarm", &updatedNodebInfo).Return(nil) err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_DISCONNECTED) @@ -147,7 +147,7 @@ func TestChangeStatusRnibErrorEventConnected(t *testing.T) { origNodebInfo := &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED} updatedNodebInfo := *origNodebInfo updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED - writerMock.On("UpdateNodebConnectivityState", &updatedNodebInfo, EventChannelForTest, RanName + "_" + CONNECTED_RAW_EVENT).Return(common.NewInternalError(errors.New("Error"))) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &updatedNodebInfo, EventChannelForTest, RanName + "_" + CONNECTED_RAW_EVENT).Return(common.NewInternalError(errors.New("Error"))) err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_CONNECTED) assert.NotNil(t, err) writerMock.AssertExpectations(t) @@ -176,7 +176,7 @@ func TestChangeStatusRanAlarmServiceErrorEventConnected(t *testing.T) { origNodebInfo := &entities.NodebInfo{RanName: ranName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED} updatedNodebInfo := *origNodebInfo updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED - writerMock.On("UpdateNodebConnectivityState", &updatedNodebInfo, EventChannelForTest, RanName + "_" + CONNECTED_RAW_EVENT).Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &updatedNodebInfo, EventChannelForTest, RanName + "_" + CONNECTED_RAW_EVENT).Return(nil) ranListManagerMock.On("UpdateRanState", &updatedNodebInfo).Return(nil) ranAlarmServiceMock.On("SetConnectivityChangeAlarm", &updatedNodebInfo).Return(common.NewInternalError(errors.New("Error"))) err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_CONNECTED) diff --git a/E2Manager/mocks/rnibWriterMock.go b/E2Manager/mocks/rnibWriterMock.go index bf2ed53..b076614 100644 --- a/E2Manager/mocks/rnibWriterMock.go +++ b/E2Manager/mocks/rnibWriterMock.go @@ -92,7 +92,7 @@ func (rnibWriterMock *RnibWriterMock) RemoveServedNrCells(inventoryName string, return args.Error(0) } -func (rnibWriterMock *RnibWriterMock) UpdateNodebConnectivityState(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error { +func (rnibWriterMock *RnibWriterMock) UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error { args := rnibWriterMock.Called(nodebInfo, stateChangeMessageChannel, event) return args.Error(0) } \ No newline at end of file diff --git a/E2Manager/rNibWriter/rNibWriter.go b/E2Manager/rNibWriter/rNibWriter.go index 5bc4a68..df4c7d6 100644 --- a/E2Manager/rNibWriter/rNibWriter.go +++ b/E2Manager/rNibWriter/rNibWriter.go @@ -45,7 +45,7 @@ type RNibWriter interface { RemoveE2TInstance(e2tAddress string) error UpdateGnbCells(nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) error RemoveServedNrCells(inventoryName string, servedNrCells []*entities.ServedNRCell) error - UpdateNodebConnectivityState(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error + UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error } /* @@ -317,9 +317,9 @@ func (w *rNibWriterInstance) RemoveE2TInstance(address string) error { } /* -UpdateNodebConnectivityState... +UpdateNodebInfoOnConnectionStatusInversion... */ -func (w *rNibWriterInstance) UpdateNodebConnectivityState(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error { +func (w *rNibWriterInstance) UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error { pairs, err := buildUpdateNodebInfoPairs(nodebInfo) diff --git a/E2Manager/rNibWriter/rNibWriter_test.go b/E2Manager/rNibWriter/rNibWriter_test.go index 7875b88..07efb66 100644 --- a/E2Manager/rNibWriter/rNibWriter_test.go +++ b/E2Manager/rNibWriter/rNibWriter_test.go @@ -742,7 +742,7 @@ func TestRemoveE2TInstanceEmptyAddressFailure(t *testing.T) { sdlInstanceMock.AssertExpectations(t) } -func TestUpdateNodebConnectivityStateSuccess(t *testing.T) { +func TestUpdateNodebInfoOnConnectionStatusInversionSuccess(t *testing.T) { inventoryName := "name" plmnId := "02f829" nbId := "4a952a0a" @@ -752,7 +752,7 @@ func TestUpdateNodebConnectivityStateSuccess(t *testing.T) { nodebInfo := generateNodebInfo(inventoryName, entities.Node_ENB, plmnId, nbId) data, err := proto.Marshal(nodebInfo) if err != nil { - t.Errorf("#rNibWriter_test.TestUpdateNodebConnectivityStateSuccess - Failed to marshal NodeB entity. Error: %v", err) + t.Errorf("#rNibWriter_test.TestUpdateNodebInfoOnConnectionStatusInversionSuccess - Failed to marshal NodeB entity. Error: %v", err) } var e error var setExpected []interface{} @@ -764,11 +764,11 @@ func TestUpdateNodebConnectivityStateSuccess(t *testing.T) { sdlInstanceMock.On("SetAndPublish", []string{channelName, eventName}, []interface{}{setExpected}).Return(e) - rNibErr := w.UpdateNodebConnectivityState(nodebInfo, channelName, eventName) + rNibErr := w.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, channelName, eventName) assert.Nil(t, rNibErr) } -func TestUpdateNodebConnectivityStateMissingInventoryNameFailure(t *testing.T) { +func TestUpdateNodebInfoOnConnectionStatusInversionMissingInventoryNameFailure(t *testing.T) { inventoryName := "name" plmnId := "02f829" nbId := "4a952a0a" @@ -778,7 +778,7 @@ func TestUpdateNodebConnectivityStateMissingInventoryNameFailure(t *testing.T) { nodebInfo := &entities.NodebInfo{} data, err := proto.Marshal(nodebInfo) if err != nil { - t.Errorf("#rNibWriter_test.TestUpdateNodebConnectivityStateMissingInventoryNameFailure - Failed to marshal NodeB entity. Error: %v", err) + t.Errorf("#rNibWriter_test.TestUpdateNodebInfoOnConnectionStatusInversionMissingInventoryNameFailure - Failed to marshal NodeB entity. Error: %v", err) } var e error var setExpected []interface{} @@ -790,13 +790,13 @@ func TestUpdateNodebConnectivityStateMissingInventoryNameFailure(t *testing.T) { sdlInstanceMock.On("SetAndPublish", []string{channelName, eventName}, []interface{}{setExpected}).Return(e) - rNibErr := w.UpdateNodebConnectivityState(nodebInfo, channelName, eventName) + rNibErr := w.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, channelName, eventName) assert.NotNil(t, rNibErr) assert.IsType(t, &common.ValidationError{}, rNibErr) } -func TestUpdateNodebConnectivityStateMissingGlobalNbId(t *testing.T) { +func TestUpdateNodebInfoOnConnectionStatusInversionMissingGlobalNbId(t *testing.T) { inventoryName := "name" channelName := "RAN_CONNECT_STATE_CHANGE" eventName := inventoryName + "_" + "CONNECTED" @@ -805,7 +805,7 @@ func TestUpdateNodebConnectivityStateMissingGlobalNbId(t *testing.T) { nodebInfo.RanName = inventoryName data, err := proto.Marshal(nodebInfo) if err != nil { - t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err) + t.Errorf("#rNibWriter_test.TestUpdateNodebInfoOnConnectionStatusInversionMissingInventoryNameFailure - Failed to marshal NodeB entity. Error: %v", err) } var e error var setExpected []interface{} @@ -814,7 +814,7 @@ func TestUpdateNodebConnectivityStateMissingGlobalNbId(t *testing.T) { setExpected = append(setExpected, nodebNameKey, data) sdlInstanceMock.On("SetAndPublish", []string{channelName, eventName}, []interface{}{setExpected}).Return(e) - rNibErr := w.UpdateNodebConnectivityState(nodebInfo, channelName, eventName) + rNibErr := w.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, channelName, eventName) assert.Nil(t, rNibErr) } diff --git a/E2Manager/services/rnib_data_service.go b/E2Manager/services/rnib_data_service.go index 3ca944a..03d7baf 100644 --- a/E2Manager/services/rnib_data_service.go +++ b/E2Manager/services/rnib_data_service.go @@ -50,7 +50,7 @@ type RNibDataService interface { UpdateGnbCells(nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) error RemoveServedNrCells(inventoryName string, servedNrCells []*entities.ServedNRCell) error GetGeneralConfiguration() (*entities.GeneralConfiguration, error) - UpdateNodebConnectivityState(nodebInfo *entities.NodebInfo, event string) error + UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, event string) error } type rNibDataService struct { @@ -297,11 +297,11 @@ func (w *rNibDataService) PingRnib() bool { return !isRnibConnectionError(err) } -func (w *rNibDataService) UpdateNodebConnectivityState(nodebInfo *entities.NodebInfo, event string) error { - w.logger.Infof("#RnibDataService.UpdateNodebConnectivityState - nodebInfo: %s", nodebInfo) +func (w *rNibDataService) UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, event string) error { + w.logger.Infof("#RnibDataService.UpdateNodebInfoOnConnectionStatusInversion - nodebInfo: %s", nodebInfo) - err := w.retry("UpdateNodebConnectivityState", func() (err error) { - err = w.rnibWriter.UpdateNodebConnectivityState(nodebInfo, w.stateChangeMessageChannel, event) + err := w.retry("UpdateNodebInfoOnConnectionStatusInversion", func() (err error) { + err = w.rnibWriter.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, w.stateChangeMessageChannel, event) return }) diff --git a/E2Manager/services/rnib_data_service_test.go b/E2Manager/services/rnib_data_service_test.go index 1d59846..f6529e3 100644 --- a/E2Manager/services/rnib_data_service_test.go +++ b/E2Manager/services/rnib_data_service_test.go @@ -259,27 +259,27 @@ func TestPingRnibOkOtherError(t *testing.T) { assert.True(t, res) } -func TestSuccessfulUpdateNodebConnectivityState(t *testing.T) { +func TestSuccessfulUpdateNodebInfoOnConnectionStatusInversion(t *testing.T) { rnibDataService, _, writerMock := setupRnibDataServiceTest(t) event := "event" nodebInfo := &entities.NodebInfo{} - writerMock.On("UpdateNodebConnectivityState", nodebInfo, CHANNEL_NAME, event).Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", nodebInfo, CHANNEL_NAME, event).Return(nil) - rnibDataService.UpdateNodebConnectivityState(nodebInfo, event) - writerMock.AssertNumberOfCalls(t, "UpdateNodebConnectivityState", 1) + rnibDataService.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, event) + writerMock.AssertNumberOfCalls(t, "UpdateNodebInfoOnConnectionStatusInversion", 1) } -func TestConnFailureUpdateNodebConnectivityState(t *testing.T) { +func TestConnFailureUpdateNodebInfoOnConnectionStatusInversion(t *testing.T) { rnibDataService, _, writerMock := setupRnibDataServiceTest(t) event := "event" nodebInfo := &entities.NodebInfo{} mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}} - writerMock.On("UpdateNodebConnectivityState", nodebInfo, CHANNEL_NAME, event).Return(mockErr) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", nodebInfo, CHANNEL_NAME, event).Return(mockErr) - rnibDataService.UpdateNodebConnectivityState(nodebInfo, event) - writerMock.AssertNumberOfCalls(t, "UpdateNodebConnectivityState", 3) + rnibDataService.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, event) + writerMock.AssertNumberOfCalls(t, "UpdateNodebInfoOnConnectionStatusInversion", 3) } //func TestConnFailureThenSuccessGetNodebIdList(t *testing.T) {