From d36bbc4b8f5a0798b46d9631af1a264979f4a28b Mon Sep 17 00:00:00 2001 From: is005q Date: Sun, 15 Dec 2019 20:40:57 +0200 Subject: [PATCH] [RICPLT-2523] Acceptance fixes - RnibDataService / E2TInstancesManager... Change-Id: I3e6918b0d4955e8d51f2f7d5757a4e0579810664 Signed-off-by: is005q --- E2Manager/managers/e2t_instances_manager.go | 36 +++++++++++----------- .../managers/ran_reconnection_manager_test.go | 4 +-- E2Manager/services/rnib_data_service.go | 18 ++++++----- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/E2Manager/managers/e2t_instances_manager.go b/E2Manager/managers/e2t_instances_manager.go index d4bff65..6800d2b 100644 --- a/E2Manager/managers/e2t_instances_manager.go +++ b/E2Manager/managers/e2t_instances_manager.go @@ -58,9 +58,9 @@ func (m *E2TInstancesManager) GetE2TInstance(e2tAddress string) (*entities.E2TIn _, ok := err.(*common.ResourceNotFoundError) if !ok { - m.logger.Errorf("#GetE2TInstance - E2T Instance address: %s - Failed retrieving E2TInstance. error: %s", e2tAddress, err) + m.logger.Errorf("#E2TInstancesManager.GetE2TInstance - E2T Instance address: %s - Failed retrieving E2TInstance. error: %s", e2tAddress, err) } else { - m.logger.Infof("#GetE2TInstance - E2T Instance address: %s not found on DB", e2tAddress) + m.logger.Infof("#E2TInstancesManager.GetE2TInstance - E2T Instance address: %s not found on DB", e2tAddress) } } @@ -76,7 +76,7 @@ func (m *E2TInstancesManager) GetE2TInstances() ([]*entities.E2TInstance, error) } if len(e2tAddresses) == 0 { - m.logger.Warnf("#E2TInstancesManager.GetE2TInstances - Empty E2T addresses list") + m.logger.Infof("#E2TInstancesManager.GetE2TInstances - Empty E2T addresses list") return []*entities.E2TInstance{}, nil } @@ -111,16 +111,17 @@ func findActiveE2TInstanceWithMinimumAssociatedRans(e2tInstances []*entities.E2T func (m *E2TInstancesManager) AddE2TInstance(e2tAddress string) error { + m.mux.Lock() + defer m.mux.Unlock() + e2tInstance := entities.NewE2TInstance(e2tAddress) err := m.rnibDataService.SaveE2TInstance(e2tInstance) if err != nil { - m.logger.Errorf("#AddE2TInstance - E2T Instance address: %s - Failed saving E2T instance. error: %s", e2tInstance.Address, err) + m.logger.Errorf("#E2TInstancesManager.AddE2TInstance - E2T Instance address: %s - Failed saving E2T instance. error: %s", e2tInstance.Address, err) return err } - m.mux.Lock() - defer m.mux.Unlock() e2tAddresses, err := m.rnibDataService.GetE2TAddresses() @@ -129,7 +130,7 @@ func (m *E2TInstancesManager) AddE2TInstance(e2tAddress string) error { _, ok := err.(*common.ResourceNotFoundError) if !ok { - m.logger.Errorf("#AddE2TInstance - E2T Instance address: %s - Failed retrieving E2T addresses list. error: %s", e2tInstance.Address, err) + m.logger.Errorf("#E2TInstancesManager.AddE2TInstance - E2T Instance address: %s - Failed retrieving E2T addresses list. error: %s", e2tInstance.Address, err) return err } } @@ -139,11 +140,11 @@ func (m *E2TInstancesManager) AddE2TInstance(e2tAddress string) error { err = m.rnibDataService.SaveE2TAddresses(e2tAddresses) if err != nil { - m.logger.Errorf("#AddE2TInstance - E2T Instance address: %s - Failed saving E2T addresses list. error: %s", e2tInstance.Address, err) + m.logger.Errorf("#E2TInstancesManager.AddE2TInstance - E2T Instance address: %s - Failed saving E2T addresses list. error: %s", e2tInstance.Address, err) return err } - m.logger.Infof("#AddE2TInstance - E2T Instance address: %s - successfully added E2T instance", e2tInstance.Address) + m.logger.Infof("#E2TInstancesManager.AddE2TInstance - E2T Instance address: %s - successfully added E2T instance", e2tInstance.Address) return nil } @@ -155,7 +156,7 @@ func (m *E2TInstancesManager) DissociateRan(ranName string, e2tAddress string) e e2tInstance, err := m.rnibDataService.GetE2TInstance(e2tAddress) if err != nil { - m.logger.Errorf("#DissociateRan - E2T Instance address: %s - Failed retrieving E2TInstance. error: %s", e2tAddress, err) + m.logger.Errorf("#E2TInstancesManager.DissociateRan - E2T Instance address: %s - Failed retrieving E2TInstance. error: %s", e2tAddress, err) return err } @@ -173,11 +174,11 @@ func (m *E2TInstancesManager) DissociateRan(ranName string, e2tAddress string) e err = m.rnibDataService.SaveE2TInstance(e2tInstance) if err != nil { - m.logger.Errorf("#DissociateRan - E2T Instance address: %s - Failed saving E2TInstance. error: %s", e2tAddress, err) + m.logger.Errorf("#E2TInstancesManager.DissociateRan - E2T Instance address: %s - Failed saving E2TInstance. error: %s", e2tAddress, err) return err } - m.logger.Infof("#DissociateRan - successfully dissociated RAN %s from E2T %s", ranName, e2tInstance.Address) + m.logger.Infof("#E2TInstancesManager.DissociateRan - successfully dissociated RAN %s from E2T %s", ranName, e2tInstance.Address) return nil } @@ -189,7 +190,6 @@ func (m *E2TInstancesManager) SelectE2TInstance() (string, error) { e2tInstances, err := m.GetE2TInstances() if err != nil { - m.logger.Errorf("#E2TInstancesManager.SelectE2TInstance - failed retrieving E2T instances. error: %s", err) return "", e2managererrors.NewRnibDbError() } @@ -201,11 +201,11 @@ func (m *E2TInstancesManager) SelectE2TInstance() (string, error) { min := findActiveE2TInstanceWithMinimumAssociatedRans(e2tInstances) if min == nil { - m.logger.Errorf("#SelectE2TInstance - No active E2T instance found") + m.logger.Errorf("#E2TInstancesManager.SelectE2TInstance - No active E2T instance found") return "", e2managererrors.NewE2TInstanceAbsenceError() } - m.logger.Infof("#SelectE2TInstance - successfully selected E2T instance. address: %s", min.Address) + m.logger.Infof("#E2TInstancesManager.SelectE2TInstance - successfully selected E2T instance. address: %s", min.Address) return min.Address, nil } @@ -217,7 +217,7 @@ func (m *E2TInstancesManager) AssociateRan(ranName string, e2tAddress string) er e2tInstance, err := m.rnibDataService.GetE2TInstance(e2tAddress) if err != nil { - m.logger.Errorf("#AssociateRan - E2T Instance address: %s - Failed retrieving E2TInstance. error: %s", e2tAddress, err) + m.logger.Errorf("#E2TInstancesManager.AssociateRan - E2T Instance address: %s - Failed retrieving E2TInstance. error: %s", e2tAddress, err) return e2managererrors.NewRnibDbError() } @@ -226,10 +226,10 @@ func (m *E2TInstancesManager) AssociateRan(ranName string, e2tAddress string) er err = m.rnibDataService.SaveE2TInstance(e2tInstance) if err != nil { - m.logger.Errorf("#AssociateRan - E2T Instance address: %s - Failed saving E2TInstance. error: %s", e2tAddress, err) + m.logger.Errorf("#E2TInstancesManager.AssociateRan - E2T Instance address: %s - Failed saving E2TInstance. error: %s", e2tAddress, err) return e2managererrors.NewRnibDbError() } - m.logger.Infof("#AssociateRan - successfully associated RAN %s with E2T %s", ranName, e2tInstance.Address) + m.logger.Infof("#E2TInstancesManager.AssociateRan - successfully associated RAN %s with E2T %s", ranName, e2tInstance.Address) return nil } diff --git a/E2Manager/managers/ran_reconnection_manager_test.go b/E2Manager/managers/ran_reconnection_manager_test.go index a78dd93..86d9a7c 100644 --- a/E2Manager/managers/ran_reconnection_manager_test.go +++ b/E2Manager/managers/ran_reconnection_manager_test.go @@ -92,7 +92,7 @@ func TestShuttingdownRanReconnection(t *testing.T) { writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 1) } -func TestConnectingRanWithMaxAttemptsReconnectionDeassociateSucceeds(t *testing.T) { +func TestConnectingRanWithMaxAttemptsReconnectionDissociateSucceeds(t *testing.T) { _, _, readerMock, writerMock, ranReconnectionManager, e2tInstancesManagerMock := initRanLostConnectionTest(t) ranName := "test" e2tAddress := "10.0.2.15" @@ -111,7 +111,7 @@ func TestConnectingRanWithMaxAttemptsReconnectionDeassociateSucceeds(t *testing. e2tInstancesManagerMock.AssertCalled(t, "DissociateRan", ranName, e2tAddress) } -func TestConnectingRanWithMaxAttemptsReconnectionDeassociateFails(t *testing.T) { +func TestConnectingRanWithMaxAttemptsReconnectionDissociateFails(t *testing.T) { _, _, readerMock, writerMock, ranReconnectionManager, e2tInstancesManagerMock := initRanLostConnectionTest(t) ranName := "test" e2tAddress := "10.0.2.15" diff --git a/E2Manager/services/rnib_data_service.go b/E2Manager/services/rnib_data_service.go index 2761239..bc6b8ef 100644 --- a/E2Manager/services/rnib_data_service.go +++ b/E2Manager/services/rnib_data_service.go @@ -120,7 +120,6 @@ func (w *rNibDataService) GetListNodebIds() ([]*entities.NbIdentity, error) { } func (w *rNibDataService) GetE2TInstance(address string) (*entities.E2TInstance, error) { - w.logger.Infof("#RnibDataService.GetE2TInstance") var e2tInstance *entities.E2TInstance = nil @@ -129,12 +128,15 @@ func (w *rNibDataService) GetE2TInstance(address string) (*entities.E2TInstance, return }) + if err == nil { + w.logger.Infof("#RnibDataService.GetE2TInstance - E2T instance address: %s, state: %s, associated RANs count: %d, keep Alive ts: %d", e2tInstance.Address, e2tInstance.State, len(e2tInstance.AssociatedRanList), e2tInstance.KeepAliveTimestamp) + } + return e2tInstance, err } func (w *rNibDataService) GetE2TInstances(addresses []string) ([]*entities.E2TInstance, error) { - w.logger.Infof("#RnibDataService.GetE2TInstances") - + w.logger.Infof("#RnibDataService.GetE2TInstances - addresses: %s", addresses) var e2tInstances []*entities.E2TInstance = nil err := w.retry("GetE2TInstance", func() (err error) { @@ -146,7 +148,6 @@ func (w *rNibDataService) GetE2TInstances(addresses []string) ([]*entities.E2TIn } func (w *rNibDataService) GetE2TAddresses() ([]string, error) { - w.logger.Infof("#RnibDataService.GetE2TAddresses") var e2tAddresses []string = nil @@ -155,12 +156,15 @@ func (w *rNibDataService) GetE2TAddresses() ([]string, error) { return }) + if err == nil { + w.logger.Infof("#RnibDataService.GetE2TAddresses - addresses: %s", e2tAddresses) + } + return e2tAddresses, err } func (w *rNibDataService) SaveE2TInstance(e2tInstance *entities.E2TInstance) error { - w.logger.Infof("#RnibDataService.SaveE2TInstance") - + w.logger.Infof("#RnibDataService.SaveE2TInstance - E2T instance address: %s, state: %s, associated RANs count: %d, keep Alive ts: %d", e2tInstance.Address, e2tInstance.State, len(e2tInstance.AssociatedRanList), e2tInstance.KeepAliveTimestamp) err := w.retry("SaveE2TInstance", func() (err error) { err = w.rnibWriter.SaveE2TInstance(e2tInstance) return @@ -170,7 +174,7 @@ func (w *rNibDataService) SaveE2TInstance(e2tInstance *entities.E2TInstance) err } func (w *rNibDataService) SaveE2TAddresses(addresses []string) error { - w.logger.Infof("#RnibDataService.SaveE2TAddresses") + w.logger.Infof("#RnibDataService.SaveE2TAddresses - addresses: %s", addresses) err := w.retry("SaveE2TAddresses", func() (err error) { err = w.rnibWriter.SaveE2TAddresses(addresses) -- 2.16.6