Taking xapp-frame v0.8.2 and the adaptation for subscription query 78/6178/3
authorwahidw <abdulwahid.w@nokia.com>
Mon, 31 May 2021 16:00:25 +0000 (16:00 +0000)
committerwahidw <abdulwahid.w@nokia.com>
Mon, 31 May 2021 17:28:41 +0000 (17:28 +0000)
Signed-off-by: wahidw <abdulwahid.w@nokia.com>
Change-Id: I03e3249b8a624e26e274cba5ac44011cdea0101a

go.mod
pkg/nbi/httprestful.go
pkg/nbi/httprestful_test.go
pkg/rpe/rmr.go
pkg/stub/stub.go

diff --git a/go.mod b/go.mod
index 2364485..eac767f 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -19,6 +19,6 @@ require (
 
 replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2
 
-replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.7.3-1
+replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.2
 
 replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.2
index 5223162..ab62a13 100644 (file)
@@ -478,12 +478,12 @@ func PopulateE2TMap(e2tDataList *[]rtmgr.E2tIdentity, e2ts map[string]rtmgr.E2TI
                                meidar += meid + " "
                        }
                        str = "mme_ar|" + e2tData.E2taddress + "|" + strings.TrimSuffix(meidar, " ")
-                   *meids = append(*meids, str)
+                       *meids = append(*meids, str)
                }
 
                e2ts[e2tinst.Fqdn] = e2tinst
        }
