# The Jenkins job requires a tag to build the Docker image.
# Global-JJB script assumes this file is in the repo root.
---
-tag: 5.4.11
+tag: 5.4.12
UpdateGnb(writer http.ResponseWriter, r *http.Request)
UpdateEnb(writer http.ResponseWriter, r *http.Request)
GetNodebIdList(writer http.ResponseWriter, r *http.Request)
+ GetNodebId(writer http.ResponseWriter, r *http.Request)
SetGeneralConfiguration(writer http.ResponseWriter, r *http.Request)
AddEnb(writer http.ResponseWriter, r *http.Request)
DeleteEnb(writer http.ResponseWriter, r *http.Request)
c.handleRequest(writer, &r.Header, httpmsghandlerprovider.GetNodebIdListRequest, nil, false, http.StatusOK)
}
+func (c *NodebController) GetNodebId(writer http.ResponseWriter, r *http.Request) {
+ c.logger.Infof("[Client -> E2 Manager] #NodebController.GetNodebId - request: %v", c.prettifyRequest(r))
+ vars := mux.Vars(r)
+ ranName := vars["ranName"]
+ request := models.GetNodebIdRequest{RanName: ranName}
+
+ c.handleRequest(writer, &r.Header, httpmsghandlerprovider.GetNodebIdRequest, request, false, http.StatusOK)
+}
+
func (c *NodebController) GetNodeb(writer http.ResponseWriter, r *http.Request) {
c.logger.Infof("[Client -> E2 Manager] #NodebController.GetNodeb - request: %v", c.prettifyRequest(r))
vars := mux.Vars(r)
return
}
- c.handleRequest(writer, &r.Header, httpmsghandlerprovider.HealthCheckRequest, request, true, http.StatusNoContent)
+ c.handleRequest(writer, &r.Header, httpmsghandlerprovider.HealthCheckRequest, request, true, http.StatusAccepted)
}
func (c *NodebController) extractRequestBodyToProto(r *http.Request, pb proto.Message, writer http.ResponseWriter) bool {
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+//
+// 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.
+//
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
+package httpmsghandlers
+
+import (
+ "e2mgr/logger"
+ "e2mgr/managers"
+ "e2mgr/models"
+)
+
+type GetNodebIdRequestHandler struct {
+ logger *logger.Logger
+ ranListManager managers.RanListManager
+}
+
+func NewGetNodebIdRequestHandler(logger *logger.Logger, ranListManager managers.RanListManager) *GetNodebIdRequestHandler {
+ return &GetNodebIdRequestHandler{
+ logger: logger,
+ ranListManager: ranListManager,
+ }
+}
+
+func (h *GetNodebIdRequestHandler) Handle(request models.Request) (models.IResponse, error) {
+ getNodebIdRequest := request.(models.GetNodebIdRequest)
+ ranName := getNodebIdRequest.RanName
+
+ nodebId, err := h.ranListManager.GetNbIdentity(ranName)
+ if err != nil {
+ return nil, err
+ }
+
+ return models.NewNodebIdResponse(nodebId), nil
+}
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+//
+// 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.
+//
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
+package httpmsghandlers
+
+import (
+ "e2mgr/mocks"
+ "e2mgr/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/stretchr/testify/assert"
+ "e2mgr/e2managererrors"
+ "testing"
+)
+
+func setupGetNodebIdRequestHandlerTest(t *testing.T) (*GetNodebIdRequestHandler, *mocks.RanListManagerMock) {
+ log := initLog(t)
+ ranListManagerMock := &mocks.RanListManagerMock{}
+
+ handler := NewGetNodebIdRequestHandler(log, ranListManagerMock)
+ return handler, ranListManagerMock
+}
+
+func TestHandleGetNodebIdSuccess(t *testing.T) {
+ handler, ranListManagerMock := setupGetNodebIdRequestHandlerTest(t)
+ nbIdentity := &entities.NbIdentity{
+ InventoryName: "test",
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ HealthCheckTimestampSent: 12345678,
+ HealthCheckTimestampReceived: 12346548,
+ }
+ ranListManagerMock.On("GetNbIdentity",nbIdentity.InventoryName).Return(nbIdentity, nil)
+ response, err := handler.Handle(models.GetNodebIdRequest{RanName: nbIdentity.InventoryName})
+
+ assert.Nil(t, err)
+ assert.NotNil(t, response)
+ assert.IsType(t, &models.NodebIdResponse{}, response)
+}
+
+func TestHandleGetNodebIdNotFoundFailure(t *testing.T) {
+ handler, ranListManagerMock := setupGetNodebIdRequestHandlerTest(t)
+ nbIdentity := &entities.NbIdentity{
+ InventoryName: "test",
+ }
+
+ ranListManagerMock.On("GetNbIdentity",nbIdentity.InventoryName).Return(nbIdentity, e2managererrors.NewResourceNotFoundError())
+ _, err := handler.Handle(models.GetNodebIdRequest{RanName: nbIdentity.InventoryName})
+
+ assert.NotNil(t, err)
+ assert.IsType(t, &e2managererrors.ResourceNotFoundError{}, err)
+}
\ No newline at end of file
)
var(
+ healthCheckSuccessResponse = "Request Accepted"
healthCheckEmptyTagsToReplaceToSelfClosingTags = []string{"reject", "ignore", "protocolIEs", "procedureCode"}
)
h.logger.Infof("#HealthcheckRequest.Handle - HealthcheckTimeStampSent Update completed to RedisDB")
- return nil, nil
+ return models.NewHealthCheckSuccessResponse(healthCheckSuccessResponse), nil
}
func (h *HealthCheckRequestHandler) sendRICServiceQuery(nodebInfo *entities.NodebInfo) error {
ranListManagerMock.On("UpdateHealthcheckTimeStampSent",nb1.RanName).Return(oldnbIdentity, newnbIdentity)
ranListManagerMock.On("UpdateNbIdentities",nb1.NodeType, []*entities.NbIdentity{oldnbIdentity}, []*entities.NbIdentity{newnbIdentity}).Return(nil)
- _, err := handler.Handle(models.HealthCheckRequest{ranNames})
+ resp, err := handler.Handle(models.HealthCheckRequest{ranNames})
+ assert.IsType(t, &models.HealthCheckSuccessResponse{}, resp)
assert.Nil(t, err)
readerMock.AssertExpectations(t)
}
nb2 := &entities.NodebInfo{RanName: "RanName_2", ConnectionStatus: entities.ConnectionStatus_DISCONNECTED}
readerMock.On("GetNodeb", "RanName_2").Return(nb2, nil)
- _, err := handler.Handle(models.HealthCheckRequest{[]string{}})
+ resp, err := handler.Handle(models.HealthCheckRequest{[]string{}})
assert.Nil(t, err)
+ assert.IsType(t, &models.HealthCheckSuccessResponse{}, resp)
}
rr := r.PathPrefix("/nodeb").Subrouter()
rr.HandleFunc("/states", nodebController.GetNodebIdList).Methods(http.MethodGet)
+ rr.HandleFunc("/states/{ranName}", nodebController.GetNodebId).Methods(http.MethodGet)
rr.HandleFunc("/{ranName}", nodebController.GetNodeb).Methods(http.MethodGet)
rr.HandleFunc("/enb", nodebController.AddEnb).Methods(http.MethodPost)
rr.HandleFunc("/enb/{ranName}", nodebController.DeleteEnb).Methods(http.MethodDelete)
nodebControllerMock.On("Shutdown").Return(nil)
nodebControllerMock.On("GetNodeb").Return(nil)
nodebControllerMock.On("GetNodebIdList").Return(nil)
+ nodebControllerMock.On("GetNodebId").Return(nil)
nodebControllerMock.On("SetGeneralConfiguration").Return(nil)
nodebControllerMock.On("DeleteEnb").Return(nil)
nodebControllerMock.On("AddEnb").Return(nil)
return router, rootControllerMock, nodebControllerMock, e2tControllerMock
}
-func TestRouteGetNodebIds(t *testing.T) {
+func TestRouteGetNodebIdList(t *testing.T) {
router, _, nodebControllerMock, _ := setupRouterAndMocks()
req, err := http.NewRequest("GET", "/v1/nodeb/states", nil)
nodebControllerMock.AssertNumberOfCalls(t, "GetNodebIdList", 1)
}
+func TestRouteGetNodebId(t *testing.T) {
+ router, _, nodebControllerMock, _ := setupRouterAndMocks()
+
+ req, err := http.NewRequest("GET", "/v1/nodeb/states/ran1", nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rr := httptest.NewRecorder()
+ router.ServeHTTP(rr, req)
+
+ assert.Equal(t, http.StatusOK, rr.Code, "handler returned wrong status code")
+ nodebControllerMock.AssertNumberOfCalls(t, "GetNodebId", 1)
+}
+
func TestRouteGetNodebRanName(t *testing.T) {
router, _, nodebControllerMock, _ := setupRouterAndMocks()
rr := httptest.NewRecorder()
router.ServeHTTP(rr, req)
+ assert.Equal(t, http.StatusAccepted, rr.Code, "handler returned wrong status code")
nodebControllerMock.AssertNumberOfCalls(t, "HealthCheckRequest", 1)
}
UpdateNbIdentityConnectionStatus(nodeType entities.Node_Type, ranName string, connectionStatus entities.ConnectionStatus) error
RemoveNbIdentity(nodeType entities.Node_Type, ranName string) error
GetNbIdentityList() []*entities.NbIdentity
+ GetNbIdentity(ranName string) (*entities.NbIdentity, error)
UpdateHealthcheckTimeStampReceived(oldRRanName string) (*entities.NbIdentity, *entities.NbIdentity)
UpdateHealthcheckTimeStampSent(oldRRanName string) (*entities.NbIdentity, *entities.NbIdentity)
UpdateNbIdentities(nodeType entities.Node_Type, oldNbIdentities []*entities.NbIdentity, newNbIdentities []*entities.NbIdentity) error
return nbIds
}
+func (m *ranListManagerInstance) GetNbIdentity(ranName string) (*entities.NbIdentity, error) {
+ nbIdentity, ok := m.nbIdentityMap[ranName]
+ if !ok {
+ m.logger.Infof("#ranListManagerInstance.GetNbIdentity - RAN name: %s - nodeb identity not found", ranName)
+ return nil , e2managererrors.NewResourceNotFoundError()
+ }
+
+ m.logger.Infof("#ranListManagerInstance.GetNbIdentity - RAN name: %s - nodeb identity returned", ranName)
+
+ return nbIdentity, nil
+}
+
func (m *ranListManagerInstance) UpdateHealthcheckTimeStampSent(oldRRanName string) (*entities.NbIdentity, *entities.NbIdentity){
currentTimeStamp := time.Now().UnixNano()
oldNbIdentity := m.nbIdentityMap[oldRRanName]
c.Called()
}
+func (c *NodebControllerMock) GetNodebId(writer http.ResponseWriter, r *http.Request) {
+ writer.Header().Set("Content-Type", "application/json")
+ writer.WriteHeader(http.StatusOK)
+
+ vars := mux.Vars(r)
+ ranName := vars["ranName"]
+
+ writer.Write([]byte(ranName))
+ c.Called()
+}
+
func (c *NodebControllerMock) Shutdown(writer http.ResponseWriter, r *http.Request) {
c.Called()
}
func (c *NodebControllerMock) HealthCheckRequest(writer http.ResponseWriter, r *http.Request) {
writer.Header().Set("Content-Type", "application/json")
- writer.WriteHeader(http.StatusOK)
+ writer.WriteHeader(http.StatusAccepted)
c.Called()
}
return args.Get(0).([]*entities.NbIdentity)
}
+func (m *RanListManagerMock) GetNbIdentity(ranName string) (*entities.NbIdentity, error) {
+ args := m.Called(ranName)
+ return args.Get(0).(*entities.NbIdentity), args.Error(1)
+}
+
func (m *RanListManagerMock) UpdateHealthcheckTimeStampSent(oldRRanName string) (*entities.NbIdentity, *entities.NbIdentity){
args := m.Called(oldRRanName)
return args.Get(0).(*entities.NbIdentity), args.Get(1).(*entities.NbIdentity)
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+//
+// 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.
+//
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
+package models
+
+type GetNodebIdRequest struct {
+ RanName string
+}
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+//
+// 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.
+//
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
+package models
+
+import (
+ "e2mgr/e2managererrors"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/golang/protobuf/jsonpb"
+)
+
+type NodebIdResponse struct {
+ nbIdentity *entities.NbIdentity
+}
+
+func NewNodebIdResponse(nbIdentity *entities.NbIdentity) *NodebIdResponse {
+ return &NodebIdResponse{
+ nbIdentity: nbIdentity,
+ }
+}
+
+func (response *NodebIdResponse) Marshal() ([]byte, error) {
+ m := jsonpb.Marshaler{}
+ result, err := m.MarshalToString(response.nbIdentity)
+
+ if err != nil {
+ return nil, e2managererrors.NewInternalError()
+ }
+
+ return []byte(result), nil
+}
+
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+//
+// 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.
+//
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
+package models
+
+import (
+ "e2mgr/e2managererrors"
+ "encoding/json"
+)
+
+type HealthCheckSuccessResponse struct {
+ Message string `json:"message"`
+}
+
+func NewHealthCheckSuccessResponse(message string) *HealthCheckSuccessResponse {
+ return &HealthCheckSuccessResponse{
+ Message: message,
+ }
+}
+
+func (response HealthCheckSuccessResponse) Marshal() ([]byte, error) {
+
+ data, err := json.Marshal(response)
+
+ if err != nil {
+ return nil, e2managererrors.NewInternalError()
+ }
+
+ return data, nil
+
+}
ResetRequest IncomingRequest = "Reset"
GetNodebRequest IncomingRequest = "GetNodebRequest"
GetNodebIdListRequest IncomingRequest = "GetNodebIdListRequest"
+ GetNodebIdRequest IncomingRequest = "GetNodebIdRequest"
GetE2TInstancesRequest IncomingRequest = "GetE2TInstancesRequest"
UpdateGnbRequest IncomingRequest = "UpdateGnbRequest"
UpdateEnbRequest IncomingRequest = "UpdateEnbRequest"
SetGeneralConfigurationRequest: httpmsghandlers.NewSetGeneralConfigurationHandler(logger, rNibDataService),
GetNodebRequest: httpmsghandlers.NewGetNodebRequestHandler(logger, rNibDataService),
GetNodebIdListRequest: httpmsghandlers.NewGetNodebIdListRequestHandler(logger, rNibDataService, ranListManager),
+ GetNodebIdRequest: httpmsghandlers.NewGetNodebIdRequestHandler(logger, ranListManager),
GetE2TInstancesRequest: httpmsghandlers.NewGetE2TInstancesRequestHandler(logger, e2tInstancesManager),
UpdateGnbRequest: httpmsghandlers.NewUpdateNodebRequestHandler(logger, rNibDataService, updateGnbManager),
UpdateEnbRequest: httpmsghandlers.NewUpdateNodebRequestHandler(logger, rNibDataService, updateEnbManager),
assert.True(t, ok)
}
+func TestGetNodebIdRequestHandler(t *testing.T) {
+ provider := setupTest(t)
+ handler, err := provider.GetHandler(GetNodebIdRequest)
+
+ assert.NotNil(t, provider)
+ assert.Nil(t, err)
+
+ _, ok := handler.(*httpmsghandlers.GetNodebIdRequestHandler)
+
+ assert.True(t, ok)
+}
+
func TestSetGeneralConfigurationHandler(t *testing.T) {
provider := setupTest(t)
handler, err := provider.GetHandler(SetGeneralConfigurationRequest)