Making Platform Static Routes configurable 30/2130/2
authorwahidw <abdulwahid.w@nokia.com>
Wed, 1 Jan 2020 04:28:41 +0000 (04:28 +0000)
committerwahidw <abdulwahid.w@nokia.com>
Thu, 2 Jan 2020 06:32:03 +0000 (06:32 +0000)
Multiple E2T instance Feature: Removed duplicate v1 field in API urls

Change-Id: If1f0c5935ba559561b00b82197bc4ee92cfbbe36
Signed-off-by: wahidw <abdulwahid.w@nokia.com>
Dockerfile
RELNOTES
api/routing_manager.yaml
container-tag.yaml
go.mod
pkg/rpe/rmr_test.go
pkg/rpe/rpe.go
pkg/rtmgr/rtmgr.go
pkg/rtmgr/types.go
pkg/sdl/sdl_test.go
pkg/stub/stub.go

index faec945..1dc624c 100644 (file)
@@ -26,9 +26,9 @@
 FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:3-u18.04-nng as rtmgrbuild
 
 # Install RMr shared library
-RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_1.10.2_amd64.deb/download.deb && dpkg -i rmr_1.10.2_amd64.deb && rm -rf rmr_1.10.2_amd64.deb
+RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_1.13.1_amd64.deb/download.deb && dpkg -i rmr_1.13.1_amd64.deb && rm -rf rmr_1.13.1_amd64.deb
 # Install RMr development header files
-RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_1.10.2_amd64.deb/download.deb && dpkg -i rmr-dev_1.10.2_amd64.deb && rm -rf rmr-dev_1.10.2_amd64.deb
+RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_1.13.1_amd64.deb/download.deb && dpkg -i rmr-dev_1.13.1_amd64.deb && rm -rf rmr-dev_1.13.1_amd64.deb
 
 ENV GOLANG_VERSION 1.12.1
 RUN wget --quiet https://dl.google.com/go/go$GOLANG_VERSION.linux-amd64.tar.gz \
@@ -81,7 +81,6 @@ COPY --from=rtmgrbuild /run_rtmgr.sh /
 COPY --from=rtmgrbuild /usr/local/include /usr/local/include
 COPY --from=rtmgrbuild /usr/local/lib /usr/local/lib
 RUN ldconfig
-
 RUN apt-get update && apt-get install -y iputils-ping net-tools curl tcpdump
 RUN mkdir /db && touch /db/rt.json && chmod 777 /db/rt.json
 RUN chmod 755 /run_rtmgr.sh
index f7946db..edaf372 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -1,3 +1,6 @@
+### v0.4.6
+* Static platform routes can be configured via configuration file
+
 ### v0.4.5
 * Multiple E2T instance Feature: Introduced APIs Delete E2T Instance, associate RANs to E2T and disassociate RANs from E2T Instance.
 
index c2dacfa..c8a742b 100644 (file)
@@ -177,7 +177,7 @@ paths:
           description: "Invalid data"
         201:
           description: "Xapp list received"
-  /handles/v1/e2t:
+  /handles/e2t:
     post:
       tags:
       - "handle"
@@ -226,7 +226,7 @@ paths:
           description: "Invalid data"
         201:
           description: "new e2t instance is considered and platform routes are established"
-  /handles/v1/associate-ran-to-e2t:
+  /handles/associate-ran-to-e2t:
     post:
       tags:
       - "handle"
@@ -251,7 +251,7 @@ paths:
           description: "Invalid data"
         201:
           description: "e2t ran mapping recieved, platform routes"
-  /handles/v1/dissociate-ran:
+  /handles/dissociate-ran:
     post:
       tags:
       - "handle"
index a89789a..94d6bc0 100644 (file)
@@ -2,4 +2,4 @@
 # By default this file is in the docker build directory,
 # but the location can configured in the JJB template.
 ---
-tag: 0.4.5
+tag: 0.4.6
diff --git a/go.mod b/go.mod
index 702d00c..e133c89 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -3,13 +3,13 @@ module routing-manager
 go 1.12.1
 
 require (
-       gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.0.20
+       gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.0.24
        nanomsg.org/go/mangos/v2 v2.0.5
 )
 
 replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.2.0
 
-replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.20
+replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.0.24
 
 replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.1
 
index da8da06..02f2608 100644 (file)
@@ -47,10 +47,13 @@ RmrPush.GeneratePolicies() method is tested for happy path case
 */
 func TestRmrPushGeneratePolicies(t *testing.T) {
        var rmrpush = RmrPush{}
-        var pcs rtmgr.RicComponents
+       var pcs rtmgr.RicComponents
        resetTestDataset(stub.ValidEndpoints)
-        stub.ValidPlatformComponents = nil
-        rtmgr.Subs =  *stub.ValidSubscriptions
+       stub.ValidPlatformComponents = nil
+       rtmgr.Subs = *stub.ValidSubscriptions
+       rtmgr.PrsCfg = stub.DummyRoutes
+       stub.E2map["E2instance1.com"] = stub.ValidE2TInstance
+       pcs = stub.ValidRicComponents
 
        rawrt := rmrpush.GeneratePolicies(rtmgr.Eps, &pcs)
        t.Log(rawrt)
@@ -60,17 +63,16 @@ func TestRmrPushGeneratePolicies(t *testing.T) {
 getEndpointByUuid: Pass empty and valid values
 */
 func TestRmrgetEndpointByUuid(t *testing.T) {
-        var ep *rtmgr.Endpoint
-        ep = getEndpointByUuid("")
-        t.Logf("getEndpointByUuid() return was correct, got: %v, want: %v.", ep, "<nil>")
-        ep = getEndpointByUuid("10.0.0.1:0")
+       var ep *rtmgr.Endpoint
+       ep = getEndpointByUuid("")
+       t.Logf("getEndpointByUuid() return was correct, got: %v, want: %v.", ep, "<nil>")
+       ep = getEndpointByUuid("10.0.0.1:0")
 }
 
 /*
 GetRpe Instance with empty and valid values
 */
 func TestRmrGetRpe(t *testing.T) {
-        _,_ = GetRpe("")
-        _,_ = GetRpe("rmrpush")
+       _, _ = GetRpe("")
+       _, _ = GetRpe("rmrpush")
 }
-
index 11440db..64b93fe 100644 (file)
@@ -74,16 +74,16 @@ func getEndpointByName(eps *rtmgr.Endpoints, name string) *rtmgr.Endpoint {
 }
 
 func getEndpointListByName(eps *rtmgr.Endpoints, name string) []rtmgr.Endpoint {
-        var eplist []rtmgr.Endpoint
+       var eplist []rtmgr.Endpoint
 
-        for _, ep := range *eps {
-                if ep.Name == name {
-                        xapp.Logger.Debug("name: %s", ep.Name)
-                        xapp.Logger.Debug("ep: %v", ep)
-                        eplist = append(eplist, *ep)
-                }
-        }
-        return eplist
+       for _, ep := range *eps {
+               if ep.Name == name {
+                       xapp.Logger.Debug("name: %s", ep.Name)
+                       xapp.Logger.Debug("ep: %v", ep)
+                       eplist = append(eplist, *ep)
+               }
+       }
+       return eplist
 }
 
 func getEndpointByUuid(uuid string) *rtmgr.Endpoint {
@@ -103,28 +103,28 @@ func (r *Rpe) addRoute(messageType string, tx *rtmgr.Endpoint, rx *rtmgr.Endpoin
        rxList := []rtmgr.EndpointList{}
 
        if tx == nil && rx == nil {
-               pc, _, _, ok := runtime.Caller(1)
-               details := runtime.FuncForPC(pc)
-               if ok && details != nil {
-                       xapp.Logger.Error("Route addition skipped: Either TX or RX endpoint not present. Caller function is %s", details.Name())
+               pc, _, _, ok := runtime.Caller(1)
+               details := runtime.FuncForPC(pc)
+               if ok && details != nil {
+                       xapp.Logger.Error("Route addition skipped: Either TX or RX endpoint not present. Caller function is %s", details.Name())
                }
        } else {
-               if (tx != nil) {
-                       txList = rtmgr.EndpointList{*tx}
-               }
-               if (rx != nil) {
-                       rxList = []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}}
-               }
-               messageId := rtmgr.MessageTypes[messageType]
-               route := rtmgr.RouteTableEntry{
-                       MessageType: messageId,
-                       TxList:      txList,
-                       RxGroups:    rxList,
-                       SubID:       subId,
-                       RouteType:   routeType}
-               *routeTable = append(*routeTable, route)
-//             xapp.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId)
-//             xapp.Logger.Trace("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx, rx, subId)
+               if tx != nil {
+                       txList = rtmgr.EndpointList{*tx}
+               }
+               if rx != nil {
+                       rxList = []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}}
+               }
+               messageId := strconv.Itoa(xapp.RICMessageTypes[messageType])
+               route := rtmgr.RouteTableEntry{
+                       MessageType: messageId,
+                       TxList:      txList,
+                       RxGroups:    rxList,
+                       SubID:       subId,
+                       RouteType:   routeType}
+               *routeTable = append(*routeTable, route)
+               //              xapp.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId)
+               //              xapp.Logger.Trace("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx, rx, subId)
        }
 }
 