-    xapp.Logger.Info("MEID's retrieved are %v", *meids)
+       xapp.Logger.Info("MEID's retrieved are %v", *meids)
 }
 
 func retrieveStartupData(xmurl string, nbiif string, fileName string, configfile string, e2murl string, sdlEngine sdl.Engine) error {
@@ -688,8 +688,7 @@ func PopulateSubscription(sub_list xfmodel.SubscriptionList) {
                var subdata models.XappSubscriptionData
                id := int32(sub_row.SubscriptionID)
                subdata.SubscriptionID = &id
-               for _, ep := range sub_row.Endpoint {
-
+               for _, ep := range sub_row.ClientEndpoint {
                        stringSlice := strings.Split(ep, ":")
                        subdata.Address = &stringSlice[0]
                        intportval, _ := strconv.Atoi(stringSlice[1])
index 16ffb38..aece2b0 100644 (file)
@@ -78,7 +78,6 @@ var InvalidSubResp = []byte(`{"Version":0, "EventType":all}`)
 
 type Consumer struct{}
 
-
 func (m Consumer) Consume(params *xapp.RMRParams) (err error) {
        xapp.Sdl.Store("myKey", params.Payload)
        return nil
@@ -113,7 +112,7 @@ func TestValidateXappCallbackDataInvalid(t *testing.T) {
 
 func TestValidateXappSubscriptionsData(t *testing.T) {
 
-    rtmgr.RMRConnStatus = make(map[string]bool)
+       rtmgr.RMRConnStatus = make(map[string]bool)
        ep := make(map[string]*rtmgr.Endpoint)
        ep["dummy"] = &rtmgr.Endpoint{Uuid: "10.0.0.1:0", Name: "E2TERM", XAppType: "app1", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true}
        p := uint16(1234)
@@ -178,7 +177,7 @@ func TestValidateE2tDataEmpty(t *testing.T) {
 }
 
 func TestValidateE2tDataDNSLookUPfails(t *testing.T) {
-    rtmgr.RMRConnStatus = make(map[string]bool)
+       rtmgr.RMRConnStatus = make(map[string]bool)
        data := models.E2tData{
                E2TAddress: swag.String("e2t.1com:1234"),
        }
@@ -187,7 +186,7 @@ func TestValidateE2tDataDNSLookUPfails(t *testing.T) {
 }
 
 func TestValidateE2tDataInvalid(t *testing.T) {
-    rtmgr.RMRConnStatus = make(map[string]bool)
+       rtmgr.RMRConnStatus = make(map[string]bool)
        data := models.E2tData{
                E2TAddress: swag.String("10.101.01.1"),
        }
@@ -196,7 +195,7 @@ func TestValidateE2tDataInvalid(t *testing.T) {
 }
 
 func TestValidateE2tDatavalid(t *testing.T) {
-    rtmgr.RMRConnStatus = make(map[string]bool)
+       rtmgr.RMRConnStatus = make(map[string]bool)
        data := models.E2tData{
                E2TAddress: swag.String("10.101.01.1:8098"),
        }
@@ -209,7 +208,7 @@ func TestValidateE2tDatavalid(t *testing.T) {
 }
 
 func TestValidateE2tDatavalidEndpointPresent(t *testing.T) {
-    rtmgr.RMRConnStatus = make(map[string]bool)
+       rtmgr.RMRConnStatus = make(map[string]bool)
        data := models.E2tData{
                E2TAddress: swag.String("10.101.01.1:8098"),
        }
@@ -231,7 +230,7 @@ func TestValidateE2tDatavalidEndpointPresent(t *testing.T) {
 
 func TestValidateDeleteE2tData(t *testing.T) {
 
-    rtmgr.RMRConnStatus = make(map[string]bool)
+       rtmgr.RMRConnStatus = make(map[string]bool)
        // test-1
        data := models.E2tDeleteData{
                E2TAddress: swag.String(""),
@@ -811,9 +810,9 @@ func TestAddDelRmr(t *testing.T) {
 func TestPopulateSubscription(t *testing.T) {
        var sublist xfmodel.SubscriptionList
 
-       subdata := xfmodel.SubscriptionData{Endpoint: []string{"xapp1.com:3800"}, SubscriptionID: -1, Meid: ""}
-       subdata2 := xfmodel.SubscriptionData{Endpoint: []string{"xapp2.com:3800"}, SubscriptionID: 11, Meid: ""}
-       subdata3 := xfmodel.SubscriptionData{Endpoint: []string{"xapp3.com:3800"}, SubscriptionID: 221, Meid: ""}
+       subdata := xfmodel.SubscriptionData{ClientEndpoint: []string{"xapp1.com:3800"}, SubscriptionID: -1, Meid: ""}
+       subdata2 := xfmodel.SubscriptionData{ClientEndpoint: []string{"xapp2.com:3800"}, SubscriptionID: 11, Meid: ""}
+       subdata3 := xfmodel.SubscriptionData{ClientEndpoint: []string{"xapp3.com:3800"}, SubscriptionID: 221, Meid: ""}
        sublist = append(sublist, &subdata)
        sublist = append(sublist, &subdata2)
        sublist = append(sublist, &subdata3)
index 56d2ff7..c1f126c 100644 (file)
@@ -99,25 +99,26 @@ func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, rcs *rtmgr.RicComponents,
        for _, value := range rcs.MeidMap {
                if _, v := keys[key+value+"\n"]; !v {
                        rawrt = append(rawrt, key+value+"\n")
-                       appendedindex := uint16(len(rawrt)-1)
-                       keys[key+value+"\n"] = RouteIndex{true,appendedindex}
+                       appendedindex := uint16(len(rawrt) - 1)
+                       keys[key+value+"\n"] = RouteIndex{true, appendedindex}
                        count++
                }
-               if strings.Contains(value,"mme_ar") {
-                   tmpstr := strings.Split(value,"|")
-
-                   MEID := strings.TrimSuffix(tmpstr[2],"\n")
-
-                   mapindex := "mme_del|"+MEID+"\n"
-                   i := keys[mapindex].index
-                   if keys[mapindex].flag {
-                   copy(rawrt[i:], rawrt[i+1:])
-                           rawrt[len(rawrt)-1] = ""
-                           rawrt = rawrt[:len(rawrt)-1]
-                           delete(keys,mapindex)
-                           count--
-                   }
-        }
+               if strings.Contains(value, "mme_ar") {
+                       tmpstr := strings.Split(value, "|")
+
+                       //MEID entry for mme_ar must always contain 3 strings speartred by | i.e "mme_ar|<string1>|<string2>"
+                       MEID := strings.TrimSuffix(tmpstr[2], "\n")
+
+                       mapindex := "mme_del|" + MEID + "\n"
+                       i := keys[mapindex].index
+                       if keys[mapindex].flag {
+                               copy(rawrt[i:], rawrt[i+1:])
+                               rawrt[len(rawrt)-1] = ""
+                               rawrt = rawrt[:len(rawrt)-1]
+                               delete(keys, mapindex)
+                               count--
+                       }
+               }
        }
        rawrt = append(rawrt, key+"meid_map|end|"+strconv.Itoa(count)+"\n")
 
index a69f949..97ea6d3 100644 (file)
@@ -60,18 +60,18 @@ var E2map = make(map[string]rtmgr.E2TInstance)
 var ValidEndPointsEmpty = rtmgr.Endpoints{}
 
 var ValidRicComponents = rtmgr.RicComponents{
-       XApps: *ValidXApps, Pcs: *ValidPlatformComponents, E2Ts: E2map, MeidMap: []string{"mme_ar|e2t.com:1234"},
+       XApps: *ValidXApps, Pcs: *ValidPlatformComponents, E2Ts: E2map, MeidMap: []string{"mme_ar|e2t.com:1234|gnbID1"},
 }
 
 var ValidPolicies = &[]string{"", ""}
 
 var ValidEndpoints1 = []rtmgr.Endpoint{
-{Uuid: "10.0.0.1:0", Name: "E2TERM", XAppType: "app1", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
-        {Uuid: "10.0.0.2:0", Name: "E2TERMINST", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
-        {Uuid: "192.168.0.1:0", Name: "SUBMAN", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: false},
-        {Uuid: "10.1.1.1:0", Name: "E2MAN", XAppType: "app3", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false},
-        {Uuid: "10.2.2.1:0", Name: "UEMAN", XAppType: "app4", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Policies: []int32{1, 2}, Socket: nil, IsReady: false, Keepalive: true},
-        {Uuid: "127.0.0.1:0", Name: "UEMAN1", XAppType: "app4", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Policies: []int32{1, 2}, Socket: nil, IsReady: false, Keepalive: true},
+       {Uuid: "10.0.0.1:0", Name: "E2TERM", XAppType: "app1", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
+       {Uuid: "10.0.0.2:0", Name: "E2TERMINST", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: true},
+       {Uuid: "192.168.0.1:0", Name: "SUBMAN", XAppType: "app2", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: false, Keepalive: false},
+       {Uuid: "10.1.1.1:0", Name: "E2MAN", XAppType: "app3", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false},
+       {Uuid: "10.2.2.1:0", Name: "UEMAN", XAppType: "app4", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Policies: []int32{1, 2}, Socket: nil, IsReady: false, Keepalive: true},
+       {Uuid: "127.0.0.1:0", Name: "UEMAN1", XAppType: "app4", Ip: "", Port: 0, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Policies: []int32{1, 2}, Socket: nil, IsReady: false, Keepalive: true},
 }
 
 var ValidSubscriptions = &[]rtmgr.Subscription{
@@ -103,6 +103,6 @@ var Rane2tmaponlyE2t = models.RanE2tMap{
 var XappSubscriptionData_port = uint16(0)
 var XappSubscriptionData_subid = int32(1)
 
-var XappSubData = models.XappSubscriptionData {
-    Address: swag.String("10.0.0.1"), Port: &XappSubscriptionData_port, SubscriptionID: &XappSubscriptionData_subid,
+var XappSubData = models.XappSubscriptionData{
+       Address: swag.String("10.0.0.1"), Port: &XappSubscriptionData_port, SubscriptionID: &XappSubscriptionData_subid,
 }