2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
21 // EXAMPLE HOW TO HAVE RMR STUB
27 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
28 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
29 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
36 type RmrDummyStub struct {
37 teststub.RmrStubControl
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
45 func CreateNewRmrDummyStub(desc string, rtfile string, port string, stat string, mtypeseed int) *RmrDummyStub {
46 dummyStub := &RmrDummyStub{}
47 dummyStub.RmrStubControl.Init(desc, rtfile, port, stat, mtypeseed)
48 dummyStub.reqMsg = mtypeseed + 1
49 dummyStub.respMsg = mtypeseed + 2
53 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
57 func (tc *RmrDummyStub) SendReq(t *testing.T) {
58 tc.Logger.Info("SendReq")
59 var dummyBuf []byte = make([]byte, 100)
60 params := xapptweaks.NewParams(nil)
61 params.Mtype = tc.reqMsg
63 params.Payload = dummyBuf
64 params.PayloadLen = 100
65 params.Meid = &xapp.RMRMeid{RanName: "TEST"}
69 snderr := tc.RmrSend(params, 5)
71 tc.TestError(t, "%s", snderr.Error())
76 func (tc *RmrDummyStub) RecvResp(t *testing.T) bool {
77 tc.Logger.Info("RecvResp")
81 if msg.Mtype != tc.respMsg {
82 tc.TestError(t, "Received wrong mtype expected %d got %d, error", tc.respMsg, msg.Mtype)
87 tc.TestError(t, "Not Received msg within %d secs", 15)
92 //-----------------------------------------------------------------------------
94 //-----------------------------------------------------------------------------
95 func RmrDummyHandleMessage(msg *xapptweaks.RMRParams, mtypeseed int, rmr xapptweaks.XAppWrapperIf) (bool, error) {
96 if msg.Mtype == mtypeseed+1 {
97 var dummyBuf []byte = make([]byte, 100)
98 params := xapptweaks.NewParams(nil)
99 params.Mtype = mtypeseed + 2
100 params.SubId = msg.SubId
101 params.Payload = dummyBuf
102 params.PayloadLen = 100
103 params.Meid = msg.Meid
106 rmr.GetLogger().Info("SEND DUMMY RESP: %s", params.String())
107 err := rmr.RmrSend(params, 5)
109 rmr.GetLogger().Error("RmrDummyHandleMessage: err(%s)", err.Error())