@@ -132,42 +132,40 @@ func (r *Rpe) addRoute_rx_list(messageType string, tx *rtmgr.Endpoint, rx []rtmg
        txList := rtmgr.EndpointList{}
        rxList := []rtmgr.EndpointList{}
 
-       if (tx != nil) {
-               txList = rtmgr.EndpointList{*tx}
+       if tx != nil {
+               txList = rtmgr.EndpointList{*tx}
        }
 
-       if (rx != nil) {
-               rxList = []rtmgr.EndpointList{rx}
+       if rx != nil {
+               rxList = []rtmgr.EndpointList{rx}
        }
 
-       messageId := rtmgr.MessageTypes[messageType]
+       messageId := strconv.Itoa(xapp.RICMessageTypes[messageType])
        route := rtmgr.RouteTableEntry{
-               MessageType: messageId,
-               TxList:      txList,
-               RxGroups:    rxList,
-               SubID:       subId,
-               RouteType:   routeType}
+               MessageType: messageId,
+               TxList:      txList,
+               RxGroups:    rxList,
+               SubID:       subId,
+               RouteType:   routeType}
        *routeTable = append(*routeTable, route)
-//     xapp.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId)
-//     xapp.Logger.Trace("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx, rx, subId)
+       //      xapp.Logger.Debug("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx.Uuid, rx.Uuid, subId)
+       //      xapp.Logger.Trace("Route added: MessageTyp: %v, Tx: %v, Rx: %v, SubId: %v", messageId, tx, rx, subId)
 }
 
-
-
 func (r *Rpe) generateXappRoutes(xAppEp *rtmgr.Endpoint, e2TermEp *rtmgr.Endpoint, subManEp *rtmgr.Endpoint, routeTable *rtmgr.RouteTable) {
        xapp.Logger.Debug("rpe.generateXappRoutes invoked")
        xapp.Logger.Debug("Endpoint: %v, xAppType: %v", xAppEp.Name, xAppEp.XAppType)
        if xAppEp.XAppType != sbi.PlatformType && (len(xAppEp.TxMessages) > 0 || len(xAppEp.RxMessages) > 0) {
-               /// TODO --- 
+               /// TODO ---
                //xApp -> Subscription Manager
                r.addRoute("RIC_SUB_REQ", xAppEp, subManEp, routeTable, -1, "")
                r.addRoute("RIC_SUB_DEL_REQ", xAppEp, subManEp, routeTable, -1, "")
                //xApp -> E2 Termination
-//             r.addRoute("RIC_CONTROL_REQ", xAppEp, e2TermEp, routeTable, -1, "")
+               //              r.addRoute("RIC_CONTROL_REQ", xAppEp, e2TermEp, routeTable, -1, "")
                r.addRoute("RIC_CONTROL_REQ", xAppEp, nil, routeTable, -1, "%meid")
                //E2 Termination -> xApp
-///            r.addRoute("RIC_CONTROL_ACK", e2TermEp, xAppEp, routeTable, -1, "")
-///            r.addRoute("RIC_CONTROL_FAILURE", e2TermEp, xAppEp, routeTable, -1, "")
+               ///             r.addRoute("RIC_CONTROL_ACK", e2TermEp, xAppEp, routeTable, -1, "")
+               ///             r.addRoute("RIC_CONTROL_FAILURE", e2TermEp, xAppEp, routeTable, -1, "")
                r.addRoute("RIC_CONTROL_ACK", nil, xAppEp, routeTable, -1, "")
                r.addRoute("RIC_CONTROL_FAILURE", nil, xAppEp, routeTable, -1, "")
        }
@@ -191,7 +189,7 @@ func (r *Rpe) generateSubscriptionRoutes(selectedxAppEp *rtmgr.Endpoint, e2TermE
                xAppEp := getEndpointByUuid(xAppUuid)
                if xAppEp.Uuid == selectedxAppEp.Uuid {
                        xapp.Logger.Debug("xApp UUID is matched for selected xApp.UUID: %v and xApp.Name: %v", selectedxAppEp.Uuid, selectedxAppEp.Name)
-/// TODO
+                       /// TODO
                        //Subscription Manager -> xApp
                        r.addRoute("RIC_SUB_RESP", subManEp, xAppEp, routeTable, subscription.SubID, "")
                        r.addRoute("RIC_SUB_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID, "")
@@ -209,68 +207,39 @@ func (r *Rpe) generatePlatformRoutes(e2TermEp []rtmgr.Endpoint, subManEp *rtmgr.
        xapp.Logger.Debug("rpe.generatePlatformRoutes invoked")
        //Platform Routes --- Subscription Routes
        //Subscription Manager -> E2 Termination
-       r.addRoute("RIC_SUB_REQ", subManEp, nil, routeTable, -1, "%meid")
-       r.addRoute("RIC_SUB_DEL_REQ", subManEp, nil, routeTable, -1, "%meid")
-       //E2 Termination -> Subscription Manager
-        r.addRoute("RIC_SUB_RESP", nil, subManEp, routeTable, -1, "")
-        r.addRoute("RIC_SUB_DEL_RESP", nil, subManEp, routeTable, -1, "")
-        r.addRoute("RIC_SUB_FAILURE", nil, subManEp, routeTable, -1, "")
-        r.addRoute("RIC_SUB_DEL_FAILURE", nil, subManEp, routeTable, -1, "")
-
-       //TODO: UE Man Routes removed (since it is not existing)
-       //UE Manager -> Subscription Manager
-       //r.addRoute("RIC_SUB_REQ", ueManEp, subManEp, routeTable)
-       //r.addRoute("RIC_SUB_DEL_REQ", ueManEp, subManEp, routeTable)
-       ////UE Manager -> E2 Termination
-       //r.addRoute("RIC_CONTROL_REQ", ueManEp, e2TermEp, routeTable)
-
-       //Platform Routes --- X2 Routes
-       //E2 Manager -> E2 Termination
-        r.addRoute("RIC_X2_SETUP_REQ", e2ManEp, nil, routeTable, -1, "%meid")
-        r.addRoute("RIC_X2_RESET_REQ", e2ManEp, nil, routeTable, -1, "%meid")
-        r.addRoute("RIC_X2_RESET_RESP", e2ManEp, nil, routeTable, -1, "%meid")
-        r.addRoute("RIC_ENDC_X2_SETUP_REQ", e2ManEp, nil, routeTable, -1, "%meid")
-        r.addRoute("RIC_ENB_CONF_UPDATE_ACK", e2ManEp, nil, routeTable, -1, "%meid")
-        r.addRoute("RIC_ENB_CONF_UPDATE_FAILURE", e2ManEp, nil, routeTable, -1, "%meid")
-        r.addRoute("RIC_ENDC_CONF_UPDATE_ACK", e2ManEp, nil, routeTable, -1, "%meid")
-        r.addRoute("RIC_ENDC_CONF_UPDATE_FAILURE", e2ManEp, nil, routeTable, -1, "%meid")
-
-        if len(e2TermEp) > 0 {
-                r.addRoute_rx_list("RIC_SCTP_CLEAR_ALL", e2ManEp, e2TermEp, routeTable, -1, "")
-                r.addRoute_rx_list("E2_TERM_KEEP_ALIVE_REQ", e2ManEp, e2TermEp, routeTable, -1, "")
-        }
-
-       //E2 Termination -> E2 Manager
-        r.addRoute("E2_TERM_INIT", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_X2_SETUP_RESP", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_X2_SETUP_FAILURE", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_X2_RESET_REQ", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_X2_RESET_RESP", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_ENDC_X2_SETUP_RESP", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_ENDC_X2_SETUP_FAILURE", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_ENDC_CONF_UPDATE", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_SCTP_CONNECTION_FAILURE", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_ERROR_INDICATION", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_ENB_CONF_UPDATE", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("RIC_ENB_LOAD_INFORMATION", nil, e2ManEp, routeTable, -1, "")
-        r.addRoute("E2_TERM_KEEP_ALIVE_RESP", nil, e2ManEp, routeTable, -1, "")
-
-
-
-       //E2 Manager -> Resource Status Manager
-        r.addRoute("RAN_CONNECTED", e2ManEp, rsmEp, routeTable, -1, "")
-        r.addRoute("RAN_RESTARTED", e2ManEp, rsmEp, routeTable, -1, "")
-        r.addRoute("RAN_RECONFIGURED", e2ManEp, rsmEp, routeTable, -1, "")
-
-       //Resource Status Manager -> E2 Termination
-       r.addRoute("RIC_RES_STATUS_REQ", rsmEp, nil, routeTable, -1, "%meid")
-       //E2 Termination -> Resource Status Manager
-        r.addRoute("RIC_RES_STATUS_RESP", nil, rsmEp, routeTable, -1, "")
-        r.addRoute("RIC_RES_STATUS_FAILURE", nil, rsmEp, routeTable, -1, "")
-
-       //ACxapp -> A1 Mediator
-       r.addRoute("A1_POLICY_QUERY", nil, a1mediatorEp, routeTable, -1, "")
-       r.addRoute("A1_POLICY_RESPONSE", nil, a1mediatorEp, routeTable, -1, "")
+       for _, routes := range *rtmgr.PrsCfg {
+               var sendEp *rtmgr.Endpoint
+               var Ep *rtmgr.Endpoint
+               switch routes.SenderEndPoint {
+               case "SUBMAN":
+                       sendEp = subManEp
+               case "E2MAN":
+                       sendEp = e2ManEp
+               case "UEMAN":
+                       sendEp = ueManEp
+               case "RSM":
+                       sendEp = rsmEp
+               case "A1MEDIATOR":
+                       sendEp = a1mediatorEp
+               }
+               switch routes.EndPoint {
+               case "SUBMAN":
+                       Ep = subManEp
+               case "E2MAN":
+                       Ep = e2ManEp
+               case "UEMAN":
+                       Ep = ueManEp
+               case "RSM":
+                       Ep = rsmEp
+               case "A1MEDIATOR":
+                       Ep = a1mediatorEp
+               }
+               if routes.EndPoint == "E2TERMINST" && len(e2TermEp) > 0 {
+                       r.addRoute_rx_list(routes.MessageType, sendEp, e2TermEp, routeTable, routes.SubscriptionId, routes.Meid)
+                       continue
+               }
+               r.addRoute(routes.MessageType, sendEp, Ep, routeTable, routes.SubscriptionId, routes.Meid)
+       }
 }
 
 func (r *Rpe) generateRouteTable(endPointList rtmgr.Endpoints) *rtmgr.RouteTable {
index f82276b..06d0f15 100644 (file)
@@ -121,11 +121,13 @@ var (
 
        Eps  Endpoints
        Subs SubscriptionList
+       PrsCfg  *PlatformRoutes
 )
 
 func GetPlatformComponents(configfile string) (*PlatformComponents, error) {
        xapp.Logger.Debug("Invoked rtmgr.GetPlatformComponents(" + configfile + ")")
        var rcfg ConfigRtmgr
+       var rtroutes RtmgrRoutes
        yamlFile, err := os.Open(configfile)
        if err != nil {
                return nil, errors.New("cannot open the file due to: " + err.Error())
@@ -139,6 +141,12 @@ func GetPlatformComponents(configfile string) (*PlatformComponents, error) {
        if err != nil {
                return nil, errors.New("cannot read the file due to: " + err.Error())
        }
+       err = json.Unmarshal(jsonByteValue,&rtroutes)
+        if err != nil {
+               return nil, errors.New("cannot parse data due to: " + err.Error())
+        }
+        PrsCfg = &(rtroutes.Prs)
+
        err = json.Unmarshal(jsonByteValue, &rcfg)
        if err != nil {
                return nil, errors.New("cannot parse data due to: " + err.Error())
index 783f49d..9378656 100644 (file)
@@ -107,3 +107,17 @@ type Subscription struct {
        Fqdn  string
        Port  uint16
 }
+
+type PlatformRoutes []struct {
+       MessageType     string `json:"messagetype"`
+       SenderEndPoint  string `json:"senderendpoint"`
+       SubscriptionId  int32  `json:"subscriptionid"`
+       EndPoint        string `json:"endpoint"`
+       Meid            string `json:"meid"`
+}
+
+type RtmgrRoutes struct {
+       Prs PlatformRoutes      `json:"PlatformRoutes"`
+}
+
+
index 06bc852..ff3bf50 100644 (file)
@@ -29,6 +29,9 @@ package sdl
 
 import (
        "routing-manager/pkg/stub"
+       "github.com/go-openapi/swag"
+       "routing-manager/pkg/models"
+       "routing-manager/pkg/rtmgr"
        "testing"
 )
 
@@ -99,3 +102,69 @@ func TestWriteNewE2TInstance(t *testing.T) {
        file.WriteNewE2TInstance("ut.rt", &stub.ValidE2TInstance)
        t.Log(err)
 }
+
+/*
+WriteAssRANToE2TInstance
+*/
+func TestWriteAssRANToE2TInstance(t *testing.T) {
+       var err error
+        var file = File{}
+       // File is not provided as argument
+       file.WriteAssRANToE2TInstance("",stub.Rane2tmap)
+       t.Log(err)
+       file.WriteNewE2TInstance("ut.rt", &stub.ValidE2TInstance)
+       file.WriteAssRANToE2TInstance("ut.rt",stub.Rane2tmap)
+       t.Log(err)
+}
+
+/*
+WriteDisAssRANFromE2TInstance 
+*/
+func TestWriteDisAssRANFromE2TInstance(t *testing.T) {
+       var err error
+        var file = File{}
+       // File is not provided as argument
+       file.WriteDisAssRANFromE2TInstance("",stub.Rane2tmap)
+       t.Log(err)
+       //RAN list is empty
+       file.WriteNewE2TInstance("ut.rt", &stub.ValidE2TInstance)
+        file.WriteAssRANToE2TInstance("ut.rt",stub.Rane2tmap)
+       file.WriteDisAssRANFromE2TInstance("ut.rt",stub.Rane2tmaponlyE2t)
+       //RAN list is present
+       file.WriteNewE2TInstance("ut.rt", &stub.ValidE2TInstance)
+        file.WriteAssRANToE2TInstance("ut.rt",stub.Rane2tmap)
+       file.WriteDisAssRANFromE2TInstance("ut.rt",stub.Rane2tmap)
+       t.Log(err)
+}
+
+/*
+WriteDeleteE2TInstance E2TInst *models.E2tDeleteData) error
+*/
+func TestWriteDeleteE2TInstance(t *testing.T) {
+       var err error
+        var file = File{}
+       e2deldata := &models.E2tDeleteData{}
+       // File is not provided as argument
+       file.WriteDeleteE2TInstance("",e2deldata)
+       //Delete E2t Instance,associate new rans and dissociate some rans
+       file.WriteNewE2TInstance("ut.rt", &rtmgr.E2TInstance{
+               Name:    "E2Tinstance1",
+               Fqdn:    "10.10.10.10:100",
+               Ranlist: []string{"1", "2"},
+                       },
+               )
+       file.WriteNewE2TInstance("ut.rt", &rtmgr.E2TInstance{
+               Name:    "E2Tinstance2",
+               Fqdn:    "11.11.11.11:100",
+               Ranlist: []string{"3", "4"},
+                       },
+               )
+       file.WriteDeleteE2TInstance("ut.rt",&models.E2tDeleteData{
+               E2TAddress: swag.String("10.10.10.10:100"),
+               RanAssocList: models.RanE2tMap{ 
+                               {E2TAddress: swag.String("11.11.11.11:100"),RanNamelist: []string{"5","6"}},
+                               {E2TAddress: swag.String("doesntexist"),RanNamelist: []string{}}, },
+                       })
+       t.Log(err)
+
+}
index 40df44a..97730a7 100644 (file)
 
 package stub
 
-import "routing-manager/pkg/rtmgr"
+import (
+       "routing-manager/pkg/rtmgr"
+       "routing-manager/pkg/models"
+       "github.com/go-openapi/swag"
+)
+
 
 var ValidXApps = &[]rtmgr.XApp{
        {Name: "app1", Status: "", Version: "", Instances: []rtmgr.XAppInstance{{Name: "E2TERM", Status: "unknown", Ip: "10.0.0.1", Port: 0, TxMessages: []string{"HandoverPreparation", "HandoverCancel"}, RxMessages: []string{"HandoverPreparation", "HandoverCancel"}}}},
@@ -60,6 +65,7 @@ var ValidE2TInstance = rtmgr.E2TInstance{
 
 var E2map = make(map[string]rtmgr.E2TInstance)
 
+
 var ValidRicComponents = rtmgr.RicComponents{
        XApps: *ValidXApps, Pcs: *ValidPlatformComponents, E2Ts: E2map,
 }
@@ -72,3 +78,23 @@ var ValidSubscriptions = &[]rtmgr.Subscription{
        {SubID: 1236, Fqdn: "10.1.1.1", Port: 0},
        {SubID: 1237, Fqdn: "10.2.2.1", Port: 0},
 }
+
+var DummyRoutes = &rtmgr.PlatformRoutes {
+       {MessageType: "12000",SenderEndPoint: "SUBMAN",SubscriptionId: 123,EndPoint: "UEMAN", Meid: ""},
+        {MessageType: "12001",SenderEndPoint: "RSM",SubscriptionId: 123,EndPoint: "A1MEDIATOR", Meid: ""},
+        {MessageType: "12002",SenderEndPoint: "E2MAN",SubscriptionId: 123,EndPoint: "E2TERMINST", Meid: ""},
+        {MessageType: "12003",SenderEndPoint: "E2TERMINST",SubscriptionId: 123,EndPoint: "E2MAN", Meid: ""},
+        {MessageType: "12004",SenderEndPoint: "A1MEDIATOR",SubscriptionId: 123,EndPoint: "RSM", Meid: ""},
+        {MessageType: "12005",SenderEndPoint: "UEMAN",SubscriptionId: 123,EndPoint: "SUBMAN", Meid: ""},
+}
+
+var Rane2tmap = models.RanE2tMap{
+        {E2TAddress: swag.String("10.10.10.10:100"),RanNamelist: []string{"1","2"}},
+        {E2TAddress: swag.String("11.11.11.11:101"),RanNamelist: []string{"3","4"}},
+        {E2TAddress: swag.String("12.12.12.12:101"),RanNamelist: []string{}},
+}
+
+var Rane2tmaponlyE2t = models.RanE2tMap{
+        {E2TAddress: swag.String("10.10.10.10:100"),RanNamelist: []string{}},
+}
+