[RIC-397] rename method to UpdateNodebInfoOnConnectionStatusInversion 34/4134/1
authorAmichai <amichai.sichel@intl.att.com>
Tue, 16 Jun 2020 14:54:03 +0000 (17:54 +0300)
committerAmichai <amichai.sichel@intl.att.com>
Tue, 16 Jun 2020 14:54:12 +0000 (17:54 +0300)
Change-Id: I696aedadf79dc43a0e4b64e725a0a7ad2be6b2ff
Signed-off-by: Amichai <amichai.sichel@intl.att.com>
E2Manager/managers/ran_connect_status_change_manager.go
E2Manager/managers/ran_connect_status_change_manager_test.go
E2Manager/mocks/rnibWriterMock.go
E2Manager/rNibWriter/rNibWriter.go
E2Manager/rNibWriter/rNibWriter_test.go
E2Manager/services/rnib_data_service.go
E2Manager/services/rnib_data_service_test.go

index 8818399..26d12b2 100644 (file)
@@ -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
 }
 
index 4dc77af..b9295e3 100644 (file)
@@ -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)
index bf2ed53..b076614 100644 (file)
@@ -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
index 5bc4a68..df4c7d6 100644 (file)
@@ -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)
 
index 7875b88..07efb66 100644 (file)
@@ -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)
 }
index 3ca944a..03d7baf 100644 (file)
@@ -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
        })
 
index 1d59846..f6529e3 100644 (file)
@@ -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) {