"e2mgr/logger"
"e2mgr/mocks"
"e2mgr/services"
+ "testing"
+
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
- "testing"
+ "github.com/stretchr/testify/mock"
)
const EventChannelForTest = "RAN_CONNECTION_STATUS_CHANGE"
if err != nil {
t.Errorf("#... - failed to initialize log, error: %s", err)
}
- config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3, StateChangeMessageChannel: EventChannelForTest}
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3,
+ RnibWriter: configuration.RnibWriterConfig{
+ StateChangeMessageChannel: EventChannelForTest,
+ },
+ }
readerMock := &mocks.RnibReaderMock{}
writerMock := &mocks.RnibWriterMock{}
origNodebInfo := &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_UNKNOWN_CONNECTION_STATUS}
updatedNodebInfo := *origNodebInfo
updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED
- 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)
+ writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", mock.Anything, RanName+"_"+CONNECTED_RAW_EVENT).Return(nil)
+ ranListManagerMock.On("UpdateNbIdentityConnectionStatus", updatedNodebInfo.GetNodeType(), RanName, updatedNodebInfo.GetConnectionStatus()).Return(nil)
+ ranAlarmServiceMock.On("SetConnectivityChangeAlarm", mock.Anything).Return(nil)
+ _, err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_CONNECTED)
assert.Nil(t, err)
writerMock.AssertExpectations(t)
ranListManagerMock.AssertExpectations(t)
origNodebInfo := &entities.NodebInfo{RanName: ranName, ConnectionStatus: entities.ConnectionStatus_SHUTTING_DOWN}
updatedNodebInfo := *origNodebInfo
updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_SHUT_DOWN
- writerMock.On("UpdateNodebInfo", &updatedNodebInfo).Return(nil)
- ranListManagerMock.On("UpdateRanState", &updatedNodebInfo).Return(nil)
- err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_SHUT_DOWN)
+ writerMock.On("UpdateNodebInfo", mock.Anything).Return(nil)
+ ranListManagerMock.On("UpdateNbIdentityConnectionStatus", updatedNodebInfo.GetNodeType(), RanName, updatedNodebInfo.GetConnectionStatus()).Return(nil)
+ _, err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_SHUT_DOWN)
assert.Nil(t, err)
writerMock.AssertExpectations(t)
ranListManagerMock.AssertExpectations(t)
origNodebInfo := &entities.NodebInfo{RanName: ranName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED}
updatedNodebInfo := *origNodebInfo
updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_SHUT_DOWN
- writerMock.On("UpdateNodebInfo", &updatedNodebInfo).Return(nil)
- ranListManagerMock.On("UpdateRanState", &updatedNodebInfo).Return(nil)
- err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_SHUT_DOWN)
+ writerMock.On("UpdateNodebInfo", mock.Anything).Return(nil)
+ ranListManagerMock.On("UpdateNbIdentityConnectionStatus", updatedNodebInfo.GetNodeType(), RanName, updatedNodebInfo.GetConnectionStatus()).Return(nil)
+ _, err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_SHUT_DOWN)
assert.Nil(t, err)
writerMock.AssertExpectations(t)
ranListManagerMock.AssertExpectations(t)
origNodebInfo := &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED}
updatedNodebInfo := *origNodebInfo
updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED
- 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)
+ writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", mock.Anything, RanName+"_"+CONNECTED_RAW_EVENT).Return(nil)
+ ranListManagerMock.On("UpdateNbIdentityConnectionStatus", updatedNodebInfo.GetNodeType(), RanName, updatedNodebInfo.GetConnectionStatus()).Return(nil)
+ ranAlarmServiceMock.On("SetConnectivityChangeAlarm", mock.Anything).Return(nil)
+ _, err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_CONNECTED)
assert.Nil(t, err)
writerMock.AssertExpectations(t)
ranListManagerMock.AssertExpectations(t)
origNodebInfo := &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_CONNECTED}
updatedNodebInfo := *origNodebInfo
updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED
- 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)
+ writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", mock.Anything, RanName+"_"+DISCONNECTED_RAW_EVENT).Return(nil)
+ ranListManagerMock.On("UpdateNbIdentityConnectionStatus", updatedNodebInfo.GetNodeType(), RanName, updatedNodebInfo.GetConnectionStatus()).Return(nil)
+ ranAlarmServiceMock.On("SetConnectivityChangeAlarm", mock.Anything).Return(nil)
+ _, err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_DISCONNECTED)
assert.Nil(t, err)
writerMock.AssertExpectations(t)
ranListManagerMock.AssertExpectations(t)
origNodebInfo := &entities.NodebInfo{RanName: ranName, ConnectionStatus: entities.ConnectionStatus_SHUTTING_DOWN}
updatedNodebInfo := *origNodebInfo
updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_SHUT_DOWN
- writerMock.On("UpdateNodebInfo", &updatedNodebInfo).Return(common.NewInternalError(errors.New("Error")))
- err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_SHUT_DOWN)
+ writerMock.On("UpdateNodebInfo", mock.Anything).Return(common.NewInternalError(errors.New("Error")))
+ _, err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_SHUT_DOWN)
assert.NotNil(t, err)
writerMock.AssertExpectations(t)
ranListManagerMock.AssertExpectations(t)
origNodebInfo := &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED}
updatedNodebInfo := *origNodebInfo
updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED
- writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &updatedNodebInfo, EventChannelForTest, RanName + "_" + CONNECTED_RAW_EVENT).Return(common.NewInternalError(errors.New("Error")))
- err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_CONNECTED)
+ writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", mock.Anything, RanName+"_"+CONNECTED_RAW_EVENT).Return(common.NewInternalError(errors.New("Error")))
+ _, err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_CONNECTED)
assert.NotNil(t, err)
writerMock.AssertExpectations(t)
ranListManagerMock.AssertExpectations(t)
origNodebInfo := &entities.NodebInfo{RanName: ranName, ConnectionStatus: entities.ConnectionStatus_SHUTTING_DOWN}
updatedNodebInfo := *origNodebInfo
updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_SHUT_DOWN
- writerMock.On("UpdateNodebInfo", &updatedNodebInfo).Return(nil)
- ranListManagerMock.On("UpdateRanState", &updatedNodebInfo).Return(common.NewInternalError(errors.New("Error")))
- err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_SHUT_DOWN)
+ writerMock.On("UpdateNodebInfo", mock.Anything).Return(nil)
+ ranListManagerMock.On("UpdateNbIdentityConnectionStatus", updatedNodebInfo.GetNodeType(), ranName, updatedNodebInfo.GetConnectionStatus()).Return(common.NewInternalError(errors.New("Error")))
+ _, err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_SHUT_DOWN)
assert.Nil(t, err)
writerMock.AssertExpectations(t)
ranListManagerMock.AssertExpectations(t)
origNodebInfo := &entities.NodebInfo{RanName: ranName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED}
updatedNodebInfo := *origNodebInfo
updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED
- 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)
+ writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", mock.Anything, RanName+"_"+CONNECTED_RAW_EVENT).Return(nil)
+ ranListManagerMock.On("UpdateNbIdentityConnectionStatus", updatedNodebInfo.GetNodeType(), RanName, updatedNodebInfo.GetConnectionStatus()).Return(nil)
+ ranAlarmServiceMock.On("SetConnectivityChangeAlarm", mock.Anything).Return(common.NewInternalError(errors.New("Error")))
+ _, err := ranConnectStatusChangeManager.ChangeStatus(origNodebInfo, entities.ConnectionStatus_CONNECTED)
assert.Nil(t, err)
writerMock.AssertExpectations(t)
ranListManagerMock.AssertExpectations(t)
ranAlarmServiceMock.AssertExpectations(t)
-}
\ No newline at end of file
+}