[RICPLT-2165] Add rnibDataService to support retries
Change-Id: Ia9dc8bbeead1d1f4fd0f970789bcd4b9af2f0540
Signed-off-by: Amichai <amichai.sichel@intl.att.com>
diff --git a/E2Manager/configuration/configuration.go b/E2Manager/configuration/configuration.go
index b0611b8..7d8992a 100644
--- a/E2Manager/configuration/configuration.go
+++ b/E2Manager/configuration/configuration.go
@@ -36,6 +36,8 @@
NotificationResponseBuffer int
BigRedButtonTimeoutSec int
MaxConnectionAttempts int
+ MaxRnibConnectionAttempts int
+ RnibRetryIntervalMs int
}
func ParseConfiguration() *Configuration{
@@ -58,6 +60,8 @@
config.NotificationResponseBuffer = viper.GetInt("notificationResponseBuffer")
config.BigRedButtonTimeoutSec = viper.GetInt("bigRedButtonTimeoutSec")
config.MaxConnectionAttempts = viper.GetInt("maxConnectionAttempts")
+ config.MaxConnectionAttempts = viper.GetInt("maxRnibConnectionAttempts")
+ config.MaxConnectionAttempts = viper.GetInt("rnibRetryIntervalMs")
return &config
}
diff --git a/E2Manager/controllers/controller.go b/E2Manager/controllers/controller.go
index f9a7bb3..12ade63 100644
--- a/E2Manager/controllers/controller.go
+++ b/E2Manager/controllers/controller.go
@@ -24,10 +24,8 @@
"e2mgr/managers"
"e2mgr/models"
"e2mgr/providers/httpmsghandlerprovider"
- "e2mgr/rNibWriter"
"e2mgr/services"
"encoding/json"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
"github.com/gorilla/mux"
"io"
"io/ioutil"
@@ -53,10 +51,10 @@
handlerProvider *httpmsghandlerprovider.IncomingRequestHandlerProvider
}
-func NewController(logger *logger.Logger, rmrService *services.RmrService, rNibReaderProvider func() reader.RNibReader, rNibWriterProvider func() rNibWriter.RNibWriter,
+func NewController(logger *logger.Logger, rmrService *services.RmrService, rnibDataService services.RNibDataService,
config *configuration.Configuration, ranSetupManager *managers.RanSetupManager) *Controller {
- provider := httpmsghandlerprovider.NewIncomingRequestHandlerProvider(logger, rmrService, config, rNibWriterProvider, rNibReaderProvider, ranSetupManager)
+ provider := httpmsghandlerprovider.NewIncomingRequestHandlerProvider(logger, rmrService, config, rnibDataService, ranSetupManager)
return &Controller{
logger: logger,
handlerProvider: provider,
diff --git a/E2Manager/controllers/controller_test.go b/E2Manager/controllers/controller_test.go
index f14d830..cf5ae71 100644
--- a/E2Manager/controllers/controller_test.go
+++ b/E2Manager/controllers/controller_test.go
@@ -29,6 +29,7 @@
"e2mgr/providers/httpmsghandlerprovider"
"e2mgr/rNibWriter"
"e2mgr/rmrCgo"
+ "e2mgr/services"
"e2mgr/tests"
"encoding/json"
"fmt"
@@ -46,17 +47,29 @@
"testing"
)
-func TestX2SetupInvalidBody(t *testing.T) {
-
- readerMock, writerMock, rmrMessengerMock, ranSetupManager := initTest(t)
+func setupControllerTest(t *testing.T) (*Controller, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.RmrMessengerMock){
log := initLog(t)
+ config := configuration.ParseConfiguration()
+ rmrMessengerMock := &mocks.RmrMessengerMock{}
+ readerMock := &mocks.RnibReaderMock{}
readerProvider := func() reader.RNibReader {
return readerMock
}
+ writerMock := &mocks.RnibWriterMock{}
writerProvider := func() rNibWriter.RNibWriter {
return writerMock
}
+ rnibDataService := services.NewRnibDataService(log, config, readerProvider, writerProvider)
+
+ ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rnibDataService)
+ controller := NewController(log, getRmrService(rmrMessengerMock, log), rnibDataService, config, ranSetupManager)
+ return controller, readerMock, writerMock, rmrMessengerMock
+}
+
+func TestX2SetupInvalidBody(t *testing.T) {
+
+ controller, _, _, _ := setupControllerTest(t)
header := http.Header{}
header.Set("Content-Type", "application/json")
@@ -64,8 +77,6 @@
httpRequest.Header = header
writer := httptest.NewRecorder()
- config := configuration.ParseConfiguration()
- controller := NewController(log, getRmrService(rmrMessengerMock, log), readerProvider, writerProvider, config, ranSetupManager)
controller.X2SetupHandler(writer, httpRequest)
var errorResponse = parseJsonRequest(t, writer.Body)
@@ -76,15 +87,7 @@
func TestX2SetupSuccess(t *testing.T) {
- readerMock, writerMock, rmrMessengerMock, ranSetupManager := initTest(t)
- log := initLog(t)
-
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
+ controller, readerMock, writerMock, rmrMessengerMock := setupControllerTest(t)
ranName := "test"
nb := &entities.NodebInfo{RanName: ranName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
@@ -105,8 +108,6 @@
httpRequest.Header = header
writer := httptest.NewRecorder()
- config := configuration.ParseConfiguration()
- controller := NewController(log, getRmrService(rmrMessengerMock, log), readerProvider, writerProvider, config, ranSetupManager)
controller.X2SetupHandler(writer, httpRequest)
assert.Equal(t, http.StatusNoContent, writer.Result().StatusCode)
@@ -114,15 +115,7 @@
func TestEndcSetupSuccess(t *testing.T) {
- readerMock, writerMock, rmrMessengerMock, ranSetupManager := initTest(t)
- log := initLog(t)
-
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
+ controller, readerMock, writerMock, rmrMessengerMock := setupControllerTest(t)
ranName := "test"
nb := &entities.NodebInfo{RanName: ranName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_ENDC_X2_SETUP_REQUEST}
@@ -143,34 +136,20 @@
httpRequest.Header = header
writer := httptest.NewRecorder()
- config := configuration.ParseConfiguration()
- controller := NewController(log, getRmrService(rmrMessengerMock, log), readerProvider, writerProvider, config, ranSetupManager)
controller.EndcSetupHandler(writer, httpRequest)
assert.Equal(t, http.StatusNoContent, writer.Result().StatusCode)
}
func TestShutdownHandlerRnibError(t *testing.T) {
- log := initLog(t)
- config := configuration.ParseConfiguration()
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
+ controller, readerMock, _, _:= setupControllerTest(t)
rnibErr := &common.ResourceNotFoundError{}
var nbIdentityList []*entities.NbIdentity
readerMock.On("GetListNodebIds").Return(nbIdentityList, rnibErr)
writer := httptest.NewRecorder()
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, getRmrService(rmrMessengerMock, log), readerProvider, writerProvider, config, ranSetupManager)
+
controller.ShutdownHandler(writer, tests.GetHttpRequest())
var errorResponse = parseJsonRequest(t, writer.Body)
@@ -180,22 +159,9 @@
}
func TestHeaderValidationFailed(t *testing.T) {
- log := initLog(t)
- config := configuration.ParseConfiguration()
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
+ controller, _, _, _ := setupControllerTest(t)
writer := httptest.NewRecorder()
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, getRmrService(rmrMessengerMock, log), readerProvider, writerProvider, config, ranSetupManager)
header := &http.Header{}
@@ -210,48 +176,22 @@
}
func TestShutdownStatusNoContent(t *testing.T) {
- log := initLog(t)
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- config := configuration.ParseConfiguration()
+ controller, readerMock, _, _ := setupControllerTest(t)
var rnibError error
nbIdentityList := []*entities.NbIdentity{}
readerMock.On("GetListNodebIds").Return(nbIdentityList, rnibError)
writer := httptest.NewRecorder()
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, getRmrService(rmrMessengerMock, log), readerProvider, writerProvider, config, ranSetupManager)
controller.ShutdownHandler(writer, tests.GetHttpRequest())
assert.Equal(t, http.StatusNoContent, writer.Result().StatusCode)
}
func TestHandleInternalError(t *testing.T) {
- log := initLog(t)
- config := configuration.ParseConfiguration()
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
+ controller, _, _, _ := setupControllerTest(t)
writer := httptest.NewRecorder()
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, getRmrService(rmrMessengerMock, log), readerProvider, writerProvider, config, ranSetupManager)
err := e2managererrors.NewInternalError()
controller.handleErrorResponse(err, writer)
@@ -263,21 +203,8 @@
}
func TestHandleCommandAlreadyInProgressError(t *testing.T) {
- log := initLog(t)
- config := configuration.ParseConfiguration()
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
+ controller, _, _, _ := setupControllerTest(t)
writer := httptest.NewRecorder()
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, getRmrService(rmrMessengerMock, log), readerProvider, writerProvider, config, ranSetupManager)
err := e2managererrors.NewCommandAlreadyInProgressError()
controller.handleErrorResponse(err, writer)
@@ -289,20 +216,7 @@
}
func TestValidateHeaders(t *testing.T) {
- log := initLog(t)
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- config := configuration.ParseConfiguration()
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, getRmrService(rmrMessengerMock, log), readerProvider, writerProvider, config, ranSetupManager)
+ controller, _, _, _ := setupControllerTest(t)
header := http.Header{}
header.Set("Content-Type", "application/json")
@@ -332,30 +246,15 @@
}
func TestX2ResetHandleSuccessfulRequestedCause(t *testing.T) {
- log := initLog(t)
+ controller, readerMock, _, rmrMessengerMock := setupControllerTest(t)
ranName := "test1"
-
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
payload := []byte{0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x05, 0x40, 0x01, 0x40}
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_RESET, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", msg, mock.Anything).Return(msg, nil)
- config := configuration.ParseConfiguration()
- rmrService := getRmrService(rmrMessengerMock, log)
-
writer := httptest.NewRecorder()
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, rmrService, readerProvider, writerProvider, config, ranSetupManager)
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED}
readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
@@ -372,31 +271,16 @@
}
func TestX2ResetHandleSuccessfulRequestedDefault(t *testing.T) {
- log := initLog(t)
+ controller, readerMock, _, rmrMessengerMock := setupControllerTest(t)
ranName := "test1"
-
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
// o&m intervention
payload := []byte{0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x05, 0x40, 0x01, 0x64}
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_RESET, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", msg, mock.Anything).Return(msg, nil)
- config := configuration.ParseConfiguration()
- rmrService := getRmrService(rmrMessengerMock, log)
-
writer := httptest.NewRecorder()
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, rmrService, readerProvider, writerProvider, config, ranSetupManager)
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED}
readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
@@ -412,26 +296,11 @@
}
func TestX2ResetHandleFailureInvalidBody(t *testing.T) {
- log := initLog(t)
+ controller, _, _, _ := setupControllerTest(t)
ranName := "test1"
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
-
- config := configuration.ParseConfiguration()
- rmrService := getRmrService(rmrMessengerMock, log)
-
writer := httptest.NewRecorder()
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, rmrService, readerProvider, writerProvider, config, ranSetupManager)
// Invalid json: attribute name without quotes (should be "cause":).
b := strings.NewReader("{cause:\"protocol:transfer-syntax-error\"")
@@ -444,22 +313,7 @@
}
func TestHandleErrorResponse(t *testing.T) {
- log := initLog(t)
-
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
-
- config := configuration.ParseConfiguration()
- rmrService := getRmrService(rmrMessengerMock, log)
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- controller := NewController(log, rmrService, readerProvider, writerProvider, config, ranSetupManager)
+ controller, _, _, _ := setupControllerTest(t)
writer := httptest.NewRecorder()
controller.handleErrorResponse(e2managererrors.NewRnibDbError(), writer)
@@ -492,21 +346,4 @@
writer = httptest.NewRecorder()
controller.handleErrorResponse(fmt.Errorf("ErrorError"), writer)
assert.Equal(t, http.StatusInternalServerError, writer.Result().StatusCode)
-}
-
-func initTest(t *testing.T)(*mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.RmrMessengerMock, *managers.RanSetupManager) {
- log := initLog(t)
-
- readerMock := &mocks.RnibReaderMock{}
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- rmrService := getRmrService(rmrMessengerMock, log)
-
- ranSetupManager := managers.NewRanSetupManager(log, rmrService, writerProvider)
-
- return readerMock, writerMock, rmrMessengerMock, ranSetupManager
}
\ No newline at end of file
diff --git a/E2Manager/controllers/nodeb_controller.go b/E2Manager/controllers/nodeb_controller.go
index cdb76a9..28b713e 100644
--- a/E2Manager/controllers/nodeb_controller.go
+++ b/E2Manager/controllers/nodeb_controller.go
@@ -20,12 +20,10 @@
import (
"e2mgr/logger"
"e2mgr/models"
- "e2mgr/rNibWriter"
"e2mgr/services"
"e2mgr/utils"
"encoding/json"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
"github.com/golang/protobuf/jsonpb"
"github.com/gorilla/mux"
"net/http"
@@ -53,25 +51,22 @@
type NodebController struct {
rmrService *services.RmrService
Logger *logger.Logger
- rnibReaderProvider func() reader.RNibReader
- rnibWriterProvider func() rNibWriter.RNibWriter
+ rnibDataService services.RNibDataService
}
-func NewNodebController(logger *logger.Logger, rmrService *services.RmrService, rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter) *NodebController {
+func NewNodebController(logger *logger.Logger, rmrService *services.RmrService, rnibDataService services.RNibDataService) *NodebController {
messageChannel = make(chan *models.E2RequestMessage)
errorChannel = make(chan error)
return &NodebController{
rmrService: rmrService,
Logger: logger,
- rnibReaderProvider: rnibReaderProvider,
- rnibWriterProvider: rnibWriterProvider,
+ rnibDataService: rnibDataService,
}
}
func (rc NodebController) GetNodebIdList (writer http.ResponseWriter, request *http.Request) {
startTime := time.Now()
- rnibReaderService := services.NewRnibReaderService(rc.rnibReaderProvider)
- nodebIdList, rnibError := rnibReaderService.GetNodebIdList()
+ nodebIdList, rnibError := rc.rnibDataService.GetListNodebIds()
if rnibError != nil {
rc.Logger.Errorf("%v", rnibError);
@@ -98,9 +93,7 @@
startTime := time.Now()
vars := mux.Vars(request)
ranName := vars["ranName"]
- // WAS: respondingNode, rnibError := reader.GetRNibReader().GetNodeb(ranName)
- rnibReaderService := services.NewRnibReaderService(rc.rnibReaderProvider)
- respondingNode, rnibError := rnibReaderService.GetNodeb(ranName)
+ respondingNode, rnibError := rc.rnibDataService.GetNodeb(ranName)
if rnibError != nil {
rc.Logger.Errorf("%v", rnibError)
httpStatusCode, errorCode, errorMessage := rnibErrorToHttpError(rnibError)
diff --git a/E2Manager/controllers/nodeb_controller_test.go b/E2Manager/controllers/nodeb_controller_test.go
index 812d7dc..f49cd8c 100644
--- a/E2Manager/controllers/nodeb_controller_test.go
+++ b/E2Manager/controllers/nodeb_controller_test.go
@@ -18,6 +18,7 @@
package controllers
import (
+ "e2mgr/configuration"
"e2mgr/logger"
"e2mgr/mocks"
"e2mgr/models"
@@ -37,19 +38,30 @@
"testing"
)
-func TestNewRequestController(t *testing.T) {
+func setupNodebControllerTest(t *testing.T) (*logger.Logger, services.RNibDataService, *mocks.RnibReaderMock){
+ logger, err := logger.InitLogger(logger.DebugLevel)
+ if err != nil {
+ t.Errorf("#... - failed to initialize logger, error: %s", err)
+ }
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
+ readerMock := &mocks.RnibReaderMock{}
rnibReaderProvider := func() reader.RNibReader {
- return &mocks.RnibReaderMock{}
+ return readerMock
}
rnibWriterProvider := func() rNibWriter.RNibWriter {
return &mocks.RnibWriterMock{}
}
+ rnibDataService := services.NewRnibDataService(logger, config, rnibReaderProvider, rnibWriterProvider)
+ return logger, rnibDataService, readerMock
+}
- assert.NotNil(t, NewNodebController(&logger.Logger{}, &services.RmrService{}, rnibReaderProvider, rnibWriterProvider))
+func TestNewRequestController(t *testing.T) {
+ logger, rnibDataService, _ := setupNodebControllerTest(t)
+ assert.NotNil(t, NewNodebController(logger, &services.RmrService{}, rnibDataService))
}
func TestHandleHealthCheckRequest(t *testing.T) {
- rc := NewNodebController(nil, nil, nil, nil)
+ rc := NewNodebController(nil, nil, nil)
writer := httptest.NewRecorder()
rc.HandleHealthCheckRequest(writer, nil)
assert.Equal(t, writer.Result().StatusCode, http.StatusOK)
@@ -62,96 +74,62 @@
return services.NewRmrService(services.NewRmrConfig(tests.Port, tests.MaxMsgSize, tests.Flags, log), rmrMessenger, messageChannel)
}
-func executeGetNodeb(logger *logger.Logger, writer *httptest.ResponseRecorder, rnibReaderProvider func() reader.RNibReader) {
+func executeGetNodeb(logger *logger.Logger, writer *httptest.ResponseRecorder, rnibDataService services.RNibDataService) {
req, _ := http.NewRequest("GET", "/nodeb", nil)
req = mux.SetURLVars(req, map[string]string{"ranName": "testNode"})
- NewNodebController(logger, nil, rnibReaderProvider, nil).GetNodeb(writer, req)
+ NewNodebController(logger, nil, rnibDataService).GetNodeb(writer, req)
}
func TestNodebController_GetNodeb_Success(t *testing.T) {
- log, err := logger.InitLogger(logger.InfoLevel)
-
- if err != nil {
- t.Errorf("#nodeb_controller_test.TestNodebController_GetNodeb_Success - failed to initialize logger, error: %s", err)
- }
+ logger, rnibDataService, rnibReaderMock := setupNodebControllerTest(t)
writer := httptest.NewRecorder()
- rnibReaderMock := mocks.RnibReaderMock{}
var rnibError error
rnibReaderMock.On("GetNodeb", "testNode").Return(&entities.NodebInfo{}, rnibError)
- rnibReaderProvider := func() reader.RNibReader {
- return &rnibReaderMock
- }
-
- executeGetNodeb(log, writer, rnibReaderProvider)
+ executeGetNodeb(logger, writer, rnibDataService)
assert.Equal(t, writer.Result().StatusCode, http.StatusOK)
}
func TestNodebController_GetNodeb_NotFound(t *testing.T) {
- log, err := logger.InitLogger(logger.InfoLevel)
-
- if err != nil {
- t.Errorf("#nodeb_controller_test.TestNodebController_GetNodeb_NotFound - failed to initialize logger, error: %s", err)
- }
+ logger, rnibDataService, rnibReaderMock := setupNodebControllerTest(t)
writer := httptest.NewRecorder()
- rnibReaderMock := mocks.RnibReaderMock{}
rnibError := common.NewResourceNotFoundErrorf("#reader.GetNodeb - responding node %s not found", "testNode")
var nodebInfo *entities.NodebInfo
rnibReaderMock.On("GetNodeb", "testNode").Return(nodebInfo, rnibError)
- rnibReaderProvider := func() reader.RNibReader {
- return &rnibReaderMock
- }
-
- executeGetNodeb(log, writer, rnibReaderProvider)
+ executeGetNodeb(logger, writer, rnibDataService)
assert.Equal(t, writer.Result().StatusCode, http.StatusNotFound)
}
func TestNodebController_GetNodeb_InternalError(t *testing.T) {
- log, err := logger.InitLogger(logger.InfoLevel)
-
- if err != nil {
- t.Errorf("#nodeb_controller_test.TestNodebController_GetNodeb_InternalError - failed to initialize logger, error: %s", err)
- }
+ logger, rnibDataService, rnibReaderMock := setupNodebControllerTest(t)
writer := httptest.NewRecorder()
- rnibReaderMock := mocks.RnibReaderMock{}
-
rnibError := common.NewInternalError(errors.New("#reader.GetNodeb - Internal Error"))
var nodebInfo *entities.NodebInfo
rnibReaderMock.On("GetNodeb", "testNode").Return(nodebInfo, rnibError)
- rnibReaderProvider := func() reader.RNibReader {
- return &rnibReaderMock
- }
-
- executeGetNodeb(log, writer, rnibReaderProvider)
+ executeGetNodeb(logger, writer, rnibDataService)
assert.Equal(t, writer.Result().StatusCode, http.StatusInternalServerError)
}
-func executeGetNodebIdList(logger *logger.Logger, writer *httptest.ResponseRecorder, rnibReaderProvider func() reader.RNibReader) {
+func executeGetNodebIdList(logger *logger.Logger, writer *httptest.ResponseRecorder, rnibDataService services.RNibDataService) {
req, _ := http.NewRequest("GET", "/nodeb-ids", nil)
- NewNodebController(logger, nil, rnibReaderProvider, nil).GetNodebIdList(writer, req)
+ NewNodebController(logger, nil, rnibDataService).GetNodebIdList(writer,req)
}
func TestNodebController_GetNodebIdList_Success(t *testing.T) {
- logger, err := logger.InitLogger(logger.InfoLevel)
-
- if err != nil {
- t.Errorf("#nodeb_controller_test.TestNodebController_GetNodebIdList_Success - failed to initialize logger, error: %s", err)
- }
-
+ logger, rnibDataService, rnibReaderMock := setupNodebControllerTest(t)
writer := httptest.NewRecorder()
- rnibReaderMock := mocks.RnibReaderMock{}
var rnibError error
nbList := []*entities.NbIdentity{
@@ -161,61 +139,38 @@
}
rnibReaderMock.On("GetListNodebIds").Return(nbList, rnibError)
- rnibReaderProvider := func() reader.RNibReader {
- return &rnibReaderMock
- }
-
- executeGetNodebIdList(logger, writer, rnibReaderProvider)
+ executeGetNodebIdList(logger, writer, rnibDataService)
assert.Equal(t, writer.Result().StatusCode, http.StatusOK)
- bodyBytes, err := ioutil.ReadAll(writer.Body)
+ bodyBytes, _ := ioutil.ReadAll(writer.Body)
assert.Equal(t, "[{\"inventoryName\":\"test1\",\"globalNbId\":{\"plmnId\":\"plmnId1\",\"nbId\":\"nbId1\"}},{\"inventoryName\":\"test2\",\"globalNbId\":{\"plmnId\":\"plmnId2\",\"nbId\":\"nbId2\"}},{\"inventoryName\":\"test3\",\"globalNbId\":{}}]", string(bodyBytes))
}
func TestNodebController_GetNodebIdList_EmptyList(t *testing.T) {
- log, err := logger.InitLogger(logger.InfoLevel)
-
- if err != nil {
- t.Errorf("#nodeb_controller_test.TestNodebController_GetNodebIdList_EmptyList - failed to initialize logger, error: %s", err)
- }
+ logger, rnibDataService, rnibReaderMock := setupNodebControllerTest(t)
writer := httptest.NewRecorder()
- rnibReaderMock := mocks.RnibReaderMock{}
-
var rnibError error
nbList := []*entities.NbIdentity{}
rnibReaderMock.On("GetListNodebIds").Return(nbList, rnibError)
- rnibReaderProvider := func() reader.RNibReader {
- return &rnibReaderMock
- }
- executeGetNodebIdList(log, writer, rnibReaderProvider)
+ executeGetNodebIdList(logger, writer, rnibDataService)
assert.Equal(t, writer.Result().StatusCode, http.StatusOK)
- bodyBytes, err := ioutil.ReadAll(writer.Body)
+ bodyBytes, _ := ioutil.ReadAll(writer.Body)
assert.Equal(t, "[]", string(bodyBytes))
}
func TestNodebController_GetNodebIdList_InternalError(t *testing.T) {
- logger, err := logger.InitLogger(logger.InfoLevel)
-
- if err != nil {
- t.Errorf("#nodeb_controller_test.TestNodebController_GetNodebIdList_InternalError - failed to initialize logger, error: %s", err)
- }
+ logger, rnibDataService, rnibReaderMock := setupNodebControllerTest(t)
writer := httptest.NewRecorder()
- rnibReaderMock := mocks.RnibReaderMock{}
-
rnibError := common.NewInternalError(errors.New("#reader.GetEnbIdList - Internal Error"))
var nbList []*entities.NbIdentity
rnibReaderMock.On("GetListNodebIds").Return(nbList, rnibError)
- rnibReaderProvider := func() reader.RNibReader {
- return &rnibReaderMock
- }
-
- executeGetNodebIdList(logger, writer, rnibReaderProvider)
+ executeGetNodebIdList(logger, writer, rnibDataService)
assert.Equal(t, writer.Result().StatusCode, http.StatusInternalServerError)
}
diff --git a/E2Manager/converters/endc_x2setupFailureResponseToProtobuf_test.go b/E2Manager/converters/endc_x2setupFailureResponseToProtobuf_test.go
index f51b987..cdd2f25 100644
--- a/E2Manager/converters/endc_x2setupFailureResponseToProtobuf_test.go
+++ b/E2Manager/converters/endc_x2setupFailureResponseToProtobuf_test.go
@@ -20,7 +20,6 @@
import (
"e2mgr/e2pdus"
"e2mgr/logger"
- "e2mgr/rNibWriter"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"strings"
@@ -35,14 +34,12 @@
logger, _ := logger.InitLogger(logger.InfoLevel)
var testCases = []struct {
- saveToRNib bool
- response string
- packedPdu string
- failure error
+ response string
+ packedPdu string
+ failure error
}{
{
- saveToRNib: false, //TODO: use MOCK?
- response: "CONNECTED_SETUP_FAILED network_layer_cause:HANDOVER_DESIRABLE_FOR_RADIO_REASONS time_to_wait:V1S criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
+ response: "CONNECTED_SETUP_FAILED network_layer_cause:HANDOVER_DESIRABLE_FOR_RADIO_REASONS time_to_wait:V1S criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
/*
E2AP-PDU:
unsuccessfulOutcome_t
@@ -77,7 +74,6 @@
/**** shares the same code with x2setup failure response to protobuf ****/
}
- initDb_f := true
for _, tc := range testCases {
t.Run(tc.packedPdu, func(t *testing.T) {
@@ -113,23 +109,6 @@
t.Errorf("want: response=[%s], got: [%s]", tc.response, respStr)
}
- // Save to rNib
- if tc.saveToRNib {
- if initDb_f {
- rNibWriter.Init("e2Manager", 1)
- initDb_f = false
- }
- nbIdentity := &entities.NbIdentity{InventoryName: "RanName"}
- if rNibErr := rNibWriter.GetRNibWriter().SaveNodeb(nbIdentity, nb); rNibErr != nil {
- if tc.failure == nil {
- t.Errorf("rNibWriter failed to save ENB. Error: %s\n", rNibErr.Error())
- } else {
- if strings.Compare(rNibErr.Error(), tc.failure.Error()) != 0 {
- t.Errorf("want: %s, got: %s", tc.failure, rNibErr.Error())
- }
- }
- }
- }
}
})
}
diff --git a/E2Manager/converters/endc_x2setupResponseToProtobuf_test.go b/E2Manager/converters/endc_x2setupResponseToProtobuf_test.go
index 60b7e6d..e3de6b3 100644
--- a/E2Manager/converters/endc_x2setupResponseToProtobuf_test.go
+++ b/E2Manager/converters/endc_x2setupResponseToProtobuf_test.go
@@ -20,7 +20,6 @@
import (
"e2mgr/e2pdus"
"e2mgr/logger"
- "e2mgr/rNibWriter"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"strings"
@@ -35,16 +34,14 @@
logger, _ := logger.InitLogger(logger.InfoLevel)
var testCases = []struct {
- saveToRNib bool
- key *entities.GlobalNbId
- gnb string
- packedPdu string
- failure error
+ key *entities.GlobalNbId
+ gnb string
+ packedPdu string
+ failure error
}{
{
- saveToRNib: false, //TODO: use MOCK?
- key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"},
- gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS60 ncnrb:NRB107 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB133 > > > > served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB121 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB132 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB11 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
+ key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
+ gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS60 ncnrb:NRB107 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB133 > > > > served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB121 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB132 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB11 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
/*
E2AP-PDU:
successfulOutcome_t
@@ -152,9 +149,8 @@
*/
packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a00021a0044033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
{
- saveToRNib: false,
- key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"},
- gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB107 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB121 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:5 sulInformation:<sul_ar_fcn:6 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB18 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
+ key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
+ gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB107 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB121 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:5 sulInformation:<sul_ar_fcn:6 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB18 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
/*
E2AP-PDU:
successfulOutcome_t
@@ -234,8 +230,7 @@
packedPdu: "2024006500000100f6005e40000200fc00090002f829504a952a0a00fd004a00004c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000209e040033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400050000150400000a00061820"},
{
- saveToRNib: false,
- key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"},
+ key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS60 ncnrb:NRB107 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB133 > > > > served_nr_cell_information:<nr_pci:8 cell_id:\"2e3f45:1f2e3d4ff0\" stac5g:\"4faa3c\" configured_stac:\"1a2f\" served_plmns:\"50321e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:4 sulInformation:<sul_ar_fcn:8 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB121 > > frequency_bands:<nr_frequency_band:7 supported_sul_bands:3 > > transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB132 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:1 sulInformation:<sul_ar_fcn:2 sul_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB11 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
/*
E2AP-PDU:
@@ -344,9 +339,8 @@
packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0008002e3f451f2e3d4ff04faa3c1a2f0050321e4400040000060400000200081a00440350321e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
{
- saveToRNib: false,
- key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"},
- gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" served_plmns:\"3e4e5e\" nr_mode:FDD choice_nr_mode:<fdd:<ul_freq_info:<nr_ar_fcn:5 frequency_bands:<nr_frequency_band:44 supported_sul_bands:33 > > dl_freq_info:<nr_ar_fcn:1 frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > ul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB11 > dl_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB135 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:FDD choice_nr_mode:<fdd:<ular_fcn_freq_info:<nr_ar_fcn:5 frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > dlar_fcn_freq_info:<nr_ar_fcn:1 frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
+ key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
+ gnb: "CONNECTED [served_nr_cell_information:<nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" served_plmns:\"3e4e5e\" nr_mode:FDD choice_nr_mode:<fdd:<ul_freq_info:<nr_ar_fcn:5 frequency_bands:<nr_frequency_band:44 supported_sul_bands:33 > > dl_freq_info:<nr_ar_fcn:1 frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > ul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB11 > dl_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB135 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:FDD choice_nr_mode:<fdd:<ular_fcn_freq_info:<nr_ar_fcn:5 frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > dlar_fcn_freq_info:<nr_ar_fcn:1 frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > > > > ]",
/*
E2AP-PDU:
successfulOutcome_t
@@ -435,9 +429,8 @@
{
- saveToRNib: false,
- key: &entities.GlobalNbId{PlmnId:"04a5c1", NbId:"4fc52bff"},
- gnb: "CONNECTED [served_nr_cell_information:<nr_pci:9 cell_id:\"aeafa7:2a3e3b4cd0\" stac5g:\"7d4773\" configured_stac:\"477f\" served_plmns:\"7e7e7e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:8 sulInformation:<sul_ar_fcn:9 sul_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB121 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS60 ncnrb:NRB18 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"5a5ff1:2a3e3b4cd0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:5 sulInformation:<sul_ar_fcn:6 sul_transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB18 > > frequency_bands:<nr_frequency_band:4 supported_sul_bands:3 > > > > > nr_neighbour_infos:<nr_pci:9 nr_cgi:\"5d5caa:af3e354ac0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:7 sulInformation:<sul_ar_fcn:8 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB25 > > frequency_bands:<nr_frequency_band:3 supported_sul_bands:1 > > > > > ]",
+ key: &entities.GlobalNbId{PlmnId: "04a5c1", NbId: "4fc52bff"},
+ gnb: "CONNECTED [served_nr_cell_information:<nr_pci:9 cell_id:\"aeafa7:2a3e3b4cd0\" stac5g:\"7d4773\" configured_stac:\"477f\" served_plmns:\"7e7e7e\" nr_mode:TDD choice_nr_mode:<tdd:<nr_freq_info:<nr_ar_fcn:8 sulInformation:<sul_ar_fcn:9 sul_transmission_bandwidth:<nrscs:SCS15 ncnrb:NRB121 > > frequency_bands:<nr_frequency_band:22 supported_sul_bands:11 > > transmission_bandwidth:<nrscs:SCS60 ncnrb:NRB18 > > > > nr_neighbour_infos:<nr_pci:44 nr_cgi:\"5a5ff1:2a3e3b4cd0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:5 sulInformation:<sul_ar_fcn:6 sul_transmission_bandwidth:<nrscs:SCS30 ncnrb:NRB18 > > frequency_bands:<nr_frequency_band:4 supported_sul_bands:3 > > > > > nr_neighbour_infos:<nr_pci:9 nr_cgi:\"5d5caa:af3e354ac0\" nr_mode:TDD choice_nr_mode:<tdd:<ar_fcn_nr_freq_info:<nr_ar_fcn:7 sulInformation:<sul_ar_fcn:8 sul_transmission_bandwidth:<nrscs:SCS120 ncnrb:NRB25 > > frequency_bands:<nr_frequency_band:3 supported_sul_bands:1 > > > > > ]",
/*
E2AP-PDU:
successfulOutcome_t
@@ -536,7 +529,7 @@
*/
packedPdu: "202400808200000100f6007b40000200fc00090004a5c1504fc52bff00fd006700004c000900aeafa72a3e3b4cd07d4773477f007e7e7e4400080000150400000a0009020204037e7e7e000100002c005a5ff12a3e3b4cd0035a5ff144000500000304000002000608200009005d5caaaf3e354ac0035d5caa4400070000020400000000081860"},
- { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952aaa"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952aaa"},
/*
E2AP-PDU:
successfulOutcome_t
@@ -562,7 +555,6 @@
failure: fmt.Errorf("getList for path [successfulOutcome_t ENDCX2SetupResponse protocolIEs_t ProtocolIE_Container_elm RespondingNodeType-EndcX2Setup respond_en_gNB_t ProtocolIE_Container_elm ServedNRcellsENDCX2ManagementList ServedNRcellsENDCX2ManagementList_elm servedNRCellInfo_t nrpCI_t] failed, rc = 1" /*NO_ITEMS*/),},
}
- initDb_f := true
for _, tc := range testCases {
t.Run(tc.packedPdu, func(t *testing.T) {
@@ -580,9 +572,9 @@
if tc.failure == nil {
t.Errorf("want: success, got: error: %v\n", err)
} else {
- if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
- t.Errorf("want: %s, got: %s", tc.failure, err)
- }
+ if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
+ t.Errorf("want: %s, got: %s", tc.failure, err)
+ }
}
}
@@ -591,7 +583,7 @@
t.Errorf("want: key=%v, got: empty key", tc.key)
}
} else {
- if strings.Compare(key.PlmnId, tc.key.PlmnId) != 0 || strings.Compare(key.NbId, tc.key.NbId) != 0{
+ if strings.Compare(key.PlmnId, tc.key.PlmnId) != 0 || strings.Compare(key.NbId, tc.key.NbId) != 0 {
t.Errorf("want: key=%v, got: %v", tc.key, key)
}
}
@@ -603,31 +595,13 @@
} else {
nb := &entities.NodebInfo{}
nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
- nb.Configuration = &entities.NodebInfo_Gnb{Gnb:gnb}
+ nb.Configuration = &entities.NodebInfo_Gnb{Gnb: gnb}
gnbStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, gnb.ServedNrCells)
if !strings.EqualFold(gnbStr, tc.gnb) {
t.Errorf("want: enb=%s, got: %s", tc.gnb, gnbStr)
}
- // Save to rNib
- if tc.saveToRNib {
- if initDb_f {
- rNibWriter.Init("e2Manager", 1)
- initDb_f = false
- }
- nbIdentity := &entities.NbIdentity{InventoryName:"RanName", GlobalNbId:key}
- if rNibErr := rNibWriter.GetRNibWriter().SaveNodeb(nbIdentity, nb); rNibErr != nil {
- if tc.failure == nil {
- t.Errorf("rNibWriter failed to save ENB. Error: %v\n", rNibErr.Error())
- } else {
- if strings.Compare(rNibErr.Error(), tc.failure.Error()) != 0 {
- t.Errorf("want: %s, got: %s", tc.failure, rNibErr.Error())
- }
- }
- }
- }
}
})
}
}
-
diff --git a/E2Manager/converters/x2setupFailureResponseToProtobuf_test.go b/E2Manager/converters/x2setupFailureResponseToProtobuf_test.go
index 3bc099b..787dd19 100644
--- a/E2Manager/converters/x2setupFailureResponseToProtobuf_test.go
+++ b/E2Manager/converters/x2setupFailureResponseToProtobuf_test.go
@@ -20,7 +20,6 @@
import (
"e2mgr/e2pdus"
"e2mgr/logger"
- "e2mgr/rNibWriter"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"strings"
@@ -35,14 +34,12 @@
logger, _ := logger.InitLogger(logger.InfoLevel)
var testCases = []struct {
- saveToRNib bool
- response string
- packedPdu string
- failure error
+ response string
+ packedPdu string
+ failure error
}{
{
- saveToRNib: false, //TODO: use MOCK?
- response: "CONNECTED_SETUP_FAILED network_layer_cause:HANDOVER_DESIRABLE_FOR_RADIO_REASONS time_to_wait:V1S criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
+ response: "CONNECTED_SETUP_FAILED network_layer_cause:HANDOVER_DESIRABLE_FOR_RADIO_REASONS time_to_wait:V1S criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
/*
E2AP-PDU:
unsuccessfulOutcome_t
@@ -74,8 +71,7 @@
*/
packedPdu: "4006001a0000030005400200000016400100001140087821a00000008040"},
{
- saveToRNib: false,
- response: "CONNECTED_SETUP_FAILED transport_layer_cause:TRANSPORT_RESOURCE_UNAVAILABLE criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
+ response: "CONNECTED_SETUP_FAILED transport_layer_cause:TRANSPORT_RESOURCE_UNAVAILABLE criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
/*
E2AP-PDU:
unsuccessfulOutcome_t
@@ -103,8 +99,7 @@
*/
packedPdu: "400600140000020005400120001140087821a00000008040"},
{
- saveToRNib: false,
- response: "CONNECTED_SETUP_FAILED protocol_cause:ABSTRACT_SYNTAX_ERROR_IGNORE_AND_NOTIFY criticality_diagnostics:<triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
+ response: "CONNECTED_SETUP_FAILED protocol_cause:ABSTRACT_SYNTAX_ERROR_IGNORE_AND_NOTIFY criticality_diagnostics:<triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
/*
E2AP-PDU:
unsuccessfulOutcome_t
@@ -132,8 +127,7 @@
packedPdu: "400600130000020005400144001140073a800000008040"},
{
- saveToRNib: false,
- response: "CONNECTED_SETUP_FAILED miscellaneous_cause:UNSPECIFIED criticality_diagnostics:<procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
+ response: "CONNECTED_SETUP_FAILED miscellaneous_cause:UNSPECIFIED criticality_diagnostics:<procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
/*
E2AP-PDU:
unsuccessfulOutcome_t
@@ -160,8 +154,7 @@
packedPdu: "400600120000020005400168001140061a0000008040"},
{
- saveToRNib: false,
- response: "CONNECTED_SETUP_FAILED miscellaneous_cause:UNSPECIFIED criticality_diagnostics:<information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > information_element_criticality_diagnostics:<ie_criticality:NOTIFY ie_id:255 type_of_error:NOT_UNDERSTOOD > > ",
+ response: "CONNECTED_SETUP_FAILED miscellaneous_cause:UNSPECIFIED criticality_diagnostics:<information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > information_element_criticality_diagnostics:<ie_criticality:NOTIFY ie_id:255 type_of_error:NOT_UNDERSTOOD > > ",
/*
E2AP-PDU:
unsuccessfulOutcome_t
@@ -192,8 +185,7 @@
{
- saveToRNib: false,
- response: "CONNECTED_SETUP_FAILED miscellaneous_cause:UNSPECIFIED criticality_diagnostics:<procedure_code:33 > ",
+ response: "CONNECTED_SETUP_FAILED miscellaneous_cause:UNSPECIFIED criticality_diagnostics:<procedure_code:33 > ",
/*
E2AP-PDU:
unsuccessfulOutcome_t
@@ -215,8 +207,7 @@
packedPdu: "4006000e0000020005400168001140024021"},
{
- saveToRNib: false,
- response: "CONNECTED_SETUP_FAILED miscellaneous_cause:UNSPECIFIED ",
+ response: "CONNECTED_SETUP_FAILED miscellaneous_cause:UNSPECIFIED ",
/*
E2AP-PDU:
unsuccessfulOutcome_t
@@ -232,7 +223,6 @@
*/
packedPdu: "400600080000010005400168"},
{
- saveToRNib: false,
response: "CONNECTED_SETUP_FAILED network_layer_cause:HANDOVER_DESIRABLE_FOR_RADIO_REASONS time_to_wait:V1S criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
/*
E2AP-PDU:
@@ -268,7 +258,6 @@
},
}
- initDb_f := true
for _, tc := range testCases {
t.Run(tc.packedPdu, func(t *testing.T) {
@@ -297,32 +286,14 @@
} else {
nb := &entities.NodebInfo{}
nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED_SETUP_FAILED
- nb.SetupFailure = response
+ nb.SetupFailure = response
nb.FailureType = entities.Failure_X2_SETUP_FAILURE
respStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, response)
if !strings.EqualFold(respStr, tc.response) {
t.Errorf("want: response=[%s], got: [%s]", tc.response, respStr)
}
- // Save to rNib
- if tc.saveToRNib {
- if initDb_f {
- rNibWriter.Init("e2Manager", 1)
- initDb_f = false
- }
- nbIdentity := &entities.NbIdentity{InventoryName:"RanName"}
- if rNibErr := rNibWriter.GetRNibWriter().SaveNodeb(nbIdentity, nb); rNibErr != nil {
- if tc.failure == nil {
- t.Errorf("rNibWriter failed to save ENB. Error: %s\n", rNibErr.Error())
- } else {
- if strings.Compare(rNibErr.Error(), tc.failure.Error()) != 0 {
- t.Errorf("want: %s, got: %s", tc.failure, rNibErr.Error())
- }
- }
- }
- }
}
})
}
}
-
diff --git a/E2Manager/converters/x2setupResponseToProtobuf_test.go b/E2Manager/converters/x2setupResponseToProtobuf_test.go
index 7ab91d1..1cd3f20 100644
--- a/E2Manager/converters/x2setupResponseToProtobuf_test.go
+++ b/E2Manager/converters/x2setupResponseToProtobuf_test.go
@@ -20,7 +20,6 @@
import (
"e2mgr/e2pdus"
"e2mgr/logger"
- "e2mgr/rNibWriter"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"strings"
@@ -35,16 +34,14 @@
logger, _ := logger.InitLogger(logger.InfoLevel)
var testCases = []struct {
- saveToRNib bool
- key *entities.GlobalNbId
- enb string
- packedPdu string
- failure error
+ key *entities.GlobalNbId
+ enb string
+ packedPdu string
+ failure error
}{
{
- saveToRNib: false, //TODO: use MOCK?
- key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
- enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD ] []",
+ key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
+ enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD ] []",
/*
X2AP-PDU:
successfulOutcome_t
@@ -81,7 +78,7 @@
*/
packedPdu: "2006002a000002001500080002f82900007a8000140017000000630002f8290007ab50102002f829000001000133"},
{
- key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD ] []",
/*
X2AP-PDU:
@@ -135,7 +132,7 @@
*/
packedPdu: "20060043000002001500080002f82900007a8000140030010000630002f8290007ab50102002f8290000010001330000640002f9290007ac50203202f82902f929000002000344"},
- { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD ] []",
/*
X2AP-PDU:
@@ -177,7 +174,7 @@
EARFCNExtension = 0x2
*/
packedPdu: "20060033000002001500080002f82900007a8000140020000000630002f8290007ab50102002f8291000010001330000005f0003800102"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD ] [02f729:0203 02f929:0304]",
/*
X2AP-PDU:
@@ -225,7 +222,7 @@
*/
packedPdu: "2006003a000003001500080002f82900007a8000140017000000630002f8290007ab50102002f8290000010001330018000c1002f72902030002f9290304"},
- { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<tdd:<ear_fcn:1 transmission_bandwidth:BW50 subframe_assignment:SA2 special_subframe_info:<special_subframe_patterns:SSP4 cyclic_prefix_dl:NORMAL cyclic_prefix_ul:EXTENDED > > > eutra_mode:TDD ] []",
/*
X2AP-PDU:
@@ -265,7 +262,7 @@
cyclicPrefixUL_t = 0x1
*/
packedPdu: "2006002a000002001500080002f82900007a8000140017000000630002f8290007ab50102002f829400001320820"},
- { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<tdd:<ear_fcn:1 transmission_bandwidth:BW50 subframe_assignment:SA2 special_subframe_info:<special_subframe_patterns:SSP4 cyclic_prefix_dl:EXTENDED cyclic_prefix_ul:NORMAL > additional_special_subframe_info:<additional_special_subframe_patterns:SSP9 cyclic_prefix_dl:NORMAL cyclic_prefix_ul:EXTENDED > > > eutra_mode:TDD ] []",
/*
X2AP-PDU:
@@ -314,7 +311,7 @@
*/
packedPdu: "20060032000002001500080002f82900007a800014001f000000630002f8290007ab50102002f8295000013208800000006140021220"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<tdd:<ear_fcn:2 transmission_bandwidth:BW50 subframe_assignment:SA2 special_subframe_info:<special_subframe_patterns:SSP4 cyclic_prefix_dl:EXTENDED cyclic_prefix_ul:NORMAL > > > eutra_mode:TDD ] []",
/*
X2AP-PDU:
@@ -360,7 +357,7 @@
*/
packedPdu: "20060033000002001500080002f82900007a8000140020000000630002f8290007ab50102002f8295000013208800000005e0003800102"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<tdd:<ear_fcn:1 transmission_bandwidth:BW50 subframe_assignment:SA2 special_subframe_info:<special_subframe_patterns:SSP4 cyclic_prefix_dl:EXTENDED cyclic_prefix_ul:NORMAL > additional_special_subframe_extension_info:<additional_special_subframe_patterns_extension:SSP10 cyclic_prefix_dl:NORMAL cyclic_prefix_ul:NORMAL > > > eutra_mode:TDD ] []",
/*
X2AP-PDU:
@@ -409,7 +406,7 @@
*/
packedPdu: "20060031000002001500080002f82900007a800014001e000000630002f8290007ab50102002f829500001320880000000b3400100"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<tdd:<ear_fcn:2 transmission_bandwidth:BW50 subframe_assignment:SA2 special_subframe_info:<special_subframe_patterns:SSP4 cyclic_prefix_dl:EXTENDED cyclic_prefix_ul:NORMAL > additional_special_subframe_info:<additional_special_subframe_patterns:SSP9 cyclic_prefix_dl:NORMAL cyclic_prefix_ul:EXTENDED > additional_special_subframe_extension_info:<additional_special_subframe_patterns_extension:SSP10 cyclic_prefix_dl:NORMAL cyclic_prefix_ul:NORMAL > > > eutra_mode:TDD ] []",
/*
X2AP-PDU:
@@ -470,7 +467,7 @@
*/
packedPdu: "2006003e000002001500080002f82900007a800014002b000000630002f8290007ab50102002f829500001320880000200b3400100006140021220005e0003800102"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80b0"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80b0"},
enb: "CONNECTED HOME_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD number_of_antenna_ports:AN1 pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD ] []",
/*
X2AP-PDU:
@@ -530,144 +527,144 @@
*/
packedPdu: "2006004b000002001500090002f82940007a80b000140037010800630002f8290007ab50102002f829000001000133000000294001000000640002f9290007ac50203202f82902f929000002000344"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a40"},
- enb: "CONNECTED SHORT_MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD number_of_antenna_ports:AN1 pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD prach_configuration:<root_sequence_index:15 zero_correlation_zone_configuration:7 high_speed_flag:true prach_frequency_offset:30 > ] []",
- /*
- X2AP-PDU:
- successfulOutcome_t
- procedureCode_t = 0x6
- criticality_t = 0
- X2SetupResponse
- protocolIEs_t:
- ProtocolIE_Container_elm
- id_t = 0x15
- criticality_t = 0
- GlobalENB-ID
- pLMN_Identity_t = 02 f8 29
- eNB_ID_t:
- short_Macro_eNB_ID_t = 00 7a 40 (18 bits)
- ProtocolIE_Container_elm
- id_t = 0x14
- criticality_t = 0
- ServedCells:
- ServedCells_elm
- servedCellInfo_t
- pCI_t = 0x63
- cellId_t
- pLMN_Identity_t = 02 f8 29
- eUTRANcellIdentifier_t = 00 07 ab 50 (28 bits)
- tAC_t = 01 02
- broadcastPLMNs_t:
- BroadcastPLMNs_Item_elm = 02 f8 29
- eUTRA_Mode_Info_t:
- fDD_t
- uL_EARFCN_t = 0x1
- dL_EARFCN_t = 0x1
- uL_Transmission_Bandwidth_t = 0x3
- dL_Transmission_Bandwidth_t = 0x3
- iE_Extensions_t:
- ProtocolExtensionContainer_elm
- id_t = 0x29
- criticality_t = 0x1
- Number-of-Antennaports = 0
- ServedCells_elm
- servedCellInfo_t
- pCI_t = 0x64
- cellId_t
- pLMN_Identity_t = 02 f9 29
- eUTRANcellIdentifier_t = 00 07 ac 50 (28 bits)
- tAC_t = 02 03
- broadcastPLMNs_t:
- BroadcastPLMNs_Item_elm = 02 f8 29
- BroadcastPLMNs_Item_elm = 02 f9 29
- eUTRA_Mode_Info_t:
- fDD_t
- uL_EARFCN_t = 0x2
- dL_EARFCN_t = 0x3
- uL_Transmission_Bandwidth_t = 0x4
- dL_Transmission_Bandwidth_t = 0x4
- iE_Extensions_t:
- ProtocolExtensionContainer_elm
- id_t = 0x37
- criticality_t = 0x1
- PRACH-Configuration
- rootSequenceIndex_t = 0xf
- zeroCorrelationIndex_t = 0x7
- highSpeedFlag_t = true
- prach_FreqOffset_t = 0x1e
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a40"},
+ enb: "CONNECTED SHORT_MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD number_of_antenna_ports:AN1 pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD prach_configuration:<root_sequence_index:15 zero_correlation_zone_configuration:7 high_speed_flag:true prach_frequency_offset:30 > ] []",
+ /*
+ X2AP-PDU:
+ successfulOutcome_t
+ procedureCode_t = 0x6
+ criticality_t = 0
+ X2SetupResponse
+ protocolIEs_t:
+ ProtocolIE_Container_elm
+ id_t = 0x15
+ criticality_t = 0
+ GlobalENB-ID
+ pLMN_Identity_t = 02 f8 29
+ eNB_ID_t:
+ short_Macro_eNB_ID_t = 00 7a 40 (18 bits)
+ ProtocolIE_Container_elm
+ id_t = 0x14
+ criticality_t = 0
+ ServedCells:
+ ServedCells_elm
+ servedCellInfo_t
+ pCI_t = 0x63
+ cellId_t
+ pLMN_Identity_t = 02 f8 29
+ eUTRANcellIdentifier_t = 00 07 ab 50 (28 bits)
+ tAC_t = 01 02
+ broadcastPLMNs_t:
+ BroadcastPLMNs_Item_elm = 02 f8 29
+ eUTRA_Mode_Info_t:
+ fDD_t
+ uL_EARFCN_t = 0x1
+ dL_EARFCN_t = 0x1
+ uL_Transmission_Bandwidth_t = 0x3
+ dL_Transmission_Bandwidth_t = 0x3
+ iE_Extensions_t:
+ ProtocolExtensionContainer_elm
+ id_t = 0x29
+ criticality_t = 0x1
+ Number-of-Antennaports = 0
+ ServedCells_elm
+ servedCellInfo_t
+ pCI_t = 0x64
+ cellId_t
+ pLMN_Identity_t = 02 f9 29
+ eUTRANcellIdentifier_t = 00 07 ac 50 (28 bits)
+ tAC_t = 02 03
+ broadcastPLMNs_t:
+ BroadcastPLMNs_Item_elm = 02 f8 29
+ BroadcastPLMNs_Item_elm = 02 f9 29
+ eUTRA_Mode_Info_t:
+ fDD_t
+ uL_EARFCN_t = 0x2
+ dL_EARFCN_t = 0x3
+ uL_Transmission_Bandwidth_t = 0x4
+ dL_Transmission_Bandwidth_t = 0x4
+ iE_Extensions_t:
+ ProtocolExtensionContainer_elm
+ id_t = 0x37
+ criticality_t = 0x1
+ PRACH-Configuration
+ rootSequenceIndex_t = 0xf
+ zeroCorrelationIndex_t = 0x7
+ highSpeedFlag_t = true
+ prach_FreqOffset_t = 0x1e
- */
- packedPdu: "20060056000002001500090002f8298003007a4000140042010800630002f8290007ab50102002f829000001000133000000294001000800640002f9290007ac50203202f82902f92900000200034400000037400500000f79e0"},
+ */
+ packedPdu: "20060056000002001500090002f8298003007a4000140042010800630002f8290007ab50102002f829000001000133000000294001000800640002f9290007ac50203202f82902f92900000200034400000037400500000f79e0"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a40"},
- enb: "CONNECTED SHORT_MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD number_of_antenna_ports:AN1 pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD mbsfn_subframe_infos:<radioframe_allocation_period:N8 radioframe_allocation_offset:3 subframe_allocation:\"28\" subframe_allocation_type:ONE_FRAME > ] []",
- /*
- X2AP-PDU:
- successfulOutcome_t
- procedureCode_t = 0x6
- criticality_t = 0
- X2SetupResponse
- protocolIEs_t:
- ProtocolIE_Container_elm
- id_t = 0x15
- criticality_t = 0
- GlobalENB-ID
- pLMN_Identity_t = 02 f8 29
- eNB_ID_t:
- short_Macro_eNB_ID_t = 00 7a 40 (18 bits)
- ProtocolIE_Container_elm
- id_t = 0x14
- criticality_t = 0
- ServedCells:
- ServedCells_elm
- servedCellInfo_t
- pCI_t = 0x63
- cellId_t
- pLMN_Identity_t = 02 f8 29
- eUTRANcellIdentifier_t = 00 07 ab 50 (28 bits)
- tAC_t = 01 02
- broadcastPLMNs_t:
- BroadcastPLMNs_Item_elm = 02 f8 29
- eUTRA_Mode_Info_t:
- fDD_t
- uL_EARFCN_t = 0x1
- dL_EARFCN_t = 0x1
- uL_Transmission_Bandwidth_t = 0x3
- dL_Transmission_Bandwidth_t = 0x3
- iE_Extensions_t:
- ProtocolExtensionContainer_elm
- id_t = 0x29
- criticality_t = 0x1
- Number-of-Antennaports = 0
- ServedCells_elm
- servedCellInfo_t
- pCI_t = 0x64
- cellId_t
- pLMN_Identity_t = 02 f9 29
- eUTRANcellIdentifier_t = 00 07 ac 50 (28 bits)
- tAC_t = 02 03
- broadcastPLMNs_t:
- BroadcastPLMNs_Item_elm = 02 f8 29
- BroadcastPLMNs_Item_elm = 02 f9 29
- eUTRA_Mode_Info_t:
- fDD_t
- uL_EARFCN_t = 0x2
- dL_EARFCN_t = 0x3
- uL_Transmission_Bandwidth_t = 0x4
- dL_Transmission_Bandwidth_t = 0x4
- iE_Extensions_t:
- ProtocolExtensionContainer_elm
- id_t = 0x38
- criticality_t = 0x1
- MBSFN-Subframe-Infolist:
- MBSFN_Subframe_Infolist_elm
- radioframeAllocationPeriod_t = 0x3
- radioframeAllocationOffset_t = 0x3
- subframeAllocation_t:
- oneframe_t = 28 (6 bits)
- */
- packedPdu: "20060054000002001500090002f8298003007a4000140040010800630002f8290007ab50102002f829000001000133000000294001000800640002f9290007ac50203202f82902f929000002000344000000384003019850"},
- { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a40"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a40"},
+ enb: "CONNECTED SHORT_MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD number_of_antenna_ports:AN1 pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD mbsfn_subframe_infos:<radioframe_allocation_period:N8 radioframe_allocation_offset:3 subframe_allocation:\"28\" subframe_allocation_type:ONE_FRAME > ] []",
+ /*
+ X2AP-PDU:
+ successfulOutcome_t
+ procedureCode_t = 0x6
+ criticality_t = 0
+ X2SetupResponse
+ protocolIEs_t:
+ ProtocolIE_Container_elm
+ id_t = 0x15
+ criticality_t = 0
+ GlobalENB-ID
+ pLMN_Identity_t = 02 f8 29
+ eNB_ID_t:
+ short_Macro_eNB_ID_t = 00 7a 40 (18 bits)
+ ProtocolIE_Container_elm
+ id_t = 0x14
+ criticality_t = 0
+ ServedCells:
+ ServedCells_elm
+ servedCellInfo_t
+ pCI_t = 0x63
+ cellId_t
+ pLMN_Identity_t = 02 f8 29
+ eUTRANcellIdentifier_t = 00 07 ab 50 (28 bits)
+ tAC_t = 01 02
+ broadcastPLMNs_t:
+ BroadcastPLMNs_Item_elm = 02 f8 29
+ eUTRA_Mode_Info_t:
+ fDD_t
+ uL_EARFCN_t = 0x1
+ dL_EARFCN_t = 0x1
+ uL_Transmission_Bandwidth_t = 0x3
+ dL_Transmission_Bandwidth_t = 0x3
+ iE_Extensions_t:
+ ProtocolExtensionContainer_elm
+ id_t = 0x29
+ criticality_t = 0x1
+ Number-of-Antennaports = 0
+ ServedCells_elm
+ servedCellInfo_t
+ pCI_t = 0x64
+ cellId_t
+ pLMN_Identity_t = 02 f9 29
+ eUTRANcellIdentifier_t = 00 07 ac 50 (28 bits)
+ tAC_t = 02 03
+ broadcastPLMNs_t:
+ BroadcastPLMNs_Item_elm = 02 f8 29
+ BroadcastPLMNs_Item_elm = 02 f9 29
+ eUTRA_Mode_Info_t:
+ fDD_t
+ uL_EARFCN_t = 0x2
+ dL_EARFCN_t = 0x3
+ uL_Transmission_Bandwidth_t = 0x4
+ dL_Transmission_Bandwidth_t = 0x4
+ iE_Extensions_t:
+ ProtocolExtensionContainer_elm
+ id_t = 0x38
+ criticality_t = 0x1
+ MBSFN-Subframe-Infolist:
+ MBSFN_Subframe_Infolist_elm
+ radioframeAllocationPeriod_t = 0x3
+ radioframeAllocationOffset_t = 0x3
+ subframeAllocation_t:
+ oneframe_t = 28 (6 bits)
+ */
+ packedPdu: "20060054000002001500090002f8298003007a4000140040010800630002f8290007ab50102002f829000001000133000000294001000800640002f9290007ac50203202f82902f929000002000344000000384003019850"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a40"},
enb: "CONNECTED SHORT_MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD number_of_antenna_ports:AN1 mbsfn_subframe_infos:<radioframe_allocation_period:N8 radioframe_allocation_offset:3 subframe_allocation:\"28\" subframe_allocation_type:ONE_FRAME > pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD ] []",
/*
X2AP-PDU:
@@ -734,7 +731,7 @@
dL_Transmission_Bandwidth_t = 0x4
*/
packedPdu: "20060052000002001500090002f8298003007a400014003e010800630002f8290007ab50102002f82900000100013300010029400100003840030198500000640002f9290007ac50203202f82902f929000002000344"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a40"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a40"},
enb: "CONNECTED SHORT_MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD number_of_antenna_ports:AN1 prach_configuration:<root_sequence_index:15 zero_correlation_zone_configuration:7 high_speed_flag:true prach_frequency_offset:30 > pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD ] []",
/*
X2AP-PDU:
@@ -800,72 +797,72 @@
dL_Transmission_Bandwidth_t = 0x4
*/
packedPdu: "20060054000002001500090002f8298003007a4000140040010800630002f8290007ab50102002f829000001000133000100294001000037400500000f79e00000640002f9290007ac50203202f82902f929000002000344"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a08"},
- enb: "CONNECTED LONG_MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD prach_configuration:<root_sequence_index:15 zero_correlation_zone_configuration:7 high_speed_flag:true prach_frequency_offset:30 prach_configuration_index:60 > pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD ] []",
- /*
- X2AP-PDU:
- successfulOutcome_t
- procedureCode_t = 0x6
- criticality_t = 0
- X2SetupResponse
- protocolIEs_t:
- ProtocolIE_Container_elm
- id_t = 0x15
- criticality_t = 0
- GlobalENB-ID
- pLMN_Identity_t = 02 f8 29
- eNB_ID_t:
- long_Macro_eNB_ID_t = 00 7a 08 (21 bits)
- ProtocolIE_Container_elm
- id_t = 0x14
- criticality_t = 0
- ServedCells:
- ServedCells_elm
- servedCellInfo_t
- pCI_t = 0x63
- cellId_t
- pLMN_Identity_t = 02 f8 29
- eUTRANcellIdentifier_t = 00 07 ab 50 (28 bits)
- tAC_t = 01 02
- broadcastPLMNs_t:
- BroadcastPLMNs_Item_elm = 02 f8 29
- eUTRA_Mode_Info_t:
- fDD_t
- uL_EARFCN_t = 0x1
- dL_EARFCN_t = 0x1
- uL_Transmission_Bandwidth_t = 0x3
- dL_Transmission_Bandwidth_t = 0x3
- iE_Extensions_t:
- ProtocolExtensionContainer_elm
- id_t = 0x37
- criticality_t = 0x1
- PRACH-Configuration
- rootSequenceIndex_t = 0xf
- zeroCorrelationIndex_t = 0x7
- highSpeedFlag_t = true
- prach_FreqOffset_t = 0x1e
- prach_ConfigIndex_t = 0x3c
- ServedCells_elm
- servedCellInfo_t
- pCI_t = 0x64
- cellId_t
- pLMN_Identity_t = 02 f9 29
- eUTRANcellIdentifier_t = 00 07 ac 50 (28 bits)
- tAC_t = 02 03
- broadcastPLMNs_t:
- BroadcastPLMNs_Item_elm = 02 f8 29
- BroadcastPLMNs_Item_elm = 02 f9 29
- eUTRA_Mode_Info_t:
- fDD_t
- uL_EARFCN_t = 0x2
- dL_EARFCN_t = 0x3
- uL_Transmission_Bandwidth_t = 0x4
- dL_Transmission_Bandwidth_t = 0x4
- */
- //packedPdu: "20060050000002001500090002f8298103007a080014003c010800630002f8290007ab50102002f82900000100013300000037400640000f79ef000000640002f9290007ac50203202f82902f929000002000344"},
- packedPdu: "20060050000002001500090002f829c003007a080014003c010800630002f8290007ab50102002f82900000100013300000037400640000f79ef000000640002f9290007ac50203202f82902f929000002000344"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a08"},
+ enb: "CONNECTED LONG_MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD prach_configuration:<root_sequence_index:15 zero_correlation_zone_configuration:7 high_speed_flag:true prach_frequency_offset:30 prach_configuration_index:60 > pci:100 cell_id:\"02f929:0007ac50\" tac:\"0203\" broadcast_plmns:\"02f829\" broadcast_plmns:\"02f929\" choice_eutra_mode:<fdd:<ulear_fcn:2 dlear_fcn:3 ul_transmission_bandwidth:BW75 dl_transmission_bandwidth:BW75 > > eutra_mode:FDD ] []",
+ /*
+ X2AP-PDU:
+ successfulOutcome_t
+ procedureCode_t = 0x6
+ criticality_t = 0
+ X2SetupResponse
+ protocolIEs_t:
+ ProtocolIE_Container_elm
+ id_t = 0x15
+ criticality_t = 0
+ GlobalENB-ID
+ pLMN_Identity_t = 02 f8 29
+ eNB_ID_t:
+ long_Macro_eNB_ID_t = 00 7a 08 (21 bits)
+ ProtocolIE_Container_elm
+ id_t = 0x14
+ criticality_t = 0
+ ServedCells:
+ ServedCells_elm
+ servedCellInfo_t
+ pCI_t = 0x63
+ cellId_t
+ pLMN_Identity_t = 02 f8 29
+ eUTRANcellIdentifier_t = 00 07 ab 50 (28 bits)
+ tAC_t = 01 02
+ broadcastPLMNs_t:
+ BroadcastPLMNs_Item_elm = 02 f8 29
+ eUTRA_Mode_Info_t:
+ fDD_t
+ uL_EARFCN_t = 0x1
+ dL_EARFCN_t = 0x1
+ uL_Transmission_Bandwidth_t = 0x3
+ dL_Transmission_Bandwidth_t = 0x3
+ iE_Extensions_t:
+ ProtocolExtensionContainer_elm
+ id_t = 0x37
+ criticality_t = 0x1
+ PRACH-Configuration
+ rootSequenceIndex_t = 0xf
+ zeroCorrelationIndex_t = 0x7
+ highSpeedFlag_t = true
+ prach_FreqOffset_t = 0x1e
+ prach_ConfigIndex_t = 0x3c
+ ServedCells_elm
+ servedCellInfo_t
+ pCI_t = 0x64
+ cellId_t
+ pLMN_Identity_t = 02 f9 29
+ eUTRANcellIdentifier_t = 00 07 ac 50 (28 bits)
+ tAC_t = 02 03
+ broadcastPLMNs_t:
+ BroadcastPLMNs_Item_elm = 02 f8 29
+ BroadcastPLMNs_Item_elm = 02 f9 29
+ eUTRA_Mode_Info_t:
+ fDD_t
+ uL_EARFCN_t = 0x2
+ dL_EARFCN_t = 0x3
+ uL_Transmission_Bandwidth_t = 0x4
+ dL_Transmission_Bandwidth_t = 0x4
+ */
+ //packedPdu: "20060050000002001500090002f8298103007a080014003c010800630002f8290007ab50102002f82900000100013300000037400640000f79ef000000640002f9290007ac50203202f82902f929000002000344"},
+ packedPdu: "20060050000002001500090002f829c003007a080014003c010800630002f8290007ab50102002f82900000100013300000037400640000f79ef000000640002f9290007ac50203202f82902f929000002000344"},
- { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD csg_id:\"0007aba0\" freq_band_indicator_priority:BROADCASTED bandwidth_reduced_si:SCHEDULED ] []",
/*
X2AP-PDU:
@@ -916,7 +913,7 @@
*/
packedPdu: "2006003e000002001500080002f82900007a800014002b000800630002f8290007ab50102002f8290000010001330002004640040007aba000a040014000b4400100"},
- { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD mbms_service_area_identities:\"02f8\" mbms_service_area_identities:\"03f9\" multiband_infos:1 multiband_infos:2 multiband_infos:3 freq_band_indicator_priority:NOT_BROADCASTED ] []",
/*
X2AP-PDU:
@@ -974,7 +971,7 @@
freqBandIndicator_t = 0x3
*/
packedPdu: "20060044000002001500080002f82900007a8000140031000800630002f8290007ab50102002f8290000010001330002004f40050102f803f900a040010000544006200000010002"},
- { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD neighbour_infos:<ecgi:\"02f829:0007ab50\" pci:99 ear_fcn:1 > neighbour_infos:<ecgi:\"03f930:0008bc50\" pci:100 ear_fcn:2 > ] []",
/*
X2AP-PDU:
@@ -1025,7 +1022,7 @@
*/
packedPdu: "20060044000002001500080002f82900007a8000140031004000630002f8290007ab50102002f82900000100013300020002f8290007ab50006300010003f9300008bc5000640002"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD neighbour_infos:<ecgi:\"02f829:0007ab50\" pci:99 ear_fcn:1 tac:\"0102\" > neighbour_infos:<ecgi:\"03f930:0008bc50\" pci:100 ear_fcn:3 > ] []",
/*
X2AP-PDU:
@@ -1086,7 +1083,7 @@
*/
packedPdu: "20060055000002001500080002f82900007a8000140042004000630002f8290007ab50102002f82900000100013300024002f8290007ab50006300010000004c400201024003f9300008bc50006400020000005e0003800103"},
- {key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"007a80"},
+ {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "007a80"},
enb: "CONNECTED MACRO_ENB [pci:99 cell_id:\"02f829:0007ab50\" tac:\"0102\" broadcast_plmns:\"02f829\" choice_eutra_mode:<fdd:<ulear_fcn:1 dlear_fcn:1 ul_transmission_bandwidth:BW50 dl_transmission_bandwidth:BW50 > > eutra_mode:FDD neighbour_infos:<ecgi:\"02f829:0007ab50\" pci:99 ear_fcn:1 tac:\"0102\" > neighbour_infos:<ecgi:\"03f930:0008bc50\" pci:100 ear_fcn:3 > ] []",
/*
X2AP-PDU:
@@ -1146,10 +1143,9 @@
EARFCNExtension = 0x3
*/
packedPdu: "20060055000002001500080002f82900007a8000140042004000630002f8290007ab50102002f82900000100013300024002f8290007ab50006300010000004c400201024003f9300008bc50006400020000005e0003800103",
- /*failure: fmt.Errorf("getAtom for path [successfulOutcome_t X2SetupResponse protocolIEs_t ProtocolIE_Container_elm GlobalENB-ID pLMN_Identity_t] failed, rc = 2" /NO_SPACE_LEFT),*/},
+ /*failure: fmt.Errorf("getAtom for path [successfulOutcome_t X2SetupResponse protocolIEs_t ProtocolIE_Container_elm GlobalENB-ID pLMN_Identity_t] failed, rc = 2" /NO_SPACE_LEFT),*/ },
}
- initDb_f := true
for _, tc := range testCases {
t.Run(tc.packedPdu, func(t *testing.T) {
@@ -1188,31 +1184,12 @@
} else {
nb := &entities.NodebInfo{}
nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
- nb.Configuration = &entities.NodebInfo_Enb{Enb:enb}
+ nb.Configuration = &entities.NodebInfo_Enb{Enb: enb}
embStr := fmt.Sprintf("%s %s %s %s", nb.ConnectionStatus, enb.EnbType, enb.ServedCells, enb.GuGroupIds)
if !strings.EqualFold(embStr, tc.enb) {
t.Errorf("want: enb=%s, got: %s", tc.enb, embStr)
}
-
- // Save to rNib
- if tc.saveToRNib {
- if initDb_f {
- rNibWriter.Init("e2Manager", 1)
- initDb_f = false
- }
- nbIdentity := &entities.NbIdentity{InventoryName:"RanName", GlobalNbId:key}
- if rNibErr := rNibWriter.GetRNibWriter().SaveNodeb(nbIdentity, nb); rNibErr != nil {
- if tc.failure == nil {
- t.Errorf("rNibWriter failed to save ENB. Error: %s\n", rNibErr.Error())
- } else {
- if strings.Compare(rNibErr.Error(), tc.failure.Error()) != 0 {
- t.Errorf("want: %s, got: %s", tc.failure, rNibErr.Error())
- }
- }
- }
- }
}
})
}
}
-
diff --git a/E2Manager/handlers/httpmsghandlers/delete_all_request_handler.go b/E2Manager/handlers/httpmsghandlers/delete_all_request_handler.go
index c25235c..ba77075 100644
--- a/E2Manager/handlers/httpmsghandlers/delete_all_request_handler.go
+++ b/E2Manager/handlers/httpmsghandlers/delete_all_request_handler.go
@@ -23,29 +23,24 @@
"e2mgr/e2managererrors"
"e2mgr/logger"
"e2mgr/models"
- "e2mgr/rNibWriter"
"e2mgr/rmrCgo"
"e2mgr/services"
"e2mgr/stateMachine"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
"time"
)
type DeleteAllRequestHandler struct {
- readerProvider func() reader.RNibReader
- writerProvider func() rNibWriter.RNibWriter
- rmrService *services.RmrService
- config *configuration.Configuration
+ rnibDataService services.RNibDataService
+ rmrService *services.RmrService
+ config *configuration.Configuration
logger *logger.Logger
}
-func NewDeleteAllRequestHandler(logger *logger.Logger, rmrService *services.RmrService, config *configuration.Configuration, writerProvider func() rNibWriter.RNibWriter,
- readerProvider func() reader.RNibReader) *DeleteAllRequestHandler {
+func NewDeleteAllRequestHandler(logger *logger.Logger, rmrService *services.RmrService, config *configuration.Configuration, rnibDataService services.RNibDataService) *DeleteAllRequestHandler {
return &DeleteAllRequestHandler{
logger: logger,
- readerProvider: readerProvider,
- writerProvider: writerProvider,
+ rnibDataService: rnibDataService,
rmrService: rmrService,
config: config,
}
@@ -81,7 +76,7 @@
}
func (handler *DeleteAllRequestHandler) updateNodebStates(timeoutExpired bool) (error, bool) {
- nbIdentityList, err := handler.readerProvider().GetListNodebIds()
+ nbIdentityList, err := handler.rnibDataService.GetListNodebIds()
if err != nil {
handler.logger.Errorf("#DeleteAllRequestHandler.updateNodebStates - failed to get nodes list from RNIB. Error: %s", err.Error())
@@ -95,7 +90,7 @@
numOfRanToShutDown := 0
for _, nbIdentity := range nbIdentityList {
- node, err := handler.readerProvider().GetNodeb((*nbIdentity).GetInventoryName())
+ node, err := handler.rnibDataService.GetNodeb((*nbIdentity).GetInventoryName())
if err != nil {
handler.logger.Errorf("#DeleteAllRequestHandler.updateNodebStates - failed to get nodeB entity for ran name: %v from RNIB. Error: %s",
@@ -138,7 +133,7 @@
node.ConnectionStatus = nextStatus
- err := handler.writerProvider().SaveNodeb(nbIdentity, node)
+ err := handler.rnibDataService.SaveNodeb(nbIdentity, node)
if err != nil {
handler.logger.Errorf("#DeleteAllRequestHandler.saveNodebNextState - failed to save nodeB entity for inventory name: %v to RNIB. Error: %s",
@@ -166,7 +161,7 @@
node.ConnectionStatus = entities.ConnectionStatus_SHUT_DOWN
- err := handler.writerProvider().SaveNodeb(nbIdentity, node)
+ err := handler.rnibDataService.SaveNodeb(nbIdentity, node)
if err != nil {
handler.logger.Errorf("#DeleteAllRequestHandler.saveNodebShutDownState - failed to save nodeB entity for inventory name: %v to RNIB. Error: %s",
diff --git a/E2Manager/handlers/httpmsghandlers/delete_all_request_handler_test.go b/E2Manager/handlers/httpmsghandlers/delete_all_request_handler_test.go
index be1cd25..6e16766 100644
--- a/E2Manager/handlers/httpmsghandlers/delete_all_request_handler_test.go
+++ b/E2Manager/handlers/httpmsghandlers/delete_all_request_handler_test.go
@@ -37,8 +37,9 @@
"testing"
)
-func TestHandleBeforeTimerGetListNodebIdsFailedFlow(t *testing.T) {
+func setupTest(t *testing.T) (*logger.Logger, *configuration.Configuration, *mocks.RnibReaderMock, *mocks.RnibWriterMock, services.RNibDataService, *mocks.RmrMessengerMock) {
log := initLog(t)
+ config := configuration.ParseConfiguration()
readerMock := &mocks.RnibReaderMock{}
readerProvider := func() reader.RNibReader {
@@ -48,11 +49,15 @@
writerProvider := func() rNibWriter.RNibWriter {
return writerMock
}
+ rnibDataService := services.NewRnibDataService(log, config, readerProvider, writerProvider)
rmrMessengerMock := &mocks.RmrMessengerMock{}
+ return log, config, readerMock, writerMock, rnibDataService, rmrMessengerMock
+}
- config := configuration.ParseConfiguration()
+func TestHandleBeforeTimerGetListNodebIdsFailedFlow(t *testing.T){
+ log, config, readerMock, _, rnibDataService, rmrMessengerMock := setupTest(t)
- handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, writerProvider, readerProvider)
+ handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, rnibDataService)
rnibErr := &common.ResourceNotFoundError{}
var nbIdentityList []*entities.NbIdentity
@@ -65,22 +70,12 @@
}
}
-func TestHandleAfterTimerGetListNodebIdsFailedFlow(t *testing.T) {
- log := initLog(t)
+func TestHandleAfterTimerGetListNodebIdsFailedFlow(t *testing.T){
+ log, config, readerMock, writerMock, rnibDataService, rmrMessengerMock := setupTest(t)
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- config := configuration.ParseConfiguration()
config.BigRedButtonTimeoutSec = 1
- handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, writerProvider, readerProvider)
+ handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, rnibDataService)
rnibErr := &common.ResourceNotFoundError{}
//Before timer: Disconnected->ShutDown, ShuttingDown->Ignore, Connected->ShuttingDown
@@ -108,21 +103,11 @@
}
}
-func TestHandleSuccessFlow(t *testing.T) {
- log := initLog(t)
+func TestHandleSuccessFlow(t *testing.T){
+ log, config, readerMock, writerMock, rnibDataService, rmrMessengerMock := setupTest(t)
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- config := configuration.ParseConfiguration()
config.BigRedButtonTimeoutSec = 1
- handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, writerProvider, readerProvider)
+ handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, rnibDataService)
//Before timer: Disconnected->ShutDown, ShuttingDown->Ignore, Connected->ShuttingDown
nbIdentityList := createIdentityList()
@@ -163,21 +148,11 @@
assert.Nil(t, actual)
}
-func TestHandleSuccessGetNextStatusFlow(t *testing.T) {
- log := initLog(t)
+func TestHandleSuccessGetNextStatusFlow(t *testing.T){
+ log, config, readerMock, writerMock, rnibDataService, rmrMessengerMock := setupTest(t)
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- config := configuration.ParseConfiguration()
config.BigRedButtonTimeoutSec = 1
- handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, writerProvider, readerProvider)
+ handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, rnibDataService)
nbIdentityList := []*entities.NbIdentity{{InventoryName: "RanName_1"}}
readerMock.On("GetListNodebIds").Return(nbIdentityList, nil)
@@ -205,21 +180,11 @@
assert.Nil(t, actual)
}
-func TestHandleShuttingDownStatusFlow(t *testing.T) {
- log := initLog(t)
+func TestHandleShuttingDownStatusFlow(t *testing.T){
+ log, config, readerMock, writerMock, rnibDataService, rmrMessengerMock := setupTest(t)
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- config := configuration.ParseConfiguration()
config.BigRedButtonTimeoutSec = 1
- handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, writerProvider, readerProvider)
+ handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, rnibDataService)
nbIdentityList := []*entities.NbIdentity{{InventoryName: "RanName_1"}}
readerMock.On("GetListNodebIds").Return(nbIdentityList, nil)
@@ -244,21 +209,11 @@
assert.Nil(t, actual)
}
-func TestHandleGetNodebFailedFlow(t *testing.T) {
- log := initLog(t)
+func TestHandleGetNodebFailedFlow(t *testing.T){
+ log, config, readerMock, writerMock, rnibDataService, rmrMessengerMock := setupTest(t)
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- config := configuration.ParseConfiguration()
config.BigRedButtonTimeoutSec = 1
- handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, writerProvider, readerProvider)
+ handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, rnibDataService)
//Before timer: Disconnected->ShutDown(will fail), ShuttingDown->Ignore, Connected->ShuttingDown
nbIdentityList := createIdentityList()
@@ -300,21 +255,11 @@
assert.Nil(t, actual)
}
-func TestHandleSaveFailedFlow(t *testing.T) {
- log := initLog(t)
+func TestHandleSaveFailedFlow(t *testing.T){
+ log, config, readerMock, writerMock, rnibDataService, rmrMessengerMock := setupTest(t)
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- config := configuration.ParseConfiguration()
config.BigRedButtonTimeoutSec = 1
- handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, writerProvider, readerProvider)
+ handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, rnibDataService)
//Before timer: Disconnected->ShutDown, ShuttingDown->Ignore, Connected->ShuttingDown(will fail)
nbIdentityList := createIdentityList()
@@ -356,21 +301,11 @@
assert.Nil(t, actual)
}
-func TestHandleSendRmrFailedFlow(t *testing.T) {
- log := initLog(t)
+func TestHandleSendRmrFailedFlow(t *testing.T){
+ log, config, readerMock, writerMock, rnibDataService, rmrMessengerMock := setupTest(t)
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- config := configuration.ParseConfiguration()
config.BigRedButtonTimeoutSec = 1
- handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, writerProvider, readerProvider)
+ handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, rnibDataService)
//Before timer: Disconnected->ShutDown, ShuttingDown->Ignore, Connected->ShuttingDown(will fail)
nbIdentityList := createIdentityList()
@@ -414,21 +349,10 @@
}
}
-func TestHandleGetListEnbIdsEmptyFlow(t *testing.T) {
- log := initLog(t)
+func TestHandleGetListEnbIdsEmptyFlow(t *testing.T){
+ log, config, readerMock, _, rnibDataService, rmrMessengerMock := setupTest(t)
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- config := configuration.ParseConfiguration()
-
- handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, writerProvider, readerProvider)
+ handler := NewDeleteAllRequestHandler(log, getRmrService(rmrMessengerMock, log), config, rnibDataService)
var rnibError error
nbIdentityList := []*entities.NbIdentity{}
diff --git a/E2Manager/handlers/httpmsghandlers/setup_request_handler.go b/E2Manager/handlers/httpmsghandlers/setup_request_handler.go
index a792a45..36df7bf 100644
--- a/E2Manager/handlers/httpmsghandlers/setup_request_handler.go
+++ b/E2Manager/handlers/httpmsghandlers/setup_request_handler.go
@@ -21,11 +21,10 @@
"e2mgr/logger"
"e2mgr/managers"
"e2mgr/models"
- "e2mgr/rNibWriter"
"e2mgr/rnibBuilders"
+ "e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
"github.com/go-ozzo/ozzo-validation"
"github.com/go-ozzo/ozzo-validation/is"
)
@@ -36,19 +35,17 @@
)
type SetupRequestHandler struct {
- readerProvider func() reader.RNibReader
- writerProvider func() rNibWriter.RNibWriter
+ rNibDataService services.RNibDataService
logger *logger.Logger
ranSetupManager *managers.RanSetupManager
protocol entities.E2ApplicationProtocol
}
-func NewSetupRequestHandler(logger *logger.Logger, writerProvider func() rNibWriter.RNibWriter, readerProvider func() reader.RNibReader,
+func NewSetupRequestHandler(logger *logger.Logger, rNibDataService services.RNibDataService,
ranSetupManager *managers.RanSetupManager, protocol entities.E2ApplicationProtocol) *SetupRequestHandler {
return &SetupRequestHandler{
logger: logger,
- readerProvider: readerProvider,
- writerProvider: writerProvider,
+ rNibDataService: rNibDataService,
ranSetupManager: ranSetupManager,
protocol: protocol,
}
@@ -63,7 +60,7 @@
return err
}
- nodebInfo, err := handler.readerProvider().GetNodeb(setupRequest.RanName)
+ nodebInfo, err := handler.rNibDataService.GetNodeb(setupRequest.RanName)
if err != nil {
_, ok := err.(*common.ResourceNotFoundError)
if !ok {
@@ -101,7 +98,7 @@
nodebInfo, nodebIdentity := rnibBuilders.CreateInitialNodeInfo(request, protocol)
- rNibErr := handler.writerProvider().SaveNodeb(nodebIdentity, nodebInfo)
+ rNibErr := handler.rNibDataService.SaveNodeb(nodebIdentity, nodebInfo)
if rNibErr != nil {
handler.logger.Errorf("#SetupRequestHandler.connectNewRan - failed to initial nodeb entity for ran name: %v in RNIB. Error: %s", request.RanName, rNibErr.Error())
return e2managererrors.NewRnibDbError()
diff --git a/E2Manager/handlers/httpmsghandlers/setup_request_handler_test.go b/E2Manager/handlers/httpmsghandlers/setup_request_handler_test.go
index 8783389..a545cff 100644
--- a/E2Manager/handlers/httpmsghandlers/setup_request_handler_test.go
+++ b/E2Manager/handlers/httpmsghandlers/setup_request_handler_test.go
@@ -17,6 +17,7 @@
package httpmsghandlers
import (
+ "e2mgr/configuration"
"e2mgr/e2managererrors"
"e2mgr/e2pdus"
"e2mgr/managers"
@@ -25,6 +26,7 @@
"e2mgr/rNibWriter"
"e2mgr/rmrCgo"
"e2mgr/rnibBuilders"
+ "e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
@@ -283,6 +285,7 @@
func initSetupRequestTest(t *testing.T, protocol entities.E2ApplicationProtocol)(*mocks.RnibReaderMock, *mocks.RnibWriterMock, *SetupRequestHandler, *mocks.RmrMessengerMock) {
log := initLog(t)
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
readerMock := &mocks.RnibReaderMock{}
readerProvider := func() reader.RNibReader {
@@ -296,8 +299,10 @@
rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrService := getRmrService(rmrMessengerMock, log)
- ranSetupManager := managers.NewRanSetupManager(log, rmrService, writerProvider)
- handler := NewSetupRequestHandler(log, writerProvider, readerProvider, ranSetupManager, protocol)
+ rnibDataService := services.NewRnibDataService(log, config, readerProvider, writerProvider)
+
+ ranSetupManager := managers.NewRanSetupManager(log, rmrService, rnibDataService)
+ handler := NewSetupRequestHandler(log, rnibDataService, ranSetupManager, protocol)
return readerMock, writerMock, handler, rmrMessengerMock
}
\ No newline at end of file
diff --git a/E2Manager/handlers/httpmsghandlers/x2_reset_request_handler.go b/E2Manager/handlers/httpmsghandlers/x2_reset_request_handler.go
index 72f7ccb..3d02272 100644
--- a/E2Manager/handlers/httpmsghandlers/x2_reset_request_handler.go
+++ b/E2Manager/handlers/httpmsghandlers/x2_reset_request_handler.go
@@ -22,12 +22,10 @@
"e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/models"
- "e2mgr/rNibWriter"
"e2mgr/rmrCgo"
"e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
)
const (
@@ -35,17 +33,14 @@
)
type X2ResetRequestHandler struct {
- readerProvider func() reader.RNibReader
- writerProvider func() rNibWriter.RNibWriter
+ rNibDataService services.RNibDataService
rmrService *services.RmrService
logger *logger.Logger
}
-func NewX2ResetRequestHandler(logger *logger.Logger, rmrService *services.RmrService, writerProvider func() rNibWriter.RNibWriter,
- readerProvider func() reader.RNibReader) *X2ResetRequestHandler {
+func NewX2ResetRequestHandler(logger *logger.Logger, rmrService *services.RmrService, rNibDataService services.RNibDataService) *X2ResetRequestHandler {
return &X2ResetRequestHandler{
- readerProvider: readerProvider,
- writerProvider: writerProvider,
+ rNibDataService: rNibDataService,
rmrService: rmrService,
logger: logger,
}
@@ -63,7 +58,7 @@
return e2managererrors.NewRequestValidationError()
}
- nodeb, err := handler.readerProvider().GetNodeb(resetRequest.RanName)
+ nodeb, err := handler.rNibDataService.GetNodeb(resetRequest.RanName)
if err != nil {
handler.logger.Errorf("#reset_request_handler.Handle - failed to get status of RAN: %s from RNIB. Error: %s", resetRequest.RanName, err.Error())
_, ok := err.(*common.ResourceNotFoundError)
diff --git a/E2Manager/handlers/httpmsghandlers/x2_reset_request_handler_test.go b/E2Manager/handlers/httpmsghandlers/x2_reset_request_handler_test.go
index 864e824..64e0c10 100644
--- a/E2Manager/handlers/httpmsghandlers/x2_reset_request_handler_test.go
+++ b/E2Manager/handlers/httpmsghandlers/x2_reset_request_handler_test.go
@@ -1,11 +1,13 @@
package httpmsghandlers
import (
+ "e2mgr/configuration"
"e2mgr/e2managererrors"
"e2mgr/mocks"
"e2mgr/models"
"e2mgr/rNibWriter"
"e2mgr/rmrCgo"
+ "e2mgr/services"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
@@ -15,11 +17,9 @@
"testing"
)
-func TestHandleSuccessfulDefaultCause(t *testing.T) {
+func setupX2ResetRequestHandlerTest(t *testing.T) (*X2ResetRequestHandler, *mocks.RmrMessengerMock, *mocks.RnibReaderMock){
log := initLog(t)
-
- ranName := "test1"
-
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
readerMock := &mocks.RnibReaderMock{}
readerProvider := func() reader.RNibReader {
return readerMock
@@ -28,15 +28,23 @@
writerProvider := func() rNibWriter.RNibWriter {
return writerMock
}
+ rnibDataService := services.NewRnibDataService(log, config, readerProvider, writerProvider)
+ rmrMessengerMock := &mocks.RmrMessengerMock{}
+ rmrService := getRmrService(rmrMessengerMock, log)
+ handler := NewX2ResetRequestHandler(log, rmrService, rnibDataService)
+
+ return handler, rmrMessengerMock, readerMock
+}
+func TestHandleSuccessfulDefaultCause(t *testing.T) {
+ handler, rmrMessengerMock, readerMock := setupX2ResetRequestHandlerTest(t)
+
+ ranName := "test1"
// o&m intervention
payload := []byte{0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x05, 0x40, 0x01, 0x64}
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_RESET, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- rmrMessengerMock.On("SendMsg", msg, mock.Anything).Return(msg, nil)
- rmrService := getRmrService(rmrMessengerMock, log)
- handler := NewX2ResetRequestHandler(log, rmrService, writerProvider, readerProvider)
+ rmrMessengerMock.On("SendMsg", msg, mock.Anything).Return(msg, nil)
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED}
readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
@@ -47,28 +55,14 @@
}
func TestHandleSuccessfulRequestedCause(t *testing.T) {
- log := initLog(t)
+ handler, rmrMessengerMock, readerMock := setupX2ResetRequestHandlerTest(t)
ranName := "test1"
-
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
payload := []byte{0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x05, 0x40, 0x01, 0x40}
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_RESET, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", msg, mock.Anything).Return(msg, nil)
- rmrService := getRmrService(rmrMessengerMock, log)
- handler := NewX2ResetRequestHandler(log, rmrService, writerProvider, readerProvider)
-
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED}
readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
@@ -78,24 +72,9 @@
}
func TestHandleFailureUnknownCause(t *testing.T) {
- log := initLog(t)
+ handler, _, readerMock := setupX2ResetRequestHandlerTest(t)
ranName := "test1"
-
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
-
- rmrService := getRmrService(rmrMessengerMock, log)
- handler := NewX2ResetRequestHandler(log, rmrService, writerProvider, readerProvider)
-
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED}
readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
@@ -106,24 +85,9 @@
}
func TestHandleFailureWrongState(t *testing.T) {
- log := initLog(t)
+ handler, _, readerMock := setupX2ResetRequestHandlerTest(t)
ranName := "test1"
-
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
-
- rmrService := getRmrService(rmrMessengerMock, log)
- handler := NewX2ResetRequestHandler(log, rmrService, writerProvider, readerProvider)
-
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_DISCONNECTED}
readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
@@ -133,24 +97,10 @@
}
func TestHandleFailureRanNotFound(t *testing.T) {
- log := initLog(t)
+ handler, _, readerMock := setupX2ResetRequestHandlerTest(t)
ranName := "test1"
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
-
- rmrService := getRmrService(rmrMessengerMock, log)
- handler := NewX2ResetRequestHandler(log, rmrService, writerProvider, readerProvider)
-
readerMock.On("GetNodeb", ranName).Return(&entities.NodebInfo{}, common.NewResourceNotFoundError("nodeb not found"))
actual := handler.Handle(models.ResetRequest{RanName: ranName})
@@ -159,24 +109,10 @@
}
func TestHandleFailureRnibError(t *testing.T) {
- log := initLog(t)
+ handler, _, readerMock := setupX2ResetRequestHandlerTest(t)
ranName := "test1"
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
- rmrMessengerMock := &mocks.RmrMessengerMock{}
-
- rmrService := getRmrService(rmrMessengerMock, log)
- handler := NewX2ResetRequestHandler(log, rmrService, writerProvider, readerProvider)
-
readerMock.On("GetNodeb", ranName).Return(&entities.NodebInfo{}, common.NewInternalError(fmt.Errorf("internal error")))
actual := handler.Handle(models.ResetRequest{RanName: ranName})
@@ -185,28 +121,15 @@
}
func TestHandleFailureRmrError(t *testing.T) {
- log := initLog(t)
+ handler, rmrMessengerMock, readerMock := setupX2ResetRequestHandlerTest(t)
ranName := "test1"
-
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
// o&m intervention
payload := []byte{0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x05, 0x40, 0x01, 0x64}
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_RESET, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", msg, mock.Anything).Return(&rmrCgo.MBuf{}, fmt.Errorf("rmr error"))
- rmrService := getRmrService(rmrMessengerMock, log)
- handler := NewX2ResetRequestHandler(log, rmrService, writerProvider, readerProvider)
-
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED}
readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
diff --git a/E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler.go b/E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler.go
index 73e86bd..783f714 100644
--- a/E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler.go
+++ b/E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler.go
@@ -21,27 +21,27 @@
"e2mgr/logger"
"e2mgr/managers"
"e2mgr/models"
+ "e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
)
type E2TermInitNotificationHandler struct {
- rnibReaderProvider func() reader.RNibReader
+ rnibDataService services.RNibDataService
ranReconnectionManager *managers.RanReconnectionManager
}
-func NewE2TermInitNotificationHandler(ranReconnectionManager *managers.RanReconnectionManager, rnibReaderProvider func() reader.RNibReader) E2TermInitNotificationHandler {
+func NewE2TermInitNotificationHandler(ranReconnectionManager *managers.RanReconnectionManager, rnibDataService services.RNibDataService) E2TermInitNotificationHandler {
return E2TermInitNotificationHandler{
- rnibReaderProvider: rnibReaderProvider,
+ rnibDataService: rnibDataService,
ranReconnectionManager: ranReconnectionManager,
}
}
func (handler E2TermInitNotificationHandler) Handle(logger *logger.Logger, request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
-logger.Infof("#E2TermInitNotificationHandler.Handle - Handling E2_TERM_INIT")
+ logger.Infof("#E2TermInitNotificationHandler.Handle - Handling E2_TERM_INIT")
- nbIdentityList, err := handler.rnibReaderProvider().GetListNodebIds()
+ nbIdentityList, err := handler.rnibDataService.GetListNodebIds()
if err != nil {
logger.Errorf("#E2TermInitNotificationHandler.Handle - Failed to get nodes list from RNIB. Error: %s", err.Error())
return
diff --git a/E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler_test.go b/E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler_test.go
index 8bb8a05..308d970 100644
--- a/E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler_test.go
+++ b/E2Manager/handlers/rmrmsghandlers/e2_term_init_notification_handler_test.go
@@ -19,9 +19,10 @@
"testing"
)
-func initRanLostConnectionTest(t *testing.T) (*logger.Logger, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.RmrMessengerMock, *managers.RanReconnectionManager) {
+func initRanLostConnectionTest(t *testing.T) (*logger.Logger, E2TermInitNotificationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock, *mocks.RmrMessengerMock) {
logger := initLog(t)
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrService := getRmrService(rmrMessengerMock, logger)
@@ -34,19 +35,17 @@
rnibWriterProvider := func() rNibWriter.RNibWriter {
return writerMock
}
- ranSetupManager := managers.NewRanSetupManager(logger, rmrService, rnibWriterProvider)
- ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibReaderProvider, rnibWriterProvider, ranSetupManager)
- return logger, readerMock, writerMock, rmrMessengerMock, ranReconnectionManager
+ rnibDataService := services.NewRnibDataService(logger, config, rnibReaderProvider, rnibWriterProvider)
+ ranSetupManager := managers.NewRanSetupManager(logger, rmrService, rnibDataService)
+ ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, ranSetupManager)
+ handler := NewE2TermInitNotificationHandler(ranReconnectionManager, rnibDataService)
+ return logger, handler, readerMock, writerMock, rmrMessengerMock
}
func TestE2TerminInitHandlerSuccessOneRan(t *testing.T) {
- log, readerMock, writerMock, rmrMessengerMock, ranReconnectMgr := initRanLostConnectionTest(t)
+ log, handler, readerMock, writerMock, rmrMessengerMock := initRanLostConnectionTest(t)
var rnibErr error
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
-
ids := []*entities.NbIdentity{{InventoryName: "test1"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
@@ -62,7 +61,6 @@
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg, nil)
- handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil)
writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 1)
@@ -70,13 +68,9 @@
}
func TestE2TerminInitHandlerSuccessTwoRans(t *testing.T) {
- log, readerMock, writerMock, rmrMessengerMock, ranReconnectMgr := initRanLostConnectionTest(t)
+ log, handler, readerMock, writerMock, rmrMessengerMock := initRanLostConnectionTest(t)
var rnibErr error
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
-
ids := []*entities.NbIdentity{{InventoryName: "test1"}, {InventoryName: "test2"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
@@ -94,7 +88,6 @@
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg, nil)
- handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil)
writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 2)
@@ -102,13 +95,9 @@
}
func TestE2TerminInitHandlerSuccessThreeRansFirstRmrFailure(t *testing.T) {
- log, readerMock, writerMock, rmrMessengerMock, ranReconnectMgr := initRanLostConnectionTest(t)
+ log, handler, readerMock, writerMock, rmrMessengerMock := initRanLostConnectionTest(t)
var rnibErr error
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
-
ids := []*entities.NbIdentity{{InventoryName: "test1"}, {InventoryName: "test2"}, {InventoryName: "test3"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
@@ -135,7 +124,6 @@
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg0, fmt.Errorf("RMR Error"))
- handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil)
//test1 (before send +1, after failure +1), test2 (0) test3 (0)
@@ -145,13 +133,9 @@
}
func TestE2TerminInitHandlerSuccessThreeRansSecondNotFoundFailure(t *testing.T) {
- log, readerMock, writerMock, rmrMessengerMock, ranReconnectMgr := initRanLostConnectionTest(t)
+ log, handler, readerMock, writerMock, rmrMessengerMock := initRanLostConnectionTest(t)
var rnibErr error
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
-
ids := []*entities.NbIdentity{{InventoryName: "test1"}, {InventoryName: "test2"}, {InventoryName: "test3"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
@@ -183,7 +167,6 @@
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg0, nil)
- handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil)
readerMock.AssertNumberOfCalls(t, "GetNodeb", 3)
@@ -194,13 +177,9 @@
}
func TestE2TerminInitHandlerSuccessThreeRansSecondRnibInternalErrorFailure(t *testing.T) {
- log, readerMock, writerMock, rmrMessengerMock, ranReconnectMgr := initRanLostConnectionTest(t)
+ log, handler, readerMock, writerMock, rmrMessengerMock := initRanLostConnectionTest(t)
var rnibErr error
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
-
ids := []*entities.NbIdentity{{InventoryName: "test1"}, {InventoryName: "test2"}, {InventoryName: "test3"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
@@ -232,7 +211,6 @@
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg0, nil)
- handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil)
readerMock.AssertNumberOfCalls(t, "GetNodeb", 2)
@@ -243,16 +221,11 @@
}
func TestE2TerminInitHandlerSuccessZeroRans(t *testing.T) {
- log, readerMock, writerMock, rmrMessengerMock, ranReconnectMgr := initRanLostConnectionTest(t)
+ log, handler, readerMock, writerMock, rmrMessengerMock := initRanLostConnectionTest(t)
var rnibErr error
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
-
readerMock.On("GetListNodebIds").Return([]*entities.NbIdentity{}, rnibErr)
- handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil)
writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 0)
@@ -260,15 +233,10 @@
}
func TestE2TerminInitHandlerFailureGetListNodebIds(t *testing.T) {
- log, readerMock, writerMock, rmrMessengerMock, ranReconnectMgr := initRanLostConnectionTest(t)
-
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
+ log, handler, readerMock, writerMock, rmrMessengerMock := initRanLostConnectionTest(t)
readerMock.On("GetListNodebIds").Return([]*entities.NbIdentity{}, common.NewInternalError(fmt.Errorf("internal error")))
- handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil)
writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 0)
diff --git a/E2Manager/handlers/rmrmsghandlers/enb_load_information_notification_handler.go b/E2Manager/handlers/rmrmsghandlers/enb_load_information_notification_handler.go
index 2185e2b..88763a3 100644
--- a/E2Manager/handlers/rmrmsghandlers/enb_load_information_notification_handler.go
+++ b/E2Manager/handlers/rmrmsghandlers/enb_load_information_notification_handler.go
@@ -6,18 +6,18 @@
"e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/models"
- "e2mgr/rNibWriter"
+ "e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"time"
)
type EnbLoadInformationNotificationHandler struct {
- rnibWriterProvider func() rNibWriter.RNibWriter
+ rnibDataService services.RNibDataService
}
-func NewEnbLoadInformationNotificationHandler(rnibWriterProvider func() rNibWriter.RNibWriter) EnbLoadInformationNotificationHandler {
+func NewEnbLoadInformationNotificationHandler(rnibDataService services.RNibDataService) EnbLoadInformationNotificationHandler {
return EnbLoadInformationNotificationHandler{
- rnibWriterProvider: rnibWriterProvider,
+ rnibDataService: rnibDataService,
}
}
@@ -47,7 +47,7 @@
logger.Debugf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Successfully done with extracting and building RAN load information. elapsed: %f ms", request.RanName, elapsed(request.StartTime))
- rnibErr := src.rnibWriterProvider().SaveRanLoadInformation(request.RanName, ranLoadInformation)
+ rnibErr := src.rnibDataService.SaveRanLoadInformation(request.RanName, ranLoadInformation)
if rnibErr != nil {
logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Failed saving RAN load information. Error: %v", request.RanName, rnibErr)
diff --git a/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler.go b/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler.go
index 3595741..f6b63f3 100644
--- a/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler.go
+++ b/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler.go
@@ -20,22 +20,19 @@
"e2mgr/logger"
"e2mgr/managers"
"e2mgr/models"
- "e2mgr/rNibWriter"
+ "e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
)
type SetupResponseNotificationHandler struct {
- rnibReaderProvider func() reader.RNibReader
- rnibWriterProvider func() rNibWriter.RNibWriter
+ rnibDataService services.RNibDataService
setupResponseManager managers.ISetupResponseManager
notificationType string
}
-func NewSetupResponseNotificationHandler(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter, setupResponseManager managers.ISetupResponseManager, notificationType string) SetupResponseNotificationHandler {
+func NewSetupResponseNotificationHandler(rnibDataService services.RNibDataService, setupResponseManager managers.ISetupResponseManager, notificationType string) SetupResponseNotificationHandler {
return SetupResponseNotificationHandler{
- rnibReaderProvider: rnibReaderProvider,
- rnibWriterProvider: rnibWriterProvider,
+ rnibDataService: rnibDataService,
setupResponseManager: setupResponseManager,
notificationType: notificationType,
}
@@ -46,7 +43,7 @@
inventoryName := request.RanName
- nodebInfo, rnibErr := h.rnibReaderProvider().GetNodeb(inventoryName)
+ nodebInfo, rnibErr := h.rnibDataService.GetNodeb(inventoryName)
if rnibErr != nil {
logger.Errorf("#SetupResponseNotificationHandler - RAN name: %s - Error fetching RAN from rNib: %v", request.RanName, rnibErr)
@@ -66,7 +63,7 @@
return
}
- rnibErr = h.rnibWriterProvider().SaveNodeb(nbIdentity, nodebInfo)
+ rnibErr = h.rnibDataService.SaveNodeb(nbIdentity, nodebInfo)
if rnibErr != nil {
logger.Errorf("#SetupResponseNotificationHandler - RAN name: %s - Error saving RAN to rNib: %v", request.RanName, rnibErr)
diff --git a/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler_test.go b/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler_test.go
index 04358a6..d4503b8 100644
--- a/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler_test.go
+++ b/E2Manager/handlers/rmrmsghandlers/setup_response_notification_handler_test.go
@@ -18,11 +18,13 @@
package rmrmsghandlers
import (
+ "e2mgr/configuration"
"e2mgr/logger"
"e2mgr/managers"
"e2mgr/mocks"
"e2mgr/models"
"e2mgr/rNibWriter"
+ "e2mgr/services"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
@@ -45,26 +47,28 @@
logger *logger.Logger
readerMock *mocks.RnibReaderMock
writerMock *mocks.RnibWriterMock
- rnibReaderProvider func() reader.RNibReader
- rnibWriterProvider func() rNibWriter.RNibWriter
+ rnibDataService services.RNibDataService
setupResponseManager managers.ISetupResponseManager
}
func NewSetupResponseTestContext(manager managers.ISetupResponseManager) *setupResponseTestContext {
logger, _ := logger.InitLogger(logger.InfoLevel)
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
readerMock := &mocks.RnibReaderMock{}
writerMock := &mocks.RnibWriterMock{}
+ rnibReaderProvider := func() reader.RNibReader {
+ return readerMock
+ }
+ rnibWriterProvider := func() rNibWriter.RNibWriter {
+ return writerMock
+ }
+ rnibDataService := services.NewRnibDataService(logger, config, rnibReaderProvider, rnibWriterProvider)
return &setupResponseTestContext{
- logger: logger,
- readerMock: readerMock,
- writerMock: writerMock,
- rnibReaderProvider: func() reader.RNibReader {
- return readerMock
- },
- rnibWriterProvider: func() rNibWriter.RNibWriter {
- return writerMock
- },
+ logger: logger,
+ readerMock: readerMock,
+ writerMock: writerMock,
+ rnibDataService: rnibDataService,
setupResponseManager: manager,
}
}
@@ -72,7 +76,7 @@
func TestSetupResponseGetNodebFailure(t *testing.T) {
notificationRequest := models.NotificationRequest{RanName: RanName}
testContext := NewSetupResponseTestContext(nil)
- handler := NewSetupResponseNotificationHandler(testContext.rnibReaderProvider, testContext.rnibWriterProvider, &managers.X2SetupResponseManager{}, "X2 Setup Response")
+ handler := NewSetupResponseNotificationHandler(testContext.rnibDataService, &managers.X2SetupResponseManager{}, "X2 Setup Response")
testContext.readerMock.On("GetNodeb", RanName).Return(&entities.NodebInfo{}, common.NewInternalError(errors.New("Error")))
handler.Handle(testContext.logger, ¬ificationRequest, nil)
testContext.readerMock.AssertCalled(t, "GetNodeb", RanName)
@@ -83,7 +87,7 @@
ranName := "test"
notificationRequest := models.NotificationRequest{RanName: ranName}
testContext := NewSetupResponseTestContext(nil)
- handler := NewSetupResponseNotificationHandler(testContext.rnibReaderProvider, testContext.rnibWriterProvider, &managers.X2SetupResponseManager{}, "X2 Setup Response")
+ handler := NewSetupResponseNotificationHandler(testContext.rnibDataService, &managers.X2SetupResponseManager{}, "X2 Setup Response")
var rnibErr error
testContext.readerMock.On("GetNodeb", ranName).Return(&entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_SHUT_DOWN}, rnibErr)
handler.Handle(testContext.logger, ¬ificationRequest, nil)
@@ -101,7 +105,7 @@
notificationRequest := models.NotificationRequest{RanName: RanName, Payload: payload}
testContext := NewSetupResponseTestContext(setupResponseManager)
- handler := NewSetupResponseNotificationHandler(testContext.rnibReaderProvider, testContext.rnibWriterProvider, testContext.setupResponseManager, notificationType)
+ handler := NewSetupResponseNotificationHandler(testContext.rnibDataService, testContext.setupResponseManager, notificationType)
var rnibErr error
@@ -173,7 +177,7 @@
ranName := "test"
notificationRequest := models.NotificationRequest{RanName: ranName, Payload: []byte("123")}
testContext := NewSetupResponseTestContext(nil)
- handler := NewSetupResponseNotificationHandler(testContext.rnibReaderProvider, testContext.rnibWriterProvider, &managers.X2SetupResponseManager{}, "X2 Setup Response")
+ handler := NewSetupResponseNotificationHandler(testContext.rnibDataService, &managers.X2SetupResponseManager{}, "X2 Setup Response")
var rnibErr error
testContext.readerMock.On("GetNodeb", ranName).Return(&entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, ConnectionAttempts: 1}, rnibErr)
handler.Handle(testContext.logger, ¬ificationRequest, nil)
diff --git a/E2Manager/handlers/rmrmsghandlers/x2_reset_request_notification_handler.go b/E2Manager/handlers/rmrmsghandlers/x2_reset_request_notification_handler.go
index e1f6841..622a338 100644
--- a/E2Manager/handlers/rmrmsghandlers/x2_reset_request_notification_handler.go
+++ b/E2Manager/handlers/rmrmsghandlers/x2_reset_request_notification_handler.go
@@ -27,18 +27,18 @@
"e2mgr/logger"
"e2mgr/models"
"e2mgr/rmrCgo"
+ "e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
"unsafe"
)
type X2ResetRequestNotificationHandler struct {
- rnibReaderProvider func() reader.RNibReader
+ rnibDataService services.RNibDataService
}
-func NewX2ResetRequestNotificationHandler(rnibReaderProvider func() reader.RNibReader) X2ResetRequestNotificationHandler {
+func NewX2ResetRequestNotificationHandler(rnibDataService services.RNibDataService) X2ResetRequestNotificationHandler {
return X2ResetRequestNotificationHandler{
- rnibReaderProvider: rnibReaderProvider,
+ rnibDataService: rnibDataService,
}
}
@@ -46,7 +46,7 @@
logger.Debugf("#X2ResetRequestNotificationHandler.Handle - Ran name: %s", request.RanName)
- nb, rNibErr := src.rnibReaderProvider().GetNodeb(request.RanName)
+ nb, rNibErr := src.rnibDataService.GetNodeb(request.RanName)
if rNibErr != nil {
logger.Errorf("#X2ResetRequestNotificationHandler.Handle - failed to retrieve nodeB entity. RanName: %s. Error: %s", request.RanName, rNibErr.Error())
printHandlingSetupResponseElapsedTimeInMs(logger, "#X2ResetRequestNotificationHandler.Handle - Summary: Elapsed time for receiving and handling reset request message from E2 terminator", request.StartTime)
diff --git a/E2Manager/handlers/rmrmsghandlers/x2_reset_request_notification_handler_test.go b/E2Manager/handlers/rmrmsghandlers/x2_reset_request_notification_handler_test.go
index 3e32c36..309a57e 100644
--- a/E2Manager/handlers/rmrmsghandlers/x2_reset_request_notification_handler_test.go
+++ b/E2Manager/handlers/rmrmsghandlers/x2_reset_request_notification_handler_test.go
@@ -18,9 +18,12 @@
package rmrmsghandlers
import (
+ "e2mgr/configuration"
+ "e2mgr/logger"
"e2mgr/mocks"
"e2mgr/models"
"e2mgr/rmrCgo"
+ "e2mgr/services"
"e2mgr/tests"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
@@ -30,15 +33,23 @@
"time"
)
-func TestX2ResetRequestNotifSuccess(t *testing.T) {
+func initX2ResetRequestNotifHandlerTest(t *testing.T) (*logger.Logger, X2ResetRequestNotificationHandler, *mocks.RnibReaderMock) {
log := initLog(t)
- payload := []byte("payload")
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
readerMock := &mocks.RnibReaderMock{}
readerProvider := func() reader.RNibReader {
return readerMock
}
+ rnibDataService := services.NewRnibDataService(log, config, readerProvider, nil)
- h := NewX2ResetRequestNotificationHandler(readerProvider)
+ h := NewX2ResetRequestNotificationHandler(rnibDataService)
+ return log, h, readerMock
+}
+
+func TestX2ResetRequestNotifSuccess(t *testing.T) {
+ log, h, readerMock := initX2ResetRequestNotifHandlerTest(t)
+
+ payload := []byte("payload")
xaction := []byte("RanName")
mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload), "RanName", &payload, &xaction)
@@ -59,14 +70,8 @@
}
func TestHandleX2ResetRequestNotifShuttingDownStatus(t *testing.T) {
- log := initLog(t)
+ log, h, readerMock := initX2ResetRequestNotifHandlerTest(t)
var payload []byte
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
-
- h := NewX2ResetRequestNotificationHandler(readerProvider)
xaction := []byte("RanName")
mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload), "RanName", &payload, &xaction)
@@ -82,14 +87,8 @@
}
func TestHandleX2ResetRequestNotifDisconnectStatus(t *testing.T) {
- log := initLog(t)
+ log, h, readerMock := initX2ResetRequestNotifHandlerTest(t)
var payload []byte
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
-
- h := NewX2ResetRequestNotificationHandler(readerProvider)
xaction := []byte("RanName")
mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload), "RanName", &payload, &xaction)
@@ -106,14 +105,8 @@
func TestHandleX2ResetRequestNotifGetNodebFailed(t *testing.T) {
- log := initLog(t)
+ log, h, readerMock := initX2ResetRequestNotifHandlerTest(t)
var payload []byte
- readerMock := &mocks.RnibReaderMock{}
- readerProvider := func() reader.RNibReader {
- return readerMock
- }
-
- h := NewX2ResetRequestNotificationHandler(readerProvider)
xaction := []byte("RanName")
mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload), "RanName", &payload, &xaction)
notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload,
diff --git a/E2Manager/handlers/rmrmsghandlers/x2_reset_response_handler.go b/E2Manager/handlers/rmrmsghandlers/x2_reset_response_handler.go
index cd1556d..1ad7d98 100644
--- a/E2Manager/handlers/rmrmsghandlers/x2_reset_response_handler.go
+++ b/E2Manager/handlers/rmrmsghandlers/x2_reset_response_handler.go
@@ -26,16 +26,16 @@
"e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/models"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
+ "e2mgr/services"
)
type X2ResetResponseHandler struct {
- rnibReaderProvider func() reader.RNibReader
+ rnibDataService services.RNibDataService
}
-func NewX2ResetResponseHandler(rnibReaderProvider func() reader.RNibReader) X2ResetResponseHandler {
+func NewX2ResetResponseHandler(rnibDataService services.RNibDataService) X2ResetResponseHandler {
return X2ResetResponseHandler{
- rnibReaderProvider: rnibReaderProvider,
+ rnibDataService: rnibDataService,
}
}
@@ -43,11 +43,11 @@
logger.Infof("#x2ResetResponseHandler.Handle - received reset response. Payload: %x", request.Payload)
- if nb, rNibErr := src.rnibReaderProvider().GetNodeb(request.RanName); rNibErr != nil {
+ if nb, rNibErr := src.rnibDataService.GetNodeb(request.RanName); rNibErr != nil {
logger.Errorf("#x2ResetResponseHandler.Handle - failed to retrieve nb entity. RanName: %s. Error: %s", request.RanName, rNibErr.Error())
} else {
logger.Debugf("#x2ResetResponseHandler.Handle - nb entity retrieved. RanName %s, ConnectionStatus %s", nb.RanName, nb.ConnectionStatus)
- refinedMessage, err := converters.UnpackX2apPduAndRefine(logger, e2pdus.MaxAsn1CodecAllocationBufferSize , request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ refinedMessage, err := converters.UnpackX2apPduAndRefine(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
logger.Errorf("#x2ResetResponseHandler.Handle - failed to unpack reset response message. RanName %s, Payload: %s", request.RanName, request.Payload)
} else {
diff --git a/E2Manager/handlers/rmrmsghandlers/x2_reset_response_handler_test.go b/E2Manager/handlers/rmrmsghandlers/x2_reset_response_handler_test.go
index 0134399..26f0ade 100644
--- a/E2Manager/handlers/rmrmsghandlers/x2_reset_response_handler_test.go
+++ b/E2Manager/handlers/rmrmsghandlers/x2_reset_response_handler_test.go
@@ -18,10 +18,12 @@
package rmrmsghandlers
import (
+ "e2mgr/configuration"
"e2mgr/logger"
"e2mgr/mocks"
"e2mgr/models"
"e2mgr/rmrCgo"
+ "e2mgr/services"
"e2mgr/tests"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
@@ -30,12 +32,9 @@
"time"
)
-func TestX2ResetResponseSuccess(t *testing.T) {
- payload, err := tests.BuildPackedX2ResetResponse()
- if err != nil {
- t.Errorf("#x2_reset_response_handler_test.TestX2resetResponse - failed to build and pack X2ResetResponse. Error %x", err)
- }
+func initX2ResetResponseHandlerTest(t *testing.T) (*logger.Logger, X2ResetResponseHandler, *mocks.RnibReaderMock) {
log, err := logger.InitLogger(logger.DebugLevel)
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
if err!=nil{
t.Errorf("#sctp_errors_notification_handler_test.TestHandleInSession - failed to initialize logger, error: %s", err)
}
@@ -43,8 +42,20 @@
rnibReaderProvider := func() reader.RNibReader {
return readerMock
}
+ rnibDataService := services.NewRnibDataService(log, config, rnibReaderProvider, nil)
- h := NewX2ResetResponseHandler(rnibReaderProvider)
+ h := NewX2ResetResponseHandler(rnibDataService)
+ return log, h, readerMock
+}
+
+func TestX2ResetResponseSuccess(t *testing.T) {
+ log, h, readerMock := initX2ResetResponseHandlerTest(t)
+
+ payload, err := tests.BuildPackedX2ResetResponse()
+ if err != nil {
+ t.Errorf("#x2_reset_response_handler_test.TestX2resetResponse - failed to build and pack X2ResetResponse. Error %x", err)
+ }
+
xaction := []byte("RanName")
mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload),"RanName", &payload, &xaction)
notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload,
@@ -61,17 +72,9 @@
}
func TestX2ResetResponseReaderFailure(t *testing.T) {
- var payload []byte
- log, err := logger.InitLogger(logger.DebugLevel)
- if err!=nil{
- t.Errorf("#sctp_errors_notification_handler_test.TestX2ResetResponseReaderFailure - failed to initialize logger, error: %s", err)
- }
- readerMock :=&mocks.RnibReaderMock{}
- rnibReaderProvider := func() reader.RNibReader {
- return readerMock
- }
+ log, h, readerMock := initX2ResetResponseHandlerTest(t)
- h := NewX2ResetResponseHandler(rnibReaderProvider)
+ var payload []byte
xaction := []byte("RanName")
mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload),"RanName", &payload, &xaction)
notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload,
@@ -88,17 +91,9 @@
}
func TestX2ResetResponseUnpackFailure(t *testing.T) {
- payload := []byte("not valid payload")
- log, err := logger.InitLogger(logger.DebugLevel)
- if err!=nil{
- t.Errorf("#sctp_errors_notification_handler_test.TestX2ResetResponseUnpackFailure - failed to initialize logger, error: %s", err)
- }
- readerMock :=&mocks.RnibReaderMock{}
- rnibReaderProvider := func() reader.RNibReader {
- return readerMock
- }
+ log, h, readerMock := initX2ResetResponseHandlerTest(t)
- h := NewX2ResetResponseHandler(rnibReaderProvider)
+ payload := []byte("not valid payload")
xaction := []byte("RanName")
mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload),"RanName", &payload, &xaction)
notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload,
diff --git a/E2Manager/main/http_server.go b/E2Manager/main/http_server.go
index cbad8ce..7cd6e39 100644
--- a/E2Manager/main/http_server.go
+++ b/E2Manager/main/http_server.go
@@ -53,19 +53,20 @@
reader.Init("e2Manager", MAX_RNIB_POOL_INSTANCES)
defer reader.Close()
+ rnibDataService := services.NewRnibDataService(logger, config, reader.GetRNibReader, rNibWriter.GetRNibWriter)
rmrResponseChannel := make(chan *models.NotificationResponse, config.NotificationResponseBuffer)
rmrService := services.NewRmrService(rmrConfig, msgImpl, rmrResponseChannel)
- var ranSetupManager = managers.NewRanSetupManager(logger, rmrService, rNibWriter.GetRNibWriter)
- var ranReconnectionManager = managers.NewRanReconnectionManager(logger, config, reader.GetRNibReader, rNibWriter.GetRNibWriter, ranSetupManager)
- var nManager = notificationmanager.NewNotificationManager(reader.GetRNibReader, rNibWriter.GetRNibWriter, ranReconnectionManager)
+ var ranSetupManager = managers.NewRanSetupManager(logger, rmrService, rnibDataService)
+ var ranReconnectionManager = managers.NewRanReconnectionManager(logger, config, rnibDataService, ranSetupManager)
+ var nManager = notificationmanager.NewNotificationManager(rnibDataService, ranReconnectionManager)
rmrServiceReceiver := receivers.NewRmrServiceReceiver(*rmrService, nManager)
defer rmrService.CloseContext()
go rmrServiceReceiver.ListenAndHandle()
go rmrService.SendResponse()
- controller := controllers.NewNodebController(logger, rmrService, reader.GetRNibReader, rNibWriter.GetRNibWriter)
- newController := controllers.NewController(logger, rmrService, reader.GetRNibReader, rNibWriter.GetRNibWriter, config, ranSetupManager)
+ controller := controllers.NewNodebController(logger, rmrService, rnibDataService)
+ newController := controllers.NewController(logger, rmrService, rnibDataService, config, ranSetupManager)
runServer(config.Http.Port, controller, newController)
}
diff --git a/E2Manager/managers/notificationmanager/notification_manager.go b/E2Manager/managers/notificationmanager/notification_manager.go
index 319dde7..70b81ed 100644
--- a/E2Manager/managers/notificationmanager/notification_manager.go
+++ b/E2Manager/managers/notificationmanager/notification_manager.go
@@ -22,10 +22,9 @@
"e2mgr/managers"
"e2mgr/models"
"e2mgr/providers/rmrmsghandlerprovider"
- "e2mgr/rNibWriter"
"e2mgr/rmrCgo"
+ "e2mgr/services"
"fmt"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
"time"
)
@@ -33,8 +32,8 @@
notificationHandlerProvider *rmrmsghandlerprovider.NotificationHandlerProvider
}
-func NewNotificationManager(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter, ranReconnectionManager *managers.RanReconnectionManager) *NotificationManager {
- notificationHandlerProvider := rmrmsghandlerprovider.NewNotificationHandlerProvider(rnibReaderProvider, rnibWriterProvider, ranReconnectionManager)
+func NewNotificationManager(rnibDataService services.RNibDataService, ranReconnectionManager *managers.RanReconnectionManager) *NotificationManager {
+ notificationHandlerProvider := rmrmsghandlerprovider.NewNotificationHandlerProvider(rnibDataService, ranReconnectionManager)
return &NotificationManager{
notificationHandlerProvider: notificationHandlerProvider,
diff --git a/E2Manager/managers/ran_reconnection_manager.go b/E2Manager/managers/ran_reconnection_manager.go
index f42986c..f27f810 100644
--- a/E2Manager/managers/ran_reconnection_manager.go
+++ b/E2Manager/managers/ran_reconnection_manager.go
@@ -20,9 +20,8 @@
import (
"e2mgr/configuration"
"e2mgr/logger"
- "e2mgr/rNibWriter"
+ "e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
)
type IRanReconnectionManager interface {
@@ -30,26 +29,23 @@
}
type RanReconnectionManager struct {
- logger *logger.Logger
- config *configuration.Configuration
- rnibReaderProvider func() reader.RNibReader
- rnibWriterProvider func() rNibWriter.RNibWriter
- ranSetupManager *RanSetupManager
+ logger *logger.Logger
+ config *configuration.Configuration
+ rnibDataService services.RNibDataService
+ ranSetupManager *RanSetupManager
}
-func NewRanReconnectionManager(logger *logger.Logger, config *configuration.Configuration, rnibReaderProvider func() reader.RNibReader,
- rnibWriterProvider func() rNibWriter.RNibWriter, ranSetupManager *RanSetupManager) *RanReconnectionManager {
+func NewRanReconnectionManager(logger *logger.Logger, config *configuration.Configuration, rnibDataService services.RNibDataService, ranSetupManager *RanSetupManager) *RanReconnectionManager {
return &RanReconnectionManager{
- logger: logger,
- config: config,
- rnibReaderProvider: rnibReaderProvider,
- rnibWriterProvider: rnibWriterProvider,
- ranSetupManager: ranSetupManager,
+ logger: logger,
+ config: config,
+ rnibDataService: rnibDataService,
+ ranSetupManager: ranSetupManager,
}
}
func (m *RanReconnectionManager) ReconnectRan(inventoryName string) error {
- nodebInfo, rnibErr := m.rnibReaderProvider().GetNodeb(inventoryName)
+ nodebInfo, rnibErr := m.rnibDataService.GetNodeb(inventoryName)
if rnibErr != nil {
m.logger.Errorf("#RanReconnectionManager.ReconnectRan - RAN name: %s - Failed fetching RAN from rNib. Error: %v", inventoryName, rnibErr)
@@ -84,7 +80,7 @@
}
nodebInfo.ConnectionStatus = connectionStatus;
- err := m.rnibWriterProvider().UpdateNodebInfo(nodebInfo)
+ err := m.rnibDataService.UpdateNodebInfo(nodebInfo)
if err != nil {
m.logger.Errorf("#RanReconnectionManager.updateNodebInfoStatus - RAN name: %s - Failed updating RAN's connection status to %s in rNib. Error: %v", nodebInfo.RanName, connectionStatus, err)
diff --git a/E2Manager/managers/ran_reconnection_manager_test.go b/E2Manager/managers/ran_reconnection_manager_test.go
index 7679473..d8e169d 100644
--- a/E2Manager/managers/ran_reconnection_manager_test.go
+++ b/E2Manager/managers/ran_reconnection_manager_test.go
@@ -40,6 +40,7 @@
if err != nil {
t.Errorf("#... - failed to initialize logger, error: %s", err)
}
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrService := getRmrService(rmrMessengerMock, logger)
@@ -52,8 +53,9 @@
rnibWriterProvider := func() rNibWriter.RNibWriter {
return writerMock
}
- ranSetupManager := NewRanSetupManager(logger, rmrService, rnibWriterProvider)
- ranReconnectionManager := NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibReaderProvider, rnibWriterProvider, ranSetupManager)
+ rnibDataService := services.NewRnibDataService(logger, config, rnibReaderProvider, rnibWriterProvider)
+ ranSetupManager := NewRanSetupManager(logger, rmrService, rnibDataService)
+ ranReconnectionManager := NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, ranSetupManager)
return logger, rmrMessengerMock, readerMock, writerMock, ranReconnectionManager
}
diff --git a/E2Manager/managers/ran_setup_manager.go b/E2Manager/managers/ran_setup_manager.go
index ef4a642..7500069 100644
--- a/E2Manager/managers/ran_setup_manager.go
+++ b/E2Manager/managers/ran_setup_manager.go
@@ -22,7 +22,6 @@
"e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/models"
- "e2mgr/rNibWriter"
"e2mgr/rmrCgo"
"e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
@@ -30,14 +29,14 @@
type RanSetupManager struct {
logger *logger.Logger
- rnibWriterProvider func() rNibWriter.RNibWriter
+ rnibDataService services.RNibDataService
rmrService *services.RmrService
}
-func NewRanSetupManager(logger *logger.Logger, rmrService *services.RmrService, rnibWriterProvider func() rNibWriter.RNibWriter) *RanSetupManager {
+func NewRanSetupManager(logger *logger.Logger, rmrService *services.RmrService, rnibDataService services.RNibDataService) *RanSetupManager {
return &RanSetupManager{
logger: logger,
- rnibWriterProvider: rnibWriterProvider,
+ rnibDataService: rnibDataService,
rmrService: rmrService,
}
}
@@ -47,7 +46,7 @@
// Update retries and connection status
nodebInfo.ConnectionStatus = status
nodebInfo.ConnectionAttempts++
- err := m.rnibWriterProvider().UpdateNodebInfo(nodebInfo)
+ err := m.rnibDataService.UpdateNodebInfo(nodebInfo)
if err != nil {
m.logger.Errorf("#RanSetupManager.updateConnectionStatus - Ran name: %s - Failed updating RAN's connection status to %v : %s", nodebInfo.RanName, status, err)
} else {
@@ -61,7 +60,7 @@
// Update retries and connection status
nodebInfo.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED
nodebInfo.ConnectionAttempts--
- err := m.rnibWriterProvider().UpdateNodebInfo(nodebInfo)
+ err := m.rnibDataService.UpdateNodebInfo(nodebInfo)
if err != nil {
m.logger.Errorf("#RanSetupManager.updateConnectionStatusDisconnected - Ran name: %s - Failed updating RAN's connection status to DISCONNECTED : %s", nodebInfo.RanName, err)
} else {
diff --git a/E2Manager/managers/ran_setup_manager_test.go b/E2Manager/managers/ran_setup_manager_test.go
index 58ca166..20f3d59 100644
--- a/E2Manager/managers/ran_setup_manager_test.go
+++ b/E2Manager/managers/ran_setup_manager_test.go
@@ -18,29 +18,50 @@
package managers
import (
+ "e2mgr/configuration"
"e2mgr/e2managererrors"
"e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/mocks"
"e2mgr/rNibWriter"
"e2mgr/rmrCgo"
+ "e2mgr/services"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"testing"
)
-func TestExecuteSetupConnectingX2Setup(t *testing.T) {
- log := initLog(t)
+func initRanSetupManagerTest(t *testing.T) (*mocks.RmrMessengerMock, *mocks.RnibWriterMock, *RanSetupManager) {
+ logger, err := logger.InitLogger(logger.DebugLevel)
+ if err != nil {
+ t.Errorf("#... - failed to initialize logger, error: %s", err)
+ }
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
- ranName := "test1"
+ rmrMessengerMock := &mocks.RmrMessengerMock{}
+ rmrService := getRmrService(rmrMessengerMock, logger)
+ readerMock := &mocks.RnibReaderMock{}
+ rnibReaderProvider := func() reader.RNibReader {
+ return readerMock
+ }
writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
+ rnibWriterProvider := func() rNibWriter.RNibWriter {
return writerMock
}
+ rnibDataService := services.NewRnibDataService(logger, config, rnibReaderProvider, rnibWriterProvider)
+ ranSetupManager := NewRanSetupManager(logger, rmrService, rnibDataService)
+ return rmrMessengerMock, writerMock, ranSetupManager
+}
+
+func TestExecuteSetupConnectingX2Setup(t *testing.T) {
+ rmrMessengerMock, writerMock, mgr := initRanSetupManagerTest(t)
+
+ ranName := "test1"
var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
var argNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
@@ -50,11 +71,8 @@
payload := e2pdus.PackedX2setupRequest
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg, nil)
- rmrService := getRmrService(rmrMessengerMock, log)
- mgr := NewRanSetupManager(log, rmrService, writerProvider)
if err := mgr.ExecuteSetup(initialNodeb, entities.ConnectionStatus_CONNECTING); err != nil {
t.Errorf("want: success, got: error: %s", err)
}
@@ -64,16 +82,11 @@
}
func TestExecuteSetupConnectingEndcX2Setup(t *testing.T) {
- log := initLog(t)
+ rmrMessengerMock, writerMock, mgr := initRanSetupManagerTest(t)
ranName := "test1"
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
- var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_ENDC_X2_SETUP_REQUEST}
+ var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_ENDC_X2_SETUP_REQUEST}
var argNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_ENDC_X2_SETUP_REQUEST, ConnectionAttempts: 1}
var rnibErr error
writerMock.On("UpdateNodebInfo", argNodeb).Return(rnibErr)
@@ -81,11 +94,8 @@
payload := e2pdus.PackedEndcX2setupRequest
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_ENDC_X2_SETUP_REQ, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg, nil)
- rmrService := getRmrService(rmrMessengerMock, log)
- mgr := NewRanSetupManager(log, rmrService, writerProvider)
if err := mgr.ExecuteSetup(initialNodeb, entities.ConnectionStatus_CONNECTING); err != nil {
t.Errorf("want: success, got: error: %s", err)
}
@@ -95,15 +105,10 @@
}
func TestExecuteSetupDisconnected(t *testing.T) {
- log := initLog(t)
+ rmrMessengerMock, writerMock, mgr := initRanSetupManagerTest(t)
ranName := "test1"
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
var argNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
var argNodebDisconnected = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 0}
@@ -114,11 +119,8 @@
payload := []byte{0}
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg, fmt.Errorf("send failure"))
- rmrService := getRmrService(rmrMessengerMock, log)
- mgr := NewRanSetupManager(log, rmrService, writerProvider)
if err := mgr.ExecuteSetup(initialNodeb, entities.ConnectionStatus_CONNECTING); err == nil {
t.Errorf("want: failure, got: success")
}
@@ -128,15 +130,10 @@
}
func TestExecuteSetupConnectingRnibError(t *testing.T) {
- log := initLog(t)
+ rmrMessengerMock, writerMock, mgr := initRanSetupManagerTest(t)
ranName := "test1"
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
var argNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
var argNodebDisconnected = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 0}
@@ -147,11 +144,8 @@
payload := []byte{0}
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg, fmt.Errorf("send failure"))
- rmrService := getRmrService(rmrMessengerMock, log)
- mgr := NewRanSetupManager(log, rmrService, writerProvider)
if err := mgr.ExecuteSetup(initialNodeb, entities.ConnectionStatus_CONNECTING); err == nil {
t.Errorf("want: failure, got: success")
} else {
@@ -163,15 +157,10 @@
}
func TestExecuteSetupDisconnectedRnibError(t *testing.T) {
- log := initLog(t)
+ rmrMessengerMock, writerMock, mgr := initRanSetupManagerTest(t)
ranName := "test1"
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
var argNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
var argNodebDisconnected = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 0}
@@ -182,11 +171,8 @@
payload := []byte{0}
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg, fmt.Errorf("send failure"))
- rmrService := getRmrService(rmrMessengerMock, log)
- mgr := NewRanSetupManager(log, rmrService, writerProvider)
if err := mgr.ExecuteSetup(initialNodeb, entities.ConnectionStatus_CONNECTING); err == nil {
t.Errorf("want: failure, got: success")
} else {
@@ -198,15 +184,10 @@
}
func TestExecuteSetupUnsupportedProtocol(t *testing.T) {
- log := initLog(t)
+ rmrMessengerMock, writerMock, mgr := initRanSetupManagerTest(t)
ranName := "test1"
- writerMock := &mocks.RnibWriterMock{}
- writerProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
-
var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_UNKNOWN_E2_APPLICATION_PROTOCOL}
var argNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_UNKNOWN_E2_APPLICATION_PROTOCOL, ConnectionAttempts: 1}
var rnibErr error
@@ -215,11 +196,8 @@
payload := e2pdus.PackedX2setupRequest
xaction := []byte(ranName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ranName, &payload, &xaction)
- rmrMessengerMock := &mocks.RmrMessengerMock{}
rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg, nil)
- rmrService := getRmrService(rmrMessengerMock, log)
- mgr := NewRanSetupManager(log, rmrService, writerProvider)
if err := mgr.ExecuteSetup(initialNodeb, entities.ConnectionStatus_CONNECTING); err == nil {
t.Errorf("want: error, got: success")
}
diff --git a/E2Manager/providers/httpmsghandlerprovider/incoming_request_handler_provider.go b/E2Manager/providers/httpmsghandlerprovider/incoming_request_handler_provider.go
index 7891d8c..23493cd 100644
--- a/E2Manager/providers/httpmsghandlerprovider/incoming_request_handler_provider.go
+++ b/E2Manager/providers/httpmsghandlerprovider/incoming_request_handler_provider.go
@@ -23,10 +23,8 @@
"e2mgr/handlers/httpmsghandlers"
"e2mgr/logger"
"e2mgr/managers"
- "e2mgr/rNibWriter"
"e2mgr/services"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
)
type IncomingRequest string
@@ -43,23 +41,21 @@
logger *logger.Logger
}
-func NewIncomingRequestHandlerProvider(logger *logger.Logger, rmrService *services.RmrService, config *configuration.Configuration, rNibWriterProvider func() rNibWriter.RNibWriter,
- rNibReaderProvider func() reader.RNibReader, ranSetupManager *managers.RanSetupManager) *IncomingRequestHandlerProvider {
+func NewIncomingRequestHandlerProvider(logger *logger.Logger, rmrService *services.RmrService, config *configuration.Configuration, rNibDataService services.RNibDataService, ranSetupManager *managers.RanSetupManager) *IncomingRequestHandlerProvider {
return &IncomingRequestHandlerProvider{
- requestMap: initRequestHandlerMap(logger, rmrService, config, rNibWriterProvider, rNibReaderProvider, ranSetupManager),
+ requestMap: initRequestHandlerMap(logger, rmrService, config, rNibDataService, ranSetupManager),
logger: logger,
}
}
-func initRequestHandlerMap(logger *logger.Logger, rmrService *services.RmrService, config *configuration.Configuration, rNibWriterProvider func() rNibWriter.RNibWriter,
- rNibReaderProvider func() reader.RNibReader, ranSetupManager *managers.RanSetupManager) map[IncomingRequest]httpmsghandlers.RequestHandler {
+func initRequestHandlerMap(logger *logger.Logger, rmrService *services.RmrService, config *configuration.Configuration, rNibDataService services.RNibDataService, ranSetupManager *managers.RanSetupManager) map[IncomingRequest]httpmsghandlers.RequestHandler {
return map[IncomingRequest]httpmsghandlers.RequestHandler{
- ShutdownRequest: httpmsghandlers.NewDeleteAllRequestHandler(logger, rmrService, config, rNibWriterProvider, rNibReaderProvider), //TODO change to pointer
- ResetRequest: httpmsghandlers.NewX2ResetRequestHandler(logger, rmrService, rNibWriterProvider, rNibReaderProvider),
- X2SetupRequest: httpmsghandlers.NewSetupRequestHandler(logger, rNibWriterProvider, rNibReaderProvider, ranSetupManager, entities.E2ApplicationProtocol_X2_SETUP_REQUEST),
- EndcSetupRequest: httpmsghandlers.NewSetupRequestHandler(logger, rNibWriterProvider, rNibReaderProvider, ranSetupManager, entities.E2ApplicationProtocol_ENDC_X2_SETUP_REQUEST), //TODO change to pointer
+ ShutdownRequest: httpmsghandlers.NewDeleteAllRequestHandler(logger, rmrService, config, rNibDataService), //TODO change to pointer
+ ResetRequest: httpmsghandlers.NewX2ResetRequestHandler(logger, rmrService, rNibDataService),
+ X2SetupRequest: httpmsghandlers.NewSetupRequestHandler(logger, rNibDataService, ranSetupManager, entities.E2ApplicationProtocol_X2_SETUP_REQUEST),
+ EndcSetupRequest: httpmsghandlers.NewSetupRequestHandler(logger, rNibDataService, ranSetupManager, entities.E2ApplicationProtocol_ENDC_X2_SETUP_REQUEST), //TODO change to pointer
}
}
diff --git a/E2Manager/providers/httpmsghandlerprovider/incoming_request_handler_provider_test.go b/E2Manager/providers/httpmsghandlerprovider/incoming_request_handler_provider_test.go
index d0e13f3..393b800 100644
--- a/E2Manager/providers/httpmsghandlerprovider/incoming_request_handler_provider_test.go
+++ b/E2Manager/providers/httpmsghandlerprovider/incoming_request_handler_provider_test.go
@@ -42,36 +42,29 @@
return services.NewRmrService(services.NewRmrConfig(tests.Port, tests.MaxMsgSize, tests.Flags, log), rmrMessenger, messageChannel)
}
-func TestNewIncomingRequestHandlerProvider(t *testing.T) {
+func setupTest(t *testing.T) *IncomingRequestHandlerProvider {
rmrMessengerMock := &mocks.RmrMessengerMock{}
-
log := initLog(t)
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
readerProvider := func() reader.RNibReader {
return &mocks.RnibReaderMock{}
}
writerProvider := func() rNibWriter.RNibWriter {
return &mocks.RnibWriterMock{}
}
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- provider := NewIncomingRequestHandlerProvider(log, getRmrService(rmrMessengerMock, log), configuration.ParseConfiguration(), writerProvider, readerProvider, ranSetupManager)
+ rnibDataService := services.NewRnibDataService(log, config, readerProvider, writerProvider)
+ ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rnibDataService)
+ return NewIncomingRequestHandlerProvider(log, getRmrService(rmrMessengerMock, log), configuration.ParseConfiguration(), rnibDataService, ranSetupManager)
+}
+
+func TestNewIncomingRequestHandlerProvider(t *testing.T) {
+ provider := setupTest(t)
assert.NotNil(t, provider)
}
func TestShutdownRequestHandler(t *testing.T) {
- rmrMessengerMock := &mocks.RmrMessengerMock{}
-
- log := initLog(t)
- readerProvider := func() reader.RNibReader {
- return &mocks.RnibReaderMock{}
- }
- writerProvider := func() rNibWriter.RNibWriter {
- return &mocks.RnibWriterMock{}
- }
-
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- provider := NewIncomingRequestHandlerProvider(log, getRmrService(rmrMessengerMock, log), configuration.ParseConfiguration(), writerProvider, readerProvider, ranSetupManager)
-
+ provider := setupTest(t)
handler, err := provider.GetHandler(ShutdownRequest)
assert.NotNil(t, provider)
@@ -83,19 +76,7 @@
}
func TestX2SetupRequestHandler(t *testing.T) {
- rmrMessengerMock := &mocks.RmrMessengerMock{}
-
- log := initLog(t)
- readerProvider := func() reader.RNibReader {
- return &mocks.RnibReaderMock{}
- }
- writerProvider := func() rNibWriter.RNibWriter {
- return &mocks.RnibWriterMock{}
- }
-
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- provider := NewIncomingRequestHandlerProvider(log, getRmrService(rmrMessengerMock, log), configuration.ParseConfiguration(), writerProvider, readerProvider, ranSetupManager)
-
+ provider := setupTest(t)
handler, err := provider.GetHandler(X2SetupRequest)
assert.NotNil(t, provider)
@@ -107,19 +88,7 @@
}
func TestEndcSetupRequestHandler(t *testing.T) {
- rmrMessengerMock := &mocks.RmrMessengerMock{}
-
- log := initLog(t)
- readerProvider := func() reader.RNibReader {
- return &mocks.RnibReaderMock{}
- }
- writerProvider := func() rNibWriter.RNibWriter {
- return &mocks.RnibWriterMock{}
- }
-
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- provider := NewIncomingRequestHandlerProvider(log, getRmrService(rmrMessengerMock, log), configuration.ParseConfiguration(), writerProvider, readerProvider, ranSetupManager)
-
+ provider := setupTest(t)
handler, err := provider.GetHandler(EndcSetupRequest)
assert.NotNil(t, provider)
@@ -131,18 +100,7 @@
}
func TestGetShutdownHandlerFailure(t *testing.T) {
- rmrMessengerMock := &mocks.RmrMessengerMock{}
- log := initLog(t)
- readerProvider := func() reader.RNibReader {
- return &mocks.RnibReaderMock{}
- }
- writerProvider := func() rNibWriter.RNibWriter {
- return &mocks.RnibWriterMock{}
- }
-
- ranSetupManager := managers.NewRanSetupManager(log, getRmrService(rmrMessengerMock, log), rNibWriter.GetRNibWriter)
- provider := NewIncomingRequestHandlerProvider(log, getRmrService(rmrMessengerMock, log), configuration.ParseConfiguration(), writerProvider, readerProvider, ranSetupManager)
-
+ provider := setupTest(t)
_, actual := provider.GetHandler("test")
expected := &e2managererrors.InternalError{}
diff --git a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go
index 0a01b76..d85bf95 100644
--- a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go
+++ b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go
@@ -20,36 +20,35 @@
import (
"e2mgr/handlers/rmrmsghandlers"
"e2mgr/managers"
- "e2mgr/rNibWriter"
"e2mgr/rmrCgo"
+ "e2mgr/services"
"fmt"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
)
type NotificationHandlerProvider struct {
notificationHandlers map[int]rmrmsghandlers.NotificationHandler
}
-func NewNotificationHandlerProvider(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter, ranReconnectionManager *managers.RanReconnectionManager) *NotificationHandlerProvider {
+func NewNotificationHandlerProvider(rnibDataService services.RNibDataService, ranReconnectionManager *managers.RanReconnectionManager) *NotificationHandlerProvider {
return &NotificationHandlerProvider{
- notificationHandlers: initNotificationHandlersMap(rnibReaderProvider, rnibWriterProvider, ranReconnectionManager),
+ notificationHandlers: initNotificationHandlersMap(rnibDataService, ranReconnectionManager),
}
}
//TODO change handlers.NotificationHandler to *handlers.NotificationHandler
-func initNotificationHandlersMap(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter, ranReconnectionManager *managers.RanReconnectionManager) map[int]rmrmsghandlers.NotificationHandler {
+func initNotificationHandlersMap(rnibDataService services.RNibDataService, ranReconnectionManager *managers.RanReconnectionManager) map[int]rmrmsghandlers.NotificationHandler {
return map[int]rmrmsghandlers.NotificationHandler{
- rmrCgo.RIC_X2_SETUP_RESP: rmrmsghandlers.NewSetupResponseNotificationHandler(rnibReaderProvider, rnibWriterProvider, managers.NewX2SetupResponseManager(), "X2 Setup Response"),
- rmrCgo.RIC_X2_SETUP_FAILURE: rmrmsghandlers.NewSetupResponseNotificationHandler(rnibReaderProvider, rnibWriterProvider, managers.NewX2SetupFailureResponseManager(), "X2 Setup Failure Response"),
- rmrCgo.RIC_ENDC_X2_SETUP_RESP: rmrmsghandlers.NewSetupResponseNotificationHandler(rnibReaderProvider, rnibWriterProvider, managers.NewEndcSetupResponseManager(), "ENDC Setup Response"),
- rmrCgo.RIC_ENDC_X2_SETUP_FAILURE: rmrmsghandlers.NewSetupResponseNotificationHandler(rnibReaderProvider, rnibWriterProvider, managers.NewEndcSetupFailureResponseManager(), "ENDC Setup Failure Response"),
+ rmrCgo.RIC_X2_SETUP_RESP: rmrmsghandlers.NewSetupResponseNotificationHandler(rnibDataService, managers.NewX2SetupResponseManager(), "X2 Setup Response"),
+ rmrCgo.RIC_X2_SETUP_FAILURE: rmrmsghandlers.NewSetupResponseNotificationHandler(rnibDataService, managers.NewX2SetupFailureResponseManager(), "X2 Setup Failure Response"),
+ rmrCgo.RIC_ENDC_X2_SETUP_RESP: rmrmsghandlers.NewSetupResponseNotificationHandler(rnibDataService, managers.NewEndcSetupResponseManager(), "ENDC Setup Response"),
+ rmrCgo.RIC_ENDC_X2_SETUP_FAILURE: rmrmsghandlers.NewSetupResponseNotificationHandler(rnibDataService, managers.NewEndcSetupFailureResponseManager(), "ENDC Setup Failure Response"),
rmrCgo.RIC_SCTP_CONNECTION_FAILURE: rmrmsghandlers.NewRanLostConnectionHandler(ranReconnectionManager),
- rmrCgo.RIC_ENB_LOAD_INFORMATION: rmrmsghandlers.NewEnbLoadInformationNotificationHandler(rnibWriterProvider),
+ rmrCgo.RIC_ENB_LOAD_INFORMATION: rmrmsghandlers.NewEnbLoadInformationNotificationHandler(rnibDataService),
rmrCgo.RIC_ENB_CONF_UPDATE: rmrmsghandlers.NewX2EnbConfigurationUpdateHandler(),
rmrCgo.RIC_ENDC_CONF_UPDATE: rmrmsghandlers.NewEndcConfigurationUpdateHandler(),
- rmrCgo.RIC_X2_RESET_RESP: rmrmsghandlers.NewX2ResetResponseHandler(rnibReaderProvider),
- rmrCgo.RIC_X2_RESET: rmrmsghandlers.NewX2ResetRequestNotificationHandler(rnibReaderProvider),
- rmrCgo.RIC_E2_TERM_INIT: rmrmsghandlers.NewE2TermInitNotificationHandler(ranReconnectionManager, rnibReaderProvider),
+ rmrCgo.RIC_X2_RESET_RESP: rmrmsghandlers.NewX2ResetResponseHandler(rnibDataService),
+ rmrCgo.RIC_X2_RESET: rmrmsghandlers.NewX2ResetRequestNotificationHandler(rnibDataService),
+ rmrCgo.RIC_E2_TERM_INIT: rmrmsghandlers.NewE2TermInitNotificationHandler(ranReconnectionManager, rnibDataService),
}
}
diff --git a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go
index b3e7c24..463259a 100644
--- a/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go
+++ b/E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider_test.go
@@ -39,9 +39,9 @@
* Verify support for known providers.
*/
-func TestGetNotificationHandlerSuccess(t *testing.T) {
-
+func initTestCase(t *testing.T) (services.RNibDataService, *managers.RanReconnectionManager) {
logger := initLog(t)
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
readerMock := &mocks.RnibReaderMock{}
rnibReaderProvider := func() reader.RNibReader {
@@ -51,27 +51,34 @@
rnibWriterProvider := func() rNibWriter.RNibWriter {
return writerMock
}
- ranSetupManager := managers.NewRanSetupManager(logger, getRmrService(&mocks.RmrMessengerMock{}, logger), rNibWriter.GetRNibWriter)
- ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibReaderProvider, rnibWriterProvider, ranSetupManager)
+ rnibDataService := services.NewRnibDataService(logger, config, rnibReaderProvider, rnibWriterProvider)
+ ranSetupManager := managers.NewRanSetupManager(logger, getRmrService(&mocks.RmrMessengerMock{}, logger), rnibDataService)
+ ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, ranSetupManager)
+ return rnibDataService, ranReconnectionManager
+}
+
+func TestGetNotificationHandlerSuccess(t *testing.T) {
+
+ rnibDataService, ranReconnectionManager := initTestCase(t)
var testCases = []struct {
msgType int
handler rmrmsghandlers.NotificationHandler
}{
- {rmrCgo.RIC_X2_SETUP_RESP, rmrmsghandlers.NewSetupResponseNotificationHandler(rnibReaderProvider, rnibWriterProvider, managers.NewX2SetupResponseManager(), "X2 Setup Response")},
- {rmrCgo.RIC_X2_SETUP_FAILURE, rmrmsghandlers.NewSetupResponseNotificationHandler(rnibReaderProvider, rnibWriterProvider, managers.NewX2SetupFailureResponseManager(), "X2 Setup Failure Response")},
- {rmrCgo.RIC_ENDC_X2_SETUP_RESP, rmrmsghandlers.NewSetupResponseNotificationHandler(rnibReaderProvider, rnibWriterProvider, managers.NewEndcSetupResponseManager(), "ENDC Setup Response")},
- {rmrCgo.RIC_ENDC_X2_SETUP_FAILURE, rmrmsghandlers.NewSetupResponseNotificationHandler(rnibReaderProvider, rnibWriterProvider, managers.NewEndcSetupFailureResponseManager(), "ENDC Setup Failure Response"),},
+ {rmrCgo.RIC_X2_SETUP_RESP, rmrmsghandlers.NewSetupResponseNotificationHandler(rnibDataService, managers.NewX2SetupResponseManager(), "X2 Setup Response")},
+ {rmrCgo.RIC_X2_SETUP_FAILURE, rmrmsghandlers.NewSetupResponseNotificationHandler(rnibDataService, managers.NewX2SetupFailureResponseManager(), "X2 Setup Failure Response")},
+ {rmrCgo.RIC_ENDC_X2_SETUP_RESP, rmrmsghandlers.NewSetupResponseNotificationHandler(rnibDataService, managers.NewEndcSetupResponseManager(), "ENDC Setup Response")},
+ {rmrCgo.RIC_ENDC_X2_SETUP_FAILURE, rmrmsghandlers.NewSetupResponseNotificationHandler(rnibDataService, managers.NewEndcSetupFailureResponseManager(), "ENDC Setup Failure Response"),},
{rmrCgo.RIC_SCTP_CONNECTION_FAILURE, rmrmsghandlers.NewRanLostConnectionHandler(ranReconnectionManager)},
- {rmrCgo.RIC_ENB_LOAD_INFORMATION, rmrmsghandlers.NewEnbLoadInformationNotificationHandler(rnibWriterProvider)},
+ {rmrCgo.RIC_ENB_LOAD_INFORMATION, rmrmsghandlers.NewEnbLoadInformationNotificationHandler(rnibDataService)},
{rmrCgo.RIC_ENB_CONF_UPDATE, rmrmsghandlers.X2EnbConfigurationUpdateHandler{}},
{rmrCgo.RIC_ENDC_CONF_UPDATE, rmrmsghandlers.EndcConfigurationUpdateHandler{}},
- {rmrCgo.RIC_E2_TERM_INIT, rmrmsghandlers.NewE2TermInitNotificationHandler(ranReconnectionManager, rnibReaderProvider)},
+ {rmrCgo.RIC_E2_TERM_INIT, rmrmsghandlers.NewE2TermInitNotificationHandler(ranReconnectionManager, rnibDataService)},
}
for _, tc := range testCases {
- provider := NewNotificationHandlerProvider(rnibReaderProvider, rnibWriterProvider, ranReconnectionManager)
+ provider := NewNotificationHandlerProvider(rnibDataService, ranReconnectionManager)
t.Run(fmt.Sprintf("%d", tc.msgType), func(t *testing.T) {
handler, err := provider.GetNotificationHandler(tc.msgType)
if err != nil {
@@ -92,8 +99,6 @@
func TestGetNotificationHandlerFailure(t *testing.T) {
- logger := initLog(t)
-
var testCases = []struct {
msgType int
errorText string
@@ -101,19 +106,9 @@
{9999 /*unknown*/, "notification handler not found"},
}
for _, tc := range testCases {
- readerMock := &mocks.RnibReaderMock{}
- rnibReaderProvider := func() reader.RNibReader {
- return readerMock
- }
- writerMock := &mocks.RnibWriterMock{}
- rnibWriterProvider := func() rNibWriter.RNibWriter {
- return writerMock
- }
- ranSetupManager := managers.NewRanSetupManager(logger, getRmrService(&mocks.RmrMessengerMock{}, logger), rNibWriter.GetRNibWriter)
- ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibReaderProvider, rnibWriterProvider, ranSetupManager)
-
- provider := NewNotificationHandlerProvider(rnibReaderProvider, rnibWriterProvider, ranReconnectionManager)
+ rnibDataService, ranReconnectionManager := initTestCase(t)
+ provider := NewNotificationHandlerProvider(rnibDataService, ranReconnectionManager)
t.Run(fmt.Sprintf("%d", tc.msgType), func(t *testing.T) {
_, err := provider.GetNotificationHandler(tc.msgType)
if err == nil {
diff --git a/E2Manager/resources/configuration.yaml b/E2Manager/resources/configuration.yaml
index 0e16ecd..4dabf92 100644
--- a/E2Manager/resources/configuration.yaml
+++ b/E2Manager/resources/configuration.yaml
@@ -8,3 +8,5 @@
notificationResponseBuffer: 100
bigRedButtonTimeoutSec: 5
maxConnectionAttempts: 3
+maxRnibConnectionAttempts: 3
+rnibRetryIntervalMs: 10
diff --git a/E2Manager/services/receivers/rmr_service_receiver_test.go b/E2Manager/services/receivers/rmr_service_receiver_test.go
index 15e9857..1482085 100644
--- a/E2Manager/services/receivers/rmr_service_receiver_test.go
+++ b/E2Manager/services/receivers/rmr_service_receiver_test.go
@@ -58,6 +58,8 @@
}
func getRmrServiceReceiver(rmrMessengerMock *mocks.RmrMessengerMock, logger *logger.Logger) *RmrServiceReceiver {
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
+
readerMock := &mocks.RnibReaderMock{}
rnibReaderProvider := func() reader.RNibReader {
return readerMock
@@ -67,10 +69,11 @@
return writerMock
}
+ rnibDataService := services.NewRnibDataService(logger, config, rnibReaderProvider, rnibWriterProvider)
rmrService := getRmrService(rmrMessengerMock, logger)
- ranSetupManager := managers.NewRanSetupManager(logger, rmrService, rNibWriter.GetRNibWriter)
- ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibReaderProvider, rnibWriterProvider, ranSetupManager)
- nManager := notificationmanager.NewNotificationManager(rnibReaderProvider, rnibWriterProvider, ranReconnectionManager)
+ ranSetupManager := managers.NewRanSetupManager(logger, rmrService, rnibDataService)
+ ranReconnectionManager := managers.NewRanReconnectionManager(logger, configuration.ParseConfiguration(), rnibDataService, ranSetupManager)
+ nManager := notificationmanager.NewNotificationManager(rnibDataService, ranReconnectionManager)
return NewRmrServiceReceiver(*rmrService, nManager)
}
diff --git a/E2Manager/services/rnib_data_service.go b/E2Manager/services/rnib_data_service.go
new file mode 100644
index 0000000..8a91894
--- /dev/null
+++ b/E2Manager/services/rnib_data_service.go
@@ -0,0 +1,128 @@
+package services
+
+import (
+ "e2mgr/configuration"
+ "e2mgr/logger"
+ "e2mgr/rNibWriter"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
+ "net"
+ "time"
+)
+
+type RNibDataService interface {
+ SaveNodeb(nbIdentity *entities.NbIdentity, nb *entities.NodebInfo) error
+ UpdateNodebInfo(nodebInfo *entities.NodebInfo) error
+ SaveRanLoadInformation(inventoryName string, ranLoadInformation *entities.RanLoadInformation) error
+ GetNodeb(ranName string) (*entities.NodebInfo, error)
+ GetListNodebIds() ([]*entities.NbIdentity, error)
+}
+
+type rNibDataService struct {
+ logger *logger.Logger
+ rnibReaderProvider func() reader.RNibReader
+ rnibWriterProvider func() rNibWriter.RNibWriter
+ maxAttempts int
+ retryInterval time.Duration
+}
+
+func NewRnibDataService(logger *logger.Logger, config *configuration.Configuration, rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter) *rNibDataService {
+ return &rNibDataService{
+ logger: logger,
+ rnibReaderProvider: rnibReaderProvider,
+ rnibWriterProvider: rnibWriterProvider,
+ maxAttempts: config.MaxRnibConnectionAttempts,
+ retryInterval: time.Duration(config.RnibRetryIntervalMs) * time.Millisecond,
+ }
+}
+
+func (w *rNibDataService) UpdateNodebInfo(nodebInfo *entities.NodebInfo) error {
+ w.logger.Infof("#RnibDataService.UpdateNodebInfo - nodebInfo: %s", nodebInfo)
+
+ err := w.retry("UpdateNodebInfo", func() (err error) {
+ err = w.rnibWriterProvider().UpdateNodebInfo(nodebInfo)
+ return
+ })
+
+ return err
+}
+
+func (w *rNibDataService) SaveNodeb(nbIdentity *entities.NbIdentity, nb *entities.NodebInfo) error {
+ w.logger.Infof("#RnibDataService.SaveNodeb - nbIdentity: %s, nodebInfo: %s", nbIdentity, nb)
+
+ err := w.retry("SaveNodeb", func() (err error) {
+ err = w.rnibWriterProvider().SaveNodeb(nbIdentity, nb)
+ return
+ })
+
+ return err
+}
+
+func (w *rNibDataService) SaveRanLoadInformation(inventoryName string, ranLoadInformation *entities.RanLoadInformation) error {
+ w.logger.Infof("#RnibDataService.SaveRanLoadInformation - inventoryName: %s, ranLoadInformation: %s", inventoryName, ranLoadInformation)
+
+ err := w.retry("SaveRanLoadInformation", func() (err error) {
+ err = w.rnibWriterProvider().SaveRanLoadInformation(inventoryName, ranLoadInformation)
+ return
+ })
+
+ return err
+}
+
+func (w *rNibDataService) GetNodeb(ranName string) (*entities.NodebInfo, error) {
+ w.logger.Infof("#RnibDataService.GetNodeb - ranName: %s", ranName)
+
+ var nodeb *entities.NodebInfo = nil
+
+ err := w.retry("GetNodeb", func() (err error) {
+ nodeb, err = w.rnibReaderProvider().GetNodeb(ranName)
+ return
+ })
+
+ 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) {
+ nodeIds, err = w.rnibReaderProvider().GetListNodebIds()
+ return
+ })
+
+ return nodeIds, err
+}
+
+func (w *rNibDataService) retry(rnibFunc string, f func() error) (err error) {
+ attempts := w.maxAttempts
+
+ for i := 1; ; i++ {
+ err = f()
+ if err == nil {
+ return
+ }
+ if !w.isConnError(err) {
+ return err
+ }
+ if i >= attempts {
+ w.logger.Errorf("#RnibDataService.retry - after %d attempts of %s, last error: %s", attempts, rnibFunc, err)
+ return err
+ }
+ time.Sleep(w.retryInterval)
+
+ w.logger.Infof("#RnibDataService.retry - retrying %d %s after error: %s", i, rnibFunc, err)
+ }
+}
+
+func (w *rNibDataService) isConnError(err error) bool {
+ internalErr, ok := err.(common.InternalError)
+ if !ok {
+ return false
+ }
+ _, ok = internalErr.Err.(*net.OpError)
+
+ return ok
+}
diff --git a/E2Manager/services/rnib_data_service_test.go b/E2Manager/services/rnib_data_service_test.go
new file mode 100644
index 0000000..7a96310
--- /dev/null
+++ b/E2Manager/services/rnib_data_service_test.go
@@ -0,0 +1,186 @@
+package services
+
+import (
+ "e2mgr/configuration"
+ "e2mgr/logger"
+ "e2mgr/mocks"
+ "e2mgr/rNibWriter"
+ "fmt"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
+ "github.com/stretchr/testify/assert"
+ "net"
+ "strings"
+ "testing"
+)
+
+func setupTest(t *testing.T) (*rNibDataService, *mocks.RnibReaderMock, *mocks.RnibWriterMock) {
+ logger, err := logger.InitLogger(logger.DebugLevel)
+ if err != nil {
+ t.Errorf("#... - failed to initialize logger, error: %s", err)
+ }
+
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
+
+ readerMock := &mocks.RnibReaderMock{}
+ rnibReaderProvider := func() reader.RNibReader {
+ return readerMock
+ }
+
+ writerMock := &mocks.RnibWriterMock{}
+ rnibWriterProvider := func() rNibWriter.RNibWriter {
+ return writerMock
+ }
+
+ rnibDataService := NewRnibDataService(logger, config, rnibReaderProvider, rnibWriterProvider)
+ assert.NotNil(t, rnibDataService)
+
+ return rnibDataService, readerMock, writerMock
+}
+
+func TestSuccessfulSaveNodeb(t *testing.T) {
+ rnibDataService, _, writerMock := setupTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ nbIdentity := &entities.NbIdentity{}
+ writerMock.On("SaveNodeb", nbIdentity, nodebInfo).Return(nil)
+
+ rnibDataService.SaveNodeb(nbIdentity, nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "SaveNodeb", 1)
+}
+
+func TestConnFailureSaveNodeb(t *testing.T) {
+ rnibDataService, _, writerMock := setupTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ nbIdentity := &entities.NbIdentity{}
+ mockErr := common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("SaveNodeb", nbIdentity, nodebInfo).Return(mockErr)
+
+ rnibDataService.SaveNodeb(nbIdentity, nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "SaveNodeb", 3)
+}
+
+func TestNonConnFailureSaveNodeb(t *testing.T) {
+ rnibDataService, _, writerMock := setupTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ nbIdentity := &entities.NbIdentity{}
+ mockErr := common.InternalError{Err: fmt.Errorf("non connection failure")}
+ writerMock.On("SaveNodeb", nbIdentity, nodebInfo).Return(mockErr)
+
+ rnibDataService.SaveNodeb(nbIdentity, nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "SaveNodeb", 1)
+}
+
+func TestSuccessfulUpdateNodebInfo(t *testing.T) {
+ rnibDataService, _, writerMock := setupTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ writerMock.On("UpdateNodebInfo", nodebInfo).Return(nil)
+
+ rnibDataService.UpdateNodebInfo(nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 1)
+}
+
+func TestConnFailureUpdateNodebInfo(t *testing.T) {
+ rnibDataService, _, writerMock := setupTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ mockErr := common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("UpdateNodebInfo", nodebInfo).Return(mockErr)
+
+ rnibDataService.UpdateNodebInfo(nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 3)
+}
+
+func TestSuccessfulSaveRanLoadInformation(t *testing.T) {
+ rnibDataService, _, writerMock := setupTest(t)
+
+ var ranName string = "abcd"
+ ranLoadInformation := &entities.RanLoadInformation{}
+ writerMock.On("SaveRanLoadInformation", ranName, ranLoadInformation).Return(nil)
+
+ rnibDataService.SaveRanLoadInformation(ranName, ranLoadInformation)
+ writerMock.AssertNumberOfCalls(t, "SaveRanLoadInformation", 1)
+}
+
+func TestConnFailureSaveRanLoadInformation(t *testing.T) {
+ rnibDataService, _, writerMock := setupTest(t)
+
+ var ranName string = "abcd"
+ ranLoadInformation := &entities.RanLoadInformation{}
+ mockErr := common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("SaveRanLoadInformation", ranName, ranLoadInformation).Return(mockErr)
+
+ rnibDataService.SaveRanLoadInformation(ranName, ranLoadInformation)
+ writerMock.AssertNumberOfCalls(t, "SaveRanLoadInformation", 3)
+}
+
+func TestSuccessfulGetNodeb(t *testing.T) {
+ rnibDataService, readerMock, _ := setupTest(t)
+
+ invName := "abcd"
+ nodebInfo := &entities.NodebInfo{}
+ readerMock.On("GetNodeb", invName).Return(nodebInfo, nil)
+
+ res, err := rnibDataService.GetNodeb(invName)
+ readerMock.AssertNumberOfCalls(t, "GetNodeb", 1)
+ assert.Equal(t, nodebInfo, res)
+ assert.Nil(t, err)
+}
+
+func TestConnFailureGetNodeb(t *testing.T) {
+ rnibDataService, readerMock, _ := setupTest(t)
+
+ invName := "abcd"
+ var nodeb *entities.NodebInfo = nil
+ mockErr := common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetNodeb", invName).Return(nodeb, mockErr)
+
+ res, err := rnibDataService.GetNodeb(invName)
+ readerMock.AssertNumberOfCalls(t, "GetNodeb", 3)
+ assert.True(t, strings.Contains(err.Error(), "connection error", ))
+ assert.Equal(t, nodeb, res)
+}
+
+func TestSuccessfulGetNodebIdList(t *testing.T) {
+ rnibDataService, readerMock, _ := setupTest(t)
+
+ nodeIds := []*entities.NbIdentity{}
+ readerMock.On("GetListNodebIds").Return(nodeIds, nil)
+
+ res, err := rnibDataService.GetListNodebIds()
+ readerMock.AssertNumberOfCalls(t, "GetListNodebIds", 1)
+ assert.Equal(t, nodeIds, res)
+ assert.Nil(t, err)
+}
+
+func TestConnFailureGetNodebIdList(t *testing.T) {
+ rnibDataService, readerMock, _ := setupTest(t)
+
+ var nodeIds []*entities.NbIdentity = nil
+ mockErr := common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetListNodebIds").Return(nodeIds, mockErr)
+
+ res, err := rnibDataService.GetListNodebIds()
+ readerMock.AssertNumberOfCalls(t, "GetListNodebIds", 3)
+ assert.True(t, strings.Contains(err.Error(), "connection error", ))
+ assert.Equal(t, nodeIds, res)
+}
+
+//func TestConnFailureThenSuccessGetNodebIdList(t *testing.T) {
+// rnibDataService, readerMock, _ := setupTest(t)
+//
+// var nilNodeIds []*entities.NbIdentity = nil
+// nodeIds := []*entities.NbIdentity{}
+// mockErr := common.InternalError{Err: &net.OpError{Err:fmt.Errorf("connection error")}}
+// //readerMock.On("GetListNodebIds").Return(nilNodeIds, mockErr)
+// //readerMock.On("GetListNodebIds").Return(nodeIds, nil)
+//
+// res, err := rnibDataService.GetListNodebIds()
+// readerMock.AssertNumberOfCalls(t, "GetListNodebIds", 2)
+// assert.True(t, strings.Contains(err.Error(),"connection failure", ))
+// assert.Equal(t, nodeIds, res)
+//}
diff --git a/E2Manager/services/rnib_reader_service.go b/E2Manager/services/rnib_reader_service.go
deleted file mode 100644
index 4b014d7..0000000
--- a/E2Manager/services/rnib_reader_service.go
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Copyright 2019 AT&T Intellectual Property
-// Copyright 2019 Nokia
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package services
-
-import (
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
-)
-
-type RnibReaderService struct {
- rnibReaderProvider func() reader.RNibReader
-}
-
-func NewRnibReaderService(rnibReaderProvider func() reader.RNibReader) *RnibReaderService{
- return &RnibReaderService{rnibReaderProvider}
-}
-
-func (s RnibReaderService) GetNodeb(ranName string) (*entities.NodebInfo, error) {
- return s.rnibReaderProvider().GetNodeb(ranName)
-}
-
-func (s RnibReaderService) GetNodebIdList()([]*entities.NbIdentity, error) {
- return s.rnibReaderProvider().GetListNodebIds()
-}
-
-