Changed xapptweak rmr send function to take in retry releated timeout
Change-Id: I5c92ecbfb578ec45ffb72600d45f7f858ce05394
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
diff --git a/Dockerfile b/Dockerfile
index 6143fdb..b7adf64 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -29,6 +29,14 @@
WORKDIR /tmp
+#RUN git clone https://github.com/nokia/asn1c.git
+#RUN cd asn1c && test -f configure || autoreconf -iv
+#RUN cd asn1c && ./configure
+#RUN cd asn1c && make
+##RUN cd asn1c && make check
+#RUN cd asn1c && make install
+
+
ARG RMRVERSION=3.2.4
# Install RMr shared library
RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb && dpkg -i rmr_${RMRVERSION}_amd64.deb && rm -rf rmr_${RMRVERSION}_amd64.deb
diff --git a/pkg/control/control.go b/pkg/control/control.go
index 7b0760c..b5c60ec 100755
--- a/pkg/control/control.go
+++ b/pkg/control/control.go
@@ -158,7 +158,7 @@
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)
+ return c.RmrSend(params, 5)
}
func (c *Control) rmrSendToXapp(desc string, subs *Subscription, trans *TransactionXapp) (err error) {
@@ -173,7 +173,7 @@
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)
+ return c.RmrSend(params, 5)
}
func (c *Control) Consume(params *xapp.RMRParams) (err error) {
diff --git a/pkg/control/subscription.go b/pkg/control/subscription.go
index f66a1f1..c3e1c20 100644
--- a/pkg/control/subscription.go
+++ b/pkg/control/subscription.go
@@ -21,6 +21,7 @@
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"
"sync"
)
@@ -42,7 +43,7 @@
}
func (s *Subscription) String() string {
- return "subs(" + s.ReqId.String() + "/" + s.Meid.RanName + "/" + s.EpList.String() + ")"
+ return "subs(" + s.ReqId.String() + "/" + (&xapptweaks.RMRMeid{s.Meid}).String() + "/" + s.EpList.String() + ")"
}
func (s *Subscription) GetCachedResponse() (interface{}, bool) {
diff --git a/pkg/control/transaction.go b/pkg/control/transaction.go
index 56dff1d..1298925 100644
--- a/pkg/control/transaction.go
+++ b/pkg/control/transaction.go
@@ -21,6 +21,7 @@
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"
@@ -52,7 +53,7 @@
}
func (t *Transaction) String() string {
- return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + t.Meid.RanName + ")"
+ return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + (&xapptweaks.RMRMeid{t.Meid}).String() + ")"
}
func (t *Transaction) SendEvent(event interface{}, waittime time.Duration) (bool, bool) {
diff --git a/pkg/teststub/controlRmrStub.go b/pkg/teststub/controlRmrStub.go
index a01a0a5..e486d13 100644
--- a/pkg/teststub/controlRmrStub.go
+++ b/pkg/teststub/controlRmrStub.go
@@ -156,7 +156,7 @@
for ; i <= seconds*2 && status == false; i++ {
rmr.GetLogger().Info("SEND TESTPING: %s", params.String())
- rmr.RmrSend(params)
+ rmr.RmrSend(params, 0)
status = true
for _, val := range allRmrStubs {
diff --git a/pkg/teststubdummy/stubRmrDummy.go b/pkg/teststubdummy/stubRmrDummy.go
index 77e4b7d..c08036f 100644
--- a/pkg/teststubdummy/stubRmrDummy.go
+++ b/pkg/teststubdummy/stubRmrDummy.go
@@ -66,7 +66,7 @@
params.Xid = "TEST"
params.Mbuf = nil
- snderr := tc.RmrSend(params)
+ snderr := tc.RmrSend(params, 5)
if snderr != nil {
tc.TestError(t, "%s", snderr.Error())
}
@@ -104,7 +104,7 @@
params.Xid = msg.Xid
params.Mbuf = nil
rmr.GetLogger().Info("SEND DUMMY RESP: %s", params.String())
- err := rmr.RmrSend(params)
+ err := rmr.RmrSend(params, 5)
if err != nil {
rmr.GetLogger().Error("RmrDummyHandleMessage: err(%s)", err.Error())
}
diff --git a/pkg/teststube2ap/stubE2.go b/pkg/teststube2ap/stubE2.go
index a5dfa54..0ebb29f 100644
--- a/pkg/teststube2ap/stubE2.go
+++ b/pkg/teststube2ap/stubE2.go
@@ -43,7 +43,7 @@
}
func (trans *RmrTransactionId) String() string {
- return "trans(" + trans.xid + "/" + trans.meid.RanName + ")"
+ return "trans(" + trans.xid + "/" + (&xapptweaks.RMRMeid{trans.meid}).String() + ")"
}
type E2Stub struct {
@@ -205,7 +205,7 @@
params.Mbuf = nil
tc.Logger.Info("SEND SUB REQ: %s", params.String())
- snderr := tc.RmrSend(params)
+ snderr := tc.RmrSend(params, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
return nil
@@ -290,7 +290,7 @@
params.Mbuf = nil
tc.Logger.Info("SEND SUB RESP: %s", params.String())
- snderr := tc.RmrSend(params)
+ snderr := tc.RmrSend(params, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
}
@@ -363,7 +363,7 @@
params.Mbuf = nil
tc.Logger.Info("SEND SUB FAIL: %s", params.String())
- snderr := tc.RmrSend(params)
+ snderr := tc.RmrSend(params, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
}
@@ -446,7 +446,7 @@
params.Mbuf = nil
tc.Logger.Info("SEND SUB DEL REQ: %s", params.String())
- snderr := tc.RmrSend(params)
+ snderr := tc.RmrSend(params, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s %s", trans.String(), snderr.Error())
return nil
@@ -516,7 +516,7 @@
params.Mbuf = nil
tc.Logger.Info("SEND SUB DEL RESP: %s", params.String())
- snderr := tc.RmrSend(params)
+ snderr := tc.RmrSend(params, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
}
@@ -588,7 +588,7 @@
params.Mbuf = nil
tc.Logger.Info("SEND SUB DEL FAIL: %s", params.String())
- snderr := tc.RmrSend(params)
+ snderr := tc.RmrSend(params, 5)
if snderr != nil {
tc.TestError(t, "RMR SEND FAILED: %s", snderr.Error())
}
diff --git a/pkg/xapptweaks/rmrparams.go b/pkg/xapptweaks/rmrparams.go
index f0ac9fb..30f42fd 100644
--- a/pkg/xapptweaks/rmrparams.go
+++ b/pkg/xapptweaks/rmrparams.go
@@ -29,14 +29,46 @@
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
+type RMRMeid struct {
+ *xapp.RMRMeid
+}
+
+func (meid *RMRMeid) String() string {
+ 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
- sum := md5.Sum(params.Payload)
- fmt.Fprintf(&b, "params(Src=%s Mtype=%d SubId=%d Xid=%s Meid=%s Paylens=%d/%d Payhash=%x)", params.Src, params.Mtype, params.SubId, params.Xid, params.Meid.RanName, params.PayloadLen, len(params.Payload), sum)
+ 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()
}
diff --git a/pkg/xapptweaks/rmrwrapper.go b/pkg/xapptweaks/rmrwrapper.go
index ef633bd..ac602bf 100644
--- a/pkg/xapptweaks/rmrwrapper.go
+++ b/pkg/xapptweaks/rmrwrapper.go
@@ -47,14 +47,16 @@
func (tc *RmrWrapper) Init() {
}
-func (tc *RmrWrapper) RmrSend(params *RMRParams) (err error) {
+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
}
- status := false
- i := 1
- for ; i <= 10 && status == false; i++ {
+ 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()
diff --git a/pkg/xapptweaks/xappwrapper.go b/pkg/xapptweaks/xappwrapper.go
index 8b7c91d..faf3c18 100644
--- a/pkg/xapptweaks/xappwrapper.go
+++ b/pkg/xapptweaks/xappwrapper.go
@@ -21,13 +21,14 @@
import (
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+ "time"
)
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
type XAppWrapperIf interface {
- RmrSend(params *RMRParams) (err error)
+ RmrSend(params *RMRParams, to time.Duration) (err error)
GetLogger() *xapp.Log
}