From: idanshal Date: Wed, 26 Feb 2020 13:42:07 +0000 (+0200) Subject: [RIC-196] Update variables naming & add UT X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;ds=inline;h=7219930da2168712ef420676ebc6aa3f1490ef53;p=ric-plt%2Fe2mgr.git [RIC-196] Update variables naming & add UT Change-Id: I44ca48b03df00ef024223f287fc9fed5e253e648 Signed-off-by: idanshal --- diff --git a/Automation/Tests/Lost_Connection/Lost_Connetion_CONNECTING_TO_DISCONNECTED.robot b/Automation/Tests/Lost_Connection/Lost_Connetion_CONNECTING_TO_DISCONNECTED.robot index 90002eb..e9f18b8 100644 --- a/Automation/Tests/Lost_Connection/Lost_Connetion_CONNECTING_TO_DISCONNECTED.robot +++ b/Automation/Tests/Lost_Connection/Lost_Connetion_CONNECTING_TO_DISCONNECTED.robot @@ -28,9 +28,6 @@ Library Collections Library REST ${url} - - - *** Test Cases *** Pre Condition for Connecting - no simu @@ -50,12 +47,9 @@ Prepare Ran in Connecting connectionStatus #String response body connectionStatus CONNECTING - -Verfiy Disconnected ConnectionStatus +Verify Disconnected ConnectionStatus Sleep 10s GET /v1/nodeb/test1 Integer response status 200 String response body ranName test1 - String response body connectionStatus DISCONNECTED - Integer response body connectionAttempts 3 - + String response body connectionStatus DISCONNECTED \ No newline at end of file diff --git a/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go b/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go index c0cd787..99292b3 100644 --- a/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go +++ b/E2Manager/handlers/rmrmsghandlers/ran_lost_connection_handler_test.go @@ -42,22 +42,22 @@ func TestLostConnectionHandlerSuccess(t *testing.T) { 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) { @@ -71,8 +71,8 @@ func setupLostConnectionHandlerTestWithRealReconnectionManager(t *testing.T, isS 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} var rnibErr error diff --git a/E2Manager/managers/ran_disconnection_manager_test.go b/E2Manager/managers/ran_disconnection_manager_test.go index fbddb40..644c552 100644 --- a/E2Manager/managers/ran_disconnection_manager_test.go +++ b/E2Manager/managers/ran_disconnection_manager_test.go @@ -53,35 +53,35 @@ func initRanLostConnectionTest(t *testing.T) (*logger.Logger, *mocks.RmrMessenge httpClient := &mocks.HttpClientMock{} routingManagerClient := clients.NewRoutingManagerClient(logger, config, httpClient) e2tAssociationManager := NewE2TAssociationManager(logger, rnibDataService, e2tInstancesManager, routingManagerClient) - ranReconnectionManager := NewRanDisconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, e2tAssociationManager) - return logger, rmrMessengerMock, readerMock, writerMock, ranReconnectionManager, httpClient + ranDisconnectionManager := NewRanDisconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, e2tAssociationManager) + return logger, rmrMessengerMock, readerMock, writerMock, ranDisconnectionManager, httpClient } func TestRanReconnectionGetNodebFailure(t *testing.T) { - _, _, readerMock, writerMock, ranReconnectionManager, _ := initRanLostConnectionTest(t) + _, _, readerMock, writerMock, ranDisconnectionManager, _ := initRanLostConnectionTest(t) var nodebInfo *entities.NodebInfo readerMock.On("GetNodeb", ranName).Return(nodebInfo, common.NewInternalError(errors.New("Error"))) - err := ranReconnectionManager.DisconnectRan(ranName) + err := ranDisconnectionManager.DisconnectRan(ranName) assert.NotNil(t, err) readerMock.AssertCalled(t, "GetNodeb", ranName) writerMock.AssertNotCalled(t, "UpdateNodebInfo") } func TestShutdownRanReconnection(t *testing.T) { - _, _, readerMock, writerMock, ranReconnectionManager, _ := initRanLostConnectionTest(t) + _, _, readerMock, writerMock, ranDisconnectionManager, _ := initRanLostConnectionTest(t) origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_SHUT_DOWN} var rnibErr error readerMock.On("GetNodeb", ranName).Return(origNodebInfo, rnibErr) - err := ranReconnectionManager.DisconnectRan(ranName) + err := ranDisconnectionManager.DisconnectRan(ranName) assert.Nil(t, err) readerMock.AssertCalled(t, "GetNodeb", ranName) writerMock.AssertNotCalled(t, "UpdateNodebInfo") } func TestShuttingdownRanReconnection(t *testing.T) { - _, _, readerMock, writerMock, ranReconnectionManager, _ := initRanLostConnectionTest(t) + _, _, readerMock, writerMock, ranDisconnectionManager, _ := initRanLostConnectionTest(t) origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_SHUTTING_DOWN} var rnibErr error @@ -89,14 +89,14 @@ func TestShuttingdownRanReconnection(t *testing.T) { updatedNodebInfo := *origNodebInfo updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_SHUT_DOWN writerMock.On("UpdateNodebInfo", &updatedNodebInfo).Return(rnibErr) - err := ranReconnectionManager.DisconnectRan(ranName) + err := ranDisconnectionManager.DisconnectRan(ranName) assert.Nil(t, err) readerMock.AssertCalled(t, "GetNodeb", ranName) writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 1) } func TestConnectingRanDissociateSucceeds(t *testing.T) { - _, _, readerMock, writerMock, ranReconnectionManager, httpClient := initRanLostConnectionTest(t) + _, _, readerMock, writerMock, ranDisconnectionManager, httpClient := initRanLostConnectionTest(t) origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_CONNECTING, AssociatedE2TInstanceAddress: E2TAddress} var rnibErr error @@ -114,14 +114,14 @@ func TestConnectingRanDissociateSucceeds(t *testing.T) { e2tInstanceToSave.AssociatedRanList = []string{} writerMock.On("SaveE2TInstance", &e2tInstanceToSave).Return(nil) mockHttpClient(httpClient, clients.DissociateRanE2TInstanceApiSuffix, true) - err := ranReconnectionManager.DisconnectRan(ranName) + err := ranDisconnectionManager.DisconnectRan(ranName) assert.Nil(t, err) readerMock.AssertCalled(t, "GetNodeb", ranName) writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 2) } func TestConnectingRanDissociateFails(t *testing.T) { - _, _, readerMock, writerMock, ranReconnectionManager, _ := initRanLostConnectionTest(t) + _, _, readerMock, writerMock, ranDisconnectionManager, _ := initRanLostConnectionTest(t) origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_CONNECTING, AssociatedE2TInstanceAddress: e2tAddress} var rnibErr error @@ -135,16 +135,15 @@ func TestConnectingRanDissociateFails(t *testing.T) { writerMock.On("UpdateNodebInfo", &updatedNodebInfo2).Return(rnibErr) e2tInstance := &entities.E2TInstance{Address: e2tAddress, AssociatedRanList: []string{ranName}} readerMock.On("GetE2TInstance", e2tAddress).Return(e2tInstance, common.NewInternalError(errors.New("Error"))) - err := ranReconnectionManager.DisconnectRan(ranName) + err := ranDisconnectionManager.DisconnectRan(ranName) assert.NotNil(t, err) readerMock.AssertCalled(t, "GetNodeb", ranName) writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 2) writerMock.AssertNotCalled(t, "SaveE2TInstance", ) } -// TODO: change test function name -func TestUnconnectableRanUpdateNodebInfoFailure(t *testing.T) { - _, _, readerMock, writerMock, ranReconnectionManager, _ := initRanLostConnectionTest(t) +func TestShuttingDownRanUpdateNodebInfoFailure(t *testing.T) { + _, _, readerMock, writerMock, ranDisconnectionManager, _ := initRanLostConnectionTest(t) origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_SHUTTING_DOWN} var rnibErr error @@ -152,7 +151,22 @@ func TestUnconnectableRanUpdateNodebInfoFailure(t *testing.T) { updatedNodebInfo := *origNodebInfo updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_SHUT_DOWN writerMock.On("UpdateNodebInfo", &updatedNodebInfo).Return(common.NewInternalError(errors.New("Error"))) - err := ranReconnectionManager.DisconnectRan(ranName) + err := ranDisconnectionManager.DisconnectRan(ranName) + assert.NotNil(t, err) + readerMock.AssertCalled(t, "GetNodeb", ranName) + writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 1) +} + +func TestRanDisconnectedUpdateNodebInfoFailure(t *testing.T) { + _, _, readerMock, writerMock, ranDisconnectionManager, _ := initRanLostConnectionTest(t) + + origNodebInfo := &entities.NodebInfo{RanName: ranName, GlobalNbId: &entities.GlobalNbId{PlmnId: "xxx", NbId: "yyy"}, ConnectionStatus: entities.ConnectionStatus_CONNECTING} + var rnibErr error + readerMock.On("GetNodeb", ranName).Return(origNodebInfo, rnibErr) + updatedNodebInfo := *origNodebInfo + updatedNodebInfo.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED + writerMock.On("UpdateNodebInfo", &updatedNodebInfo).Return(common.NewInternalError(errors.New("Error"))) + err := ranDisconnectionManager.DisconnectRan(ranName) assert.NotNil(t, err) readerMock.AssertCalled(t, "GetNodeb", ranName) writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 1) diff --git a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go index 1eaa6b5..252e047 100644 --- a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go +++ b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go @@ -68,7 +68,7 @@ func (provider *NotificationHandlerProvider) Init(logger *logger.Logger, config x2ResetResponseExtractor := converters.NewX2ResetResponseExtractor(logger) // Init managers - ranReconnectionManager := managers.NewRanDisconnectionManager(logger, config, rnibDataService, e2tAssociationManager) + ranDisconnectionManager := managers.NewRanDisconnectionManager(logger, config, rnibDataService, e2tAssociationManager) ranStatusChangeManager := managers.NewRanStatusChangeManager(logger, rmrSender) x2SetupResponseManager := managers.NewX2SetupResponseManager(x2SetupResponseConverter) x2SetupFailureResponseManager := managers.NewX2SetupFailureResponseManager(x2SetupFailureResponseConverter) @@ -80,13 +80,13 @@ func (provider *NotificationHandlerProvider) Init(logger *logger.Logger, config x2SetupFailureResponseHandler := rmrmsghandlers.NewSetupResponseNotificationHandler(logger, rnibDataService, x2SetupFailureResponseManager, nil, rmrCgo.RIC_X2_SETUP_FAILURE) endcSetupResponseHandler := rmrmsghandlers.NewSetupResponseNotificationHandler(logger, rnibDataService, endcSetupResponseManager, ranStatusChangeManager, rmrCgo.RIC_ENDC_X2_SETUP_RESP) endcSetupFailureResponseHandler := rmrmsghandlers.NewSetupResponseNotificationHandler(logger, rnibDataService, endcSetupFailureResponseManager, nil, rmrCgo.RIC_ENDC_X2_SETUP_FAILURE) - ranLostConnectionHandler := rmrmsghandlers.NewRanLostConnectionHandler(logger, ranReconnectionManager) + ranLostConnectionHandler := rmrmsghandlers.NewRanLostConnectionHandler(logger, ranDisconnectionManager) enbLoadInformationNotificationHandler := rmrmsghandlers.NewEnbLoadInformationNotificationHandler(logger, rnibDataService, enbLoadInformationExtractor) x2EnbConfigurationUpdateHandler := rmrmsghandlers.NewX2EnbConfigurationUpdateHandler(logger, rmrSender) endcConfigurationUpdateHandler := rmrmsghandlers.NewEndcConfigurationUpdateHandler(logger, rmrSender) x2ResetResponseHandler := rmrmsghandlers.NewX2ResetResponseHandler(logger, rnibDataService, ranStatusChangeManager, x2ResetResponseExtractor) x2ResetRequestNotificationHandler := rmrmsghandlers.NewX2ResetRequestNotificationHandler(logger, rnibDataService, ranStatusChangeManager, rmrSender) - e2TermInitNotificationHandler := rmrmsghandlers.NewE2TermInitNotificationHandler(logger, ranReconnectionManager, e2tInstancesManager, routingManagerClient) + e2TermInitNotificationHandler := rmrmsghandlers.NewE2TermInitNotificationHandler(logger, ranDisconnectionManager, e2tInstancesManager, routingManagerClient) e2TKeepAliveResponseHandler := rmrmsghandlers.NewE2TKeepAliveResponseHandler(logger, rnibDataService, e2tInstancesManager) provider.Register(rmrCgo.RIC_X2_SETUP_RESP, x2SetupResponseHandler) diff --git a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go index f50001f..c5167c0 100644 --- a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go +++ b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go @@ -64,7 +64,7 @@ func TestGetNotificationHandlerSuccess(t *testing.T) { logger, config, rnibDataService, rmrSender, ranSetupManager, e2tInstancesManager, routingManagerClient, e2tAssociationManager := initTestCase(t) - ranReconnectionManager := managers.NewRanDisconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, e2tAssociationManager) + ranDisconnectionManager := managers.NewRanDisconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, e2tAssociationManager) ranStatusChangeManager := managers.NewRanStatusChangeManager(logger, rmrSender) x2SetupResponseConverter := converters.NewX2SetupResponseConverter(logger) @@ -89,11 +89,11 @@ func TestGetNotificationHandlerSuccess(t *testing.T) { {rmrCgo.RIC_X2_SETUP_FAILURE, rmrmsghandlers.NewSetupResponseNotificationHandler(logger, rnibDataService, x2SetupFailureResponseManager, ranStatusChangeManager, rmrCgo.RIC_X2_SETUP_FAILURE)}, {rmrCgo.RIC_ENDC_X2_SETUP_RESP, rmrmsghandlers.NewSetupResponseNotificationHandler(logger, rnibDataService, endcSetupResponseManager, ranStatusChangeManager, rmrCgo.RIC_ENDC_X2_SETUP_RESP)}, {rmrCgo.RIC_ENDC_X2_SETUP_FAILURE, rmrmsghandlers.NewSetupResponseNotificationHandler(logger, rnibDataService, endcSetupFailureResponseManager, ranStatusChangeManager, rmrCgo.RIC_ENDC_X2_SETUP_FAILURE),}, - {rmrCgo.RIC_SCTP_CONNECTION_FAILURE, rmrmsghandlers.NewRanLostConnectionHandler(logger, ranReconnectionManager)}, + {rmrCgo.RIC_SCTP_CONNECTION_FAILURE, rmrmsghandlers.NewRanLostConnectionHandler(logger, ranDisconnectionManager)}, {rmrCgo.RIC_ENB_LOAD_INFORMATION, rmrmsghandlers.NewEnbLoadInformationNotificationHandler(logger, rnibDataService, converters.NewEnbLoadInformationExtractor(logger))}, {rmrCgo.RIC_ENB_CONF_UPDATE, rmrmsghandlers.NewX2EnbConfigurationUpdateHandler(logger, rmrSender)}, {rmrCgo.RIC_ENDC_CONF_UPDATE, rmrmsghandlers.NewEndcConfigurationUpdateHandler(logger, rmrSender)}, - {rmrCgo.RIC_E2_TERM_INIT, rmrmsghandlers.NewE2TermInitNotificationHandler(logger, ranReconnectionManager, e2tInstancesManager, routingManagerClient)}, + {rmrCgo.RIC_E2_TERM_INIT, rmrmsghandlers.NewE2TermInitNotificationHandler(logger, ranDisconnectionManager, e2tInstancesManager, routingManagerClient)}, {rmrCgo.E2_TERM_KEEP_ALIVE_RESP, rmrmsghandlers.NewE2TKeepAliveResponseHandler(logger, rnibDataService, e2tInstancesManager)}, {rmrCgo.RIC_X2_RESET_RESP, rmrmsghandlers.NewX2ResetResponseHandler(logger, rnibDataService, ranStatusChangeManager, converters.NewX2ResetResponseExtractor(logger))}, {rmrCgo.RIC_X2_RESET, rmrmsghandlers.NewX2ResetRequestNotificationHandler(logger, rnibDataService, ranStatusChangeManager, rmrSender)},