logger, _ := logger.InitLogger(logger.InfoLevel)
notificationRequest := models.NotificationRequest{RanName: ranName}
- ranReconnectionManagerMock := &mocks.RanDisconnectionManagerMock{}
- ranReconnectionManagerMock.On("DisconnectRan", ranName).Return(nil)
- handler := NewRanLostConnectionHandler(logger, ranReconnectionManagerMock)
+ ranDisconnectionManagerMock := &mocks.RanDisconnectionManagerMock{}
+ ranDisconnectionManagerMock.On("DisconnectRan", ranName).Return(nil)
+ handler := NewRanLostConnectionHandler(logger, ranDisconnectionManagerMock)
handler.Handle(¬ificationRequest)
- ranReconnectionManagerMock.AssertCalled(t, "DisconnectRan", ranName)
+ ranDisconnectionManagerMock.AssertCalled(t, "DisconnectRan", ranName)
}
func TestLostConnectionHandlerFailure(t *testing.T) {
logger, _ := logger.InitLogger(logger.InfoLevel)
notificationRequest := models.NotificationRequest{RanName: ranName}
- ranReconnectionManagerMock := &mocks.RanDisconnectionManagerMock{}
- ranReconnectionManagerMock.On("DisconnectRan", ranName).Return(errors.New("error"))
- handler := NewRanLostConnectionHandler(logger, ranReconnectionManagerMock)
+ ranDisconnectionManagerMock := &mocks.RanDisconnectionManagerMock{}
+ ranDisconnectionManagerMock.On("DisconnectRan", ranName).Return(errors.New("error"))
+ handler := NewRanLostConnectionHandler(logger, ranDisconnectionManagerMock)
handler.Handle(¬ificationRequest)
- ranReconnectionManagerMock.AssertCalled(t, "DisconnectRan", ranName)
+ ranDisconnectionManagerMock.AssertCalled(t, "DisconnectRan", ranName)
}
-func setupLostConnectionHandlerTestWithRealReconnectionManager(t *testing.T, isSuccessfulHttpPost bool) (RanLostConnectionHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.HttpClientMock) {
+func setupLostConnectionHandlerTestWithRealDisconnectionManager(t *testing.T, isSuccessfulHttpPost bool) (RanLostConnectionHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.HttpClientMock) {
logger, _ := logger.InitLogger(logger.InfoLevel)
config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
httpClientMock := &mocks.HttpClientMock{}
routingManagerClient := clients.NewRoutingManagerClient(logger, config, httpClientMock)
e2tAssociationManager := managers.NewE2TAssociationManager(logger, rnibDataService, e2tInstancesManager, routingManagerClient)
- ranReconnectionManager := managers.NewRanDisconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, e2tAssociationManager)
- handler := NewRanLostConnectionHandler(logger, ranReconnectionManager)
+ ranDisconnectionManager := managers.NewRanDisconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, e2tAssociationManager)
+ handler := NewRanLostConnectionHandler(logger, ranDisconnectionManager)
- origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_CONNECTING, ConnectionAttempts: 20, AssociatedE2TInstanceAddress: e2tAddress}
+ origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_CONNECTING, AssociatedE2TInstanceAddress: e2tAddress}
var rnibErr error
readerMock.On("GetNodeb", ranName).Return(origNodebInfo, rnibErr)
updatedNodebInfo1 := *origNodebInfo
httpClientMock.On("Post", clients.DissociateRanE2TInstanceApiSuffix, "application/json", body).Return(&http.Response{StatusCode: respStatusCode, Body: respBody}, nil)
}
-func TestLostConnectionHandlerFailureWithRealReconnectionManager(t *testing.T) {
- handler, readerMock, writerMock, httpClientMock := setupLostConnectionHandlerTestWithRealReconnectionManager(t, false)
+func TestLostConnectionHandlerFailureWithRealDisconnectionManager(t *testing.T) {
+ handler, readerMock, writerMock, httpClientMock := setupLostConnectionHandlerTestWithRealDisconnectionManager(t, false)
notificationRequest := models.NotificationRequest{RanName: ranName}
handler.Handle(¬ificationRequest)
writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 2)
}
-func TestLostConnectionHandlerSuccessWithRealReconnectionManager(t *testing.T) {
- handler, readerMock, writerMock, httpClientMock := setupLostConnectionHandlerTestWithRealReconnectionManager(t, true)
+func TestLostConnectionHandlerSuccessWithRealDisconnectionManager(t *testing.T) {
+ handler, readerMock, writerMock, httpClientMock := setupLostConnectionHandlerTestWithRealDisconnectionManager(t, true)
notificationRequest := models.NotificationRequest{RanName: ranName}
handler.Handle(¬ificationRequest)