Added timer & change status to connected state. 95/10695/2
authornaman.gupta <naman.gupta@samsung.com>
Thu, 9 Mar 2023 08:25:45 +0000 (13:55 +0530)
committernaman.gupta <naman.gupta@samsung.com>
Fri, 10 Mar 2023 10:44:32 +0000 (16:14 +0530)
Added timer for e2 reset handling & changing status to connected state
after timeout.

Signed-off-by: naman.gupta <naman.gupta@samsung.com>
Change-Id: I979adcc64ddb3b5d1a486242acc0a3295c653325

E2Manager/configuration/configuration.go
E2Manager/configuration/configuration_test.go
E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler.go
E2Manager/handlers/rmrmsghandlers/e2_reset_request_handler_test.go
E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go
E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go
E2Manager/resources/configuration.yaml

index 8582edd..56b9d1e 100644 (file)
@@ -22,8 +22,9 @@ package configuration
 import (
        "errors"
        "fmt"
-       "github.com/spf13/viper"
        "strconv"
+
+       "github.com/spf13/viper"
 )
 
 type RnibWriterConfig struct {
@@ -53,6 +54,7 @@ type Configuration struct {
        KeepAliveResponseTimeoutMs   int
        KeepAliveDelayMs             int
        E2TInstanceDeletionTimeoutMs int
+       E2ResetTimeOutSec            int
        GlobalRicId                  struct {
                RicId string
                Mcc   string
@@ -85,6 +87,8 @@ func ParseConfiguration() *Configuration {
        config.KeepAliveResponseTimeoutMs = viper.GetInt("keepAliveResponseTimeoutMs")
        config.KeepAliveDelayMs = viper.GetInt("KeepAliveDelayMs")
        config.E2TInstanceDeletionTimeoutMs = viper.GetInt("e2tInstanceDeletionTimeoutMs")
+       //E2ResetTimeOutSec : timeout expiry threshold required for handling reset and thus the time for which the nodeb is under reset connection state.
+       config.E2ResetTimeOutSec = viper.GetInt("e2ResetTimeOutSec")
        config.populateGlobalRicIdConfig(viper.Sub("globalRicId"))
        config.populateRnibWriterConfig(viper.Sub("rnibWriter"))
        return &config
@@ -229,7 +233,7 @@ func validateRicId(ricId string) error {
 func (c *Configuration) String() string {
        return fmt.Sprintf("{logging.logLevel: %s, http.port: %d, rmr: { port: %d, maxMsgSize: %d}, routingManager.baseUrl: %s, "+
                "notificationResponseBuffer: %d, bigRedButtonTimeoutSec: %d, maxRnibConnectionAttempts: %d, "+
-               "rnibRetryIntervalMs: %d, keepAliveResponseTimeoutMs: %d, keepAliveDelayMs: %d, e2tInstanceDeletionTimeoutMs: %d, "+
+               "rnibRetryIntervalMs: %d, keepAliveResponseTimeoutMs: %d, keepAliveDelayMs: %d, e2tInstanceDeletionTimeoutMs: %d,e2ResetTimeOutSec: %d,"+
                "globalRicId: { ricId: %s, mcc: %s, mnc: %s}, rnibWriter: { stateChangeMessageChannel: %s, ranManipulationChannel: %s}",
                c.Logging.LogLevel,
                c.Http.Port,
@@ -243,6 +247,7 @@ func (c *Configuration) String() string {
                c.KeepAliveResponseTimeoutMs,
                c.KeepAliveDelayMs,
                c.E2TInstanceDeletionTimeoutMs,
+               c.E2ResetTimeOutSec,
                c.GlobalRicId.RicId,
                c.GlobalRicId.Mcc,
                c.GlobalRicId.Mnc,
index 01a0a83..d7d5970 100644 (file)
 package configuration
 
 import (
-       "github.com/stretchr/testify/assert"
-       "gopkg.in/yaml.v2"
        "io/ioutil"
        "os"
        "testing"
+
+       "github.com/stretchr/testify/assert"
+       "gopkg.in/yaml.v2"
 )
 
 func TestParseConfigurationSuccess(t *testing.T) {
@@ -38,6 +39,7 @@ func TestParseConfigurationSuccess(t *testing.T) {
        assert.Equal(t, 4500, config.KeepAliveResponseTimeoutMs)
        assert.Equal(t, 1500, config.KeepAliveDelayMs)
        assert.Equal(t, 15000, config.E2TInstanceDeletionTimeoutMs)
+       assert.Equal(t, 10, config.E2ResetTimeOutSec)
        assert.NotNil(t, config.GlobalRicId)
        assert.Equal(t, "AACCE", config.GlobalRicId.RicId)
        assert.Equal(t, "310", config.GlobalRicId.Mcc)
@@ -239,7 +241,7 @@ func TestRnibWriterConfigNotFoundFailure(t *testing.T) {
                "logging":        map[string]interface{}{"logLevel": "info"},
                "http":           map[string]interface{}{"port": 3800},
                "routingManager": map[string]interface{}{"baseUrl": "http://localhost:8080/ric/v1/handles/"},
-               "globalRicId": map[string]interface{}{"mcc": 327, "mnc": 94, "ricId": "AACCE"},
+               "globalRicId":    map[string]interface{}{"mcc": 327, "mnc": 94, "ricId": "AACCE"},
        }
        buf, err := yaml.Marshal(yamlMap)
        if err != nil {
index a800fef..76a0b1a 100644 (file)
 package rmrmsghandlers\r
 \r
 import (\r
+       "e2mgr/configuration"\r
        "e2mgr/logger"\r
        "e2mgr/models"\r
        "e2mgr/services"\r
        "e2mgr/utils"\r
+       "time"\r
+\r
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"\r
 )\r
 \r
@@ -31,12 +34,14 @@ const E2ResetRequestLogInfoElapsedTime = "#E2ResetRequestNotificationHandler.Han
 type E2ResetRequestNotificationHandler struct {\r
        logger          *logger.Logger\r
        rnibDataService services.RNibDataService\r
+       config          *configuration.Configuration\r
 }\r
 \r
-func NewE2ResetRequestNotificationHandler(logger *logger.Logger, rnibDataService services.RNibDataService) *E2ResetRequestNotificationHandler {\r
+func NewE2ResetRequestNotificationHandler(logger *logger.Logger, rnibDataService services.RNibDataService, config *configuration.Configuration) *E2ResetRequestNotificationHandler {\r
        return &E2ResetRequestNotificationHandler{\r
                logger:          logger,\r
                rnibDataService: rnibDataService,\r
+               config:          config,\r
        }\r
 }\r
 \r
@@ -66,6 +71,19 @@ func (e *E2ResetRequestNotificationHandler) Handle(request *models.NotificationR
        e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity under reset state. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus)\r
 \r
        e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime))\r
+\r
+       e.waitfortimertimeout(request)\r
+\r
+       nodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED\r
+\r
+       err = e.rnibDataService.UpdateNodebInfoAndPublish(nodebInfo)\r
+\r
+       if err != nil {\r
+               e.logger.Errorf("#E2ResetRequestNotificationHandler.Handle - failed to update connection status of nodeB entity. RanName: %s. Error: %s", request.RanName, err.Error())\r
+       }\r
+\r
+       e.logger.Debugf("#E2ResetRequestNotificationHandler.Handle - nodeB entity connected state. RanName %s, ConnectionStatus %s", nodebInfo.RanName, nodebInfo.ConnectionStatus)\r
+\r
 }\r
 \r
 func (e *E2ResetRequestNotificationHandler) getNodebInfo(ranName string) (*entities.NodebInfo, error) {\r
@@ -77,3 +95,15 @@ func (e *E2ResetRequestNotificationHandler) getNodebInfo(ranName string) (*entit
        }\r
        return nodebInfo, err\r
 }\r
+\r
+func (e *E2ResetRequestNotificationHandler) waitfortimertimeout(request *models.NotificationRequest) {\r
+       timeout := e.config.E2ResetTimeOutSec\r
+       for {\r
+               timeElapsed := utils.ElapsedTime(request.StartTime)\r
+               e.logger.Infof(E2ResetRequestLogInfoElapsedTime, utils.ElapsedTime(request.StartTime))\r
+               if int(timeElapsed) > timeout {\r
+                       break\r
+               }\r
+               time.Sleep(time.Duration(timeout/100) * time.Millisecond)\r
+       }\r
+}\r
index 8b15865..c5d8747 100644 (file)
@@ -25,9 +25,10 @@ import (
        "e2mgr/services"\r
        "e2mgr/tests"\r
        "e2mgr/utils"\r
+       "testing"\r
+\r
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"\r
        "github.com/stretchr/testify/mock"\r
-       "testing"\r
 )\r
 \r
 const (\r
@@ -45,7 +46,7 @@ func initE2ResetMocks(t *testing.T) (*E2ResetRequestNotificationHandler, *mocks.
        readerMock := &mocks.RnibReaderMock{}\r
        writerMock := &mocks.RnibWriterMock{}\r
        rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock)\r
-       handler := NewE2ResetRequestNotificationHandler(logger, rnibDataService)\r
+       handler := NewE2ResetRequestNotificationHandler(logger, rnibDataService, config)\r
        return handler, readerMock, writerMock\r
 }\r
 \r
index 82db437..3d13a30 100644 (file)
@@ -95,7 +95,7 @@ func (provider *NotificationHandlerProvider) Init(logger *logger.Logger, config
        e2SetupRequestNotificationHandler := rmrmsghandlers.NewE2SetupRequestNotificationHandler(logger, config, e2tInstancesManager, rmrSender, rnibDataService, e2tAssociationManager, ranConnectStatusChangeManager, ranListManager)
        ricServiceUpdateHandler := rmrmsghandlers.NewRicServiceUpdateHandler(logger, rmrSender, rnibDataService, ranListManager)
        ricE2nodeConfigUpdateHandler := rmrmsghandlers.NewE2nodeConfigUpdateNotificationHandler(logger, rnibDataService, rmrSender)
-       e2ResetRequestNotificationHandler := rmrmsghandlers.NewE2ResetRequestNotificationHandler(logger, rnibDataService)
+       e2ResetRequestNotificationHandler := rmrmsghandlers.NewE2ResetRequestNotificationHandler(logger, rnibDataService, config)
 
        provider.Register(rmrCgo.RIC_X2_SETUP_RESP, x2SetupResponseHandler)
        provider.Register(rmrCgo.RIC_X2_SETUP_FAILURE, x2SetupFailureResponseHandler)
index 2e3d364..9d6d1ad 100644 (file)
@@ -99,6 +99,7 @@ func TestGetNotificationHandlerSuccess(t *testing.T) {
                {rmrCgo.RIC_X2_RESET, rmrmsghandlers.NewX2ResetRequestNotificationHandler(logger, rnibDataService, ranStatusChangeManager, rmrSender)},
                {rmrCgo.RIC_SERVICE_UPDATE, rmrmsghandlers.NewRicServiceUpdateHandler(logger, rmrSender, rnibDataService, ranListManager)},
                {rmrCgo.RIC_E2NODE_CONFIG_UPDATE, rmrmsghandlers.NewE2nodeConfigUpdateNotificationHandler(logger, rnibDataService, rmrSender)},
+               {rmrCgo.RIC_E2_RESET_REQ, rmrmsghandlers.NewE2ResetRequestNotificationHandler(logger, rnibDataService, config)},
        }
 
        for _, tc := range testCases {
index 468b6d2..e4bb14c 100644 (file)
@@ -14,6 +14,7 @@ rnibRetryIntervalMs: 10
 keepAliveResponseTimeoutMs: 4500
 keepAliveDelayMs: 1500
 e2tInstanceDeletionTimeoutMs: 15000
+e2ResetTimeOutSec: 10
 globalRicId:
   ricId: "AACCE"
   mcc: "310"