SVC address support for rmr stubs. 59/3159/5
authorJuha Hyttinen <juha.hyttinen@nokia.com>
Mon, 6 Apr 2020 12:01:52 +0000 (15:01 +0300)
committerJuha Hyttinen <juha.hyttinen@nokia.com>
Mon, 6 Apr 2020 12:56:27 +0000 (15:56 +0300)
Have seen that if used may cause netlink errno 9. Maybe
due we have several rmr instances inside one procedure?

Change-Id: Ia52ae40bc05592179e3fc9143cd6c398af46adba
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
Dockerfile
pkg/control/ut_ctrl_submgr_test.go
pkg/control/ut_test.go
pkg/teststub/controlRmr.go
pkg/teststub/controlRmrStub.go
pkg/teststub/rmrroutetable.go
pkg/teststubdummy/stubRmrDummy.go
pkg/teststube2ap/stubE2.go

index 34f5252..71d2130 100644 (file)
@@ -170,6 +170,9 @@ ENV CFG_FILE=/opt/submgr/test/config-file.json
 COPY test/uta_rtg.rt test/uta_rtg.rt
 ENV RMR_SEED_RT=/opt/submgr/test/uta_rtg.rt 
 
+#ENV CGO_LDFLAGS="-fsanitize=address"
+#ENV CGO_CFLAGS="-fsanitize=address"
+
 RUN go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control 
 RUN go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html
 
index 9fb852a..3a57177 100644 (file)
@@ -34,9 +34,9 @@ type testingSubmgrControl struct {
        c *Control
 }
 
