From: rh362j Date: Sun, 27 Oct 2019 08:57:57 +0000 (+0200) Subject: Remove the rnib pool, enable the use of shared db and sdl instances. X-Git-Tag: common/v1.0.25~4 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=63e943757e689470e70e0c27b8460420d52ea25c;p=ric-plt%2Fnodeb-rnib.git Remove the rnib pool, enable the use of shared db and sdl instances. Change-Id: I6fab248ac14aea02c8a2580e76c0d89f40cf46b0 Signed-off-by: rh362j --- diff --git a/common/rNibPool.go b/common/rNibPool.go deleted file mode 100644 index 2d90704..0000000 --- a/common/rNibPool.go +++ /dev/null @@ -1,83 +0,0 @@ -package common - -import ( - "sync/atomic" -) - -type Pool struct { - New func() interface{} - Destroy func(interface{}) - pool chan interface{} - created int32 //Number of objects created -} - -/* -NewPool creates thread safe Pool object and returns a pointer to it. -poolSize int - sets the capacity of the pool -newObj func - specifies a function to generate a value (pool element) -destroyObj func - specifies a function to destroy a value (pool element) -*/ -func NewPool(poolSize int, newObj func() interface{}, destroyObj func(interface{})) *Pool{ - return &Pool{ - New: newObj, - Destroy: destroyObj, - pool: make(chan interface{}, poolSize), - } -} - -/* -Retrieve an object from the pool. -If the pool is empty and the number of used object is less than capacity, a new object is created by calling New. -Otherwise, the method blocks until an object is returned to the pool. -*/ -func (p *Pool) Get() interface{} { - select { - case obj := <-p.pool: - return obj - default: - if atomic.AddInt32(&p.created, 1) <= int32(cap(p.pool)) && p.New != nil { - p.pool <- p.New() - } - } - return <-p.pool //block waiting -} - -/* -Return an object to the pool. -If capacity is exceeded the object is discarded after calling Destroy on it if Destroy is not nil. -*/ -func (p *Pool) Put(obj interface{}) { - if obj != nil { - select { - case p.pool <- obj: - default: - if p.Destroy != nil { - p.Destroy(obj) - } - } - } -} - -/* - Closes the pool and if Destroy is not nil, call Destroy on each object in the pool - The pool must not be used once this method is called. -*/ -func (p *Pool) Close() { - close(p.pool) - available := len(p.pool) - if p.Destroy != nil { - for obj := range p.pool { - p.Destroy(obj) - - } - } - atomic.AddInt32(&p.created, -int32(available)) -} -/* -Return statistics. -available - the number of available instances -created - the number of created instances -*/ -func (p *Pool) Stats() (available int, created int) { - return len(p.pool), int(p.created) -} diff --git a/common/rNibPool_test.go b/common/rNibPool_test.go deleted file mode 100644 index e3bffa5..0000000 --- a/common/rNibPool_test.go +++ /dev/null @@ -1,239 +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 common - -import ( - "github.com/stretchr/testify/assert" - "sync" - "sync/atomic" - "testing" - "time" -) - -var max int32 -var counter int32 -var poolGlob *Pool -type instance struct{} - -func(instance) up(){ - tmpc := atomic.AddInt32(&counter, 1) - swapped:= false - for !swapped { - tmpm := atomic.LoadInt32(&max) - if tmpc >tmpm { - swapped = atomic.CompareAndSwapInt32(&max, tmpm, tmpc) - } else { - break - } - } -} - -func(instance) down(){ - atomic.AddInt32(&counter, - 1) -} - -func TestPoolMax(t *testing.T){ - counter = 0 - max = 0 - validateMaxLimit(1, 1, t) - counter = 0 - max = 0 - validateMaxLimit(1, 2, t) - counter = 0 - max = 0 - validateMaxLimit(5, 10, t) -} - -func validateMaxLimit(size int, iterations int, t *testing.T) { - poolGlob = NewPool(size, func() interface{} { - inst := instance{} - return inst - }, - func(obj interface{}) { - }, - ) - group := sync.WaitGroup{} - for i := 0; i < iterations; i++ { - group.Add(1) - go func() { - getPutInstance() - group.Done() - }() - } - time.Sleep(time.Second) - group.Wait() - assert.Equal(t, int32(size), max) -} - -func getPutInstance() { - inst := poolGlob.Get().(instance) - inst.up() - time.Sleep(time.Millisecond*10) - inst.down() - poolGlob.Put(inst) -} - -func TestNewPool(t *testing.T){ - size := 5 - pool := NewPool(size, func() interface{} { - inst := instance{} - return inst - }, - func(obj interface{}) { - }, - ) - assert.NotNil(t, pool) - assert.NotNil(t, pool.New) - assert.NotNil(t, pool.Destroy) - assert.NotNil(t, pool.pool) - assert.Equal(t, cap(pool.pool), size, "the capacity of the pool should be " + string(size)) -} - -func TestGetCreated(t *testing.T) { - pool := NewPool(1, func() interface{} { - inst := instance{} - return inst - }, - func(obj interface{}) { - }, - ) - pool.Get() - available, created := pool.Stats() - assert.Equal(t, 0, available, "number of available objects in the pool should be 0") - assert.Equal(t, 1, created, "number of created objects in the pool should be 1") - pool.Close() -} - -func TestGetAndPut(t *testing.T) { - pool := NewPool(1, func() interface{} { - inst := instance{} - return inst - }, - func(obj interface{}) { - }, - ) - pool.Put(pool.Get()) - available, created := pool.Stats() - assert.Equal(t, 1, available, "number of available objects in the pool should be 1") - assert.Equal(t, 1, created, "number of created objects in the pool should be 1") - pool.Close() -} - -func TestPutOutOfCapacity(t *testing.T) { - pool := NewPool(1, func() interface{} { - inst := instance{} - return inst - }, - func(obj interface{}) { - }, - ) - pool.Put(pool.Get()) - pool.Put(new(instance)) - available, created := pool.Stats() - assert.Equal(t, 1, available, "number of available objects in the pool should be 1") - assert.Equal(t, 1, created, "number of created objects in the pool should be 1") - pool.Close() -} - -func TestNotInitializedPut(t *testing.T) { - var poolEmpty Pool - poolEmpty.Put(new(instance)) - available, created := poolEmpty.Stats() - assert.Equal(t, 0, available, "number of available objects in the pool should be 0") - assert.Equal(t, 0, created, "number of created objects in the pool should be 0") -} - -func TestPutNilObject(t *testing.T) { - var poolEmpty Pool - poolEmpty.Put(nil) - available, created := poolEmpty.Stats() - assert.Equal(t, 0, available, "number of available objects in the pool should be 0") - assert.Equal(t, 0, created, "number of created objects in the pool should be 0") -} - -func TestGet(t *testing.T) { - pool := NewPool(2, func() interface{} { - inst := instance{} - return inst - }, - func(obj interface{}) { - }, - ) - i1 := pool.Get() - i2 := pool.Get() - available, created := pool.Stats() - assert.Equal(t, 0, available, "number of available objects in the pool should be 0") - assert.Equal(t, 2, created, "number of created objects in the pool should be 2") - pool.Put(i1) - pool.Put(i2) - pool.Put(new(instance)) - available, created = pool.Stats() - assert.Equal(t, 2, available, "number of available objects in the pool should be 2") - assert.Equal(t, 2, created, "number of created objects in the pool should be 2") -} - -func TestClose(t *testing.T) { - pool := NewPool(3, func() interface{} { - inst := instance{} - return inst - }, - func(obj interface{}) { - }, - ) - i1 := pool.Get() - i2 := pool.Get() - i3 := pool.Get() - available, created := pool.Stats() - assert.Equal(t, 0, available, "number of available objects in the pool should be 0") - assert.Equal(t, 3, created, "number of created objects in the pool should be 3") - pool.Put(i1) - pool.Put(i2) - pool.Put(i3) - available, created = pool.Stats() - assert.Equal(t, 3, available, "number of available objects in the pool should be 3") - assert.Equal(t, 3, created, "number of created objects in the pool should be 3") - pool.Close() - i := pool.Get() - assert.Nil(t, i) - available, created = pool.Stats() - assert.Equal(t, 0, available, "number of available objects in the pool should be 0") - assert.Equal(t, 0, created, "number of created objects in the pool should be 0") -} - -func TestPoolPutPanicsOnClosedChannel(t *testing.T){ - pool := NewPool(1, func() interface{} { - inst := instance{} - return inst - }, - func(obj interface{}) { - }, - ) - close(pool.pool) - assert.Panics(t, func(){pool.Put(instance{})}) -} - -func TestPoolClosePanicsOnClosedChannel(t *testing.T) { - pool := NewPool(1, func() interface{} { - inst := instance{} - return inst - }, - func(obj interface{}) { - }, - ) - close(pool.pool) - assert.Panics(t, func(){pool.Close()}) -} diff --git a/reader/go.mod b/reader/go.mod index cbda325..50004a6 100644 --- a/reader/go.mod +++ b/reader/go.mod @@ -5,7 +5,7 @@ go 1.12 require ( gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.23 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.23 - gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.3.1 + gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.5.0 github.com/golang/protobuf v1.3.1 github.com/pkg/errors v0.8.1 github.com/stretchr/testify v1.3.0 @@ -15,4 +15,4 @@ replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common => ../common replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities => ../entities -replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.3.1 +replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.0 diff --git a/reader/go.sum b/reader/go.sum index 5e6f72d..ed70528 100644 --- a/reader/go.sum +++ b/reader/go.sum @@ -3,6 +3,8 @@ gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.2.0/go.mod h1:2Y8gw2jqj9urI8VFqFQn7BX gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.3.0/go.mod h1:y2WhrCvdLkAKdH+ySdHSOSehACJkTMyZghCGVcqoZzc= gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.3.1 h1:ZIhABs0WLMn8lp1Y3719315/3jbV+yLcovOGScL03eM= gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.3.1/go.mod h1:y2WhrCvdLkAKdH+ySdHSOSehACJkTMyZghCGVcqoZzc= +gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.0 h1:+P3XuWKSaMbzh5PNtrW9gkZlCN0hKrZq+Cn8JetwBys= +gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.0/go.mod h1:y2WhrCvdLkAKdH+ySdHSOSehACJkTMyZghCGVcqoZzc= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= diff --git a/reader/rNibReader.go b/reader/rNibReader.go index be31a1d..0d1d80f 100644 --- a/reader/rNibReader.go +++ b/reader/rNibReader.go @@ -19,16 +19,12 @@ package reader import ( "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/sdlgo" "github.com/golang/protobuf/proto" "reflect" ) -var readerPool *common.Pool - type rNibReaderInstance struct { - sdl *common.ISdlInstance - namespace string + sdl common.ISdlInstance } /* @@ -52,65 +48,39 @@ type RNibReader interface { // GetCellById retrieves the cell entity from redis DB by cell type and cell Id GetCellById(cellType entities.Cell_Type, cellId string) (*entities.Cell, error) // GetListNodebIds returns the full list of Nodeb identity entities - GetListNodebIds()([]*entities.NbIdentity, error) + GetListNodebIds() ([]*entities.NbIdentity, error) // GetRanLoadInformation retrieves nodeb load information entity from redis DB by nodeb inventory name GetRanLoadInformation(inventoryName string) (*entities.RanLoadInformation, error) } -/* - Init initializes the infrastructure required for the RNibReader instance -*/ -func Init(namespace string, poolSize int) { - initPool(poolSize, - func() interface{} { - var sdlI common.ISdlInstance = sdlgo.NewSdlInstance(namespace, sdlgo.NewDatabase()) - return &rNibReaderInstance{sdl: &sdlI, namespace: namespace} - }, - func(obj interface{}) { - i, ok := obj.(*rNibReaderInstance) - if ok{ - (*i.sdl).Close() - } - }) -} - -func initPool(poolSize int, newObj func() interface{}, destroyObj func(interface{})) { - readerPool = common.NewPool(poolSize, newObj, destroyObj) -} - /* GetRNibReader returns reference to RNibReader */ -func GetRNibReader() RNibReader { - return &rNibReaderInstance{} +func GetRNibReader(sdl common.ISdlInstance) RNibReader { + return &rNibReaderInstance{sdl: sdl} } - -func (*rNibReaderInstance) GetNodeb(inventoryName string) (*entities.NodebInfo, error) { - w := readerPool.Get().(*rNibReaderInstance) - defer readerPool.Put(w) +func (w *rNibReaderInstance) GetNodeb(inventoryName string) (*entities.NodebInfo, error) { key, rNibErr := common.ValidateAndBuildNodeBNameKey(inventoryName) if rNibErr != nil { return nil, rNibErr } nbInfo := &entities.NodebInfo{} err := w.getByKeyAndUnmarshal(key, nbInfo) - if err!= nil{ + if err != nil { return nil, err } return nbInfo, nil } -func (*rNibReaderInstance) GetNodebByGlobalNbId(nodeType entities.Node_Type, globalNbId *entities.GlobalNbId) (*entities.NodebInfo, error) { - w := readerPool.Get().(*rNibReaderInstance) - defer readerPool.Put(w) +func (w *rNibReaderInstance) GetNodebByGlobalNbId(nodeType entities.Node_Type, globalNbId *entities.GlobalNbId) (*entities.NodebInfo, error) { key, rNibErr := common.ValidateAndBuildNodeBIdKey(nodeType.String(), globalNbId.GetPlmnId(), globalNbId.GetNbId()) if rNibErr != nil { return nil, rNibErr } nbInfo := &entities.NodebInfo{} err := w.getByKeyAndUnmarshal(key, nbInfo) - if err!= nil{ + if err != nil { return nil, err } return nbInfo, nil @@ -132,49 +102,39 @@ func (w *rNibReaderInstance) GetCellList(inventoryName string) (*entities.Cells, cells.List = &entities.Cells_ServedNrCells{ServedNrCells: &entities.ServedNRCellList{ServedCells: nb.GetGnb().GetServedNrCells()}} return cells, nil } - return nil, common.NewResourceNotFoundErrorf("#rNibReader.GetCellList - served cells not found. Responding node RAN name: %s .", inventoryName) + return nil, common.NewResourceNotFoundErrorf("#rNibReader.GetCellList - served cells not found. Responding node RAN name: %s.", inventoryName) } -func (*rNibReaderInstance) GetListGnbIds() ([]*entities.NbIdentity, error) { - w := readerPool.Get().(*rNibReaderInstance) - defer readerPool.Put(w) +func (w *rNibReaderInstance) GetListGnbIds() ([]*entities.NbIdentity, error) { return w.getListNodebIdsByType(entities.Node_GNB.String()) } -func (*rNibReaderInstance) GetListEnbIds() ([]*entities.NbIdentity, error) { - w := readerPool.Get().(*rNibReaderInstance) - defer readerPool.Put(w) +func (w *rNibReaderInstance) GetListEnbIds() ([]*entities.NbIdentity, error) { return w.getListNodebIdsByType(entities.Node_ENB.String()) } -func (*rNibReaderInstance) GetCountGnbList() (int, error) { - w := readerPool.Get().(*rNibReaderInstance) - defer readerPool.Put(w) - size, err := (*w.sdl).GroupSize(entities.Node_GNB.String()) +func (w *rNibReaderInstance) GetCountGnbList() (int, error) { + size, err := w.sdl.GroupSize(entities.Node_GNB.String()) if err != nil { return 0, common.NewInternalError(err) } return int(size), nil } -func (*rNibReaderInstance) GetCell(inventoryName string, pci uint32) (*entities.Cell, error) { - w := readerPool.Get().(*rNibReaderInstance) - defer readerPool.Put(w) +func (w *rNibReaderInstance) GetCell(inventoryName string, pci uint32) (*entities.Cell, error) { key, rNibErr := common.ValidateAndBuildCellNamePciKey(inventoryName, pci) if rNibErr != nil { return nil, rNibErr } cell := &entities.Cell{} err := w.getByKeyAndUnmarshal(key, cell) - if err!= nil{ + if err != nil { return nil, err } return cell, err } -func (*rNibReaderInstance) GetCellById(cellType entities.Cell_Type, cellId string) (*entities.Cell, error) { - w := readerPool.Get().(*rNibReaderInstance) - defer readerPool.Put(w) +func (w *rNibReaderInstance) GetCellById(cellType entities.Cell_Type, cellId string) (*entities.Cell, error) { var key string var rNibErr error if cellType == entities.Cell_LTE_CELL { @@ -189,25 +149,23 @@ func (*rNibReaderInstance) GetCellById(cellType entities.Cell_Type, cellId strin } cell := &entities.Cell{} err := w.getByKeyAndUnmarshal(key, cell) - if err!= nil{ + if err != nil { return nil, err } return cell, err } -func (*rNibReaderInstance) GetListNodebIds()([]*entities.NbIdentity, error){ - w := readerPool.Get().(*rNibReaderInstance) - defer readerPool.Put(w) - dataEnb, err := (*w.sdl).GetMembers(entities.Node_ENB.String()) - if err != nil{ +func (w *rNibReaderInstance) GetListNodebIds() ([]*entities.NbIdentity, error) { + dataEnb, err := w.sdl.GetMembers(entities.Node_ENB.String()) + if err != nil { return nil, common.NewInternalError(err) } - dataGnb, err := (*w.sdl).GetMembers(entities.Node_GNB.String()) - if err != nil{ + dataGnb, err := w.sdl.GetMembers(entities.Node_GNB.String()) + if err != nil { return nil, common.NewInternalError(err) } - dataUnknown, err := (*w.sdl).GetMembers(entities.Node_UNKNOWN.String()) - if err != nil{ + dataUnknown, err := w.sdl.GetMembers(entities.Node_UNKNOWN.String()) + if err != nil { return nil, common.NewInternalError(err) } allIds := append(dataEnb, dataGnb...) @@ -216,22 +174,21 @@ func (*rNibReaderInstance) GetListNodebIds()([]*entities.NbIdentity, error){ return data, rnibErr } -func (*rNibReaderInstance) GetRanLoadInformation(inventoryName string) (*entities.RanLoadInformation, error){ - w := readerPool.Get().(*rNibReaderInstance) +func (w *rNibReaderInstance) GetRanLoadInformation(inventoryName string) (*entities.RanLoadInformation, error) { key, rNibErr := common.ValidateAndBuildRanLoadInformationKey(inventoryName) if rNibErr != nil { return nil, rNibErr } loadInfo := &entities.RanLoadInformation{} err := w.getByKeyAndUnmarshal(key, loadInfo) - if err!= nil{ + if err != nil { return nil, err } return loadInfo, err } -func (w *rNibReaderInstance) getByKeyAndUnmarshal(key string, entity proto.Message)error{ - data, err := (*w.sdl).Get([]string{key}) +func (w *rNibReaderInstance) getByKeyAndUnmarshal(key string, entity proto.Message) error { + data, err := w.sdl.Get([]string{key}) if err != nil { return common.NewInternalError(err) } @@ -246,7 +203,7 @@ func (w *rNibReaderInstance) getByKeyAndUnmarshal(key string, entity proto.Messa } func (w *rNibReaderInstance) getListNodebIdsByType(nbType string) ([]*entities.NbIdentity, error) { - data, err := (*w.sdl).GetMembers(nbType) + data, err := w.sdl.GetMembers(nbType) if err != nil { return nil, common.NewInternalError(err) } @@ -266,6 +223,7 @@ func (w *rNibReaderInstance) unmarshalIdentityList(data []string) ([]*entities.N return members, nil } +//Close the reader func Close() { - readerPool.Close() -} \ No newline at end of file + // Nothing to do +} diff --git a/reader/rNibReader_test.go b/reader/rNibReader_test.go index 2ee7584..91f37c3 100644 --- a/reader/rNibReader_test.go +++ b/reader/rNibReader_test.go @@ -29,52 +29,15 @@ import ( var namespace = "namespace" -func TestInit(t *testing.T) { - readerPool = nil - Init("", 1) - assert.NotNil(t, readerPool) - assert.NotNil(t, readerPool.New) - assert.NotNil(t, readerPool.Destroy) - available, created := readerPool.Stats() - assert.Equal(t, 0, available, "number of available objects in the readerPool should be 0") - assert.Equal(t, 0, created, "number of created objects in the readerPool should be 0") -} - -func TestInitPool(t *testing.T) { - readerPool = nil - sdlInstanceMock := new(MockSdlInstance) - initPool(1, func() interface{} { - sdlI := common.ISdlInstance(sdlInstanceMock) - return &rNibReaderInstance{sdl: &sdlI, namespace: namespace} - }, - func(obj interface{}) { - }, - ) - assert.NotNil(t, readerPool) - assert.NotNil(t, readerPool.New) - assert.NotNil(t, readerPool.Destroy) - available, created := readerPool.Stats() - assert.Equal(t, 0, available, "number of available objects in the readerPool should be 0") - assert.Equal(t, 0, created, "number of created objects in the readerPool should be 0") -} - -func initSdlInstanceMock(namespace string, poolSize int) *MockSdlInstance { - sdlInstanceMock := new(MockSdlInstance) - initPool(poolSize, func() interface{} { - sdlI := common.ISdlInstance(sdlInstanceMock) - return &rNibReaderInstance{sdl: &sdlI, namespace: namespace} - }, - func(obj interface{}) { - }, - ) - return sdlInstanceMock +func initSdlInstanceMock(namespace string) (w RNibReader, sdlInstanceMock *MockSdlInstance) { + sdlInstanceMock = new(MockSdlInstance) + w = GetRNibReader(sdlInstanceMock) + return } func TestGetNodeB(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) nb := entities.NodebInfo{} nb.ConnectionStatus = 1 nb.Ip = "localhost" @@ -105,9 +68,7 @@ func TestGetNodeB(t *testing.T) { func TestGetNodeBNotFoundFailure(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error var ret map[string]interface{} redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name) @@ -124,9 +85,7 @@ func TestGetNodeBNotFoundFailure(t *testing.T) { func TestGetNodeBUnmarshalFailure(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error ret := make(map[string]interface{}, 1) redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name) @@ -146,9 +105,7 @@ func TestGetNodeBSdlgoFailure(t *testing.T) { name := "name" errMsg := "expected Sdlgo error" errMsgExpected := "expected Sdlgo error" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) e := errors.New(errMsg) var ret map[string]interface{} redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name) @@ -165,9 +122,7 @@ func TestGetNodeBSdlgoFailure(t *testing.T) { func TestGetNodeBCellsListEnb(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) nb := entities.NodebInfo{} nb.ConnectionStatus = 1 nb.Ip = "localhost" @@ -197,9 +152,7 @@ func TestGetNodeBCellsListEnb(t *testing.T) { func TestGetNodeBCellsListGnb(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) nb := entities.NodebInfo{} nb.ConnectionStatus = 1 nb.Ip = "localhost" @@ -230,9 +183,7 @@ func TestGetNodeBCellsListGnb(t *testing.T) { func TestGetNodeBCellsListNodeUnmarshalFailure(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error ret := make(map[string]interface{}, 1) redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name) @@ -250,9 +201,7 @@ func TestGetNodeBCellsListNodeUnmarshalFailure(t *testing.T) { func TestGetNodeBCellsListNodeNotFoundFailure(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error var ret map[string]interface{} redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name) @@ -269,9 +218,7 @@ func TestGetNodeBCellsListNodeNotFoundFailure(t *testing.T) { func TestGetNodeBCellsListNotFoundFailureEnb(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) nb := entities.NodebInfo{} nb.ConnectionStatus = 1 nb.Ip = "localhost" @@ -296,9 +243,7 @@ func TestGetNodeBCellsListNotFoundFailureEnb(t *testing.T) { func TestGetNodeBCellsListNotFoundFailureGnb(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) nb := entities.NodebInfo{} nb.ConnectionStatus = 1 nb.Ip = "localhost" @@ -321,47 +266,8 @@ func TestGetNodeBCellsListNotFoundFailureGnb(t *testing.T) { assert.EqualValues(t, "#rNibReader.GetCellList - served cells not found. Responding node RAN name: name.", er.Error()) } -func TestCloseOnClosedPoolFailure(t *testing.T) { - readerPool = nil - instanceMock := initSdlInstanceMock(namespace, 1) - w1 := GetRNibReader() - _, err := w1.GetNodeb("") - if err == nil{ - t.Errorf("#rNibReader_test.TestCloseOnClosedPoolFailure - failed to validate key parameter") - } - readerPool.Put(w1) - available, created := readerPool.Stats() - assert.Equal(t, 1, available, "number of available objects in the readerPool should be 1") - assert.Equal(t, 1, created, "number of created objects in the readerPool should be 1") - var e error - instanceMock.On("Close").Return(e) - Close() - assert.Panics(t, func() { Close() }) -} - -func TestCloseFailure(t *testing.T) { - readerPool = nil - instanceMock := initSdlInstanceMock(namespace, 2) - w1 := GetRNibReader() - _, err := w1.GetNodeb("") - if err == nil{ - t.Errorf("#rNibReader_test.TestCloseFailure - failed to validate key parameter") - } - available, created := readerPool.Stats() - assert.Equal(t, 1, available, "number of available objects in the readerPool should be 2") - assert.Equal(t, 1, created, "number of created objects in the readerPool should be 1") - e := errors.New("expected error") - instanceMock.On("Close").Return(e) - Close() - available, created = readerPool.Stats() - assert.Equal(t, 0, available, "number of available objects in the readerPool should be 0") - assert.Equal(t, 0, created, "number of created objects in the readerPool should be 0") -} - func TestGetListGnbIdsUnmarshalFailure(t *testing.T) { - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{"data"}, e) ids, er := w.GetListGnbIds() @@ -374,9 +280,7 @@ func TestGetListGnbIdsUnmarshalFailure(t *testing.T) { func TestGetListGnbIdsSdlgoFailure(t *testing.T) { errMsg := "expected Sdlgo error" errMsgExpected := "expected Sdlgo error" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) e := errors.New(errMsg) var data []string sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return(data, e) @@ -388,10 +292,7 @@ func TestGetListGnbIdsSdlgoFailure(t *testing.T) { } func TestGetListNodesIdsGnbSdlgoFailure(t *testing.T) { - - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) name := "name" plmnId := "02f829" @@ -418,10 +319,7 @@ func TestGetListNodesIdsGnbSdlgoFailure(t *testing.T) { } func TestGetListNodesIdsEnbSdlgoFailure(t *testing.T) { - - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) name := "name" plmnId := "02f829" @@ -448,10 +346,7 @@ func TestGetListNodesIdsEnbSdlgoFailure(t *testing.T) { } func TestGetListNodesIdsSuccess(t *testing.T) { - - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var nilError error name := "name" @@ -490,9 +385,7 @@ func TestGetListNodesIdsSuccess(t *testing.T) { } func TestGetListEnbIdsUnmarshalFailure(t *testing.T) { - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{"data"}, e) ids, er := w.GetListEnbIds() @@ -506,9 +399,7 @@ func TestGetListEnbIdsOneId(t *testing.T) { name := "name" plmnId := "02f829" nbId := "4a952a0a" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}} var e error data, err := proto.Marshal(nbIdentity) @@ -525,9 +416,7 @@ func TestGetListEnbIdsOneId(t *testing.T) { } func TestGetListEnbIdsNoIds(t *testing.T) { - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{}, e) ids, er := w.GetListEnbIds() @@ -540,9 +429,7 @@ func TestGetListEnbIds(t *testing.T) { plmnId := 0x02f829 nbId := 0x4a952a0a listSize := 3 - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) idsData := make([]string, listSize) idsEntities := make([]*entities.NbIdentity, listSize) for i := 0; i < listSize; i++ { @@ -570,9 +457,7 @@ func TestGetListGnbIdsOneId(t *testing.T) { name := "name" plmnId := "02f829" nbId := "4a952a0a" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}} var e error data, err := proto.Marshal(nbIdentity) @@ -589,9 +474,7 @@ func TestGetListGnbIdsOneId(t *testing.T) { } func TestGetListGnbIdsNoIds(t *testing.T) { - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{}, e) ids, er := w.GetListGnbIds() @@ -604,9 +487,7 @@ func TestGetListGnbIds(t *testing.T) { plmnId := 0x02f829 nbId := 0x4a952a0a listSize := 3 - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) idsData := make([]string, listSize) idsEntities := make([]*entities.NbIdentity, listSize) for i := 0; i < listSize; i++ { @@ -633,9 +514,7 @@ func TestGetListGnbIds(t *testing.T) { func TestGetListEnbIdsSdlgoFailure(t *testing.T) { errMsg := "expected Sdlgo error" errMsgExpected := "expected Sdlgo error" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) e := errors.New(errMsg) var data []string sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return(data, e) @@ -647,9 +526,7 @@ func TestGetListEnbIdsSdlgoFailure(t *testing.T) { } func TestGetCountGnbListOneId(t *testing.T) { - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error sdlInstanceMock.On("GroupSize", entities.Node_GNB.String()).Return(1, e) count, er := w.GetCountGnbList() @@ -658,9 +535,7 @@ func TestGetCountGnbListOneId(t *testing.T) { } func TestGetCountGnbList(t *testing.T) { - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error sdlInstanceMock.On("GroupSize", entities.Node_GNB.String()).Return(3, e) count, er := w.GetCountGnbList() @@ -671,9 +546,7 @@ func TestGetCountGnbList(t *testing.T) { func TestGetCountGnbListSdlgoFailure(t *testing.T) { errMsg := "expected Sdlgo error" errMsgExpected := "expected Sdlgo error" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) e := errors.New(errMsg) var count int sdlInstanceMock.On("GroupSize", entities.Node_GNB.String()).Return(count, e) @@ -687,9 +560,7 @@ func TestGetCountGnbListSdlgoFailure(t *testing.T) { func TestGetCell(t *testing.T) { name := "name" var pci uint32 = 10 - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: &entities.ServedCellInfo{Pci: pci}}} cellData, err := proto.Marshal(&cellEntity) if err != nil { @@ -713,9 +584,7 @@ func TestGetCell(t *testing.T) { func TestGetCellNotFoundFailure(t *testing.T) { name := "name" var pci uint32 - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error var ret map[string]interface{} key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci) @@ -733,9 +602,7 @@ func TestGetCellNotFoundFailure(t *testing.T) { func TestGetCellUnmarshalFailure(t *testing.T) { name := "name" var pci uint32 - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error ret := make(map[string]interface{}, 1) key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci) @@ -756,9 +623,7 @@ func TestGetCellSdlgoFailure(t *testing.T) { var pci uint32 errMsg := "expected Sdlgo error" errMsgExpected := "expected Sdlgo error" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) e := errors.New(errMsg) var ret map[string]interface{} key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci) @@ -774,9 +639,7 @@ func TestGetCellSdlgoFailure(t *testing.T) { } func TestGetNodebById(t *testing.T) { - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) nb := entities.NodebInfo{NodeType: entities.Node_ENB} nb.ConnectionStatus = 1 nb.Ip = "localhost" @@ -812,9 +675,7 @@ func TestGetNodebById(t *testing.T) { func TestGetNodebByIdNotFoundFailureEnb(t *testing.T) { plmnId := "02f829" nbId := "4a952a0a" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId) if rNibErr != nil { @@ -833,9 +694,7 @@ func TestGetNodebByIdNotFoundFailureEnb(t *testing.T) { func TestGetNodebByIdNotFoundFailureGnb(t *testing.T) { plmnId := "02f829" nbId := "4a952a0a" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_GNB.String(), plmnId, nbId) if rNibErr != nil { @@ -854,9 +713,7 @@ func TestGetNodebByIdNotFoundFailureGnb(t *testing.T) { func TestGetNodeByIdUnmarshalFailure(t *testing.T) { plmnId := "02f829" nbId := "4a952a0a" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId) if rNibErr != nil { t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId) @@ -878,9 +735,7 @@ func TestGetNodeByIdSdlgoFailure(t *testing.T) { nbId := "4a952a0a" errMsg := "expected Sdlgo error" errMsgExpected := "expected Sdlgo error" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_GNB.String(), plmnId, nbId) if rNibErr != nil { t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId) @@ -899,9 +754,7 @@ func TestGetNodeByIdSdlgoFailure(t *testing.T) { func TestGetCellById(t *testing.T) { cellId := "aaaa" var pci uint32 = 10 - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: &entities.ServedCellInfo{Pci: pci}}} cellData, err := proto.Marshal(&cellEntity) if err != nil { @@ -924,9 +777,7 @@ func TestGetCellById(t *testing.T) { func TestGetCellByIdNotFoundFailureEnb(t *testing.T) { cellId := "bbbb" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error var ret map[string]interface{} key, rNibErr := common.ValidateAndBuildCellIdKey(cellId) @@ -943,9 +794,7 @@ func TestGetCellByIdNotFoundFailureEnb(t *testing.T) { func TestGetCellByIdNotFoundFailureGnb(t *testing.T) { cellId := "bbbb" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error var ret map[string]interface{} key, rNibErr := common.ValidateAndBuildNrCellIdKey(cellId) @@ -962,9 +811,7 @@ func TestGetCellByIdNotFoundFailureGnb(t *testing.T) { func TestGetCellByIdTypeValidationFailure(t *testing.T) { cellId := "dddd" - readerPool = nil - initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, _ := initSdlInstanceMock(namespace) cell, er := w.GetCellById(5, cellId) assert.NotNil(t, er) assert.Nil(t, cell) @@ -974,9 +821,7 @@ func TestGetCellByIdTypeValidationFailure(t *testing.T) { func TestGetCellByIdValidationFailureGnb(t *testing.T) { cellId := "" - readerPool = nil - initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, _ := initSdlInstanceMock(namespace) cell, er := w.GetCellById(entities.Cell_NR_CELL, cellId) assert.NotNil(t, er) assert.Nil(t, cell) @@ -986,9 +831,7 @@ func TestGetCellByIdValidationFailureGnb(t *testing.T) { func TestGetCellByIdValidationFailureEnb(t *testing.T) { cellId := "" - readerPool = nil - initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, _ := initSdlInstanceMock(namespace) cell, er := w.GetCellById(entities.Cell_LTE_CELL, cellId) assert.NotNil(t, er) assert.Nil(t, cell) @@ -998,9 +841,7 @@ func TestGetCellByIdValidationFailureEnb(t *testing.T) { func TestGetRanLoadInformation(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) loadInfo := generateRanLoadInformation() var e error data, err := proto.Marshal(loadInfo) @@ -1029,9 +870,7 @@ func TestGetRanLoadInformation(t *testing.T) { func TestGetRanLoadInformationValidationFailure(t *testing.T) { name := "" - readerPool = nil - initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, _ := initSdlInstanceMock(namespace) getNb, er := w.GetRanLoadInformation(name) assert.NotNil(t, er) assert.Nil(t, getNb) @@ -1041,9 +880,7 @@ func TestGetRanLoadInformationValidationFailure(t *testing.T) { func TestGetRanLoadInformationNotFoundFailure(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error var ret map[string]interface{} redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name) @@ -1060,9 +897,7 @@ func TestGetRanLoadInformationNotFoundFailure(t *testing.T) { func TestGetRanLoadInformationUnmarshalFailure(t *testing.T) { name := "name" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) var e error ret := make(map[string]interface{}, 1) redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name) @@ -1082,9 +917,7 @@ func TestGetRanLoadInformationSdlgoFailure(t *testing.T) { name := "name" errMsg := "expected Sdlgo error" errMsgExpected := "expected Sdlgo error" - readerPool = nil - sdlInstanceMock := initSdlInstanceMock(namespace, 1) - w := GetRNibReader() + w, sdlInstanceMock := initSdlInstanceMock(namespace) e := errors.New(errMsg) var ret map[string]interface{} redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name) @@ -1108,54 +941,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{{CellId: "789", CompHypothesis: "xxx"}}, - BenefitMetric:50, + 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 @@ -1322,4 +1155,4 @@ func generateRanLoadInformation() *entities.RanLoadInformation { // } // assert.NotNil(t, ranLoadInformation) // fmt.Printf("#rNibReader_test.TestGetRanLoadInformationInteg - GNB ID: %s\n", ranLoadInformation) -//} \ No newline at end of file +//}