Updated xapp-frame to 0.4.18. Updated rmr to 4.1.2.
Change-Id: I723a2b9968e1b29e83979c0dee6ab039529b7ab5
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
diff --git a/pkg/control/client.go b/pkg/control/client.go
index d26bbd0..1ef7a69 100644
--- a/pkg/control/client.go
+++ b/pkg/control/client.go
@@ -24,7 +24,6 @@
rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
rtmgrhandle "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client/handle"
"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_models"
- "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"
@@ -35,7 +34,7 @@
//
//-----------------------------------------------------------------------------
type SubRouteInfo struct {
- EpList xapptweaks.RmrEndpointList
+ EpList xapp.RmrEndpointList
SubID uint16
}
diff --git a/pkg/control/control.go b/pkg/control/control.go
index 35e39f4..5128458 100755
--- a/pkg/control/control.go
+++ b/pkg/control/control.go
@@ -23,7 +23,6 @@
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
httptransport "github.com/go-openapi/runtime/client"
@@ -63,11 +62,12 @@
var e2tRecvMsgTimeout time.Duration = 5 * time.Second
type Control struct {
- xapptweaks.XappWrapper
+ *xapp.RMRClient
e2ap *E2ap
registry *Registry
tracker *Tracker
//subscriber *xapp.Subscriber
+ CntRecvMsg uint64
}
type RMRMeid struct {
@@ -102,15 +102,14 @@
tracker: tracker,
//subscriber: subscriber,
}
- c.XappWrapper.Init("")
go xapp.Subscription.Listen(c.SubscriptionHandler, c.QueryHandler, c.SubscriptionDeleteHandler)
//go c.subscriber.Listen(c.SubscriptionHandler, c.QueryHandler)
return c
}
func (c *Control) ReadyCB(data interface{}) {
- if c.Rmr == nil {
- c.Rmr = xapp.Rmr
+ if c.RMRClient == nil {
+ c.RMRClient = xapp.Rmr
}
}
@@ -152,7 +151,7 @@
//-------------------------------------------------------------------
func (c *Control) rmrSendToE2T(desc string, subs *Subscription, trans *TransactionSubs) (err error) {
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = trans.GetMtype()
params.SubId = int(subs.GetReqId().InstanceId)
params.Xid = ""
@@ -162,12 +161,12 @@
params.Payload = trans.Payload.Buf
params.Mbuf = nil
xapp.Logger.Info("MSG to E2T: %s %s %s", desc, trans.String(), params.String())
- return c.RmrSend(params, 5)
+ return c.SendWithRetry(params, false, 5)
}
func (c *Control) rmrSendToXapp(desc string, subs *Subscription, trans *TransactionXapp) (err error) {
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = trans.GetMtype()
params.SubId = int(subs.GetReqId().InstanceId)
params.Xid = trans.GetXid()
@@ -177,19 +176,18 @@
params.Payload = trans.Payload.Buf
params.Mbuf = nil
xapp.Logger.Info("MSG to XAPP: %s %s %s", desc, trans.String(), params.String())
- return c.RmrSend(params, 5)
+ return c.SendWithRetry(params, false, 5)
}
-func (c *Control) Consume(params *xapp.RMRParams) (err error) {
- msg := xapptweaks.NewParams(params)
- if c.Rmr == nil {
+func (c *Control) Consume(msg *xapp.RMRParams) (err error) {
+ if c.RMRClient == nil {
err = fmt.Errorf("Rmr object nil can handle %s", msg.String())
xapp.Logger.Error("%s", err.Error())
return
}
c.CntRecvMsg++
- defer c.Rmr.Free(msg.Mbuf)
+ defer c.RMRClient.Free(msg.Mbuf)
// xapp-frame might use direct access to c buffer and
// when msg.Mbuf is freed, someone might take it into use
@@ -223,7 +221,7 @@
//-------------------------------------------------------------------
// handle from XAPP Subscription Request
//------------------------------------------------------------------
-func (c *Control) handleXAPPSubscriptionRequest(params *xapptweaks.RMRParams) {
+func (c *Control) handleXAPPSubscriptionRequest(params *xapp.RMRParams) {
xapp.Logger.Info("MSG from XAPP: %s", params.String())
subReqMsg, err := c.e2ap.UnpackSubscriptionRequest(params.Payload)
@@ -232,7 +230,7 @@
return
}
- trans := c.tracker.NewXappTransaction(xapptweaks.NewRmrEndpoint(params.Src), params.Xid, subReqMsg.RequestId.InstanceId, params.Meid)
+ trans := c.tracker.NewXappTransaction(xapp.NewRmrEndpoint(params.Src), params.Xid, subReqMsg.RequestId.InstanceId, params.Meid)
if trans == nil {
xapp.Logger.Error("XAPP-SubReq: %s", idstring(fmt.Errorf("transaction not created"), params))
return
@@ -284,7 +282,7 @@
//-------------------------------------------------------------------
// handle from XAPP Subscription Delete Request
//------------------------------------------------------------------
-func (c *Control) handleXAPPSubscriptionDeleteRequest(params *xapptweaks.RMRParams) {
+func (c *Control) handleXAPPSubscriptionDeleteRequest(params *xapp.RMRParams) {
xapp.Logger.Info("MSG from XAPP: %s", params.String())
subDelReqMsg, err := c.e2ap.UnpackSubscriptionDeleteRequest(params.Payload)
@@ -293,7 +291,7 @@
return
}
- trans := c.tracker.NewXappTransaction(xapptweaks.NewRmrEndpoint(params.Src), params.Xid, subDelReqMsg.RequestId.InstanceId, params.Meid)
+ trans := c.tracker.NewXappTransaction(xapp.NewRmrEndpoint(params.Src), params.Xid, subDelReqMsg.RequestId.InstanceId, params.Meid)
if trans == nil {
xapp.Logger.Error("XAPP-SubDelReq: %s", idstring(fmt.Errorf("transaction not created"), params))
return
@@ -483,7 +481,7 @@
//-------------------------------------------------------------------
// handle from E2T Subscription Reponse
//-------------------------------------------------------------------
-func (c *Control) handleE2TSubscriptionResponse(params *xapptweaks.RMRParams) {
+func (c *Control) handleE2TSubscriptionResponse(params *xapp.RMRParams) {
xapp.Logger.Info("MSG from E2T: %s", params.String())
subRespMsg, err := c.e2ap.UnpackSubscriptionResponse(params.Payload)
if err != nil {
@@ -512,7 +510,7 @@
//-------------------------------------------------------------------
// handle from E2T Subscription Failure
//-------------------------------------------------------------------
-func (c *Control) handleE2TSubscriptionFailure(params *xapptweaks.RMRParams) {
+func (c *Control) handleE2TSubscriptionFailure(params *xapp.RMRParams) {
xapp.Logger.Info("MSG from E2T: %s", params.String())
subFailMsg, err := c.e2ap.UnpackSubscriptionFailure(params.Payload)
if err != nil {
@@ -541,7 +539,7 @@
//-------------------------------------------------------------------
// handle from E2T Subscription Delete Response
//-------------------------------------------------------------------
-func (c *Control) handleE2TSubscriptionDeleteResponse(params *xapptweaks.RMRParams) (err error) {
+func (c *Control) handleE2TSubscriptionDeleteResponse(params *xapp.RMRParams) (err error) {
xapp.Logger.Info("MSG from E2T: %s", params.String())
subDelRespMsg, err := c.e2ap.UnpackSubscriptionDeleteResponse(params.Payload)
if err != nil {
@@ -570,7 +568,7 @@
//-------------------------------------------------------------------
// handle from E2T Subscription Delete Failure
//-------------------------------------------------------------------
-func (c *Control) handleE2TSubscriptionDeleteFailure(params *xapptweaks.RMRParams) {
+func (c *Control) handleE2TSubscriptionDeleteFailure(params *xapp.RMRParams) {
xapp.Logger.Info("MSG from E2T: %s", params.String())
subDelFailMsg, err := c.e2ap.UnpackSubscriptionDeleteFailure(params.Payload)
if err != nil {
diff --git a/pkg/control/registry.go b/pkg/control/registry.go
index 396dade..275d572 100644
--- a/pkg/control/registry.go
+++ b/pkg/control/registry.go
@@ -22,7 +22,6 @@
import (
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"sync"
@@ -247,7 +246,7 @@
//
// Subscription route delete
//
- tmpList := xapptweaks.RmrEndpointList{}
+ tmpList := xapp.RmrEndpointList{}
tmpList.AddEndpoint(trans.GetEndpoint())
subRouteAction := SubRouteInfo{tmpList, uint16(subId)}
r.rtmgrClient.SubscriptionRequestDelete(subRouteAction)
diff --git a/pkg/control/subscription.go b/pkg/control/subscription.go
index 5243093..9342ccc 100644
--- a/pkg/control/subscription.go
+++ b/pkg/control/subscription.go
@@ -21,7 +21,6 @@
import (
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
//"reflect"
"sync"
@@ -36,7 +35,7 @@
registry *Registry // Registry
ReqId RequestId // ReqId (Requestor Id + Seq Nro a.k.a subsid)
Meid *xapp.RMRMeid // Meid/ RanName
- EpList xapptweaks.RmrEndpointList // Endpoints
+ EpList xapp.RmrEndpointList // Endpoints
TransLock sync.Mutex // Lock transactions, only one executed per time for subs
TheTrans TransactionIf // Ongoing transaction
SubReqMsg *e2ap.E2APSubscriptionRequest // Subscription information
@@ -44,7 +43,11 @@
}
func (s *Subscription) String() string {
- return "subs(" + s.ReqId.String() + "/" + (&xapptweaks.RMRMeid{s.Meid}).String() + "/" + s.EpList.String() + ")"
+ meidstr := "N/A"
+ if s.Meid != nil {
+ meidstr = s.Meid.String()
+ }
+ return "subs(" + s.ReqId.String() + "/" + meidstr + "/" + s.EpList.String() + ")"
}
func (s *Subscription) GetCachedResponse() (interface{}, bool) {
diff --git a/pkg/control/tracker.go b/pkg/control/tracker.go
index 0879a4f..46971d9 100644
--- a/pkg/control/tracker.go
+++ b/pkg/control/tracker.go
@@ -21,7 +21,6 @@
import (
"fmt"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"sync"
)
@@ -57,7 +56,7 @@
}
func (t *Tracker) NewXappTransaction(
- endpoint *xapptweaks.RmrEndpoint,
+ endpoint *xapp.RmrEndpoint,
xid string,
subid uint32,
meid *xapp.RMRMeid) *TransactionXapp {
diff --git a/pkg/control/transaction.go b/pkg/control/transaction.go
index d922d18..f722d11 100644
--- a/pkg/control/transaction.go
+++ b/pkg/control/transaction.go
@@ -21,7 +21,6 @@
import (
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"strconv"
"sync"
@@ -53,7 +52,11 @@
}
func (t *Transaction) String() string {
- return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + (&xapptweaks.RMRMeid{t.Meid}).String() + ")"
+ meidstr := "N/A"
+ if t.Meid != nil {
+ meidstr = t.Meid.String()
+ }
+ return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + meidstr + ")"
}
func (t *Transaction) SendEvent(event interface{}, waittime time.Duration) (bool, bool) {
@@ -126,7 +129,7 @@
//
//-----------------------------------------------------------------------------
type TransactionXappKey struct {
- xapptweaks.RmrEndpoint
+ xapp.RmrEndpoint
Xid string // xapp xid in req
}
@@ -151,7 +154,7 @@
return "transxapp(" + t.Transaction.String() + "/" + transkey + "/" + strconv.FormatUint(uint64(t.SubId), 10) + ")"
}
-func (t *TransactionXapp) GetEndpoint() *xapptweaks.RmrEndpoint {
+func (t *TransactionXapp) GetEndpoint() *xapp.RmrEndpoint {
t.mutex.Lock()
defer t.mutex.Unlock()
if t.XappKey != nil {
diff --git a/pkg/control/ut_stub_rtmgr_test.go b/pkg/control/ut_stub_rtmgr_test.go
index 8546ad4..97bedfa 100644
--- a/pkg/control/ut_stub_rtmgr_test.go
+++ b/pkg/control/ut_stub_rtmgr_test.go
@@ -90,17 +90,17 @@
var req rtmgr_models.XappSubscriptionData
err := json.NewDecoder(r.Body).Decode(&req)
if err != nil {
- tc.Logger.Error("%s", err.Error())
+ tc.Error("%s", err.Error())
}
- tc.Logger.Info("handling SubscriptionID=%d Address=%s Port=%d", *req.SubscriptionID, *req.Address, *req.Port)
+ tc.Info("handling SubscriptionID=%d Address=%s Port=%d", *req.SubscriptionID, *req.Address, *req.Port)
}
if r.Method == http.MethodPut {
var req rtmgr_models.XappList
err := json.NewDecoder(r.Body).Decode(&req)
if err != nil {
- tc.Logger.Error("%s", err.Error())
+ tc.Error("%s", err.Error())
}
- tc.Logger.Info("handling put")
+ tc.Info("handling put")
}
var code int = 0
@@ -135,7 +135,7 @@
if waiter != nil {
waiter.SetResult(true)
}
- tc.Logger.Info("Method=%s Reply with code %d", r.Method, code)
+ tc.Info("Method=%s Reply with code %d", r.Method, code)
w.WriteHeader(code)
}
diff --git a/pkg/control/ut_test.go b/pkg/control/ut_test.go
index baedbae..e7ddbc0 100644
--- a/pkg/control/ut_test.go
+++ b/pkg/control/ut_test.go
@@ -23,7 +23,7 @@
"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststubdummy"
"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"os"
"testing"
"time"
@@ -34,7 +34,7 @@
//-----------------------------------------------------------------------------
func CaseBegin(desc string) *teststub.TestWrapper {
tent := teststub.NewTestWrapper(desc)
- tent.Logger.Info(desc)
+ tent.Info(desc)
return tent
}
@@ -103,7 +103,7 @@
defer os.Remove(cfgfilename)
os.Setenv("CFG_FILE", cfgfilename)
*/
- tent.Logger.Info("Using cfg file %s", os.Getenv("CFG_FILE"))
+ tent.Info("Using cfg file %s", os.Getenv("CFG_FILE"))
//---------------------------------
// Static routetable for rmr
@@ -120,12 +120,12 @@
// Entity
// -------------------
- mainsrc := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 14560}}
- xapp1src := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 13560}}
- xapp2src := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 13660}}
- e2term1src := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 15560}}
- e2term2src := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 15660}}
- dummysrc := teststub.RmrSrcId{xapptweaks.RmrEndpoint{"localhost", 16560}}
+ mainsrc := teststub.RmrSrcId{xapp.RmrEndpoint{"localhost", 14560}}
+ xapp1src := teststub.RmrSrcId{xapp.RmrEndpoint{"localhost", 13560}}
+ xapp2src := teststub.RmrSrcId{xapp.RmrEndpoint{"localhost", 13660}}
+ e2term1src := teststub.RmrSrcId{xapp.RmrEndpoint{"localhost", 15560}}
+ e2term2src := teststub.RmrSrcId{xapp.RmrEndpoint{"localhost", 15660}}
+ dummysrc := teststub.RmrSrcId{xapp.RmrEndpoint{"localhost", 16560}}
//---------------------------------
rt := &teststub.RmrRouteTable{}
@@ -151,12 +151,12 @@
rt.AddMeid(e2term2src.String(), []string{"RAN_NAME_11", "RAN_NAME_12"})
rt.Enable()
- tent.Logger.Info("rttable[%s]", rt.Table())
+ tent.Info("rttable[%s]", rt.Table())
//---------------------------------
//
//---------------------------------
- tent.Logger.Info("### submgr ctrl run ###")
+ tent.Info("### submgr ctrl run ###")
mainCtrl = createSubmgrControl(mainsrc, teststub.RmrRtgSvc{})
//
@@ -167,61 +167,61 @@
//env variables. Re-create rt info.
for i := 0; i < int(10)*2; i++ {
if os.Getenv("RMR_SEED_RT") == rt.FileName() {
- tent.Logger.Info("Waiting that alarm alternates RMR_SEED_RT=%s", os.Getenv("RMR_SEED_RT"))
+ tent.Info("Waiting that alarm alternates RMR_SEED_RT=%s", os.Getenv("RMR_SEED_RT"))
time.Sleep(500 * time.Millisecond)
} else {
- tent.Logger.Info("Alarm has alternated RMR_SEED_RT=%s, so waiting 0.5 secs before restoring it", os.Getenv("RMR_SEED_RT"))
+ tent.Info("Alarm has alternated RMR_SEED_RT=%s, so waiting 0.5 secs before restoring it", os.Getenv("RMR_SEED_RT"))
time.Sleep(500 * time.Millisecond)
rt.Enable()
- tent.Logger.Info("rttable[%s]", rt.Table())
+ tent.Info("rttable[%s]", rt.Table())
break
}
}
if os.Getenv("RMR_SEED_RT") != rt.FileName() {
- tent.Logger.Error("Unittest timing issue with alarm RMR_SEED_RT=%s", os.Getenv("RMR_SEED_RT"))
+ tent.Error("Unittest timing issue with alarm RMR_SEED_RT=%s", os.Getenv("RMR_SEED_RT"))
os.Exit(1)
}
//---------------------------------
//
//---------------------------------
- tent.Logger.Info("### xapp1 stub run ###")
+ tent.Info("### xapp1 stub run ###")
xappConn1 = teststube2ap.CreateNewE2Stub("xappstub1", xapp1src, teststub.RmrRtgSvc{}, "RMRXAPP1STUB", teststubPortSeed)
//---------------------------------
//
//---------------------------------
- tent.Logger.Info("### xapp2 stub run ###")
+ tent.Info("### xapp2 stub run ###")
xappConn2 = teststube2ap.CreateNewE2Stub("xappstub2", xapp2src, teststub.RmrRtgSvc{}, "RMRXAPP2STUB", teststubPortSeed)
//---------------------------------
//
//---------------------------------
- tent.Logger.Info("### e2term1 stub run ###")
+ tent.Info("### e2term1 stub run ###")
e2termConn1 = teststube2ap.CreateNewE2termStub("e2termstub1", e2term1src, teststub.RmrRtgSvc{}, "RMRE2TERMSTUB1", teststubPortSeed)
//---------------------------------
//
//---------------------------------
- tent.Logger.Info("### e2term2 stub run ###")
+ tent.Info("### e2term2 stub run ###")
e2termConn2 = teststube2ap.CreateNewE2termStub("e2termstub2", e2term2src, teststub.RmrRtgSvc{}, "RMRE2TERMSTUB2", teststubPortSeed)
//---------------------------------
// Just to test dummy stub
//---------------------------------
- tent.Logger.Info("### dummy stub run ###")
+ tent.Info("### dummy stub run ###")
dummystub = teststubdummy.CreateNewRmrDummyStub("dummystub", dummysrc, teststub.RmrRtgSvc{}, "DUMMYSTUB", teststubPortSeed)
//---------------------------------
// Testing message sending
//---------------------------------
- if teststub.RmrStubControlWaitAlive(10, teststubPortSeed, mainCtrl.c) == false {
+ if teststub.RmrStubControlWaitAlive(10, teststubPortSeed, mainCtrl.c.RMRClient, tent) == false {
os.Exit(1)
}
if os.Getenv("RMR_SEED_RT") != rt.FileName() {
- tent.Logger.Error("Unittest timing issue with alarm RMR_SEED_RT=%s", os.Getenv("RMR_SEED_RT"))
+ tent.Error("Unittest timing issue with alarm RMR_SEED_RT=%s", os.Getenv("RMR_SEED_RT"))
os.Exit(1)
}
diff --git a/pkg/teststub/controlRmr.go b/pkg/teststub/controlRmr.go
index 18b821e..71d66fe 100644
--- a/pkg/teststub/controlRmr.go
+++ b/pkg/teststub/controlRmr.go
@@ -55,11 +55,11 @@
}
func (tc *RmrControl) TestError(t *testing.T, pattern string, args ...interface{}) {
- tc.Logger.Error(fmt.Sprintf(pattern, args...))
+ tc.Error(fmt.Sprintf(pattern, args...))
t.Errorf(fmt.Sprintf(pattern, args...))
}
func (tc *RmrControl) TestLog(t *testing.T, pattern string, args ...interface{}) {
- tc.Logger.Info(fmt.Sprintf(pattern, args...))
+ tc.Info(fmt.Sprintf(pattern, args...))
t.Logf(fmt.Sprintf(pattern, args...))
}
diff --git a/pkg/teststub/controlRmrStub.go b/pkg/teststub/controlRmrStub.go
index 958b8b8..60b3cc5 100644
--- a/pkg/teststub/controlRmrStub.go
+++ b/pkg/teststub/controlRmrStub.go
@@ -19,7 +19,6 @@
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"
@@ -32,8 +31,8 @@
//-----------------------------------------------------------------------------
type RmrStubControl struct {
RmrControl
- xapptweaks.RmrWrapper
- RecvChan chan *xapptweaks.RMRParams
+ *xapp.RMRClient
+ RecvChan chan *xapp.RMRParams
Active bool
InitMsg int
CheckXid bool
@@ -71,65 +70,62 @@
func (tc *RmrStubControl) Init(desc string, srcId RmrSrcId, rtgSvc RmrRtgSvc, stat string, initMsg int) {
tc.InitMsg = initMsg
tc.Active = false
- tc.RecvChan = make(chan *xapptweaks.RMRParams)
+ tc.RecvChan = make(chan *xapp.RMRParams)
tc.RmrControl.Init(desc, srcId, rtgSvc)
- tc.RmrWrapper.Init()
- tc.Rmr = xapp.NewRMRClientWithParams("tcp:"+strconv.FormatUint(uint64(srcId.Port), 10), 65534, 1, 0, stat)
- tc.Rmr.SetReadyCB(tc.ReadyCB, nil)
- go tc.Rmr.Start(tc)
+ tc.RMRClient = xapp.NewRMRClientWithParams("tcp:"+strconv.FormatUint(uint64(srcId.Port), 10), 65534, 0, stat)
+ tc.RMRClient.SetReadyCB(tc.ReadyCB, nil)
+ go tc.RMRClient.Start(tc)
tc.WaitCB()
allRmrStubs = append(allRmrStubs, tc)
}
-func (tc *RmrStubControl) Consume(params *xapp.RMRParams) (err error) {
- defer tc.Rmr.Free(params.Mbuf)
- msg := xapptweaks.NewParams(params)
- tc.CntRecvMsg++
+func (tc *RmrStubControl) Consume(msg *xapp.RMRParams) (err error) {
+ defer tc.RMRClient.Free(msg.Mbuf)
cPay := append(msg.Payload[:0:0], msg.Payload...)
msg.Payload = cPay
msg.PayloadLen = len(cPay)
if msg.Mtype == tc.InitMsg {
- tc.Logger.Info("Testing message ignore %s", msg.String())
+ tc.Info("Testing message ignore %s", msg.String())
tc.SetActive()
return
}
if tc.IsCheckXid() == true && strings.Contains(msg.Xid, tc.GetDesc()) == false {
- tc.Logger.Info("Ignore %s", msg.String())
+ tc.Info("Ignore %s", msg.String())
return
}
- tc.Logger.Info("Consume %s", msg.String())
+ tc.Info("Consume %s", msg.String())
tc.PushMsg(msg)
return
}
-func (tc *RmrStubControl) PushMsg(msg *xapptweaks.RMRParams) {
- tc.Logger.Debug("RmrStubControl PushMsg ... msg(%d) waiting", msg.Mtype)
+func (tc *RmrStubControl) PushMsg(msg *xapp.RMRParams) {
+ tc.Debug("RmrStubControl PushMsg ... msg(%d) waiting", msg.Mtype)
tc.RecvChan <- msg
- tc.Logger.Debug("RmrStubControl PushMsg ... done")
+ tc.Debug("RmrStubControl PushMsg ... done")
}
-func (tc *RmrStubControl) WaitMsg(secs time.Duration) *xapptweaks.RMRParams {
- tc.Logger.Debug("RmrStubControl WaitMsg ... waiting")
+func (tc *RmrStubControl) WaitMsg(secs time.Duration) *xapp.RMRParams {
+ tc.Debug("RmrStubControl WaitMsg ... waiting")
if secs == 0 {
msg := <-tc.RecvChan
- tc.Logger.Debug("RmrStubControl WaitMsg ... msg(%d) done", msg.Mtype)
+ tc.Debug("RmrStubControl WaitMsg ... msg(%d) done", msg.Mtype)
return msg
}
select {
case msg := <-tc.RecvChan:
- tc.Logger.Debug("RmrStubControl WaitMsg ... msg(%d) done", msg.Mtype)
+ tc.Debug("RmrStubControl WaitMsg ... msg(%d) done", msg.Mtype)
return msg
case <-time.After(secs * time.Second):
- tc.Logger.Debug("RmrStubControl WaitMsg ... timeout")
+ tc.Debug("RmrStubControl WaitMsg ... timeout")
return nil
}
- tc.Logger.Debug("RmrStubControl WaitMsg ... error")
+ tc.Debug("RmrStubControl WaitMsg ... error")
return nil
}
@@ -139,11 +135,11 @@
//
//-----------------------------------------------------------------------------
-func RmrStubControlWaitAlive(seconds int, mtype int, rmr xapptweaks.XAppWrapperIf) bool {
+func RmrStubControlWaitAlive(seconds int, mtype int, rmr *xapp.RMRClient, tent *TestWrapper) bool {
var dummyBuf []byte = make([]byte, 100)
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = mtype
params.SubId = -1
params.Payload = dummyBuf
@@ -153,15 +149,15 @@
params.Mbuf = nil
if len(allRmrStubs) == 0 {
- rmr.GetLogger().Info("No rmr stubs so no need to wait those to be alive")
+ tent.Info("No rmr stubs so no need to wait those to be alive")
return true
}
status := false
i := 1
for ; i <= seconds*2 && status == false; i++ {
- rmr.GetLogger().Info("SEND TESTPING: %s", params.String())
- rmr.RmrSend(params, 0)
+ tent.Info("SEND TESTPING: %s", params.String())
+ rmr.SendWithRetry(params, false, 0)
status = true
for _, val := range allRmrStubs {
@@ -173,12 +169,12 @@
if status == true {
break
}
- rmr.GetLogger().Info("Sleep 0.5 secs and try routes again")
+ tent.Info("Sleep 0.5 secs and try routes again")
time.Sleep(500 * time.Millisecond)
}
if status == false {
- rmr.GetLogger().Error("Could not initialize routes")
+ tent.Error("Could not initialize routes")
}
return status
}
diff --git a/pkg/teststub/rmrenv.go b/pkg/teststub/rmrenv.go
index cf1e284..4b1f1b7 100644
--- a/pkg/teststub/rmrenv.go
+++ b/pkg/teststub/rmrenv.go
@@ -20,7 +20,6 @@
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"
"os"
"strconv"
@@ -115,7 +114,7 @@
//-----------------------------------------------------------------------------
type RmrSrcId struct {
- xapptweaks.RmrEndpoint
+ xapp.RmrEndpoint
}
func (rsi *RmrSrcId) Enable() {
@@ -134,7 +133,7 @@
//
//-----------------------------------------------------------------------------
type RmrRtgSvc struct {
- xapptweaks.RmrEndpoint
+ xapp.RmrEndpoint
}
func (rrs *RmrRtgSvc) Enable() {
diff --git a/pkg/teststub/testwrapper.go b/pkg/teststub/testwrapper.go
index f27392d..7752be8 100644
--- a/pkg/teststub/testwrapper.go
+++ b/pkg/teststub/testwrapper.go
@@ -20,23 +20,31 @@
import (
"fmt"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+ "strings"
"testing"
)
type TestWrapper struct {
- xapptweaks.LogWrapper
+ *xapp.Log
+ desc string
}
func (tw *TestWrapper) Init(desc string) {
- tw.LogWrapper.Init(desc)
+ tw.desc = strings.ToUpper(desc)
+ tw.Log = xapp.NewLogger(tw.desc)
+ //tw.SetLevel(defaultLogLevel)
+}
+
+func (tw *TestWrapper) GetDesc() string {
+ return tw.desc
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
func (tw *TestWrapper) TestError(t *testing.T, pattern string, args ...interface{}) {
- tw.Logger.Error(fmt.Sprintf(pattern, args...))
+ tw.Error(fmt.Sprintf(pattern, args...))
t.Errorf(fmt.Sprintf(pattern, args...))
}
@@ -44,7 +52,7 @@
//
//-----------------------------------------------------------------------------
func (tw *TestWrapper) TestLog(t *testing.T, pattern string, args ...interface{}) {
- tw.Logger.Info(fmt.Sprintf(pattern, args...))
+ tw.Info(fmt.Sprintf(pattern, args...))
t.Logf(fmt.Sprintf(pattern, args...))
}
diff --git a/pkg/teststubdummy/stubRmrDummy.go b/pkg/teststubdummy/stubRmrDummy.go
index b3b4352..2520c54 100644
--- a/pkg/teststubdummy/stubRmrDummy.go
+++ b/pkg/teststubdummy/stubRmrDummy.go
@@ -25,7 +25,6 @@
import (
"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"testing"
)
@@ -55,12 +54,12 @@
//-----------------------------------------------------------------------------
func (tc *RmrDummyStub) SendReq(t *testing.T, plen int) {
- tc.Logger.Info("SendReq")
+ tc.Info("SendReq")
len := plen
if len == 0 {
len = 100
}
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = tc.reqMsg
params.SubId = -1
@@ -70,7 +69,7 @@
params.Xid = "TEST"
params.Mbuf = nil
- snderr := tc.RmrSend(params, 5)
+ snderr := tc.SendWithRetry(params, false, 5)
if snderr != nil {
tc.TestError(t, "%s", snderr.Error())
}
@@ -78,12 +77,12 @@
}
func (tc *RmrDummyStub) SendResp(t *testing.T, plen int) {
- tc.Logger.Info("SendReq")
+ tc.Info("SendReq")
len := plen
if len == 0 {
len = 100
}
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = tc.respMsg
params.SubId = -1
params.Payload = make([]byte, len)
@@ -92,7 +91,7 @@
params.Xid = "TEST"
params.Mbuf = nil
- snderr := tc.RmrSend(params, 5)
+ snderr := tc.SendWithRetry(params, false, 5)
if snderr != nil {
tc.TestError(t, "%s", snderr.Error())
}
@@ -100,7 +99,7 @@
}
func (tc *RmrDummyStub) RecvReq(t *testing.T) bool {
- tc.Logger.Info("RecvReq")
+ tc.Info("RecvReq")
msg := tc.WaitMsg(15)
if msg != nil {
@@ -116,7 +115,7 @@
}
func (tc *RmrDummyStub) RecvResp(t *testing.T) bool {
- tc.Logger.Info("RecvResp")
+ tc.Info("RecvResp")
msg := tc.WaitMsg(15)
if msg != nil {
diff --git a/pkg/teststube2ap/stubE2.go b/pkg/teststube2ap/stubE2.go
index 160597f..d830aa7 100644
--- a/pkg/teststube2ap/stubE2.go
+++ b/pkg/teststube2ap/stubE2.go
@@ -23,7 +23,6 @@
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"strconv"
"testing"
@@ -43,7 +42,11 @@
}
func (trans *RmrTransactionId) String() string {
- return "trans(" + trans.xid + "/" + (&xapptweaks.RMRMeid{trans.meid}).String() + ")"
+ meidstr := "N/A"
+ if trans.meid != nil {
+ meidstr = trans.meid.String()
+ }
+ return "trans(" + trans.xid + "/" + meidstr + ")"
}
type E2Stub struct {
@@ -85,7 +88,7 @@
trans.xid = xid
}
trans.meid = &xapp.RMRMeid{RanName: ranname}
- tc.Logger.Info("New test %s", trans.String())
+ tc.Info("New test %s", trans.String())
return trans
}
@@ -172,7 +175,7 @@
trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
}
- tc.Logger.Info("SendSubsReq %s", trans.String())
+ tc.Info("SendSubsReq %s", trans.String())
e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
//---------------------------------
@@ -190,9 +193,9 @@
tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
return nil
}
- tc.Logger.Debug("%s %s", trans.String(), e2SubsReq.String())
+ tc.Debug("%s %s", trans.String(), e2SubsReq.String())
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = xapp.RIC_SUB_REQ
params.SubId = -1
params.Payload = packedMsg.Buf
@@ -201,8 +204,8 @@
params.Xid = trans.xid
params.Mbuf = nil
- tc.Logger.Info("SEND SUB REQ: %s", params.String())
- snderr := tc.RmrSend(params, 5)
+ tc.Info("SEND SUB REQ: %s", params.String())
+ snderr := tc.SendWithRetry(params, false, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
return nil
@@ -213,8 +216,8 @@
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
-func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapptweaks.RMRParams) {
- tc.Logger.Info("RecvSubsReq")
+func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapp.RMRParams) {
+ tc.Info("RecvSubsReq")
e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
//---------------------------------
@@ -225,7 +228,7 @@
if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] {
tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype])
} else {
- tc.Logger.Info("Recv Subs Req")
+ tc.Info("Recv Subs Req")
packedData := &e2ap.PackedData{}
packedData.Buf = msg.Payload
unpackerr, req := e2SubsReq.UnPack(packedData)
@@ -244,8 +247,8 @@
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
-func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapptweaks.RMRParams) {
- tc.Logger.Info("SendSubsResp")
+func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) {
+ tc.Info("SendSubsResp")
e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
//---------------------------------
@@ -274,9 +277,9 @@
if packerr != nil {
tc.TestError(t, "pack NOK %s", packerr.Error())
}
- tc.Logger.Debug("%s", e2SubsResp.String())
+ tc.Debug("%s", e2SubsResp.String())
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = xapp.RIC_SUB_RESP
//params.SubId = msg.SubId
params.SubId = -1
@@ -286,8 +289,8 @@
//params.Xid = msg.Xid
params.Mbuf = nil
- tc.Logger.Info("SEND SUB RESP: %s", params.String())
- snderr := tc.RmrSend(params, 5)
+ tc.Info("SEND SUB RESP: %s", params.String())
+ snderr := tc.SendWithRetry(params, false, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
}
@@ -297,7 +300,7 @@
//
//-----------------------------------------------------------------------------
func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 {
- tc.Logger.Info("RecvSubsResp")
+ tc.Info("RecvSubsResp")
e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
var e2SubsId uint32
@@ -324,7 +327,7 @@
if unpackerr != nil {
tc.TestError(t, "RIC_SUB_RESP unpack failed err: %s", unpackerr.Error())
}
- tc.Logger.Info("Recv Subs Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
+ tc.Info("Recv Subs Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
return e2SubsId
}
} else {
@@ -337,8 +340,8 @@
//
//-----------------------------------------------------------------------------
-func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg *xapptweaks.RMRParams) {
- tc.Logger.Info("SendSubsFail")
+func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg *xapp.RMRParams) {
+ tc.Info("SendSubsFail")
e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
//---------------------------------
@@ -348,9 +351,9 @@
if packerr != nil {
tc.TestError(t, "pack NOK %s", packerr.Error())
}
- tc.Logger.Debug("%s", e2SubsFail.String())
+ tc.Debug("%s", e2SubsFail.String())
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = xapp.RIC_SUB_FAILURE
params.SubId = msg.SubId
params.Payload = packedMsg.Buf
@@ -359,8 +362,8 @@
params.Xid = msg.Xid
params.Mbuf = nil
- tc.Logger.Info("SEND SUB FAIL: %s", params.String())
- snderr := tc.RmrSend(params, 5)
+ tc.Info("SEND SUB FAIL: %s", params.String())
+ snderr := tc.SendWithRetry(params, false, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
}
@@ -370,7 +373,7 @@
//
//-----------------------------------------------------------------------------
func (tc *E2Stub) RecvSubsFail(t *testing.T, trans *RmrTransactionId) uint32 {
- tc.Logger.Info("RecvSubsFail")
+ tc.Info("RecvSubsFail")
e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
var e2SubsId uint32
@@ -397,7 +400,7 @@
if unpackerr != nil {
tc.TestError(t, "RIC_SUB_FAILURE unpack failed err: %s", unpackerr.Error())
}
- tc.Logger.Info("Recv Subs Fail rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
+ tc.Info("Recv Subs Fail rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
return e2SubsId
}
} else {
@@ -416,7 +419,7 @@
trans = tc.NewRmrTransactionId("", "RAN_NAME_1")
}
- tc.Logger.Info("SendSubsDelReq %s", trans.String())
+ tc.Info("SendSubsDelReq %s", trans.String())
e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
//---------------------------------
// xapp activity: Send Subs Del Req
@@ -431,9 +434,9 @@
tc.TestError(t, "pack NOK %s %s", trans.String(), err.Error())
return nil
}
- tc.Logger.Debug("%s %s", trans.String(), e2SubsDelReq.String())
+ tc.Debug("%s %s", trans.String(), e2SubsDelReq.String())
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = xapp.RIC_SUB_DEL_REQ
params.SubId = int(e2SubsId)
params.Payload = packedMsg.Buf
@@ -442,8 +445,8 @@
params.Xid = trans.xid
params.Mbuf = nil
- tc.Logger.Info("SEND SUB DEL REQ: %s", params.String())
- snderr := tc.RmrSend(params, 5)
+ tc.Info("SEND SUB DEL REQ: %s", params.String())
+ snderr := tc.SendWithRetry(params, false, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
return nil
@@ -454,8 +457,8 @@
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
-func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapptweaks.RMRParams) {
- tc.Logger.Info("RecvSubsDelReq")
+func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapp.RMRParams) {
+ tc.Info("RecvSubsDelReq")
e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
//---------------------------------
@@ -466,7 +469,7 @@
if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] {
tc.TestError(t, "Received wrong mtype expected %s got %s, error", "RIC_SUB_DEL_REQ", xapp.RicMessageTypeToName[msg.Mtype])
} else {
- tc.Logger.Info("Recv Subs Del Req")
+ tc.Info("Recv Subs Del Req")
packedData := &e2ap.PackedData{}
packedData.Buf = msg.Payload
@@ -485,8 +488,8 @@
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
-func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
- tc.Logger.Info("SendSubsDelResp")
+func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
+ tc.Info("SendSubsDelResp")
e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
//---------------------------------
@@ -501,9 +504,9 @@
if packerr != nil {
tc.TestError(t, "pack NOK %s", packerr.Error())
}
- tc.Logger.Debug("%s", e2SubsDelResp.String())
+ tc.Debug("%s", e2SubsDelResp.String())
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = xapp.RIC_SUB_DEL_RESP
params.SubId = msg.SubId
params.Payload = packedMsg.Buf
@@ -512,8 +515,8 @@
params.Xid = msg.Xid
params.Mbuf = nil
- tc.Logger.Info("SEND SUB DEL RESP: %s", params.String())
- snderr := tc.RmrSend(params, 5)
+ tc.Info("SEND SUB DEL RESP: %s", params.String())
+ snderr := tc.SendWithRetry(params, false, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
}
@@ -523,7 +526,7 @@
//
//-----------------------------------------------------------------------------
func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) {
- tc.Logger.Info("RecvSubsDelResp")
+ tc.Info("RecvSubsDelResp")
e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
//---------------------------------
@@ -544,7 +547,7 @@
if unpackerr != nil {
tc.TestError(t, "RIC_SUB_DEL_RESP unpack failed err: %s", unpackerr.Error())
}
- tc.Logger.Info("Recv Subs Del Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
+ tc.Info("Recv Subs Del Resp rmr: xid=%s subid=%d, asn: instanceid=%d", msg.Xid, msg.SubId, resp.RequestId.InstanceId)
return
}
} else {
@@ -555,8 +558,8 @@
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
-func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapptweaks.RMRParams) {
- tc.Logger.Info("SendSubsDelFail")
+func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
+ tc.Info("SendSubsDelFail")
e2SubsDelFail := e2asnpacker.NewPackerSubscriptionDeleteFailure()
//---------------------------------
@@ -573,9 +576,9 @@
if packerr != nil {
tc.TestError(t, "pack NOK %s", packerr.Error())
}
- tc.Logger.Debug("%s", e2SubsDelFail.String())
+ tc.Debug("%s", e2SubsDelFail.String())
- params := xapptweaks.NewParams(nil)
+ params := &xapp.RMRParams{}
params.Mtype = xapp.RIC_SUB_DEL_FAILURE
params.SubId = msg.SubId
params.Payload = packedMsg.Buf
@@ -584,8 +587,8 @@
params.Xid = msg.Xid
params.Mbuf = nil
- tc.Logger.Info("SEND SUB DEL FAIL: %s", params.String())
- snderr := tc.RmrSend(params, 5)
+ tc.Info("SEND SUB DEL FAIL: %s", params.String())
+ snderr := tc.SendWithRetry(params, false, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
}
diff --git a/pkg/xapptweaks/logwrapper.go b/pkg/xapptweaks/logwrapper.go
deleted file mode 100644
index 9b5388f..0000000
--- a/pkg/xapptweaks/logwrapper.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-==================================================================================
- Copyright (c) 2019 AT&T Intellectual Property.
- Copyright (c) 2019 Nokia
-
- 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.
-==================================================================================
-*/
-
-package xapptweaks
-
-import (
- "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
- "strings"
-)
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type LogWrapper struct {
- desc string
- Logger *xapp.Log
-}
-
-func (tc *LogWrapper) GetDesc() string {
- return tc.desc
-}
-
-func (tc *LogWrapper) GetLogger() *xapp.Log {
- return tc.Logger
-}
-
-func (tc *LogWrapper) Init(desc string) {
- tc.desc = strings.ToUpper(desc)
- if len(desc) == 0 {
- tc.Logger = xapp.Logger
- } else {
- tc.Logger = xapp.NewLogger(tc.desc)
- }
-}
diff --git a/pkg/xapptweaks/rmrendpoint.go b/pkg/xapptweaks/rmrendpoint.go
deleted file mode 100644
index 4b5ae48..0000000
--- a/pkg/xapptweaks/rmrendpoint.go
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
-==================================================================================
- Copyright (c) 2019 AT&T Intellectual Property.
- Copyright (c) 2019 Nokia
-
- 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.
-==================================================================================
-*/
-
-package xapptweaks
-
-import (
- "strconv"
- "strings"
-)
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type RmrEndpoint struct {
- Addr string // xapp addr
- Port uint16 // xapp port
-}
-
-func (endpoint RmrEndpoint) String() string {
- return endpoint.Addr + ":" + strconv.FormatUint(uint64(endpoint.Port), 10)
-}
-
-func (endpoint *RmrEndpoint) Equal(ep *RmrEndpoint) bool {
- if (endpoint.Addr == ep.Addr) &&
- (endpoint.Port == ep.Port) {
- return true
- }
- return false
-}
-
-func (endpoint *RmrEndpoint) GetAddr() string {
- return endpoint.Addr
-}
-
-func (endpoint *RmrEndpoint) GetPort() uint16 {
- return endpoint.Port
-}
-
-func (endpoint *RmrEndpoint) Set(src string) bool {
- elems := strings.Split(src, ":")
- if len(elems) == 2 {
- srcAddr := elems[0]
- srcPort, err := strconv.ParseUint(elems[1], 10, 16)
- if err == nil {
- endpoint.Addr = srcAddr
- endpoint.Port = uint16(srcPort)
- return true
- }
- }
- return false
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type RmrEndpointList struct {
- Endpoints []RmrEndpoint
-}
-
-func (eplist *RmrEndpointList) String() string {
- valuesText := eplist.StringList()
- return strings.Join(valuesText, ",")
-}
-
-func (eplist *RmrEndpointList) StringList() []string {
- tmpList := eplist.Endpoints
- valuesText := []string{}
- for i := range tmpList {
- valuesText = append(valuesText, tmpList[i].String())
- }
- return valuesText
-}
-
-func (eplist *RmrEndpointList) Size() int {
- return len(eplist.Endpoints)
-}
-
-func (eplist *RmrEndpointList) AddEndpoint(ep *RmrEndpoint) bool {
- for i := range eplist.Endpoints {
- if eplist.Endpoints[i].Equal(ep) {
- return false
- }
- }
- eplist.Endpoints = append(eplist.Endpoints, *ep)
- return true
-}
-
-func (eplist *RmrEndpointList) DelEndpoint(ep *RmrEndpoint) bool {
- for i := range eplist.Endpoints {
- if eplist.Endpoints[i].Equal(ep) {
- eplist.Endpoints[i] = eplist.Endpoints[len(eplist.Endpoints)-1]
- eplist.Endpoints[len(eplist.Endpoints)-1] = RmrEndpoint{"", 0}
- eplist.Endpoints = eplist.Endpoints[:len(eplist.Endpoints)-1]
- return true
- }
- }
- return false
-}
-
-func (eplist *RmrEndpointList) DelEndpoints(otheplist *RmrEndpointList) bool {
- var retval bool = false
- for i := range otheplist.Endpoints {
- if eplist.DelEndpoint(&otheplist.Endpoints[i]) {
- retval = true
- }
- }
- return retval
-}
-
-func (eplist *RmrEndpointList) HasEndpoint(ep *RmrEndpoint) bool {
- for i := range eplist.Endpoints {
- if eplist.Endpoints[i].Equal(ep) {
- return true
- }
- }
- return false
-}
-
-func NewRmrEndpoint(src string) *RmrEndpoint {
- ep := &RmrEndpoint{}
- if ep.Set(src) == false {
- return nil
- }
- return ep
-}
diff --git a/pkg/xapptweaks/rmrendpoint_test.go b/pkg/xapptweaks/rmrendpoint_test.go
deleted file mode 100644
index e56cea4..0000000
--- a/pkg/xapptweaks/rmrendpoint_test.go
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
-==================================================================================
- Copyright (c) 2019 AT&T Intellectual Property.
- Copyright (c) 2019 Nokia
-
- 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.
-==================================================================================
-*/
-
-package xapptweaks
-
-import (
- "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
- "testing"
-)
-
-func TestRmrEndpoint(t *testing.T) {
-
- tent := teststub.NewTestWrapper("TestRmrEndpoint")
-
- testEp := func(t *testing.T, val string, expect *RmrEndpoint) {
- res := NewRmrEndpoint(val)
-
- if expect == nil && res == nil {
- return
- }
- if res == nil {
- tent.TestError(t, "Endpoint elems for value %s expected addr %s port %d got nil", val, expect.GetAddr(), expect.GetPort())
- return
- }
- if expect.GetAddr() != res.GetAddr() || expect.GetPort() != res.GetPort() {
- tent.TestError(t, "Endpoint elems for value %s expected addr %s port %d got addr %s port %d", val, expect.GetAddr(), expect.GetPort(), res.GetAddr(), res.GetPort())
- }
- if expect.String() != res.String() {
- tent.TestError(t, "Endpoint string for value %s expected %s got %s", val, expect.String(), res.String())
- }
-
- }
-
- testEp(t, "localhost:8080", &RmrEndpoint{"localhost", 8080})
- testEp(t, "127.0.0.1:8080", &RmrEndpoint{"127.0.0.1", 8080})
- testEp(t, "localhost:70000", nil)
- testEp(t, "localhost?8080", nil)
- testEp(t, "abcdefghijklmnopqrstuvwxyz", nil)
- testEp(t, "", nil)
-}
-
-func TestRmrEndpointList(t *testing.T) {
-
- tent := teststub.NewTestWrapper("TestRmrEndpointList")
-
- epl := &RmrEndpointList{}
-
- // Simple add / has / delete
- if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == false {
- tent.TestError(t, "RmrEndpointList: 8080 add failed")
- }
- if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == true {
- tent.TestError(t, "RmrEndpointList: 8080 duplicate add success")
- }
- if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
- tent.TestError(t, "RmrEndpointList: 8081 add failed")
- }
- if epl.HasEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
- tent.TestError(t, "RmrEndpointList: 8081 has failed")
- }
- if epl.DelEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
- tent.TestError(t, "RmrEndpointList: 8081 del failed")
- }
- if epl.HasEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == true {
- tent.TestError(t, "RmrEndpointList: 8081 has non existing success")
- }
- if epl.DelEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == true {
- tent.TestError(t, "RmrEndpointList: 8081 del non existing success")
- }
- if epl.DelEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == false {
- tent.TestError(t, "RmrEndpointList: 8080 del failed")
- }
-
- // list delete
- if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == false {
- tent.TestError(t, "RmrEndpointList: 8080 add failed")
- }
- if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
- tent.TestError(t, "RmrEndpointList: 8081 add failed")
- }
- if epl.AddEndpoint(NewRmrEndpoint("127.0.0.1:8082")) == false {
- tent.TestError(t, "RmrEndpointList: 8082 add failed")
- }
-
- epl2 := &RmrEndpointList{}
- if epl2.AddEndpoint(NewRmrEndpoint("127.0.0.1:9080")) == false {
- tent.TestError(t, "RmrEndpointList: othlist add 9080 failed")
- }
-
- if epl.DelEndpoints(epl2) == true {
- tent.TestError(t, "RmrEndpointList: delete list not existing successs")
- }
-
- if epl2.AddEndpoint(NewRmrEndpoint("127.0.0.1:8080")) == false {
- tent.TestError(t, "RmrEndpointList: othlist add 8080 failed")
- }
- if epl.DelEndpoints(epl2) == false {
- tent.TestError(t, "RmrEndpointList: delete list 8080,9080 failed")
- }
-
- if epl2.AddEndpoint(NewRmrEndpoint("127.0.0.1:8081")) == false {
- tent.TestError(t, "RmrEndpointList: othlist add 8081 failed")
- }
- if epl2.AddEndpoint(NewRmrEndpoint("127.0.0.1:8082")) == false {
- tent.TestError(t, "RmrEndpointList: othlist add 8082 failed")
- }
-
- if epl.DelEndpoints(epl2) == false {
- tent.TestError(t, "RmrEndpointList: delete list 8080,8081,8082,9080 failed")
- }
-
-}
diff --git a/pkg/xapptweaks/rmrparams.go b/pkg/xapptweaks/rmrparams.go
deleted file mode 100644
index d4e9479..0000000
--- a/pkg/xapptweaks/rmrparams.go
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-==================================================================================
- Copyright (c) 2019 AT&T Intellectual Property.
- Copyright (c) 2019 Nokia
-
- 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.
-==================================================================================
-*/
-
-package xapptweaks
-
-import (
- "bytes"
- "crypto/md5"
- "fmt"
- "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-)
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type RMRMeid struct {
- *xapp.RMRMeid
-}
-
-func (meid *RMRMeid) String() string {
- if meid.RMRMeid == nil {
- return "meid()"
- }
- str := "meid("
- pad := ""
- if len(meid.PlmnID) > 0 {
- str += pad + "PlmnID=" + meid.PlmnID
- pad = " "
- }
- if len(meid.EnbID) > 0 {
- str += pad + "EnbID=" + meid.EnbID
- pad = " "
- }
- if len(meid.RanName) > 0 {
- str += pad + "RanName=" + meid.RanName
- pad = " "
- }
- str += ")"
- return str
-}
-
-func NewMeid(meid *xapp.RMRMeid) *RMRMeid {
- if meid != nil {
- return &RMRMeid{meid}
- }
- return &RMRMeid{&xapp.RMRMeid{}}
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type RMRParams struct {
- *xapp.RMRParams
-}
-
-func (params *RMRParams) String() string {
- var b bytes.Buffer
- fmt.Fprintf(&b, "params(Src=%s Mtype=%d SubId=%d Xid=%s Meid=%s Paylens=%d/%d Paymd5=%x)", params.Src, params.Mtype, params.SubId, params.Xid, (&RMRMeid{params.Meid}).String(), params.PayloadLen, len(params.Payload), md5.Sum(params.Payload))
- return b.String()
-}
-
-func NewParams(params *xapp.RMRParams) *RMRParams {
- if params != nil {
- return &RMRParams{params}
- }
- return &RMRParams{&xapp.RMRParams{}}
-}
diff --git a/pkg/xapptweaks/rmrwrapper.go b/pkg/xapptweaks/rmrwrapper.go
deleted file mode 100644
index 09fa6de..0000000
--- a/pkg/xapptweaks/rmrwrapper.go
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-==================================================================================
- Copyright (c) 2019 AT&T Intellectual Property.
- Copyright (c) 2019 Nokia
-
- 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.
-==================================================================================
-*/
-
-package xapptweaks
-
-import (
- "fmt"
- "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
- "sync"
- "time"
-)
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type RmrWrapper struct {
- mtx sync.Mutex
- Rmr *xapp.RMRClient
- CntRecvMsg uint64
- CntSentMsg uint64
-}
-
-func (tc *RmrWrapper) Lock() {
- tc.mtx.Lock()
-}
-
-func (tc *RmrWrapper) Unlock() {
- tc.mtx.Unlock()
-}
-
-func (tc *RmrWrapper) Init() {
-}
-
-func (tc *RmrWrapper) RmrSend(params *RMRParams, to time.Duration) (err error) {
- if tc.Rmr == nil {
- err = fmt.Errorf("Failed rmr object nil for %s", params.String())
- return
- }
- tc.Lock()
- status := tc.Rmr.Send(params.RMRParams, false)
- tc.Unlock()
- i := 0
- for ; i < int(to)*2 && status == false; i++ {
- tc.Lock()
- status = tc.Rmr.Send(params.RMRParams, false)
- tc.Unlock()
- if status == false {
- time.Sleep(500 * time.Millisecond)
- }
- }
- if status == false {
- err = fmt.Errorf("Failed with retries(%d) %s", i, params.String())
- if params.Mbuf != nil {
- tc.Rmr.Free(params.Mbuf)
- params.Mbuf = nil
- }
- } else {
- tc.CntSentMsg++
- }
- return
-}
diff --git a/pkg/xapptweaks/xappwrapper.go b/pkg/xapptweaks/xappwrapper.go
deleted file mode 100644
index faf3c18..0000000
--- a/pkg/xapptweaks/xappwrapper.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-==================================================================================
- Copyright (c) 2019 AT&T Intellectual Property.
- Copyright (c) 2019 Nokia
-
- 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.
-==================================================================================
-*/
-
-package xapptweaks
-
-import (
- "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
- "time"
-)
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type XAppWrapperIf interface {
- RmrSend(params *RMRParams, to time.Duration) (err error)
- GetLogger() *xapp.Log
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-type XappWrapper struct {
- LogWrapper
- RmrWrapper
-}
-
-func (tc *XappWrapper) GetDesc() string {
- return tc.desc
-}
-
-func (tc *XappWrapper) Init(desc string) {
- tc.LogWrapper.Init(desc)
- tc.RmrWrapper.Init()
-}