X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fmanagers%2Fe2t_shutdown_manager_test.go;h=537d153ffe3da3078cc3d189446c159754cf3469;hb=refs%2Fchanges%2F20%2F4520%2F2;hp=0a1d00dcb0d33800d9e68128daf7a2ef76c1fc35;hpb=14eb5132c3dca8cdad98e7e5420701b04f452046;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/managers/e2t_shutdown_manager_test.go b/E2Manager/managers/e2t_shutdown_manager_test.go index 0a1d00d..537d153 100644 --- a/E2Manager/managers/e2t_shutdown_manager_test.go +++ b/E2Manager/managers/e2t_shutdown_manager_test.go @@ -44,7 +44,7 @@ import ( const E2TAddress3 = "10.10.2.17:9800" -func initE2TShutdownManagerTest(t *testing.T) (*E2TShutdownManager, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.HttpClientMock, *KubernetesManager) { +func initE2TShutdownManagerTest(t *testing.T) (*E2TShutdownManager, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.HttpClientMock) { log := initLog(t) config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3, E2TInstanceDeletionTimeoutMs: 15000, RnibWriter: configuration.RnibWriterConfig{StateChangeMessageChannel: "RAN_CONNECTION_STATUS_CHANGE"}} @@ -56,22 +56,17 @@ func initE2TShutdownManagerTest(t *testing.T) (*E2TShutdownManager, *mocks.RnibR httpClientMock := &mocks.HttpClientMock{} rmClient := clients.NewRoutingManagerClient(log, config, httpClientMock) - ranListManager := NewRanListManager(log) + ranListManager := NewRanListManager(log, rnibDataService) ranAlarmService := services.NewRanAlarmService(log, config) ranConnectStatusChangeManager := NewRanConnectStatusChangeManager(log, rnibDataService, ranListManager, ranAlarmService) associationManager := NewE2TAssociationManager(log, rnibDataService, e2tInstancesManager, rmClient, ranConnectStatusChangeManager) - //kubernetesManager := initKubernetesManagerTest(t) + shutdownManager := NewE2TShutdownManager(log, config, rnibDataService, e2tInstancesManager, associationManager, ranConnectStatusChangeManager) - /*shutdownManager := NewE2TShutdownManager(log, config, rnibDataService, e2tInstancesManager, associationManager, kubernetesManager) - - return shutdownManager, readerMock, writerMock, httpClientMock, kubernetesManager*/ - shutdownManager := NewE2TShutdownManager(log, config, rnibDataService, e2tInstancesManager, associationManager, nil, ranConnectStatusChangeManager) - - return shutdownManager, readerMock, writerMock, httpClientMock, nil + return shutdownManager, readerMock, writerMock, httpClientMock } func TestShutdownSuccess1OutOf3Instances(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -106,7 +101,7 @@ func TestShutdownSuccess1OutOf3Instances(t *testing.T) { /*** nodeb 1 ***/ nodeb1connected := *nodeb1 nodeb1connected.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1connected, "RAN_CONNECTION_STATUS_CHANGE", "test1_DISCONNECTED").Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1connected, "test1_DISCONNECTED").Return(nil) nodeb1NotAssociated := *nodeb1 nodeb1NotAssociated.AssociatedE2TInstanceAddress = "" @@ -126,7 +121,7 @@ func TestShutdownSuccess1OutOf3Instances(t *testing.T) { /*** nodeb 5 ***/ nodeb5connected := *nodeb5 nodeb5connected.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb5connected, "RAN_CONNECTION_STATUS_CHANGE", "test5_DISCONNECTED").Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb5connected, "test5_DISCONNECTED").Return(nil) nodeb5NotAssociated := *nodeb5 nodeb5NotAssociated.AssociatedE2TInstanceAddress = "" @@ -142,7 +137,7 @@ func TestShutdownSuccess1OutOf3Instances(t *testing.T) { } func TestShutdownSuccess1InstanceWithoutRans(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -168,7 +163,7 @@ func TestShutdownSuccess1InstanceWithoutRans(t *testing.T) { } func TestShutdownSuccess1Instance2Rans(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -193,7 +188,7 @@ func TestShutdownSuccess1Instance2Rans(t *testing.T) { /*** nodeb 1 connected ***/ nodeb1new := *nodeb1 nodeb1new.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1new, "RAN_CONNECTION_STATUS_CHANGE", "test1_DISCONNECTED").Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1new, "test1_DISCONNECTED").Return(nil) nodeb1NotAssociated := *nodeb1 nodeb1NotAssociated.AssociatedE2TInstanceAddress = "" @@ -219,7 +214,7 @@ func TestShutdownSuccess1Instance2Rans(t *testing.T) { } func TestShutdownE2tInstanceAlreadyBeingDeleted(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.ToBeDeleted @@ -235,7 +230,7 @@ func TestShutdownE2tInstanceAlreadyBeingDeleted(t *testing.T) { } func TestShutdownFailureMarkInstanceAsToBeDeleted(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -251,7 +246,7 @@ func TestShutdownFailureMarkInstanceAsToBeDeleted(t *testing.T) { } func TestShutdownFailureRoutingManagerError(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -286,7 +281,7 @@ func TestShutdownFailureRoutingManagerError(t *testing.T) { /*** nodeb 1 connected ***/ nodeb1connected := *nodeb1 nodeb1connected.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1connected, "RAN_CONNECTION_STATUS_CHANGE", "test1_DISCONNECTED").Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1connected, "test1_DISCONNECTED").Return(nil) nodeb1NotAssociated := *nodeb1 nodeb1NotAssociated.AssociatedE2TInstanceAddress = "" @@ -306,7 +301,7 @@ func TestShutdownFailureRoutingManagerError(t *testing.T) { /*** nodeb 5 connected ***/ nodeb5connected := *nodeb5 nodeb5connected.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb5connected, "RAN_CONNECTION_STATUS_CHANGE", "test5_DISCONNECTED").Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb5connected, "test5_DISCONNECTED").Return(nil) nodeb5NotAssociated := *nodeb5 nodeb5NotAssociated.AssociatedE2TInstanceAddress = "" @@ -322,7 +317,7 @@ func TestShutdownFailureRoutingManagerError(t *testing.T) { } func TestShutdownFailureInClearNodebsAssociation(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -334,7 +329,7 @@ func TestShutdownFailureInClearNodebsAssociation(t *testing.T) { nodeb1new := *nodeb1 nodeb1new.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1new, "RAN_CONNECTION_STATUS_CHANGE", "test1_DISCONNECTED").Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1new, "test1_DISCONNECTED").Return(nil) nodeb1NotAssociated := *nodeb1 nodeb1NotAssociated.AssociatedE2TInstanceAddress = "" @@ -350,7 +345,7 @@ func TestShutdownFailureInClearNodebsAssociation(t *testing.T) { } func TestShutdownFailureInClearNodebsAssociation_UpdateConnectionStatus(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -362,7 +357,7 @@ func TestShutdownFailureInClearNodebsAssociation_UpdateConnectionStatus(t *testi nodeb1new := *nodeb1 nodeb1new.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1new, "RAN_CONNECTION_STATUS_CHANGE", "test1_DISCONNECTED").Return(common.NewInternalError(fmt.Errorf("for tests"))) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1new, "test1_DISCONNECTED").Return(common.NewInternalError(fmt.Errorf("for tests"))) err := shutdownManager.Shutdown(e2tInstance1) @@ -373,7 +368,7 @@ func TestShutdownFailureInClearNodebsAssociation_UpdateConnectionStatus(t *testi } func TestShutdownResourceNotFoundErrorInGetNodeb(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -387,7 +382,7 @@ func TestShutdownResourceNotFoundErrorInGetNodeb(t *testing.T) { nodeb1new := *nodeb1 nodeb1new.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1new, "RAN_CONNECTION_STATUS_CHANGE", "test1_DISCONNECTED").Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1new, "test1_DISCONNECTED").Return(nil) nodeb1NotAssociated := *nodeb1 nodeb1NotAssociated.AssociatedE2TInstanceAddress = "" @@ -403,7 +398,7 @@ func TestShutdownResourceNotFoundErrorInGetNodeb(t *testing.T) { } func TestShutdownResourceGeneralErrorInGetNodeb(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -444,7 +439,7 @@ func TestShutdownResourceGeneralErrorInGetNodeb(t *testing.T) { } func TestShutdownFailureInRemoveE2TInstance(t *testing.T) { - shutdownManager, readerMock, writerMock, httpClientMock, _ := initE2TShutdownManagerTest(t) + shutdownManager, readerMock, writerMock, httpClientMock := initE2TShutdownManagerTest(t) e2tInstance1 := entities.NewE2TInstance(E2TAddress, PodName) e2tInstance1.State = entities.Active @@ -475,7 +470,7 @@ func TestShutdownFailureInRemoveE2TInstance(t *testing.T) { /*** nodeb 1 connected ***/ nodeb1connected := *nodeb1 nodeb1connected.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1connected, "RAN_CONNECTION_STATUS_CHANGE", "test1_DISCONNECTED").Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb1connected, "test1_DISCONNECTED").Return(nil) nodeb1NotAssociated := *nodeb1 nodeb1NotAssociated.AssociatedE2TInstanceAddress = "" @@ -495,7 +490,7 @@ func TestShutdownFailureInRemoveE2TInstance(t *testing.T) { /*** nodeb 5 connected ***/ nodeb5connected := *nodeb5 nodeb5connected.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb5connected, "RAN_CONNECTION_STATUS_CHANGE", "test5_DISCONNECTED").Return(nil) + writerMock.On("UpdateNodebInfoOnConnectionStatusInversion", &nodeb5connected, "test5_DISCONNECTED").Return(nil) nodeb5NotAssociated := *nodeb5 nodeb5NotAssociated.AssociatedE2TInstanceAddress = ""