X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fhandlers%2Frmrmsghandlers%2Fran_lost_connection_handler_test.go;h=a1043a7f58957f7c10d528c3cb1ea4670091559d;hb=a75da9a56d61ca4754650d44a54bbf0b04f610d1;hp=836c02a0298f27f0bd1f23ee4b9868f85d25ea33;hpb=1f62f4c6e2746153275b6c3b1e24a705e25b90c0;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go b/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go index 836c02a..a1043a7 100644 --- a/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go +++ b/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go @@ -42,42 +42,39 @@ func TestLostConnectionHandlerSuccess(t *testing.T) { logger, _ := logger.InitLogger(logger.InfoLevel) notificationRequest := models.NotificationRequest{RanName: ranName} - ranReconnectionManagerMock := &mocks.RanReconnectionManagerMock{} - ranReconnectionManagerMock.On("ReconnectRan", 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, "ReconnectRan", ranName) + ranDisconnectionManagerMock.AssertCalled(t, "DisconnectRan", ranName) } func TestLostConnectionHandlerFailure(t *testing.T) { logger, _ := logger.InitLogger(logger.InfoLevel) notificationRequest := models.NotificationRequest{RanName: ranName} - ranReconnectionManagerMock := &mocks.RanReconnectionManagerMock{} - ranReconnectionManagerMock.On("ReconnectRan", 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, "ReconnectRan", 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} - rmrMessengerMock := &mocks.RmrMessengerMock{} - rmrSender := initRmrSender(rmrMessengerMock, logger) readerMock := &mocks.RnibReaderMock{} writerMock := &mocks.RnibWriterMock{} rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock) e2tInstancesManager := managers.NewE2TInstancesManager(rnibDataService, logger) - ranSetupManager := managers.NewRanSetupManager(logger, rmrSender, rnibDataService) httpClientMock := &mocks.HttpClientMock{} routingManagerClient := clients.NewRoutingManagerClient(logger, config, httpClientMock) e2tAssociationManager := managers.NewE2TAssociationManager(logger, rnibDataService, e2tInstancesManager, routingManagerClient) - ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, ranSetupManager, 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 @@ -87,10 +84,10 @@ func setupLostConnectionHandlerTestWithRealReconnectionManager(t *testing.T, isS updatedNodebInfo2.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED updatedNodebInfo2.AssociatedE2TInstanceAddress = "" writerMock.On("UpdateNodebInfo", &updatedNodebInfo2).Return(rnibErr) - e2tInstance := &entities.E2TInstance{Address: e2tAddress, AssociatedRanList:[]string{ranName}} + e2tInstance := &entities.E2TInstance{Address: e2tAddress, AssociatedRanList: []string{ranName}} readerMock.On("GetE2TInstance", e2tAddress).Return(e2tInstance, nil) e2tInstanceToSave := *e2tInstance - e2tInstanceToSave .AssociatedRanList = []string{} + e2tInstanceToSave.AssociatedRanList = []string{} writerMock.On("SaveE2TInstance", &e2tInstanceToSave).Return(nil) mockHttpClient(httpClientMock, isSuccessfulHttpPost) @@ -111,8 +108,8 @@ func mockHttpClient(httpClientMock *mocks.HttpClientMock, isSuccessful bool) { 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) @@ -123,8 +120,8 @@ func TestLostConnectionHandlerFailureWithRealReconnectionManager(t *testing.T) { 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)