2 // Copyright 2023 Nokia
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
16 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
17 // platform project (RICP).
28 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
30 "github.com/stretchr/testify/assert"
32 "github.com/stretchr/testify/mock"
36 serviceUpdateRANName1 = "gnb:TestRan1"
37 E2tAddress = "10.10.2.15:9800"
41 func initRicServiceUpdateManagerTest(t *testing.T) (*logger.Logger,*mocks.RnibReaderMock, *mocks.RnibWriterMock,services.RNibDataService, *configuration.Configuration, *RicServiceUpdateManager) {
42 logger := tests.InitLog(t)
44 config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
45 readerMock := &mocks.RnibReaderMock{}
46 writerMock := &mocks.RnibWriterMock{}
47 rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock)
48 RicServiceUpdateManager := NewRicServiceUpdateManager(logger, rnibDataService)
49 return logger, readerMock, writerMock, rnibDataService, config, RicServiceUpdateManager
51 func TestUpdateRevertRanFunctions(t *testing.T) {
53 _,readerMock, writerMock, _, _, RicServiceUpdateManager := initRicServiceUpdateManagerTest(t)
55 nodebInfo := &entities.NodebInfo{
57 NodeType: entities.Node_GNB,
58 Configuration: &entities.NodebInfo_Gnb{Gnb: &entities.Gnb{}},
60 gnb := nodebInfo.GetGnb()
61 gnb.RanFunctions = []*entities.RanFunction{{RanFunctionId: 2, RanFunctionRevision: 2}}
62 readerMock.On("GetNodeb", InvName).Return(nodebInfo, nil)
63 writerMock.On("UpdateNodebInfoAndPublish", mock.Anything).Return(nil)
64 err := RicServiceUpdateManager.StoreExistingRanFunctions(ranName)
66 err = RicServiceUpdateManager.RevertRanFunctions(ranName)
68 writerMock.AssertExpectations(t)
69 readerMock.AssertExpectations(t)
70 readerMock.AssertCalled(t, "GetNodeb", InvName)