-func createSubmgrControl(rtfile string, port string) *testingSubmgrControl {
+func createSubmgrControl(rtfile string, port uint16, rtport uint16) *testingSubmgrControl {
        mainCtrl = &testingSubmgrControl{}
-       mainCtrl.RmrControl.Init("SUBMGRCTL", rtfile, port)
+       mainCtrl.RmrControl.Init("SUBMGRCTL", rtfile, port, rtport)
        mainCtrl.c = NewControl()
        xapp.SetReadyCB(mainCtrl.ReadyCB, nil)
        go xapp.RunWithParams(mainCtrl.c, false)
index 7d27412..05d34b8 100644 (file)
@@ -110,7 +110,8 @@ func ut_test_init() {
        //
        // NOTE3: Ports per entity:
        //
-       // Port    Entity
+       // DataPort Entity
+       // RoutePort (svc) will be DataPort+1
        // -------------------
        // 14560   submgr
        // 15560   e2term1 stub
@@ -149,37 +150,37 @@ func ut_test_init() {
        //
        //---------------------------------
        tent.Logger.Info("### submgr ctrl run ###")
-       mainCtrl = createSubmgrControl(rtfilename, "14560")
+       mainCtrl = createSubmgrControl(rtfilename, 14560, 0)
 
        //---------------------------------
        //
        //---------------------------------
        tent.Logger.Info("### xapp1 stub run ###")
-       xappConn1 = teststube2ap.CreateNewE2Stub("xappstub1", rtfilename, "13560", "RMRXAPP1STUB", 55555)
+       xappConn1 = teststube2ap.CreateNewE2Stub("xappstub1", rtfilename, 13560, 0, "RMRXAPP1STUB", 55555)
 
        //---------------------------------
        //
        //---------------------------------
        tent.Logger.Info("### xapp2 stub run ###")
-       xappConn2 = teststube2ap.CreateNewE2Stub("xappstub2", rtfilename, "13660", "RMRXAPP2STUB", 55555)
+       xappConn2 = teststube2ap.CreateNewE2Stub("xappstub2", rtfilename, 13660, 0, "RMRXAPP2STUB", 55555)
 
        //---------------------------------
        //
        //---------------------------------
        tent.Logger.Info("### e2term1 stub run ###")
-       e2termConn1 = teststube2ap.CreateNewE2termStub("e2termstub1", rtfilename, "15560", "RMRE2TERMSTUB1", 55555)
+       e2termConn1 = teststube2ap.CreateNewE2termStub("e2termstub1", rtfilename, 15560, 0, "RMRE2TERMSTUB1", 55555)
 
        //---------------------------------
        //
        //---------------------------------
        tent.Logger.Info("### e2term2 stub run ###")
-       e2termConn2 = teststube2ap.CreateNewE2termStub("e2termstub2", rtfilename, "15660", "RMRE2TERMSTUB2", 55555)
+       e2termConn2 = teststube2ap.CreateNewE2termStub("e2termstub2", rtfilename, 15660, 0, "RMRE2TERMSTUB2", 55555)
 
        //---------------------------------
        // Just to test dummy stub
        //---------------------------------
        tent.Logger.Info("### dummy stub run ###")
-       dummystub = teststubdummy.CreateNewRmrDummyStub("dummystub", rtfilename, "16560", "DUMMYSTUB", 55555)
+       dummystub = teststubdummy.CreateNewRmrDummyStub("dummystub", rtfilename, 16560, 0, "DUMMYSTUB", 55555)
 
        //---------------------------------
        // Testing message sending
index 06c434b..41a6606 100644 (file)
@@ -22,6 +22,7 @@ import (
        "fmt"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "os"
+       "strconv"
        "testing"
 )
 
@@ -30,7 +31,9 @@ import (
 //-----------------------------------------------------------------------------
 type RmrControl struct {
        TestWrapper
-       syncChan chan struct{}
+       syncChan  chan struct{}
+       DataPort  uint16
+       RoutePort uint16
 }
 
 func (tc *RmrControl) ReadyCB(data interface{}) {
@@ -42,14 +45,20 @@ func (tc *RmrControl) WaitCB() {
        <-tc.syncChan
 }
 
-func (tc *RmrControl) Init(desc string, rtfile string, port string) {
+func (tc *RmrControl) Init(desc string, rtfile string, port uint16, rtport uint16) {
        tc.TestWrapper.Init(desc)
+       tc.DataPort = port
+       tc.RoutePort = rtport
        os.Setenv("RMR_SEED_RT", rtfile)
-       os.Setenv("RMR_SRC_ID", "localhost:"+port)
-       //os.Setenv("RMR_RTG_SVC", "localhost:"+rtport)
        xapp.Logger.Info("Using rt file %s", os.Getenv("RMR_SEED_RT"))
-       xapp.Logger.Info("Using src id  %s", os.Getenv("RMR_SRC_ID"))
-       //xapp.Logger.Info("Using rtg svc  %s", os.Getenv("RMR_RTG_SVC"))
+       if tc.DataPort > 0 {
+               os.Setenv("RMR_SRC_ID", "localhost:"+strconv.FormatUint(uint64(tc.DataPort), 10))
+               xapp.Logger.Info("Using src id  %s", os.Getenv("RMR_SRC_ID"))
+       }
+       if tc.RoutePort > 0 {
+               os.Setenv("RMR_RTG_SVC", "localhost:"+strconv.FormatUint(uint64(tc.RoutePort), 10))
+               xapp.Logger.Info("Using rtg svc  %s", os.Getenv("RMR_RTG_SVC"))
+       }
        tc.syncChan = make(chan struct{})
 }
 
index 05a8e32..f14bd1f 100644 (file)
@@ -21,6 +21,7 @@ package teststub
 import (
        "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+       "strconv"
        "strings"
        "testing"
        "time"
@@ -67,14 +68,14 @@ func (tc *RmrStubControl) TestMsgChanEmpty(t *testing.T) {
        }
 }
 
-func (tc *RmrStubControl) Init(desc string, rtfile string, port string, stat string, initMsg int) {
+func (tc *RmrStubControl) Init(desc string, rtfile string, port uint16, rtport uint16, stat string, initMsg int) {
        tc.InitMsg = initMsg
        tc.Active = false
        tc.RecvChan = make(chan *xapptweaks.RMRParams)
-       tc.RmrControl.Init(desc, rtfile, port)
+       tc.RmrControl.Init(desc, rtfile, port, rtport)
        tc.RmrWrapper.Init()
 
-       tc.Rmr = xapp.NewRMRClientWithParams("tcp:"+port, 65534, 1, 0, stat)
+       tc.Rmr = xapp.NewRMRClientWithParams("tcp:"+strconv.FormatUint(uint64(port), 10), 65534, 1, 0, stat)
        tc.Rmr.SetReadyCB(tc.ReadyCB, nil)
        go tc.Rmr.Start(tc)
 
index cb7adeb..281110c 100644 (file)
@@ -74,12 +74,10 @@ func (rrt *RmrRouteTable) GetTable() string {
                allrt += val + "\n"
        }
        allrt += "newrt|end\n"
-       if len(rrt.meids) > 0 {
-               allrt += "meid_map | start\n"
-               for _, val := range rrt.meids {
-                       allrt += val + "\n"
-               }
-               allrt += "meid_map | end | " + strconv.FormatInt(int64(len(rrt.meids)), 10) + "\n"
+       allrt += "meid_map | start\n"
+       for _, val := range rrt.meids {
+               allrt += val + "\n"
        }
+       allrt += "meid_map | end | " + strconv.FormatInt(int64(len(rrt.meids)), 10) + "\n"
        return allrt
 }
index c08036f..c4745ba 100644 (file)
@@ -42,9 +42,9 @@ type RmrDummyStub struct {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func CreateNewRmrDummyStub(desc string, rtfile string, port string, stat string, mtypeseed int) *RmrDummyStub {
+func CreateNewRmrDummyStub(desc string, rtfile string, port uint16, rtport uint16, stat string, mtypeseed int) *RmrDummyStub {
        dummyStub := &RmrDummyStub{}
-       dummyStub.RmrStubControl.Init(desc, rtfile, port, stat, mtypeseed)
+       dummyStub.RmrStubControl.Init(desc, rtfile, port, rtport, stat, mtypeseed)
        dummyStub.reqMsg = mtypeseed + 1
        dummyStub.respMsg = mtypeseed + 2
        return dummyStub
index 292f964..576a954 100644 (file)
@@ -54,9 +54,9 @@ type E2Stub struct {
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func CreateNewE2Stub(desc string, rtfile string, port string, stat string, mtypeseed int) *E2Stub {
+func CreateNewE2Stub(desc string, rtfile string, port uint16, rtport uint16, stat string, mtypeseed int) *E2Stub {
        tc := &E2Stub{}
-       tc.RmrStubControl.Init(desc, rtfile, port, stat, mtypeseed)
+       tc.RmrStubControl.Init(desc, rtfile, port, rtport, stat, mtypeseed)
        tc.xid_seq = 1
        tc.SetCheckXid(true)
        return tc
@@ -65,9 +65,9 @@ func CreateNewE2Stub(desc string, rtfile string, port string, stat string, mtype
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
-func CreateNewE2termStub(desc string, rtfile string, port string, stat string, mtypeseed int) *E2Stub {
+func CreateNewE2termStub(desc string, rtfile string, port uint16, rtport uint16, stat string, mtypeseed int) *E2Stub {
        tc := &E2Stub{}
-       tc.RmrStubControl.Init(desc, rtfile, port, stat, mtypeseed)
+       tc.RmrStubControl.Init(desc, rtfile, port, rtport, stat, mtypeseed)
        tc.xid_seq = 1
        tc.SetCheckXid(false)
        return tc