[RICPLT-1739] Extract and build Load Information Message
Change-Id: I5b877c47722abe2a61d6672c2919723ca4162715
Signed-off-by: is005q <idan.shalom@intl.att.com>
diff --git a/E2Manager/rNibWriter/rNibWriter_test.go b/E2Manager/rNibWriter/rNibWriter_test.go
index 97535cc..c2b6d23 100644
--- a/E2Manager/rNibWriter/rNibWriter_test.go
+++ b/E2Manager/rNibWriter/rNibWriter_test.go
@@ -18,13 +18,12 @@
package rNibWriter
import (
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"e2mgr/mocks"
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"errors"
"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"
"github.com/golang/protobuf/proto"
- "github.com/golang/protobuf/ptypes/timestamp"
"github.com/stretchr/testify/assert"
"testing"
"time"
@@ -84,10 +83,10 @@
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)
@@ -105,7 +104,7 @@
setExpected = append(setExpected, fmt.Sprintf("PCI:%s:%02x", name, cell.GetPci()), 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.TestSaveEnb - Failed to marshal NodeB Identity entity. Error: %v", err)
@@ -126,11 +125,11 @@
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())
@@ -147,11 +146,11 @@
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())
@@ -169,7 +168,7 @@
nb.Ip = "localhost"
nb.Port = 5656
enb := entities.Enb{}
- 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.TestSaveEnbOnClosedPool - Failed to marshal NodeB entity. Error: %v", err)
@@ -179,7 +178,7 @@
sdlInstanceMock.On("Set", setExpected).Return(e)
writerPool.Close()
nbIdentity := &entities.NbIdentity{}
- assert.Panics(t, func(){w.SaveNodeb(nbIdentity, &nb)})
+ assert.Panics(t, func() { w.SaveNodeb(nbIdentity, &nb) })
}
func TestSaveGnbCellIdValidationFailure(t *testing.T) {
@@ -193,12 +192,12 @@
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())
@@ -217,18 +216,17 @@
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)
@@ -240,7 +238,7 @@
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)
@@ -263,7 +261,6 @@
sdlInstanceMock := initSdlInstanceMock(namespace, 1)
w := GetRNibWriter()
-
ranLoadInformation := generateRanLoadInformation()
data, err := proto.Marshal(ranLoadInformation)
@@ -276,7 +273,6 @@
setExpected = append(setExpected, loadKey, data)
sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
-
rNibErr := w.SaveRanLoadInformation(inventoryName, ranLoadInformation)
assert.Nil(t, rNibErr)
}
@@ -288,7 +284,7 @@
w := GetRNibWriter()
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)
}
@@ -298,7 +294,7 @@
initSdlInstanceMock(namespace, 1)
w := GetRNibWriter()
- err:= w.SaveRanLoadInformation(inventoryName, nil)
+ err := w.SaveRanLoadInformation(inventoryName, nil)
assert.NotNil(t, err)
assert.Equal(t, common.VALIDATION_ERROR, err.GetCode())
}
@@ -312,7 +308,6 @@
t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationSuccess - Failed to build ran load infromation key. Error: %v", validationErr)
}
-
writerPool = nil
sdlInstanceMock := initSdlInstanceMock(namespace, 1)
w := GetRNibWriter()
@@ -324,13 +319,11 @@
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())
@@ -346,54 +339,54 @@
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,
- EnhancedRntpStartTimes: []*entities.StartTime{&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{&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
@@ -402,8 +395,7 @@
func generateRanLoadInformation() *entities.RanLoadInformation {
ranLoadInformation := entities.RanLoadInformation{}
- ranLoadInformation.LoadTimestamp = ×tamp.Timestamp{Seconds:time.Now().Unix(),Nanos: int32(time.Now().UnixNano())}
-
+ ranLoadInformation.LoadTimestamp = uint64(time.Now().UnixNano())
cellLoadInformation := generateCellLoadInformation()
ranLoadInformation.CellLoadInfos = []*entities.CellLoadInformation{cellLoadInformation}
@@ -426,7 +418,7 @@
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"}}
+ nbIdentity := &entities.NbIdentity{InventoryName: "name", GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
nb := &entities.NodebInfo{}
nb.Port = 5656
nb.Ip = "localhost"
@@ -448,9 +440,9 @@
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)
@@ -459,7 +451,7 @@
func TestGetRNibWriterPoolNotInitializedFailure(t *testing.T) {
writerPool = nil
- assert.Panics(t, func(){GetRNibWriter()})
+ assert.Panics(t, func() { GetRNibWriter() })
}
func TestGetRNibWriter(t *testing.T) {
@@ -502,7 +494,7 @@
var e error
instanceMock.On("Close").Return(e)
Close()
- assert.Panics(t, func(){Close()})
+ assert.Panics(t, func() { Close() })
}
func TestCloseFailure(t *testing.T) {
@@ -584,4 +576,4 @@
// if err != nil{
// t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationInteg - Failed to save RanLoadInformation entity. Error: %v", err)
// }
-//}
\ No newline at end of file
+//}