[RICPLT-2523] Improvements...
[ric-plt/e2mgr.git] / E2Manager / rNibWriter / rNibWriter_test.go
index 92a0918..dd4f793 100644 (file)
@@ -19,6 +19,7 @@ package rNibWriter
 
 import (
        "e2mgr/mocks"
+       "encoding/json"
        "errors"
        "fmt"
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
@@ -29,64 +30,105 @@ import (
        "time"
 )
 
-func TestInitRNibWriter(t *testing.T) {
-       writerPool = nil
-       initSdlInstanceMock(namespace, 1)
-       available, created := writerPool.Stats()
-       assert.Equal(t, available, 0, "number of available objects in the writerPool should be 0")
-       assert.Equal(t, created, 0, "number of created objects in the writerPool should be 0")
-       w := GetRNibWriter()
-       assert.NotNil(t, w)
+func initSdlInstanceMock(namespace string) (w RNibWriter, sdlInstanceMock *mocks.MockSdlInstance) {
+       sdlInstanceMock = new(mocks.MockSdlInstance)
+       w = GetRNibWriter(sdlInstanceMock)
+       return
 }
 
-func TestInitPool(t *testing.T) {
-       writerPool = nil
-       sdlInstanceMock := new(mocks.MockSdlInstance)
-       initPool(1, func() interface{} {
-               sdlI := common.ISdlInstance(sdlInstanceMock)
-               return &rNibWriterInstance{sdl: &sdlI, namespace: namespace}
-       },
-               func(obj interface{}) {
-               },
-       )
-       assert.NotNil(t, writerPool)
-       assert.NotNil(t, writerPool.New)
-       assert.NotNil(t, writerPool.Destroy)
-       available, created := writerPool.Stats()
-       assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
-       assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
+var namespace = "namespace"
+
+func TestUpdateNodebInfoSuccess(t *testing.T) {
+       inventoryName := "name"
+       plmnId := "02f829"
+       nbId := "4a952a0a"
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
+       nodebInfo := &entities.NodebInfo{}
+       nodebInfo.RanName = inventoryName
+       nodebInfo.GlobalNbId = &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
+       nodebInfo.NodeType = entities.Node_ENB
+       nodebInfo.ConnectionStatus = 1
+       enb := entities.Enb{}
+       nodebInfo.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
+       data, err := proto.Marshal(nodebInfo)
+       if err != nil {
+               t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
+       }
+       var e error
+       var setExpected []interface{}
+
+       nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
+       nodebIdKey := fmt.Sprintf("ENB:%s:%s", plmnId, nbId)
+       setExpected = append(setExpected, nodebNameKey, data)
+       setExpected = append(setExpected, nodebIdKey, data)
+
+       sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
+
+       rNibErr := w.UpdateNodebInfo(nodebInfo)
+       assert.Nil(t, rNibErr)
 }
 
-var namespace = "namespace"
+func TestUpdateNodebInfoMissingInventoryNameFailure(t *testing.T) {
+       inventoryName := "name"
+       plmnId := "02f829"
+       nbId := "4a952a0a"
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
+       nodebInfo := &entities.NodebInfo{}
+       data, err := proto.Marshal(nodebInfo)
+       if err != nil {
+               t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
+       }
+       var e error
+       var setExpected []interface{}
 
-func initSdlInstanceMock(namespace string, poolSize int) *mocks.MockSdlInstance {
-       sdlInstanceMock := new(mocks.MockSdlInstance)
-       initPool(poolSize, func() interface{} {
-               sdlI := common.ISdlInstance(sdlInstanceMock)
-               return &rNibWriterInstance{sdl: &sdlI, namespace: namespace}
-       },
-               func(obj interface{}) {
-               },
-       )
-       return sdlInstanceMock
+       nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
+       nodebIdKey := fmt.Sprintf("ENB:%s:%s", plmnId, nbId)
+       setExpected = append(setExpected, nodebNameKey, data)
+       setExpected = append(setExpected, nodebIdKey, data)
+
+       sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
+
+       rNibErr := w.UpdateNodebInfo(nodebInfo)
+
+       assert.NotNil(t, rNibErr)
+       assert.IsType(t, &common.ValidationError{}, rNibErr)
+}
+
+func TestUpdateNodebInfoMissingGlobalNbId(t *testing.T) {
+       inventoryName := "name"
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
+       nodebInfo := &entities.NodebInfo{}
+       nodebInfo.RanName = inventoryName
+       data, err := proto.Marshal(nodebInfo)
+       if err != nil {
+               t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
+       }
+       var e error
+       var setExpected []interface{}
+
+       nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
+       setExpected = append(setExpected, nodebNameKey, data)
+       sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
+
+       rNibErr := w.UpdateNodebInfo(nodebInfo)
+
+       assert.Nil(t, rNibErr)
 }
 
 func TestSaveEnb(t *testing.T) {
        name := "name"
        ranName := "RAN:" + name
-       writerPool = nil
-       sdlInstanceMock := initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
        nb := entities.NodebInfo{}
        nb.NodeType = entities.Node_ENB
        nb.ConnectionStatus = 1
        nb.Ip = "localhost"
        nb.Port = 5656
        enb := entities.Enb{}
-       cell := &entities.ServedCellInfo{CellId:"aaff", Pci:3}
-       cellEntity := entities.Cell{Type:entities.Cell_LTE_CELL, Cell:&entities.Cell_ServedCellInfo{ServedCellInfo:cell}}
+       cell := &entities.ServedCellInfo{CellId: "aaff", Pci: 3}
+       cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: cell}}
        enb.ServedCells = []*entities.ServedCellInfo{cell}
-       nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
+       nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
        data, err := proto.Marshal(&nb)
        if err != nil {
                t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
@@ -111,7 +153,7 @@ func TestSaveEnb(t *testing.T) {
        }
        sdlInstanceMock.On("RemoveMember", entities.Node_UNKNOWN.String(), []interface{}{nbIdData}).Return(e)
 
-       nbIdentity := &entities.NbIdentity{InventoryName:name, GlobalNbId:&entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"}}
+       nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
        nbIdData, err = proto.Marshal(nbIdentity)
        if err != nil {
                t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB Identity entity. Error: %v", err)
@@ -124,118 +166,85 @@ func TestSaveEnb(t *testing.T) {
 
 func TestSaveEnbCellIdValidationFailure(t *testing.T) {
        name := "name"
-       writerPool = nil
-       initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, _ := initSdlInstanceMock(namespace)
        nb := entities.NodebInfo{}
        nb.NodeType = entities.Node_ENB
        nb.ConnectionStatus = 1
        nb.Ip = "localhost"
        nb.Port = 5656
        enb := entities.Enb{}
-       cell := &entities.ServedCellInfo{Pci:3}
+       cell := &entities.ServedCellInfo{Pci: 3}
        enb.ServedCells = []*entities.ServedCellInfo{cell}
-       nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
+       nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
 
-       nbIdentity := &entities.NbIdentity{InventoryName:name, GlobalNbId:&entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"}}
+       nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
        rNibErr := w.SaveNodeb(nbIdentity, &nb)
        assert.NotNil(t, rNibErr)
-       assert.Equal(t, common.VALIDATION_ERROR, rNibErr.GetCode())
-       assert.Equal(t, "3 VALIDATION_ERROR - #utils.ValidateAndBuildCellIdKey - an empty cell id received", rNibErr.Error())
+       assert.IsType(t, &common.ValidationError{}, rNibErr)
+       assert.Equal(t, "#utils.ValidateAndBuildCellIdKey - an empty cell id received", rNibErr.Error())
 }
 
 func TestSaveEnbInventoryNameValidationFailure(t *testing.T) {
-       writerPool = nil
-       initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, _ := initSdlInstanceMock(namespace)
        nb := entities.NodebInfo{}
        nb.NodeType = entities.Node_ENB
        nb.ConnectionStatus = 1
        nb.Ip = "localhost"
        nb.Port = 5656
        enb := entities.Enb{}
-       cell := &entities.ServedCellInfo{CellId:"aaa",Pci:3}
+       cell := &entities.ServedCellInfo{CellId: "aaa", Pci: 3}
        enb.ServedCells = []*entities.ServedCellInfo{cell}
-       nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
+       nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
 
-       nbIdentity := &entities.NbIdentity{InventoryName:"", GlobalNbId:&entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"}}
+       nbIdentity := &entities.NbIdentity{InventoryName: "", GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
        rNibErr := w.SaveNodeb(nbIdentity, &nb)
        assert.NotNil(t, rNibErr)
-       assert.Equal(t, common.VALIDATION_ERROR, rNibErr.GetCode())
-       assert.Equal(t, "3 VALIDATION_ERROR - #utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", rNibErr.Error())
-}
-
-func TestSaveEnbOnClosedPool(t *testing.T) {
-       name := "name"
-       writerPool = nil
-       sdlInstanceMock := initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
-       nb := entities.NodebInfo{}
-       nb.NodeType = entities.Node_ENB
-       nb.ConnectionStatus = 1
-       nb.Ip = "localhost"
-       nb.Port = 5656
-       enb := entities.Enb{}
-       nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
-       data, err := proto.Marshal(&nb)
-       if err != nil {
-               t.Errorf("#rNibWriter_test.TestSaveEnbOnClosedPool - Failed to marshal NodeB entity. Error: %v", err)
-       }
-       setExpected := []interface{}{name, data}
-       var e error
-       sdlInstanceMock.On("Set", setExpected).Return(e)
-       writerPool.Close()
-       nbIdentity := &entities.NbIdentity{}
-       assert.Panics(t, func(){w.SaveNodeb(nbIdentity, &nb)})
+       assert.IsType(t, &common.ValidationError{}, rNibErr)
+       assert.Equal(t, "#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", rNibErr.Error())
 }
 
 func TestSaveGnbCellIdValidationFailure(t *testing.T) {
        name := "name"
-       writerPool = nil
-       initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, _ := initSdlInstanceMock(namespace)
        nb := entities.NodebInfo{}
        nb.NodeType = entities.Node_GNB
        nb.ConnectionStatus = 1
        nb.Ip = "localhost"
        nb.Port = 5656
        gnb := entities.Gnb{}
-       cellInfo:= &entities.ServedNRCellInformation{NrPci:2}
-       cell := &entities.ServedNRCell{ServedNrCellInformation:cellInfo}
+       cellInfo := &entities.ServedNRCellInformation{NrPci: 2}
+       cell := &entities.ServedNRCell{ServedNrCellInformation: cellInfo}
        gnb.ServedNrCells = []*entities.ServedNRCell{cell}
-       nb.Configuration = &entities.NodebInfo_Gnb{Gnb:&gnb}
+       nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
 
-       nbIdentity := &entities.NbIdentity{InventoryName:name, GlobalNbId:&entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"}}
+       nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
        rNibErr := w.SaveNodeb(nbIdentity, &nb)
        assert.NotNil(t, rNibErr)
-       assert.Equal(t, common.VALIDATION_ERROR, rNibErr.GetCode())
-       assert.Equal(t, "3 VALIDATION_ERROR - #utils.ValidateAndBuildNrCellIdKey - an empty cell id received", rNibErr.Error())
+       assert.IsType(t, &common.ValidationError{}, rNibErr)
+       assert.Equal(t, "#utils.ValidateAndBuildNrCellIdKey - an empty cell id received", rNibErr.Error())
 }
 
 func TestSaveGnb(t *testing.T) {
        name := "name"
        ranName := "RAN:" + name
-       writerPool = nil
-       sdlInstanceMock := initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
        nb := entities.NodebInfo{}
        nb.NodeType = entities.Node_GNB
        nb.ConnectionStatus = 1
        nb.Ip = "localhost"
        nb.Port = 5656
        gnb := entities.Gnb{}
-       cellInfo:= &entities.ServedNRCellInformation{NrPci:2,CellId:"ccdd"}
-       cell := &entities.ServedNRCell{ServedNrCellInformation:cellInfo}
-       cellEntity := entities.Cell{Type:entities.Cell_NR_CELL, Cell:&entities.Cell_ServedNrCell{ServedNrCell:cell}}
+       cellInfo := &entities.ServedNRCellInformation{NrPci: 2, CellId: "ccdd"}
+       cell := &entities.ServedNRCell{ServedNrCellInformation: cellInfo}
+       cellEntity := entities.Cell{Type: entities.Cell_NR_CELL, Cell: &entities.Cell_ServedNrCell{ServedNrCell: cell}}
        gnb.ServedNrCells = []*entities.ServedNRCell{cell}
-       nb.Configuration = &entities.NodebInfo_Gnb{Gnb:&gnb}
+       nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
        data, err := proto.Marshal(&nb)
        if err != nil {
                t.Errorf("#rNibWriter_test.TestSaveGnb - Failed to marshal NodeB entity. Error: %v", err)
        }
        var e error
 
-
        cellData, err := proto.Marshal(&cellEntity)
        if err != nil {
                t.Errorf("#rNibWriter_test.TestSaveGnb - Failed to marshal Cell entity. Error: %v", err)
@@ -247,7 +256,7 @@ func TestSaveGnb(t *testing.T) {
        setExpected = append(setExpected, fmt.Sprintf("PCI:%s:%02x", name, cell.GetServedNrCellInformation().GetNrPci()), cellData)
 
        sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
-       nbIdentity := &entities.NbIdentity{InventoryName:name, GlobalNbId:&entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"}}
+       nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
        nbIdData, err := proto.Marshal(nbIdentity)
        if err != nil {
                t.Errorf("#rNibWriter_test.TestSaveGnb - Failed to marshal NodeB Identity entity. Error: %v", err)
@@ -272,10 +281,7 @@ func TestSaveRanLoadInformationSuccess(t *testing.T) {
                t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationSuccess - Failed to build ran load infromation key. Error: %v", validationErr)
        }
 
-       writerPool = nil
-       sdlInstanceMock := initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
-
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
 
        ranLoadInformation := generateRanLoadInformation()
        data, err := proto.Marshal(ranLoadInformation)
@@ -289,31 +295,26 @@ func TestSaveRanLoadInformationSuccess(t *testing.T) {
        setExpected = append(setExpected, loadKey, data)
        sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
 
-
        rNibErr := w.SaveRanLoadInformation(inventoryName, ranLoadInformation)
        assert.Nil(t, rNibErr)
 }
 
 func TestSaveRanLoadInformationMarshalNilFailure(t *testing.T) {
        inventoryName := "name2"
-       writerPool = nil
-       initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, _ := initSdlInstanceMock(namespace)
 
        expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
-       err:= w.SaveRanLoadInformation(inventoryName, nil)
+       err := w.SaveRanLoadInformation(inventoryName, nil)
        assert.Equal(t, expectedErr, err)
 }
 
 func TestSaveRanLoadInformationEmptyInventoryNameFailure(t *testing.T) {
        inventoryName := ""
-       writerPool = nil
-       initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, _ := initSdlInstanceMock(namespace)
 
-       err:= w.SaveRanLoadInformation(inventoryName, nil)
+       err := w.SaveRanLoadInformation(inventoryName, nil)
        assert.NotNil(t, err)
-       assert.Equal(t, common.VALIDATION_ERROR, err.GetCode())
+       assert.IsType(t, &common.ValidationError{}, err)
 }
 
 func TestSaveRanLoadInformationSdlFailure(t *testing.T) {
@@ -325,10 +326,7 @@ func TestSaveRanLoadInformationSdlFailure(t *testing.T) {
                t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationSuccess - Failed to build ran load infromation key. Error: %v", validationErr)
        }
 
-
-       writerPool = nil
-       sdlInstanceMock := initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
 
        ranLoadInformation := generateRanLoadInformation()
        data, err := proto.Marshal(ranLoadInformation)
@@ -337,17 +335,14 @@ func TestSaveRanLoadInformationSdlFailure(t *testing.T) {
                t.Errorf("#rNibWriter_test.TestSaveRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
        }
 
-
        expectedErr := errors.New("expected error")
        var setExpected []interface{}
        setExpected = append(setExpected, loadKey, data)
        sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(expectedErr)
 
-
        rNibErr := w.SaveRanLoadInformation(inventoryName, ranLoadInformation)
        assert.NotNil(t, rNibErr)
-       assert.Equal(t, common.INTERNAL_ERROR, rNibErr.GetCode())
-       assert.Equal(t, expectedErr, rNibErr.GetError())
+       assert.IsType(t, &common.InternalError{}, rNibErr)
 }
 
 func generateCellLoadInformation() *entities.CellLoadInformation {
@@ -359,54 +354,54 @@ func generateCellLoadInformation() *entities.CellLoadInformation {
        cellLoadInformation.UlInterferenceOverloadIndications = []entities.UlInterferenceOverloadIndication{ulInterferenceOverloadIndication}
 
        ulHighInterferenceInformation := entities.UlHighInterferenceInformation{
-               TargetCellId:"456",
-               UlHighInterferenceIndication:"xxx",
+               TargetCellId:                 "456",
+               UlHighInterferenceIndication: "xxx",
        }
 
-       cellLoadInformation.UlHighInterferenceInfos = []*entities.UlHighInterferenceInformation{&ulHighInterferenceInformation }
+       cellLoadInformation.UlHighInterferenceInfos = []*entities.UlHighInterferenceInformation{&ulHighInterferenceInformation}
 
        cellLoadInformation.RelativeNarrowbandTxPower = &entities.RelativeNarrowbandTxPower{
-               RntpPerPrb:"xxx",
-               RntpThreshold:entities.RntpThreshold_NEG_4,
+               RntpPerPrb:                       "xxx",
+               RntpThreshold:                    entities.RntpThreshold_NEG_4,
                NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V1_ANT_PRT,
-               PB: 1,
-               PdcchInterferenceImpact:2,
+               PB:                               1,
+               PdcchInterferenceImpact:          2,
                EnhancedRntp: &entities.EnhancedRntp{
-                       EnhancedRntpBitmap:"xxx",
-                       RntpHighPowerThreshold:entities.RntpThreshold_NEG_2,
-                       EnhancedRntpStartTime: &entities.StartTime{StartSfn:500,StartSubframeNumber:5},
+                       EnhancedRntpBitmap:     "xxx",
+                       RntpHighPowerThreshold: entities.RntpThreshold_NEG_2,
+                       EnhancedRntpStartTime:  &entities.StartTime{StartSfn: 500, StartSubframeNumber: 5},
                },
        }
 
        cellLoadInformation.AbsInformation = &entities.AbsInformation{
-               Mode: entities.AbsInformationMode_ABS_INFO_FDD,
-               AbsPatternInfo:"xxx",
-               NumberOfCellSpecificAntennaPorts:entities.NumberOfCellSpecificAntennaPorts_V2_ANT_PRT,
-               MeasurementSubset:"xxx",
+               Mode:                             entities.AbsInformationMode_ABS_INFO_FDD,
+               AbsPatternInfo:                   "xxx",
+               NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V2_ANT_PRT,
+               MeasurementSubset:                "xxx",
        }
 
        cellLoadInformation.InvokeIndication = entities.InvokeIndication_ABS_INFORMATION
 
        cellLoadInformation.ExtendedUlInterferenceOverloadInfo = &entities.ExtendedUlInterferenceOverloadInfo{
-               AssociatedSubframes:"xxx",
-               ExtendedUlInterferenceOverloadIndications:cellLoadInformation.UlInterferenceOverloadIndications,
+               AssociatedSubframes:                       "xxx",
+               ExtendedUlInterferenceOverloadIndications: cellLoadInformation.UlInterferenceOverloadIndications,
        }
 
        compInformationItem := &entities.CompInformationItem{
-               CompHypothesisSets: []*entities.CompHypothesisSet{&entities.CompHypothesisSet{CellId: "789", CompHypothesis:"xxx"}},
-               BenefitMetric:50,
+               CompHypothesisSets: []*entities.CompHypothesisSet{&entities.CompHypothesisSet{CellId: "789", CompHypothesis: "xxx"}},
+               BenefitMetric:      50,
        }
 
        cellLoadInformation.CompInformation = &entities.CompInformation{
-               CompInformationItems:[]*entities.CompInformationItem{compInformationItem},
-               CompInformationStartTime:&entities.StartTime{StartSfn:123,StartSubframeNumber:456},
+               CompInformationItems:     []*entities.CompInformationItem{compInformationItem},
+               CompInformationStartTime: &entities.StartTime{StartSfn: 123, StartSubframeNumber: 456},
        }
 
        cellLoadInformation.DynamicDlTransmissionInformation = &entities.DynamicDlTransmissionInformation{
-               State: entities.NaicsState_NAICS_ACTIVE,
-               TransmissionModes:"xxx",
-               PB: 2,
-               PAList:[]entities.PA{entities.PA_DB_NEG_3},
+               State:             entities.NaicsState_NAICS_ACTIVE,
+               TransmissionModes: "xxx",
+               PB:                2,
+               PAList:            []entities.PA{entities.PA_DB_NEG_3},
        }
 
        return &cellLoadInformation
@@ -417,7 +412,6 @@ func generateRanLoadInformation() *entities.RanLoadInformation {
 
        ranLoadInformation.LoadTimestamp = uint64(time.Now().UnixNano())
 
-
        cellLoadInformation := generateCellLoadInformation()
        ranLoadInformation.CellLoadInfos = []*entities.CellLoadInformation{cellLoadInformation}
 
@@ -425,9 +419,7 @@ func generateRanLoadInformation() *entities.RanLoadInformation {
 }
 
 func TestSaveNilEntityFailure(t *testing.T) {
-       writerPool = nil
-       initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, _ := initSdlInstanceMock(namespace)
        expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
        nbIdentity := &entities.NbIdentity{}
        actualErr := w.SaveNodeb(nbIdentity, nil)
@@ -435,11 +427,9 @@ func TestSaveNilEntityFailure(t *testing.T) {
 }
 
 func TestSaveUnknownTypeEntityFailure(t *testing.T) {
-       writerPool = nil
-       initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
-       expectedErr := common.NewValidationError(errors.New("#rNibWriter.saveNodeB - Unknown responding node type, entity: ip:\"localhost\" port:5656 "))
-       nbIdentity := &entities.NbIdentity{InventoryName:"name", GlobalNbId:&entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"}}
+       w, _ := initSdlInstanceMock(namespace)
+       expectedErr := common.NewValidationError("#rNibWriter.saveNodeB - Unknown responding node type, entity: ip:\"localhost\" port:5656 ")
+       nbIdentity := &entities.NbIdentity{InventoryName: "name", GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
        nb := &entities.NodebInfo{}
        nb.Port = 5656
        nb.Ip = "localhost"
@@ -452,97 +442,136 @@ func TestSaveEntityFailure(t *testing.T) {
        plmnId := "02f829"
        nbId := "4a952a0a"
 
-       writerPool = nil
-       sdlInstanceMock := initSdlInstanceMock(namespace, 1)
-       w := GetRNibWriter()
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
        gnb := entities.NodebInfo{}
        gnb.NodeType = entities.Node_GNB
        data, err := proto.Marshal(&gnb)
        if err != nil {
                t.Errorf("#rNibWriter_test.TestSaveEntityFailure - Failed to marshal NodeB entity. Error: %v", err)
        }
-       nbIdentity := &entities.NbIdentity{InventoryName:name, GlobalNbId:&entities.GlobalNbId{PlmnId:plmnId, NbId:nbId}}
+       nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
        setExpected := []interface{}{"RAN:" + name, data}
-       setExpected = append(setExpected,"GNB:" + plmnId + ":" + nbId, data)
+       setExpected = append(setExpected, "GNB:"+plmnId+":"+nbId, data)
        expectedErr := errors.New("expected error")
        sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(expectedErr)
        rNibErr := w.SaveNodeb(nbIdentity, &gnb)
        assert.NotEmpty(t, rNibErr)
 }
 
-func TestGetRNibWriterPoolNotInitializedFailure(t *testing.T) {
-       writerPool = nil
-       assert.Panics(t, func(){GetRNibWriter()})
-}
-
 func TestGetRNibWriter(t *testing.T) {
-       writerPool = nil
-       initSdlInstanceMock(namespace, 1)
-       received := GetRNibWriter()
+       received, _ := initSdlInstanceMock(namespace)
        assert.NotEmpty(t, received)
-       available, created := writerPool.Stats()
-       assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
-       assert.Equal(t, 1, created, "number of created objects in the writerPool should be 1")
-       writerPool.Close()
 }
 
-func TestClose(t *testing.T) {
-       writerPool = nil
-       instanceMock := initSdlInstanceMock(namespace, 2)
-       w1 := GetRNibWriter()
-       w2 := GetRNibWriter()
-       writerPool.Put(w1)
-       writerPool.Put(w2)
-       available, created := writerPool.Stats()
-       assert.Equal(t, 2, available, "number of available objects in the writerPool should be 2")
-       assert.Equal(t, 2, created, "number of created objects in the writerPool should be 2")
+func TestSaveE2TInstanceSuccess(t *testing.T) {
+       address := "10.10.2.15:9800"
+       loadKey, validationErr := common.ValidateAndBuildE2TInstanceKey(address)
+
+       if validationErr != nil {
+               t.Errorf("#rNibWriter_test.TestSaveE2TInstanceSuccess - Failed to build E2T Instance key. Error: %v", validationErr)
+       }
+
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+       e2tInstance := generateE2tInstance(address)
+       data, err := json.Marshal(e2tInstance)
+
+       if err != nil {
+               t.Errorf("#rNibWriter_test.TestSaveE2TInstanceSuccess - Failed to marshal E2tInstance entity. Error: %v", err)
+       }
+
        var e error
-       instanceMock.On("Close").Return(e)
-       Close()
-       available, created = writerPool.Stats()
-       assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
-       assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
+       var setExpected []interface{}
+       setExpected = append(setExpected, loadKey, data)
+       sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
+
+       rNibErr := w.SaveE2TInstance(e2tInstance)
+       assert.Nil(t, rNibErr)
 }
 
-func TestCloseOnClosedPoolFailure(t *testing.T) {
-       writerPool = nil
-       instanceMock := initSdlInstanceMock(namespace, 1)
-       w1 := GetRNibWriter()
-       writerPool.Put(w1)
-       available, created := writerPool.Stats()
-       assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
-       assert.Equal(t, 1, created, "number of created objects in the writerPool should be 1")
-       var e error
-       instanceMock.On("Close").Return(e)
-       Close()
-       assert.Panics(t, func(){Close()})
+func TestSaveE2TInstanceNullE2tInstanceFailure(t *testing.T) {
+       w, _ := initSdlInstanceMock(namespace)
+       var address string
+       e2tInstance := entities.NewE2TInstance(address)
+       err := w.SaveE2TInstance(e2tInstance)
+       assert.NotNil(t, err)
+       assert.IsType(t, &common.ValidationError{}, err)
 }
 
-func TestCloseFailure(t *testing.T) {
-       writerPool = nil
-       instanceMock := initSdlInstanceMock(namespace, 2)
-       w1 := GetRNibWriter()
-       writerPool.Put(w1)
-       available, created := writerPool.Stats()
-       assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
-       assert.Equal(t, 1, created, "number of created objects in the writerPool should be 1")
-       e := errors.New("expected error")
-       instanceMock.On("Close").Return(e)
-       Close()
-       available, created = writerPool.Stats()
-       assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
-       assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
+func TestSaveE2TInstanceSdlFailure(t *testing.T) {
+       address := "10.10.2.15:9800"
+       loadKey, validationErr := common.ValidateAndBuildE2TInstanceKey(address)
+
+       if validationErr != nil {
+               t.Errorf("#rNibWriter_test.TestSaveE2TInstanceSdlFailure - Failed to build E2T Instance key. Error: %v", validationErr)
+       }
+
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+       e2tInstance := generateE2tInstance(address)
+       data, err := json.Marshal(e2tInstance)
+
+       if err != nil {
+               t.Errorf("#rNibWriter_test.TestSaveE2TInstanceSdlFailure - Failed to marshal E2tInstance entity. Error: %v", err)
+       }
+
+       expectedErr := errors.New("expected error")
+       var setExpected []interface{}
+       setExpected = append(setExpected, loadKey, data)
+       sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(expectedErr)
+
+       rNibErr := w.SaveE2TInstance(e2tInstance)
+       assert.NotNil(t, rNibErr)
+       assert.IsType(t, &common.InternalError{}, rNibErr)
 }
 
-func TestInit(t *testing.T) {
-       writerPool = nil
-       Init("", 1)
-       assert.NotNil(t, writerPool)
-       assert.NotNil(t, writerPool.New)
-       assert.NotNil(t, writerPool.Destroy)
-       available, created := writerPool.Stats()
-       assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
-       assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
+func generateE2tInstance(address string) *entities.E2TInstance {
+       e2tInstance := entities.NewE2TInstance(address)
+
+       e2tInstance.AssociatedRanList = []string{"test1", "test2"}
+
+       return e2tInstance
+}
+
+func TestSaveE2TAddressesSuccess(t *testing.T) {
+       address := "10.10.2.15:9800"
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+       e2tAddresses := []string{address}
+       data, err := json.Marshal(e2tAddresses)
+
+       if err != nil {
+               t.Errorf("#rNibWriter_test.TestSaveE2TInfoListSuccess - Failed to marshal E2TInfoList. Error: %v", err)
+       }
+
+       var e error
+       var setExpected []interface{}
+       setExpected = append(setExpected, E2TAddressesKey, data)
+       sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
+
+       rNibErr := w.SaveE2TAddresses(e2tAddresses)
+       assert.Nil(t, rNibErr)
+}
+
+func TestSaveE2TAddressesSdlFailure(t *testing.T) {
+       address := "10.10.2.15:9800"
+       w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+       e2tAddresses := []string{address}
+       data, err := json.Marshal(e2tAddresses)
+
+       if err != nil {
+               t.Errorf("#rNibWriter_test.TestSaveE2TInfoListSdlFailure - Failed to marshal E2TInfoList. Error: %v", err)
+       }
+
+       expectedErr := errors.New("expected error")
+       var setExpected []interface{}
+       setExpected = append(setExpected, E2TAddressesKey, data)
+       sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(expectedErr)
+
+       rNibErr := w.SaveE2TAddresses(e2tAddresses)
+       assert.NotNil(t, rNibErr)
+       assert.IsType(t, &common.InternalError{}, rNibErr)
 }
 
 //Integration tests
@@ -613,4 +642,4 @@ func TestInit(t *testing.T) {
 //             if err != nil{
 //                     t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationInteg - Failed to save RanLoadInformation entity. Error: %v", err)
 //             }
-//}
\ No newline at end of file
+//}