From 5c9533257e79cc65d506df54105933bf5844e7ab Mon Sep 17 00:00:00 2001 From: is005q Date: Sun, 5 Jan 2020 16:22:47 +0200 Subject: [PATCH] [RICPLT-2590] US completion........ Change-Id: I887014d126485201f526d1e7ff03cc2e82e097b9 Signed-off-by: is005q --- .../Tests/RedButton/RedButton_CONNECTED.robot | 3 + .../RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot | 3 + .../RedButton/RedButton_CONNECTION_FAILURE.robot | 4 ++ .../Tests/RedButton/RedButton_DISCONNECTED.robot | 5 +- .../RedButton/RedButton_SHUTDOWN_SHUTDOWN.robot | 9 ++- .../Tests/RedButton/red_button_keywords.robot | 8 +-- Automation/Tests/Scripts/e2mdbscripts.py | 8 +++ E2Manager/configuration/configuration_test.go | 4 +- .../httpmsghandlers/delete_all_request_handler.go | 73 +++++++++++++++------- E2Manager/managers/e2t_instances_manager.go | 2 +- E2Manager/resources/configuration.yaml | 4 +- E2Manager/services/rnib_data_service.go | 11 +++- 12 files changed, 97 insertions(+), 37 deletions(-) diff --git a/Automation/Tests/RedButton/RedButton_CONNECTED.robot b/Automation/Tests/RedButton/RedButton_CONNECTED.robot index ed75f4c..6a0f312 100644 --- a/Automation/Tests/RedButton/RedButton_CONNECTED.robot +++ b/Automation/Tests/RedButton/RedButton_CONNECTED.robot @@ -41,3 +41,6 @@ Execute Shutdown Verify nodeb's connection status is SHUT_DOWN and it's NOT associated to an e2t instance Verify shutdown for enb +Verify E2T instance has no associated RANs + Verify E2T instance has no associated RANs + diff --git a/Automation/Tests/RedButton/RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot b/Automation/Tests/RedButton/RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot index 4c9c974..cbb02b4 100644 --- a/Automation/Tests/RedButton/RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot +++ b/Automation/Tests/RedButton/RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot @@ -40,6 +40,9 @@ Execute Shutdown Verify nodeb's connection status is SHUT_DOWN and it's NOT associated to an e2t instance Verify shutdown for enb +Verify E2T instance has no associated RANs + Verify E2T instance has no associated RANs + Restart simulator Restart simulator diff --git a/Automation/Tests/RedButton/RedButton_CONNECTION_FAILURE.robot b/Automation/Tests/RedButton/RedButton_CONNECTION_FAILURE.robot index 0b96a94..291171a 100644 --- a/Automation/Tests/RedButton/RedButton_CONNECTION_FAILURE.robot +++ b/Automation/Tests/RedButton/RedButton_CONNECTION_FAILURE.robot @@ -41,3 +41,7 @@ Execute Shutdown Verify nodeb's connection status is SHUT_DOWN and it's NOT associated to an e2t instance Verify shutdown for enb +Verify E2T instance has no associated RANs + Verify E2T instance has no associated RANs + + diff --git a/Automation/Tests/RedButton/RedButton_DISCONNECTED.robot b/Automation/Tests/RedButton/RedButton_DISCONNECTED.robot index 1156bd2..7bf7c82 100644 --- a/Automation/Tests/RedButton/RedButton_DISCONNECTED.robot +++ b/Automation/Tests/RedButton/RedButton_DISCONNECTED.robot @@ -51,4 +51,7 @@ Execute Shutdown Execute Shutdown Verify nodeb's connection status is SHUT_DOWN and it's NOT associated to an e2t instance - Verify shutdown for gnb \ No newline at end of file + Verify shutdown for gnb + +Verify E2T instance has no associated RANs + Verify E2T instance has no associated RANs diff --git a/Automation/Tests/RedButton/RedButton_SHUTDOWN_SHUTDOWN.robot b/Automation/Tests/RedButton/RedButton_SHUTDOWN_SHUTDOWN.robot index f97e384..fbab47b 100644 --- a/Automation/Tests/RedButton/RedButton_SHUTDOWN_SHUTDOWN.robot +++ b/Automation/Tests/RedButton/RedButton_SHUTDOWN_SHUTDOWN.robot @@ -40,8 +40,15 @@ Execute Shutdown Verify nodeb's connection status is SHUT_DOWN and it's NOT associated to an e2t instance Verify shutdown for enb +Verify E2T instance has no associated RANs + Verify E2T instance has no associated RANs + + Execute second Shutdown Execute Shutdown Verify again nodeb's connection status is SHUT_DOWN and it's NOT associated to an e2t instance - Verify shutdown for enb \ No newline at end of file + Verify shutdown for enb + +Verify again E2T instance has no associated RANs + Verify E2T instance has no associated RANs diff --git a/Automation/Tests/RedButton/red_button_keywords.robot b/Automation/Tests/RedButton/red_button_keywords.robot index 34bd6ef..c743543 100644 --- a/Automation/Tests/RedButton/red_button_keywords.robot +++ b/Automation/Tests/RedButton/red_button_keywords.robot @@ -50,8 +50,6 @@ Verify shutdown for enb String response body ranName test1 String response body connectionStatus SHUT_DOWN Missing response body associatedE2tInstanceAddress - ${result} e2mdbscripts.verify_ran_is_associated_with_e2t_instance test1 e2t.att.com:38000 - Should Be True ${result} == False Verify shutdown for gnb @@ -60,8 +58,10 @@ Verify shutdown for gnb String response body ranName test2 String response body connectionStatus SHUT_DOWN Missing response body associatedE2tInstanceAddress - ${result} e2mdbscripts.verify_ran_is_associated_with_e2t_instance test2 e2t.att.com:38000 - Should Be True ${result} == False + +Verify E2T instance has no associated RANs + ${result} e2mdbscripts.verify_e2t_instance_has_no_associated_rans e2t.att.com:38000 + Should Be True ${result} Execute Shutdown PUT /v1/nodeb/shutdown diff --git a/Automation/Tests/Scripts/e2mdbscripts.py b/Automation/Tests/Scripts/e2mdbscripts.py index 6753f80..936346b 100644 --- a/Automation/Tests/Scripts/e2mdbscripts.py +++ b/Automation/Tests/Scripts/e2mdbscripts.py @@ -33,6 +33,14 @@ def verify_ran_is_associated_with_e2t_instance(ranName, e2tAddress): assocRanList = e2tInstanceDic.get("associatedRanList") return ranName in assocRanList +def verify_e2t_instance_has_no_associated_rans(e2tAddress): + r = getRedisClientDecodeResponse() + e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress) + e2tInstanceDic = json.loads(e2tInstanceJson) + assocRanList = e2tInstanceDic.get("associatedRanList") + return not assocRanList + + def populate_e2t_instances_in_e2m_db_for_get_e2t_instances_tc(): r = getRedisClientDecodeResponse() r.set("{e2Manager},E2TAddresses", "[\"e2t.att.com:38000\",\"e2t.att.com:38001\"]") diff --git a/E2Manager/configuration/configuration_test.go b/E2Manager/configuration/configuration_test.go index ec16c1f..b83c661 100644 --- a/E2Manager/configuration/configuration_test.go +++ b/E2Manager/configuration/configuration_test.go @@ -36,8 +36,8 @@ func TestParseConfigurationSuccess(t *testing.T) { assert.Equal(t, "info", config.Logging.LogLevel) assert.Equal(t, 100, config.NotificationResponseBuffer) assert.Equal(t, 5, config.BigRedButtonTimeoutSec) - assert.Equal(t, 1500, config.KeepAliveResponseTimeoutMs) - assert.Equal(t, 500, config.KeepAliveDelayMs) + assert.Equal(t, 4500, config.KeepAliveResponseTimeoutMs) + assert.Equal(t, 1500, config.KeepAliveDelayMs) } func TestParseConfigurationFileNotFoundFailure(t *testing.T) { diff --git a/E2Manager/handlers/httpmsghandlers/delete_all_request_handler.go b/E2Manager/handlers/httpmsghandlers/delete_all_request_handler.go index 869890a..975640a 100644 --- a/E2Manager/handlers/httpmsghandlers/delete_all_request_handler.go +++ b/E2Manager/handlers/httpmsghandlers/delete_all_request_handler.go @@ -30,6 +30,7 @@ import ( "e2mgr/rmrCgo" "e2mgr/services" "e2mgr/services/rmrsender" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common" "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" "time" ) @@ -43,6 +44,8 @@ type DeleteAllRequestHandler struct { rmClient clients.IRoutingManagerClient } +const PartialSuccessDueToRmErrorMessage = "Operation succeeded except for routing manager outbound call" + func NewDeleteAllRequestHandler(logger *logger.Logger, rmrSender *rmrsender.RmrSender, config *configuration.Configuration, rnibDataService services.RNibDataService, e2tInstancesManager managers.IE2TInstancesManager, rmClient clients.IRoutingManagerClient) *DeleteAllRequestHandler { return &DeleteAllRequestHandler{ logger: logger, @@ -55,6 +58,7 @@ func NewDeleteAllRequestHandler(logger *logger.Logger, rmrSender *rmrsender.RmrS } func (h *DeleteAllRequestHandler) Handle(request models.Request) (models.IResponse, error) { + h.logger.Infof("#DeleteAllRequestHandler.Handle - handling shutdown request") e2tAddresses, err := h.e2tInstancesManager.GetE2TAddresses() @@ -73,7 +77,7 @@ func (h *DeleteAllRequestHandler) Handle(request models.Request) (models.IRespon h.logger.Warnf("#DeleteAllRequestHandler.Handle - routing manager failure. continue flow.") } - err, allRansAreShutDown := h.updateNodebs(h.updateNodebInfoShuttingDown) + err, updatedAtLeastOnce := h.updateNodebs(h.updateNodebInfoShuttingDown) if err != nil { return nil, err @@ -94,10 +98,11 @@ func (h *DeleteAllRequestHandler) Handle(request models.Request) (models.IRespon return nil, e2managererrors.NewRmrError() } - if allRansAreShutDown { + if !updatedAtLeastOnce { + h.logger.Infof("#DeleteAllRequestHandler.Handle - DB wasn't updated, not activating timer") if dissocErr != nil { - return models.NewRedButtonPartialSuccessResponseModel("Operation succeeded, except Routing Manager failure"), nil + return models.NewRedButtonPartialSuccessResponseModel(PartialSuccessDueToRmErrorMessage), nil } return nil, nil @@ -113,13 +118,13 @@ func (h *DeleteAllRequestHandler) Handle(request models.Request) (models.IRespon } if dissocErr != nil { - return models.NewRedButtonPartialSuccessResponseModel("Operation succeeded, except Routing Manager failure"), nil + return models.NewRedButtonPartialSuccessResponseModel(PartialSuccessDueToRmErrorMessage), nil } return nil, nil } -func (h *DeleteAllRequestHandler) updateNodebs(updateCb func(node *entities.NodebInfo) error) (error, bool) { +func (h *DeleteAllRequestHandler) updateNodebs(updateCb func(node *entities.NodebInfo) (error, bool)) (error, bool) { nbIdentityList, err := h.rnibDataService.GetListNodebIds() if err != nil { @@ -127,54 +132,76 @@ func (h *DeleteAllRequestHandler) updateNodebs(updateCb func(node *entities.Node return e2managererrors.NewRnibDbError(), false } - allRansAreShutdown := true + updatedAtLeastOnce := false for _, nbIdentity := range nbIdentityList { node, err := h.rnibDataService.GetNodeb(nbIdentity.InventoryName) if err != nil { - h.logger.Errorf("#DeleteAllRequestHandler.updateNodebs - failed to get nodeB entity for ran name: %s from rNib. error: %s", nbIdentity.InventoryName, err) - return e2managererrors.NewRnibDbError(), false - } + _, ok := err.(*common.ResourceNotFoundError) - if node.ConnectionStatus != entities.ConnectionStatus_SHUT_DOWN { - allRansAreShutdown = false + if !ok { + h.logger.Errorf("#DeleteAllRequestHandler.updateNodebs - failed to get nodeB entity for ran name: %s from rNib. error: %s", nbIdentity.InventoryName, err) + return e2managererrors.NewRnibDbError(), false + } + continue } - err = updateCb(node) + err, updated := updateCb(node) if err != nil { return err, false } - } - return nil, allRansAreShutdown + if updated { + updatedAtLeastOnce = true + } + } + return nil, updatedAtLeastOnce } -func (h *DeleteAllRequestHandler) updateNodebInfoForceShutdown(node *entities.NodebInfo) error { - return h.updateNodebInfo(node, entities.ConnectionStatus_SHUT_DOWN, true) +func (h *DeleteAllRequestHandler) updateNodebInfoForceShutdown(node *entities.NodebInfo) (error, bool) { + err := h.updateNodebInfo(node, entities.ConnectionStatus_SHUT_DOWN, true) + + if err != nil { + return err, false + } + + return nil, true } -func (h *DeleteAllRequestHandler) updateNodebInfoShuttingDown(node *entities.NodebInfo) error { +func (h *DeleteAllRequestHandler) updateNodebInfoShuttingDown(node *entities.NodebInfo) (error, bool) { if node.ConnectionStatus == entities.ConnectionStatus_SHUT_DOWN { - return nil + return nil, false } - return h.updateNodebInfo(node, entities.ConnectionStatus_SHUTTING_DOWN, true) + err := h.updateNodebInfo(node, entities.ConnectionStatus_SHUTTING_DOWN, true) + + if err != nil { + return err, false + } + + return nil, true } -func (h *DeleteAllRequestHandler) updateNodebInfoShutDown(node *entities.NodebInfo) error { +func (h *DeleteAllRequestHandler) updateNodebInfoShutDown(node *entities.NodebInfo) (error, bool) { if node.ConnectionStatus == entities.ConnectionStatus_SHUT_DOWN { - return nil + return nil, false } if node.ConnectionStatus != entities.ConnectionStatus_SHUTTING_DOWN { h.logger.Warnf("#DeleteAllRequestHandler.updateNodebInfoShutDown - RAN name: %s - ignore, status is not Shutting Down", node.RanName) - return nil + return nil, false + } + + err := h.updateNodebInfo(node, entities.ConnectionStatus_SHUT_DOWN, false) + + if err != nil { + return err, false } - return h.updateNodebInfo(node, entities.ConnectionStatus_SHUT_DOWN, false) + return nil, true } func (h *DeleteAllRequestHandler) updateNodebInfo(node *entities.NodebInfo, connectionStatus entities.ConnectionStatus, resetAssociatedE2TAddress bool) error { diff --git a/E2Manager/managers/e2t_instances_manager.go b/E2Manager/managers/e2t_instances_manager.go index c970c76..1e12943 100644 --- a/E2Manager/managers/e2t_instances_manager.go +++ b/E2Manager/managers/e2t_instances_manager.go @@ -372,7 +372,7 @@ func (m *E2TInstancesManager) ResetKeepAliveTimestamp(e2tAddress string) error { } func (m *E2TInstancesManager) ClearRansOfAllE2TInstances() error { - + m.logger.Infof("#E2TInstancesManager.ClearRansOfAllE2TInstances - Going to clear associated RANs from E2T instances") m.mux.Lock() defer m.mux.Unlock() diff --git a/E2Manager/resources/configuration.yaml b/E2Manager/resources/configuration.yaml index 0914b88..b70ddfc 100644 --- a/E2Manager/resources/configuration.yaml +++ b/E2Manager/resources/configuration.yaml @@ -12,5 +12,5 @@ bigRedButtonTimeoutSec: 5 maxConnectionAttempts: 3 maxRnibConnectionAttempts: 3 rnibRetryIntervalMs: 10 -keepAliveResponseTimeoutMs: 1500 -keepAliveDelayMs: 500 +keepAliveResponseTimeoutMs: 4500 +keepAliveDelayMs: 1500 diff --git a/E2Manager/services/rnib_data_service.go b/E2Manager/services/rnib_data_service.go index 1274c53..1a5af59 100644 --- a/E2Manager/services/rnib_data_service.go +++ b/E2Manager/services/rnib_data_service.go @@ -101,7 +101,6 @@ func (w *rNibDataService) SaveRanLoadInformation(inventoryName string, ranLoadIn } func (w *rNibDataService) GetNodeb(ranName string) (*entities.NodebInfo, error) { - w.logger.Infof("#RnibDataService.GetNodeb - RAN name: %s", ranName) var nodeb *entities.NodebInfo = nil @@ -110,12 +109,14 @@ func (w *rNibDataService) GetNodeb(ranName string) (*entities.NodebInfo, error) return }) + if err == nil { + w.logger.Infof("#RnibDataService.GetNodeb - RAN name: %s, connection status: %s", nodeb.RanName, nodeb.ConnectionStatus) + } + return nodeb, err } func (w *rNibDataService) GetListNodebIds() ([]*entities.NbIdentity, error) { - w.logger.Infof("#RnibDataService.GetListNodebIds") - var nodeIds []*entities.NbIdentity = nil err := w.retry("GetListNodebIds", func() (err error) { @@ -123,6 +124,10 @@ func (w *rNibDataService) GetListNodebIds() ([]*entities.NbIdentity, error) { return }) + if err == nil { + w.logger.Infof("#RnibDataService.GetListNodebIds - RANs count: %d", len(nodeIds)) + } + return nodeIds, err } -- 2.16.6