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 ==================================================================================
23 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststub"
24 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststubdummy"
25 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
33 func CaseBegin(desc string) *teststub.TestWrapper {
34 tent := teststub.NewTestWrapper(desc)
35 tent.Logger.Info(desc)
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
43 var xappConn1 *teststube2ap.E2Stub
44 var xappConn2 *teststube2ap.E2Stub
45 var e2termConn1 *teststube2ap.E2Stub
46 var e2termConn2 *teststube2ap.E2Stub
47 var rtmgrHttp *testingHttpRtmgrStub
48 var mainCtrl *testingSubmgrControl
50 var dummystub *teststubdummy.RmrDummyStub
53 tent := CaseBegin("ut_test_init")
55 //---------------------------------
57 //---------------------------------
58 rtmgrHttp = createNewHttpRtmgrStub("RTMGRSTUB", "8989")
61 //---------------------------------
63 //---------------------------------
66 //Cfg creation won't work like this as xapp-frame reads it during init.
77 "protPort": "tcp:14560",
80 "txMessages": ["RIC_SUB_REQ", "RIC_SUB_DEL_REQ"],
81 "rxMessages": ["RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE", "RIC_INDICATION"]
86 "namespaces": ["sdl", "rnib"]
89 "HostAddr" : "localhost",
95 cfgfilename,_ := testCreateTmpFile(cfgstr)
96 defer os.Remove(cfgfilename)
97 os.Setenv("CFG_FILE", cfgfilename)
99 tent.Logger.Info("Using cfg file %s", os.Getenv("CFG_FILE"))
101 //---------------------------------
102 // Static routetable for rmr
104 // NOTE: Routing table is configured so, that responses
105 // are duplicated to xapp1 and xapp2 instances.
106 // If XID is not matching xapp stub will just
107 // drop message. (Messages 12011, 12012, 12021, 12022)
109 // NOTE2: 55555 message type is for stub rmr connectivity probing
111 // NOTE3: Ports per entity:
114 // RoutePort (svc) will be DataPort+1
115 // -------------------
117 // 15560 e2term1 stub
118 // 15660 e2term2 stub
123 //---------------------------------
124 rt := &teststub.RmrRouteTable{}
125 rt.AddRoute(12010, "", -1, "localhost:14560")
126 rt.AddRoute(12010, "localhost:14560", -1, "%meid")
127 rt.AddRoute(12011, "localhost:15560", -1, "localhost:14560")
128 rt.AddRoute(12012, "localhost:15560", -1, "localhost:14560")
129 rt.AddRoute(12011, "localhost:15660", -1, "localhost:14560")
130 rt.AddRoute(12012, "localhost:15660", -1, "localhost:14560")
131 rt.AddRoute(12011, "localhost:14560", -1, "localhost:13660;localhost:13560")
132 rt.AddRoute(12012, "localhost:14560", -1, "localhost:13660;localhost:13560")
133 rt.AddRoute(12020, "", -1, "localhost:14560")
134 rt.AddRoute(12020, "localhost:14560", -1, "%meid")
135 rt.AddRoute(12021, "localhost:15560", -1, "localhost:14560")
136 rt.AddRoute(12022, "localhost:15560", -1, "localhost:14560")
137 rt.AddRoute(12021, "localhost:15660", -1, "localhost:14560")
138 rt.AddRoute(12022, "localhost:15660", -1, "localhost:14560")
139 rt.AddRoute(12021, "localhost:14560", -1, "localhost:13660;localhost:13560")
140 rt.AddRoute(12022, "localhost:14560", -1, "localhost:13660;localhost:13560")
141 rt.AddRoute(55555, "", -1, "localhost:13660;localhost:13560;localhost:15560;localhost:15660;localhost:16560")
143 rt.AddMeid("localhost:15560", []string{"RAN_NAME_1", "RAN_NAME_2"})
144 rt.AddMeid("localhost:15660", []string{"RAN_NAME_11", "RAN_NAME_12"})
146 rtfilename, _ := teststub.CreateTmpFile(rt.GetTable())
147 defer os.Remove(rtfilename)
148 tent.Logger.Info("table[%s]", rt.GetTable())
149 //---------------------------------
151 //---------------------------------
152 tent.Logger.Info("### submgr ctrl run ###")
153 mainCtrl = createSubmgrControl(rtfilename, 14560, 0)
155 //---------------------------------
157 //---------------------------------
158 tent.Logger.Info("### xapp1 stub run ###")
159 xappConn1 = teststube2ap.CreateNewE2Stub("xappstub1", rtfilename, 13560, 0, "RMRXAPP1STUB", 55555)
161 //---------------------------------
163 //---------------------------------
164 tent.Logger.Info("### xapp2 stub run ###")
165 xappConn2 = teststube2ap.CreateNewE2Stub("xappstub2", rtfilename, 13660, 0, "RMRXAPP2STUB", 55555)
167 //---------------------------------
169 //---------------------------------
170 tent.Logger.Info("### e2term1 stub run ###")
171 e2termConn1 = teststube2ap.CreateNewE2termStub("e2termstub1", rtfilename, 15560, 0, "RMRE2TERMSTUB1", 55555)
173 //---------------------------------
175 //---------------------------------
176 tent.Logger.Info("### e2term2 stub run ###")
177 e2termConn2 = teststube2ap.CreateNewE2termStub("e2termstub2", rtfilename, 15660, 0, "RMRE2TERMSTUB2", 55555)
179 //---------------------------------
180 // Just to test dummy stub
181 //---------------------------------
182 tent.Logger.Info("### dummy stub run ###")
183 dummystub = teststubdummy.CreateNewRmrDummyStub("dummystub", rtfilename, 16560, 0, "DUMMYSTUB", 55555)
185 //---------------------------------
186 // Testing message sending
187 //---------------------------------
188 if teststub.RmrStubControlWaitAlive(10, 55555, mainCtrl.c) == false {
193 //-----------------------------------------------------------------------------
195 //-----------------------------------------------------------------------------
196 func TestMain(m *testing.M) {
197 CaseBegin("TestMain start")