From 9dc5adc78d459157a42ef8997eeced82a3616f01 Mon Sep 17 00:00:00 2001 From: Juha Hyttinen Date: Thu, 13 Aug 2020 10:02:40 +0300 Subject: [PATCH] Updated xapp-frame to 0.4.18. Updated rmr to 4.1.2. Change-Id: I723a2b9968e1b29e83979c0dee6ab039529b7ab5 Signed-off-by: Juha Hyttinen --- Dockerfile | 20 ++++-- container-tag.yaml | 2 +- go.mod | 18 ++--- go.sum | 42 +++-------- pkg/control/client.go | 3 +- pkg/control/control.go | 40 +++++------ pkg/control/registry.go | 3 +- pkg/control/subscription.go | 9 ++- pkg/control/tracker.go | 3 +- pkg/control/transaction.go | 11 +-- pkg/control/ut_stub_rtmgr_test.go | 10 +-- pkg/control/ut_test.go | 44 ++++++------ pkg/teststub/controlRmr.go | 4 +- pkg/teststub/controlRmrStub.go | 58 +++++++-------- pkg/teststub/rmrenv.go | 5 +- pkg/teststub/testwrapper.go | 18 +++-- pkg/teststubdummy/stubRmrDummy.go | 17 +++-- pkg/teststube2ap/stubE2.go | 101 +++++++++++++------------- pkg/xapptweaks/logwrapper.go | 50 ------------- pkg/xapptweaks/rmrendpoint.go | 141 ------------------------------------- pkg/xapptweaks/rmrendpoint_test.go | 128 --------------------------------- pkg/xapptweaks/rmrparams.go | 83 ---------------------- pkg/xapptweaks/rmrwrapper.go | 77 -------------------- pkg/xapptweaks/xappwrapper.go | 50 ------------- 24 files changed, 201 insertions(+), 736 deletions(-) delete mode 100644 pkg/xapptweaks/logwrapper.go delete mode 100644 pkg/xapptweaks/rmrendpoint.go delete mode 100644 pkg/xapptweaks/rmrendpoint_test.go delete mode 100644 pkg/xapptweaks/rmrparams.go delete mode 100644 pkg/xapptweaks/rmrwrapper.go delete mode 100644 pkg/xapptweaks/xappwrapper.go diff --git a/Dockerfile b/Dockerfile index 67fd2e4..52c8fa3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ RUN export GOBIN=/usr/local/bin/ ; \ # # RMR # -ARG RMRVERSION=4.0.2 +ARG RMRVERSION=4.1.2 ARG RMRLIBURL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb ARG RMRDEVURL=https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb RUN wget --content-disposition ${RMRLIBURL} && dpkg -i rmr_${RMRVERSION}_amd64.deb @@ -93,6 +93,7 @@ RUN cd 3rdparty/E2AP-v01.00.00 && \ RUN echo "E2AP E2AP-v01.00.00" >> /manifests/versions.txt + COPY e2ap e2ap RUN cd e2ap/libe2ap_wrapper && \ gcc -c ${CFLAGS} -g -fPIC *.c && \ @@ -172,15 +173,26 @@ 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 +# +# To get debug from rmr +# +#RUN echo 5 > /opt/submgr/level +#RUN RMR_VCTL_FILE=/opt/submgr/level go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control + +# +# go tests. comment out ipv6 localhost if exist when tests are executed. +# +RUN sed -r "s/^(::1.*)/#\1/" /etc/hosts > /etc/hosts.new \ + && cat /etc/hosts.new > /etc/hosts \ + && cat /etc/hosts \ + && go test -test.coverprofile /tmp/submgr_cover.out -count=1 -v ./pkg/control \ + && go tool cover -html=/tmp/submgr_cover.out -o /tmp/submgr_cover.html # test formating (not important) RUN test -z "$(gofmt -l pkg/control/*.go)" RUN test -z "$(gofmt -l pkg/teststub/*.go)" RUN test -z "$(gofmt -l pkg/teststubdummy/*.go)" RUN test -z "$(gofmt -l pkg/teststube2ap/*.go)" -RUN test -z "$(gofmt -l pkg/xapptweaks/*.go)" ########################################################### diff --git a/container-tag.yaml b/container-tag.yaml index f15f32f..9182b1e 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -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.5.0" +tag: "0.5.1" diff --git a/go.mod b/go.mod index 6410b0f..e3b9a71 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ -go 1.12 - module gerrit.o-ran-sc.org/r/ric-plt/submgr +go 1.12 + 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.4.11 +replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.18 replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.1 @@ -13,11 +13,11 @@ replace gerrit.o-ran-sc.org/r/ric-plt/e2ap => ./e2ap/ require ( gerrit.o-ran-sc.org/r/ric-plt/e2ap v0.0.0-00010101000000-000000000000 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.0.0-00010101000000-000000000000 - github.com/go-openapi/errors v0.19.4 - github.com/go-openapi/runtime v0.19.15 - github.com/go-openapi/strfmt v0.19.5 - github.com/go-openapi/swag v0.19.8 - github.com/go-openapi/validate v0.19.7 - github.com/spf13/viper v1.6.2 + github.com/go-openapi/errors v0.19.3 + github.com/go-openapi/runtime v0.19.4 + github.com/go-openapi/strfmt v0.19.4 + github.com/go-openapi/swag v0.19.7 + github.com/go-openapi/validate v0.19.6 + github.com/spf13/viper v1.4.0 github.com/stretchr/testify v1.5.1 ) diff --git a/go.sum b/go.sum index 2186933..e2897ba 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,8 @@ gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35 h1:LcxnUUDwsCzYEISKm gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35/go.mod h1:2bSaXTpECbZieB8bMnubTqMwF3n+mMBxlTaAXvcduNg= gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2 h1:UK7awyRKIkVdokWvvkYvazlg3EWIfMnIqCcJxTnLlDA= gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2/go.mod h1:y2WhrCvdLkAKdH+ySdHSOSehACJkTMyZghCGVcqoZzc= -gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.11 h1:XDdMGircM79SJ7FD+GEw60qK6RfdfEtyvO88VcoYt+s= -gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.11/go.mod h1:bjhhEII07w+zPQzyvqTq84TjKQPa6IkcnSyWB1DfGHo= +gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.17 h1:Cl/IVxvymTobUovUEiFc3mdMzhk1epSSKEYbBKEHkPE= +gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.17/go.mod h1:bjhhEII07w+zPQzyvqTq84TjKQPa6IkcnSyWB1DfGHo= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -59,15 +59,13 @@ github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70t github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= -github.com/go-openapi/analysis v0.19.4/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= github.com/go-openapi/analysis v0.19.5 h1:8b2ZgKfKIUTVQpTb77MoRDIMEIwvDVw40o3aOXdfYzI= github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/errors v0.19.3 h1:7MGZI1ibQDLasvAz8HuhvYk9eNJbJkCOXWsSjjMS+Zc= github.com/go-openapi/errors v0.19.3/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= -github.com/go-openapi/errors v0.19.4 h1:fSGwO1tSYHFu70NKaWJt5Qh0qoBRtCm/mXS1yhf+0W0= -github.com/go-openapi/errors v0.19.4/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= @@ -82,14 +80,12 @@ github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= -github.com/go-openapi/loads v0.19.3/go.mod h1:YVfqhUCdahYwR3f3iiwQLhicVRvLlU/WO5WPaZvcvSI= github.com/go-openapi/loads v0.19.4 h1:5I4CCSqoWzT+82bBkNIvmLc0UOsoKKQ4Fz+3VxOB7SY= github.com/go-openapi/loads v0.19.4/go.mod h1:zZVHonKd8DXyxyw4yfnVjPzBjIQcLt0CCsn0N0ZrQsk= github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= +github.com/go-openapi/runtime v0.19.4 h1:csnOgcgAiuGoM/Po7PEpKDoNulCcF3FGbSnbHfxgjMI= github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= -github.com/go-openapi/runtime v0.19.15 h1:2GIefxs9Rx1vCDNghRtypRq+ig8KSLrjHbAYI/gCLCM= -github.com/go-openapi/runtime v0.19.15/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo= github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= @@ -98,24 +94,19 @@ github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8 github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= -github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= +github.com/go-openapi/strfmt v0.19.4 h1:eRvaqAhpL0IL6Trh5fDsGnGhiXndzHFuA05w6sXH6/g= github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= -github.com/go-openapi/strfmt v0.19.5 h1:0utjKrw+BAh8s57XE9Xz8DUBsVvPmRUB6styvl9wWIM= -github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.7 h1:VRuXN2EnMSsZdauzdss6JBC29YotDqG59BZ+tdlIL1s= github.com/go-openapi/swag v0.19.7/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= -github.com/go-openapi/swag v0.19.8 h1:vfK6jLhs7OI4tAXkvkooviaE1JEPcw3mutyegLHHjmk= -github.com/go-openapi/swag v0.19.8/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= -github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo= +github.com/go-openapi/validate v0.19.6 h1:WsKw9J1WzYBVxWRYwLqEk3325RL6G0SSWksuamkk6q0= github.com/go-openapi/validate v0.19.6/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= -github.com/go-openapi/validate v0.19.7 h1:fR4tP2xc+25pdo5Qvv4v6g+5QKFgNg8nrifTE7V8ibA= -github.com/go-openapi/validate v0.19.7/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= github.com/go-redis/redis v6.15.3+incompatible h1:NZ0O90AhLSvSrvLZ/S9h7D4kl1mW2PrKyxL7MyBKO2g= github.com/go-redis/redis v6.15.3+incompatible/go.mod h1:W2YCLaZryXHirdd9QqwkiVUxCQsrx8SbLq9Uqk7JS7A= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= @@ -137,8 +128,6 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.7.1 h1:Dw4jY2nghMMRsh1ol8dv1axHkDwMQK2DHerMNJsIpJU= github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= @@ -152,8 +141,6 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -165,9 +152,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -209,10 +195,6 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= @@ -223,9 +205,8 @@ github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9 github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E= -github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= @@ -235,8 +216,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -296,7 +275,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -309,8 +287,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 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 @@ import ( 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 @@ import ( // //----------------------------------------------------------------------------- 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 @@ import ( "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 e2tMaxSubDelReqTryCount uint64 = 2 // Initial try + retry 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 @@ func NewControl() *Control { 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) QueryHandler() (models.SubscriptionList, error) { //------------------------------------------------------------------- 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 @@ func (c *Control) rmrSendToE2T(desc string, subs *Subscription, trans *Transacti 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 @@ func (c *Control) rmrSendToXapp(desc string, subs *Subscription, trans *Transact 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 @@ func (c *Control) Consume(params *xapp.RMRParams) (err error) { //------------------------------------------------------------------- // 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 @@ func (c *Control) handleXAPPSubscriptionRequest(params *xapptweaks.RMRParams) { 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 @@ func (c *Control) handleXAPPSubscriptionRequest(params *xapptweaks.RMRParams) { //------------------------------------------------------------------- // 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 @@ func (c *Control) handleXAPPSubscriptionDeleteRequest(params *xapptweaks.RMRPara 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 @@ func (c *Control) sendE2TSubscriptionDeleteRequest(subs *Subscription, trans *Tr //------------------------------------------------------------------- // 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 @@ func (c *Control) handleE2TSubscriptionResponse(params *xapptweaks.RMRParams) { //------------------------------------------------------------------- // 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 @@ func (c *Control) handleE2TSubscriptionFailure(params *xapptweaks.RMRParams) { //------------------------------------------------------------------- // 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 @@ func (c *Control) handleE2TSubscriptionDeleteResponse(params *xapptweaks.RMRPara //------------------------------------------------------------------- // 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 @@ package control 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 @@ func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *Transaction // // 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 @@ package control 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 @@ type Subscription struct { 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 @@ type Subscription struct { } 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 @@ package control 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) NewSubsTransaction(subs *Subscription) *TransactionSubs { } 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 @@ package control 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 @@ type Transaction struct { } 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 @@ func (t *TransactionSubs) Release() { // //----------------------------------------------------------------------------- type TransactionXappKey struct { - xapptweaks.RmrEndpoint + xapp.RmrEndpoint Xid string // xapp xid in req } @@ -151,7 +154,7 @@ func (t *TransactionXapp) String() string { 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 @@ func (tc *testingHttpRtmgrStub) http_handler(w http.ResponseWriter, r *http.Requ 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 @@ func (tc *testingHttpRtmgrStub) http_handler(w http.ResponseWriter, r *http.Requ 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 @@ import ( "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 @@ import ( //----------------------------------------------------------------------------- func CaseBegin(desc string) *teststub.TestWrapper { tent := teststub.NewTestWrapper(desc) - tent.Logger.Info(desc) + tent.Info(desc) return tent } @@ -103,7 +103,7 @@ func ut_test_init() func() { 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 @@ func ut_test_init() func() { // 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 @@ func ut_test_init() func() { 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 @@ func ut_test_init() func() { //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) Init(desc string, srcId RmrSrcId, rtgSvc RmrRtgSvc) { } 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 @@ import ( //----------------------------------------------------------------------------- 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) TestMsgChanEmpty(t *testing.T) { 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 @@ var allRmrStubs []*RmrStubControl // //----------------------------------------------------------------------------- -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 @@ func RmrStubControlWaitAlive(seconds int, mtype int, rmr xapptweaks.XAppWrapperI 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 @@ func RmrStubControlWaitAlive(seconds int, mtype int, rmr xapptweaks.XAppWrapperI 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 @@ func (rrt *RmrRouteTable) Disable() { //----------------------------------------------------------------------------- type RmrSrcId struct { - xapptweaks.RmrEndpoint + xapp.RmrEndpoint } func (rsi *RmrSrcId) Enable() { @@ -134,7 +133,7 @@ func (rsi *RmrSrcId) Disable() { // //----------------------------------------------------------------------------- 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 @@ package teststub 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) TestError(t *testing.T, pattern string, args ...interface // //----------------------------------------------------------------------------- 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 @@ package teststubdummy 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 CreateNewRmrDummyStub(desc string, srcId teststub.RmrSrcId, rtgSvc teststub //----------------------------------------------------------------------------- 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 @@ func (tc *RmrDummyStub) SendReq(t *testing.T, plen int) { 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) SendReq(t *testing.T, plen int) { } 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 @@ func (tc *RmrDummyStub) SendResp(t *testing.T, plen int) { 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) SendResp(t *testing.T, plen int) { } 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) RecvReq(t *testing.T) bool { } 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 @@ import ( "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 @@ type RmrTransactionId struct { } 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 @@ func (tc *E2Stub) NewRmrTransactionId(xid string, ranname string) *RmrTransactio 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 @@ func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTra 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 @@ func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTra 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 @@ func (tc *E2Stub) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTra 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) SendSubsReq(t *testing.T, rparams *E2StubSubsReqParams, oldTra //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -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 @@ func (tc *E2Stub) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xap 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) RecvSubsReq(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xap //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -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 @@ func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, 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 @@ func (tc *E2Stub) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, //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) SendSubsResp(t *testing.T, req *e2ap.E2APSubscriptionRequest, // //----------------------------------------------------------------------------- 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 @@ func (tc *E2Stub) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 { 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) RecvSubsResp(t *testing.T, trans *RmrTransactionId) uint32 { // //----------------------------------------------------------------------------- -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 @@ func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg 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 @@ func (tc *E2Stub) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg 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) SendSubsFail(t *testing.T, fparams *E2StubSubsFailParams, msg // //----------------------------------------------------------------------------- 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 @@ func (tc *E2Stub) RecvSubsFail(t *testing.T, trans *RmrTransactionId) uint32 { 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 @@ func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2Sub 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 @@ func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2Sub 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 @@ func (tc *E2Stub) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2Sub 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) SendSubsDelReq(t *testing.T, oldTrans *RmrTransactionId, e2Sub //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -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 @@ func (tc *E2Stub) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequ 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) RecvSubsDelReq(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequ //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -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 @@ func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDelete 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 @@ func (tc *E2Stub) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDelete 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) SendSubsDelResp(t *testing.T, req *e2ap.E2APSubscriptionDelete // //----------------------------------------------------------------------------- func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) { - tc.Logger.Info("RecvSubsDelResp") + tc.Info("RecvSubsDelResp") e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse() //--------------------------------- @@ -544,7 +547,7 @@ func (tc *E2Stub) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) { 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) RecvSubsDelResp(t *testing.T, trans *RmrTransactionId) { //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -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 @@ func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDelete 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 @@ func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDelete 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() -} -- 2.16.6