blob: 92ff1785ca80b98f3ca3e9433197ffc4e1b12d4e [file] [log] [blame]
Juha Hyttinenfa015662020-01-24 10:05:18 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
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
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
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==================================================================================
18*/
19
20package control
21
22import (
Anssi Mannila4abf1802021-01-28 13:06:46 +020023 "testing"
24 "time"
25
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020026 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000027 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020028 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020029 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
30 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020031)
32
Markku Virtanenfa39fed2021-05-25 08:18:43 +000033func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
34
35 // The effect of this call shall endure thgough the UT suite!
36 // If this causes any issues, the previout interface can be restored
37 // like this:
38 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
39
40 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
41
42 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
43
44 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
45
46 waitSubsCleanup(t, e2SubsId, 10)
47}
48
Juha Hyttinenfa015662020-01-24 10:05:18 +020049//-----------------------------------------------------------------------------
50// TestSubReqAndRouteNok
51//
52// stub stub
53// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +020054// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +020055// +-------+ +---------+ +---------+
56// | | |
57// | SubReq | |
58// |------------->| |
59// | | |
60// | | RouteCreate |
61// | |------------->|
62// | | |
63// | | RouteCreate |
64// | | status:400 |
65// | |<-------------|
66// | | |
67// | [SUBS INT DELETE] |
68// | | |
69//
70//-----------------------------------------------------------------------------
71
72func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020073 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +020074
Anssi Mannila4abf1802021-01-28 13:06:46 +020075 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +020076 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
77 Counter{cSubReqFromXapp, 1},
78 Counter{cRouteCreateFail, 1},
79 })
Anssi Mannila4abf1802021-01-28 13:06:46 +020080
Juha Hyttinenfa015662020-01-24 10:05:18 +020081 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +030082 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020083 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +020084 waiter.WaitResult(t)
85
86 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +020087 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +020088
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020089 xappConn1.TestMsgChanEmpty(t)
90 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020091 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +020092 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +020093
94 <-time.After(1 * time.Second)
95 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +020096}
97
98//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +020099// TestSubReqAndRouteUpdateNok
100
101// stub stub
102// +-------+ +-------+ +---------+ +---------+
103// | xapp2 | | xapp1 | | submgr | | rtmgr |
104// +-------+ +-------+ +---------+ +---------+
105// | | | |
106// | [SUBS CREATE] | |
107// | | | |
108// | | | |
109// | | | |
110// | SubReq (mergeable) | |
111// |--------------------------->| | |
112// | | | |
113// | | | RouteUpdate |
114// | | |------------->|
115// | | | |
116// | | | RouteUpdate |
117// | | | status:400 |
118// | | |<-------------|
119// | | | |
120// | [SUBS INT DELETE] | |
121// | | | |
122// | | | |
123// | [SUBS DELETE] | |
124// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300125
Anssi Mannila4abf1802021-01-28 13:06:46 +0200126func TestSubReqAndRouteUpdateNok(t *testing.T) {
127 CaseBegin("TestSubReqAndRouteUpdateNok")
128
129 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200130 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
131 Counter{cSubReqFromXapp, 2},
132 Counter{cSubReqToE2, 1},
133 Counter{cSubRespFromE2, 1},
134 Counter{cSubRespToXapp, 1},
135 Counter{cRouteCreateUpdateFail, 1},
136 Counter{cSubDelReqFromXapp, 1},
137 Counter{cSubDelReqToE2, 1},
138 Counter{cSubDelRespFromE2, 1},
139 Counter{cSubDelRespToXapp, 1},
140 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200141
142 cretrans := xappConn1.SendSubsReq(t, nil, nil)
143 crereq, cremsg := e2termConn1.RecvSubsReq(t)
144 e2termConn1.SendSubsResp(t, crereq, cremsg)
145 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
146
147 resp, _ := xapp.Subscription.QuerySubscriptions()
148 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
149 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300150 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200151
152 waiter := rtmgrHttp.AllocNextEvent(false)
153 newSubsId := mainCtrl.get_registry_next_subid(t)
154 xappConn2.SendSubsReq(t, nil, nil)
155 waiter.WaitResult(t)
156
157 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
158 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
159
160 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
161 xappConn1.RecvSubsDelResp(t, deltrans)
162
163 //Wait that subs is cleaned
164 mainCtrl.wait_subs_clean(t, newSubsId, 10)
165 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
166
167 xappConn1.TestMsgChanEmpty(t)
168 xappConn2.TestMsgChanEmpty(t)
169 e2termConn1.TestMsgChanEmpty(t)
170 mainCtrl.wait_registry_empty(t, 10)
171
172 mainCtrl.VerifyCounterValues(t)
173}
174
175//-----------------------------------------------------------------------------
176// TestSubDelReqAndRouteDeleteNok
177//
178// stub stub
179// +-------+ +---------+ +---------+ +---------+
180// | xapp | | submgr | | e2term | | rtmgr |
181// +-------+ +---------+ +---------+ +---------+
182// | | | |
183// | [SUBS CREATE] | |
184// | | | |
185// | | | |
186// | | | |
187// | SubDelReq | | |
188// |------------->| | |
189// | | SubDelReq | |
190// | |------------->| |
191// | | SubDelRsp | |
192// | |<-------------| |
193// | SubDelRsp | | |
194// |<-------------| | |
195// | | RouteDelete | |
196// | |---------------------------->|
197// | | | |
198// | | RouteDelete | |
199// | | status:400 | |
200// | |<----------------------------|
201// | | | |
202func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
203 CaseBegin("TestSubDelReqAndRouteDeleteNok")
204
205 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200206 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
207 Counter{cSubReqFromXapp, 1},
208 Counter{cSubReqToE2, 1},
209 Counter{cSubRespFromE2, 1},
210 Counter{cSubRespToXapp, 1},
211 Counter{cSubDelReqFromXapp, 1},
212 Counter{cRouteDeleteFail, 1},
213 Counter{cSubDelReqToE2, 1},
214 Counter{cSubDelRespFromE2, 1},
215 Counter{cSubDelRespToXapp, 1},
216 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200217
218 cretrans := xappConn1.SendSubsReq(t, nil, nil)
219 crereq, cremsg := e2termConn1.RecvSubsReq(t)
220 e2termConn1.SendSubsResp(t, crereq, cremsg)
221 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
222
223 resp, _ := xapp.Subscription.QuerySubscriptions()
224 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
225 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300226 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200227
228 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
229 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
230
231 waiter := rtmgrHttp.AllocNextEvent(false)
232 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
233 waiter.WaitResult(t)
234
235 xappConn1.RecvSubsDelResp(t, deltrans)
236
237 //Wait that subs is cleaned
238 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
239
240 xappConn1.TestMsgChanEmpty(t)
241 xappConn2.TestMsgChanEmpty(t)
242 e2termConn1.TestMsgChanEmpty(t)
243 mainCtrl.wait_registry_empty(t, 10)
244
245 mainCtrl.VerifyCounterValues(t)
246}
247
248//-----------------------------------------------------------------------------
249// TestSubMergeDelAndRouteUpdateNok
250// stub stub
251// +-------+ +-------+ +---------+ +---------+
252// | xapp2 | | xapp1 | | submgr | | e2term |
253// +-------+ +-------+ +---------+ +---------+
254// | | | |
255// | | | |
256// | | | |
257// | | SubReq1 | |
258// | |------------->| |
259// | | | |
260// | | | SubReq1 |
261// | | |------------->|
262// | | | SubResp1 |
263// | | |<-------------|
264// | | SubResp1 | |
265// | |<-------------| |
266// | | | |
267// | SubReq2 | |
268// |--------------------------->| |
269// | | | |
270// | SubResp2 | |
271// |<---------------------------| |
272// | | | |
273// | | SubDelReq 1 | |
274// | |------------->| |
275// | | | RouteUpdate |
276// | | |-----> rtmgr |
277// | | | |
278// | | | RouteUpdate |
279// | | | status:400 |
280// | | |<----- rtmgr |
281// | | | |
282// | | SubDelResp 1 | |
283// | |<-------------| |
284// | | | |
285// | SubDelReq 2 | |
286// |--------------------------->| |
287// | | | |
288// | | | SubDelReq 2 |
289// | | |------------->|
290// | | | |
291// | | | SubDelReq 2 |
292// | | |------------->|
293// | | | |
294// | SubDelResp 2 | |
295// |<---------------------------| |
296//
297//-----------------------------------------------------------------------------
298func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
299 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
300
301 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200302 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
303 Counter{cSubReqFromXapp, 2},
304 Counter{cSubReqToE2, 1},
305 Counter{cSubRespFromE2, 1},
306 Counter{cSubRespToXapp, 2},
307 Counter{cSubDelReqFromXapp, 2},
308 Counter{cRouteDeleteUpdateFail, 1},
309 Counter{cSubDelReqToE2, 1},
310 Counter{cSubDelRespFromE2, 1},
311 Counter{cSubDelRespToXapp, 2},
312 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200313
314 //Req1
315 rparams1 := &teststube2ap.E2StubSubsReqParams{}
316 rparams1.Init()
317 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
318 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
319 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
320 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
321
322 //Req2
323 rparams2 := &teststube2ap.E2StubSubsReqParams{}
324 rparams2.Init()
325 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
326 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
327
328 resp, _ := xapp.Subscription.QuerySubscriptions()
329 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
330 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300331 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200332
333 //Del1
334 waiter := rtmgrHttp.AllocNextEvent(false)
335 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
336 waiter.WaitResult(t)
337
338 xappConn1.RecvSubsDelResp(t, deltrans1)
339
340 //Del2
341 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
342 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
343 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
344 xappConn2.RecvSubsDelResp(t, deltrans2)
345 //Wait that subs is cleaned
346 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
347
348 xappConn1.TestMsgChanEmpty(t)
349 xappConn2.TestMsgChanEmpty(t)
350 e2termConn1.TestMsgChanEmpty(t)
351 mainCtrl.wait_registry_empty(t, 10)
352
353 mainCtrl.VerifyCounterValues(t)
354}
355
356//-----------------------------------------------------------------------------
357
358//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200359// TestSubReqAndSubDelOk
360//
361// stub stub
362// +-------+ +---------+ +---------+
363// | xapp | | submgr | | e2term |
364// +-------+ +---------+ +---------+
365// | | |
366// | SubReq | |
367// |------------->| |
368// | | |
369// | | SubReq |
370// | |------------->|
371// | | |
372// | | SubResp |
373// | |<-------------|
374// | | |
375// | SubResp | |
376// |<-------------| |
377// | | |
378// | | |
379// | SubDelReq | |
380// |------------->| |
381// | | |
382// | | SubDelReq |
383// | |------------->|
384// | | |
385// | | SubDelResp |
386// | |<-------------|
387// | | |
388// | SubDelResp | |
389// |<-------------| |
390//
391//-----------------------------------------------------------------------------
392func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200393 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200394
Anssi Mannila4abf1802021-01-28 13:06:46 +0200395 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200396 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
397 Counter{cSubReqFromXapp, 1},
398 Counter{cSubReqToE2, 1},
399 Counter{cSubRespFromE2, 1},
400 Counter{cSubRespToXapp, 1},
401 Counter{cSubDelReqFromXapp, 1},
402 Counter{cSubDelReqToE2, 1},
403 Counter{cSubDelRespFromE2, 1},
404 Counter{cSubDelRespToXapp, 1},
405 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200406
407 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200408 crereq, cremsg := e2termConn1.RecvSubsReq(t)
409 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200410 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200411
412 resp, _ := xapp.Subscription.QuerySubscriptions()
413 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
414 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300415 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200416
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200417 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200418 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200419
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200420 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200421 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200422
423 //Wait that subs is cleaned
424 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
425
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200426 xappConn1.TestMsgChanEmpty(t)
427 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200428 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200429 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200430
431 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200432}
433
434//-----------------------------------------------------------------------------
435// TestSubReqRetransmission
436//
437// stub stub
438// +-------+ +---------+ +---------+
439// | xapp | | submgr | | e2term |
440// +-------+ +---------+ +---------+
441// | | |
442// | SubReq | |
443// |------------->| |
444// | | |
445// | | SubReq |
446// | |------------->|
447// | | |
448// | SubReq | |
449// | (retrans) | |
450// |------------->| |
451// | | |
452// | | SubResp |
453// | |<-------------|
454// | | |
455// | SubResp | |
456// |<-------------| |
457// | | |
458// | [SUBS DELETE] |
459// | | |
460//
461//-----------------------------------------------------------------------------
462func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200463 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200464
465 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200466 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200467 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200468
469 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200470 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200471 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
472
Juha Hyttinen1683f912020-04-17 10:39:57 +0300473 // hack as there is no real way to see has message be handled.
474 // Previuos counter check just tells that is has been received by submgr
475 // --> artificial delay
476 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200477 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200478 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200479
480 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200481 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200482 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
483 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200484 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200485
486 //Wait that subs is cleaned
487 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
488
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200489 xappConn1.TestMsgChanEmpty(t)
490 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200491 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200492 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200493}
494
495//-----------------------------------------------------------------------------
496// TestSubDelReqRetransmission
497//
498// stub stub
499// +-------+ +---------+ +---------+
500// | xapp | | submgr | | e2term |
501// +-------+ +---------+ +---------+
502// | | |
503// | [SUBS CREATE] |
504// | | |
505// | | |
506// | SubDelReq | |
507// |------------->| |
508// | | |
509// | | SubDelReq |
510// | |------------->|
511// | | |
512// | SubDelReq | |
513// | (same sub) | |
514// | (same xid) | |
515// |------------->| |
516// | | |
517// | | SubDelResp |
518// | |<-------------|
519// | | |
520// | SubDelResp | |
521// |<-------------| |
522//
523//-----------------------------------------------------------------------------
524func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200525 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200526
527 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200528 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200529 crereq, cremsg := e2termConn1.RecvSubsReq(t)
530 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200531 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200532
533 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200534 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200535 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200536
537 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200538 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200539 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
540
Juha Hyttinen1683f912020-04-17 10:39:57 +0300541 // hack as there is no real way to see has message be handled.
542 // Previuos counter check just tells that is has been received by submgr
543 // --> artificial delay
544 <-time.After(1 * time.Second)
545
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200546 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200547 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200548
549 //Wait that subs is cleaned
550 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
551
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200552 xappConn1.TestMsgChanEmpty(t)
553 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200554 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200555 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200556}
557
558//-----------------------------------------------------------------------------
559// TestSubDelReqCollision
560//
561// stub stub
562// +-------+ +---------+ +---------+
563// | xapp | | submgr | | e2term |
564// +-------+ +---------+ +---------+
565// | | |
566// | [SUBS CREATE] |
567// | | |
568// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200569// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200570// |------------->| |
571// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200572// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200573// | |------------->|
574// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200575// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200576// | (same sub) | |
577// | (diff xid) | |
578// |------------->| |
579// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200580// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200581// | |<-------------|
582// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200583// | SubDelResp 1 | |
584// |<-------------| |
585// | | |
586// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200587// |<-------------| |
588//
589//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200590
Juha Hyttinenfa015662020-01-24 10:05:18 +0200591func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200592 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200593
594 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200595 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200596 crereq, cremsg := e2termConn1.RecvSubsReq(t)
597 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200598 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200599
600 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200601 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200602 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200603
Juha Hyttinen3944a222020-01-24 11:51:46 +0200604 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200605 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200606 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
607 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200608 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
609
Juha Hyttinen1683f912020-04-17 10:39:57 +0300610 // hack as there is no real way to see has message be handled.
611 // Previuos counter check just tells that is has been received by submgr
612 // --> artificial delay
613 <-time.After(1 * time.Second)
614
Juha Hyttinen3944a222020-01-24 11:51:46 +0200615 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200616 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200617
618 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200619 xappConn1.RecvSubsDelResp(t, nil)
620 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200621
622 //Wait that subs is cleaned
623 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
624
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200625 xappConn1.TestMsgChanEmpty(t)
626 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200627 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200628 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200629}
630
631//-----------------------------------------------------------------------------
632// TestSubReqAndSubDelOkTwoParallel
633//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200634// stub stub stub
635// +-------+ +-------+ +---------+ +---------+
636// | xapp | | xapp | | submgr | | e2term |
637// +-------+ +-------+ +---------+ +---------+
638// | | | |
639// | | | |
640// | | | |
641// | | SubReq1 | |
642// | |------------->| |
643// | | | |
644// | | | SubReq1 |
645// | | |------------->|
646// | | | |
647// | SubReq2 | |
648// |------------------------>| |
649// | | | |
650// | | | SubReq2 |
651// | | |------------->|
652// | | | |
653// | | | SubResp1 |
654// | | |<-------------|
655// | | SubResp1 | |
656// | |<-------------| |
657// | | | |
658// | | | SubResp2 |
659// | | |<-------------|
660// | SubResp2 | |
661// |<------------------------| |
662// | | | |
663// | | [SUBS 1 DELETE] |
664// | | | |
665// | | [SUBS 2 DELETE] |
666// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200667//
668//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +0300669
Juha Hyttinenfa015662020-01-24 10:05:18 +0200670func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200671 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200672
673 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200674 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200675 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200676 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200677 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200678
679 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200680 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200681 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300682
683 rparams2.Req.EventTriggerDefinition.Data.Length = 1
684 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
685 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
686
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200687 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200688 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200689
690 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200691 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200692 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200693
694 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200695 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200696 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200697
698 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200699 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200700 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
701 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200702 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200703 //Wait that subs is cleaned
704 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
705
706 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200707 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200708 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
709 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200710 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200711 //Wait that subs is cleaned
712 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
713
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200714 xappConn1.TestMsgChanEmpty(t)
715 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200716 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200717 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200718}
719
720//-----------------------------------------------------------------------------
721// TestSameSubsDiffRan
722// Same subscription to different RANs
723//
724// stub stub
725// +-------+ +---------+ +---------+
726// | xapp | | submgr | | e2term |
727// +-------+ +---------+ +---------+
728// | | |
729// | | |
730// | | |
731// | SubReq(r1) | |
732// |------------->| |
733// | | |
734// | | SubReq(r1) |
735// | |------------->|
736// | | |
737// | | SubResp(r1) |
738// | |<-------------|
739// | | |
740// | SubResp(r1) | |
741// |<-------------| |
742// | | |
743// | SubReq(r2) | |
744// |------------->| |
745// | | |
746// | | SubReq(r2) |
747// | |------------->|
748// | | |
749// | | SubResp(r2) |
750// | |<-------------|
751// | | |
752// | SubResp(r2) | |
753// |<-------------| |
754// | | |
755// | [SUBS r1 DELETE] |
756// | | |
757// | [SUBS r2 DELETE] |
758// | | |
759//
760//-----------------------------------------------------------------------------
761func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200762 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200763
764 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200765 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
766 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200767 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
768 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200769 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200770
771 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200772 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
773 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200774 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
775 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200776 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200777
778 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200779 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
780 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200781 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
782 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200783 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200784 //Wait that subs is cleaned
785 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
786
787 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200788 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
789 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200790 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
791 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200792 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200793 //Wait that subs is cleaned
794 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
795
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200796 xappConn1.TestMsgChanEmpty(t)
797 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200798 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200799 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200800}
801
802//-----------------------------------------------------------------------------
803// TestSubReqRetryInSubmgr
804//
805// stub stub
806// +-------+ +---------+ +---------+
807// | xapp | | submgr | | e2term |
808// +-------+ +---------+ +---------+
809// | | |
810// | SubReq | |
811// |------------->| |
812// | | |
813// | | SubReq |
814// | |------------->|
815// | | |
816// | | |
817// | | SubReq |
818// | |------------->|
819// | | |
820// | | SubResp |
821// | |<-------------|
822// | | |
823// | SubResp | |
824// |<-------------| |
825// | | |
826// | [SUBS DELETE] |
827// | | |
828//
829//-----------------------------------------------------------------------------
830
831func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200832 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200833
834 // Init counter check
835 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
836 Counter{cSubReqFromXapp, 1},
837 Counter{cSubReqToE2, 1},
838 Counter{cSubReReqToE2, 1},
839 Counter{cSubRespFromE2, 1},
840 Counter{cSubRespToXapp, 1},
841 Counter{cSubDelReqFromXapp, 1},
842 Counter{cSubDelReqToE2, 1},
843 Counter{cSubDelRespFromE2, 1},
844 Counter{cSubDelRespToXapp, 1},
845 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200846
847 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200848 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200849
850 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200851 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200852
853 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200854 crereq, cremsg := e2termConn1.RecvSubsReq(t)
855 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200856
857 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200858 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200859
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200860 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200861 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
862 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200863 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200864
865 // Wait that subs is cleaned
866 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
867
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200868 xappConn1.TestMsgChanEmpty(t)
869 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200870 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200871 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200872
873 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200874}
875
876//-----------------------------------------------------------------------------
877// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
878//
879// stub stub
880// +-------+ +---------+ +---------+
881// | xapp | | submgr | | e2term |
882// +-------+ +---------+ +---------+
883// | | |
884// | SubReq | |
885// |------------->| |
886// | | |
887// | | SubReq |
888// | |------------->|
889// | | |
890// | | |
891// | | SubReq |
892// | |------------->|
893// | | |
894// | | SubDelReq |
895// | |------------->|
896// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200897// | | SubDelResp |
898// | |<-------------|
899// | | |
900//
901//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200902func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200903 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200904
905 // Init counter check
906 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
907 Counter{cSubReqFromXapp, 1},
908 Counter{cSubReqToE2, 1},
909 Counter{cSubReReqToE2, 1},
910 Counter{cSubReqTimerExpiry, 2},
911 Counter{cSubDelReqToE2, 1},
912 Counter{cSubDelRespFromE2, 1},
913 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200914
915 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200916 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200917
918 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200919 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200920
921 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200922 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200923
924 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200925 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
926 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200927
928 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300929 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200930
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200931 xappConn1.TestMsgChanEmpty(t)
932 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200933 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200934 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200935
936 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200937}
938
939//-----------------------------------------------------------------------------
940// TestSubReqTwoRetriesNoRespAtAllInSubmgr
941//
942// stub stub
943// +-------+ +---------+ +---------+
944// | xapp | | submgr | | e2term |
945// +-------+ +---------+ +---------+
946// | | |
947// | SubReq | |
948// |------------->| |
949// | | |
950// | | SubReq |
951// | |------------->|
952// | | |
953// | | |
954// | | SubReq |
955// | |------------->|
956// | | |
957// | | SubDelReq |
958// | |------------->|
959// | | |
960// | | |
961// | | SubDelReq |
962// | |------------->|
963// | | |
964// | | |
965//
966//-----------------------------------------------------------------------------
967
968func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200969 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200970
971 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
972 Counter{cSubReqFromXapp, 1},
973 Counter{cSubReqToE2, 1},
974 Counter{cSubReReqToE2, 1},
975 Counter{cSubReqTimerExpiry, 2},
976 Counter{cSubDelReqToE2, 1},
977 Counter{cSubDelReReqToE2, 1},
978 Counter{cSubDelReqTimerExpiry, 2},
979 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200980
981 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200982 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200983
984 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200985 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200986
987 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200988 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200989
990 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200991 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200992
993 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200994 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200995
996 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300997 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200998
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200999 xappConn1.TestMsgChanEmpty(t)
1000 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001001 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001002 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001003
1004 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001005}
1006
1007//-----------------------------------------------------------------------------
1008// TestSubReqSubFailRespInSubmgr
1009//
1010// stub stub
1011// +-------+ +---------+ +---------+
1012// | xapp | | submgr | | e2term |
1013// +-------+ +---------+ +---------+
1014// | | |
1015// | SubReq | |
1016// |------------->| |
1017// | | |
1018// | | SubReq |
1019// | |------------->|
1020// | | |
1021// | | SubFail |
1022// | |<-------------|
1023// | | |
archaggeafbf95f2021-04-14 08:54:05 +03001024// | | SubDelReq |
1025// | |------------->|
1026// | | |
1027// | | SubDelResp |
1028// | |<-------------|
1029// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001030// | SubFail | |
1031// |<-------------| |
1032// | | |
1033//
1034//-----------------------------------------------------------------------------
1035
1036func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001037 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001038
1039 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1040 Counter{cSubReqFromXapp, 1},
1041 Counter{cSubReqToE2, 1},
1042 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001043 Counter{cSubFailToXapp, 1},
1044 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001045
1046 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001047 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001048
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001049 // E2t: Receive SubsReq and send SubsFail (first)
1050 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1051 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1052 fparams1.Set(crereq1)
1053 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1054
archaggeafbf95f2021-04-14 08:54:05 +03001055 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1056 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1057 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1058
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001059 // Xapp: Receive SubsFail
1060 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1061
1062 // Wait that subs is cleaned
1063 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1064
1065 xappConn1.TestMsgChanEmpty(t)
1066 xappConn2.TestMsgChanEmpty(t)
1067 e2termConn1.TestMsgChanEmpty(t)
1068 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001069
1070 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001071}
1072
1073//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001074// TestSubDelReqRetryInSubmgr
1075//
1076// stub stub
1077// +-------+ +---------+ +---------+
1078// | xapp | | submgr | | e2term |
1079// +-------+ +---------+ +---------+
1080// | | |
1081// | [SUBS CREATE] |
1082// | | |
1083// | | |
1084// | SubDelReq | |
1085// |------------->| |
1086// | | |
1087// | | SubDelReq |
1088// | |------------->|
1089// | | |
1090// | | SubDelReq |
1091// | |------------->|
1092// | | |
1093// | | SubDelResp |
1094// | |<-------------|
1095// | | |
1096// | SubDelResp | |
1097// |<-------------| |
1098//
1099//-----------------------------------------------------------------------------
1100
1101func TestSubDelReqRetryInSubmgr(t *testing.T) {
1102
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001103 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001104
1105 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001106 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001107 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1108 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001109 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001110
1111 // Subs Delete
1112 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001113 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001114
1115 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001116 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001117
1118 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001119 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1120 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001121
1122 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001123 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001124
1125 // Wait that subs is cleaned
1126 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1127
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001128 xappConn1.TestMsgChanEmpty(t)
1129 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001130 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001131 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001132}
1133
1134//-----------------------------------------------------------------------------
1135// TestSubDelReqTwoRetriesNoRespInSubmgr
1136//
1137// stub stub
1138// +-------+ +---------+ +---------+
1139// | xapp | | submgr | | e2term |
1140// +-------+ +---------+ +---------+
1141// | | |
1142// | [SUBS CREATE] |
1143// | | |
1144// | | |
1145// | SubDelReq | |
1146// |------------->| |
1147// | | |
1148// | | SubDelReq |
1149// | |------------->|
1150// | | |
1151// | | SubDelReq |
1152// | |------------->|
1153// | | |
1154// | | |
1155// | SubDelResp | |
1156// |<-------------| |
1157//
1158//-----------------------------------------------------------------------------
1159
1160func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1161
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001162 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001163
1164 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001165 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001166 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1167 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001168 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001169
1170 // Subs Delete
1171 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001172 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001173
1174 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001175 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001176
1177 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001178 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001179
1180 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001181 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001182
1183 // Wait that subs is cleaned
1184 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1185
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001186 xappConn1.TestMsgChanEmpty(t)
1187 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001188 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001189 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001190}
1191
1192//-----------------------------------------------------------------------------
1193// TestSubDelReqSubDelFailRespInSubmgr
1194//
1195// stub stub
1196// +-------+ +---------+ +---------+
1197// | xapp | | submgr | | e2term |
1198// +-------+ +---------+ +---------+
1199// | | |
1200// | [SUBS CREATE] |
1201// | | |
1202// | | |
1203// | SubDelReq | |
1204// |------------->| |
1205// | | |
1206// | | SubDelReq |
1207// | |------------->|
1208// | | |
1209// | | SubDelFail |
1210// | |<-------------|
1211// | | |
1212// | SubDelResp | |
1213// |<-------------| |
1214// | | |
1215//
1216//-----------------------------------------------------------------------------
1217
1218func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001219 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001220
1221 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1222 Counter{cSubReqFromXapp, 1},
1223 Counter{cSubReqToE2, 1},
1224 Counter{cSubRespFromE2, 1},
1225 Counter{cSubRespToXapp, 1},
1226 Counter{cSubDelReqFromXapp, 1},
1227 Counter{cSubDelReqToE2, 1},
1228 Counter{cSubDelFailFromE2, 1},
1229 Counter{cSubDelRespToXapp, 1},
1230 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001231
1232 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001233 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001234 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1235 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001236 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001237
1238 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001239 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001240
1241 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001242 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1243 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001244
1245 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001246 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001247
1248 // Wait that subs is cleaned
1249 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1250
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001251 xappConn1.TestMsgChanEmpty(t)
1252 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001253 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001254 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001255
1256 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001257}
1258
1259//-----------------------------------------------------------------------------
1260// TestSubReqAndSubDelOkSameAction
1261//
1262// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001263// +-------+ +-------+ +---------+ +---------+
1264// | xapp2 | | xapp1 | | submgr | | e2term |
1265// +-------+ +-------+ +---------+ +---------+
1266// | | | |
1267// | | | |
1268// | | | |
1269// | | SubReq1 | |
1270// | |------------->| |
1271// | | | |
1272// | | | SubReq1 |
1273// | | |------------->|
1274// | | | SubResp1 |
1275// | | |<-------------|
1276// | | SubResp1 | |
1277// | |<-------------| |
1278// | | | |
1279// | SubReq2 | |
1280// |--------------------------->| |
1281// | | | |
1282// | SubResp2 | |
1283// |<---------------------------| |
1284// | | | |
1285// | | SubDelReq 1 | |
1286// | |------------->| |
1287// | | | |
1288// | | SubDelResp 1 | |
1289// | |<-------------| |
1290// | | | |
1291// | SubDelReq 2 | |
1292// |--------------------------->| |
1293// | | | |
1294// | | | SubDelReq 2 |
1295// | | |------------->|
1296// | | | |
1297// | | | SubDelReq 2 |
1298// | | |------------->|
1299// | | | |
1300// | SubDelResp 2 | |
1301// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001302//
1303//-----------------------------------------------------------------------------
1304func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001305 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001306
Anssi Mannila4abf1802021-01-28 13:06:46 +02001307 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001308 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1309 Counter{cSubReqFromXapp, 2},
1310 Counter{cSubReqToE2, 1},
1311 Counter{cSubRespFromE2, 1},
1312 Counter{cSubRespToXapp, 2},
1313 Counter{cMergedSubscriptions, 1},
1314 Counter{cUnmergedSubscriptions, 1},
1315 Counter{cSubDelReqFromXapp, 2},
1316 Counter{cSubDelReqToE2, 1},
1317 Counter{cSubDelRespFromE2, 1},
1318 Counter{cSubDelRespToXapp, 2},
1319 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001320
Juha Hyttinen3944a222020-01-24 11:51:46 +02001321 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001322 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001323 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001324 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001325 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1326 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001327 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001328
1329 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001330 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001331 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001332 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001333 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1334 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001335 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001336
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001337 resp, _ := xapp.Subscription.QuerySubscriptions()
1338 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1339 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001340 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001341
Juha Hyttinen3944a222020-01-24 11:51:46 +02001342 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001343 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001344 //e2termConn1.RecvSubsDelReq(t)
1345 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001346 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001347 //Wait that subs is cleaned
1348 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1349
1350 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001351 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001352 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1353 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001354 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001355 //Wait that subs is cleaned
1356 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1357
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001358 xappConn1.TestMsgChanEmpty(t)
1359 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001360 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001361 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001362
1363 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001364}
1365
1366//-----------------------------------------------------------------------------
1367// TestSubReqAndSubDelOkSameActionParallel
1368//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001369// stub stub stub
1370// +-------+ +-------+ +---------+ +---------+
1371// | xapp2 | | xapp1 | | submgr | | e2term |
1372// +-------+ +-------+ +---------+ +---------+
1373// | | | |
1374// | | | |
1375// | | | |
1376// | | SubReq1 | |
1377// | |------------->| |
1378// | | | |
1379// | | | SubReq1 |
1380// | | |------------->|
1381// | SubReq2 | |
1382// |--------------------------->| |
1383// | | | SubResp1 |
1384// | | |<-------------|
1385// | | SubResp1 | |
1386// | |<-------------| |
1387// | | | |
1388// | SubResp2 | |
1389// |<---------------------------| |
1390// | | | |
1391// | | SubDelReq 1 | |
1392// | |------------->| |
1393// | | | |
1394// | | SubDelResp 1 | |
1395// | |<-------------| |
1396// | | | |
1397// | SubDelReq 2 | |
1398// |--------------------------->| |
1399// | | | |
1400// | | | SubDelReq 2 |
1401// | | |------------->|
1402// | | | |
1403// | | | SubDelReq 2 |
1404// | | |------------->|
1405// | | | |
1406// | SubDelResp 2 | |
1407// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001408//
1409//-----------------------------------------------------------------------------
1410func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001411 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001412
1413 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001414 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001415 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001416 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001417 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001418
1419 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001420 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001421 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001422 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001423
1424 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001425 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001426 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001427
1428 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001429 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001430
1431 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001432 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1433 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001434
1435 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001436 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001437 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1438 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001439 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001440
1441 //Wait that subs is cleaned
1442 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1443
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001444 xappConn1.TestMsgChanEmpty(t)
1445 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001446 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001447 mainCtrl.wait_registry_empty(t, 10)
1448}
1449
1450//-----------------------------------------------------------------------------
1451// TestSubReqAndSubDelNokSameActionParallel
1452//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001453// stub stub stub
1454// +-------+ +-------+ +---------+ +---------+
1455// | xapp2 | | xapp1 | | submgr | | e2term |
1456// +-------+ +-------+ +---------+ +---------+
1457// | | | |
1458// | | | |
1459// | | | |
1460// | | SubReq1 | |
1461// | |------------->| |
1462// | | | |
1463// | | | SubReq1 |
1464// | | |------------->|
1465// | SubReq2 | |
1466// |--------------------------->| |
1467// | | | SubFail1 |
1468// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001469// | | | |
archaggeafbf95f2021-04-14 08:54:05 +03001470// | | | SubDelReq |
1471// | | |------------->|
1472// | | | SubDelResp |
1473// | | |<-------------|
1474// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001475// | | SubFail1 | |
1476// | |<-------------| |
1477// | | | |
1478// | SubFail2 | |
1479// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001480//
1481//-----------------------------------------------------------------------------
1482func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001483 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001484
1485 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001486 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001487 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001488 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001489
1490 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001491 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001492
1493 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001494 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001495 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001496 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001497 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001498 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001499
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001500 // E2t: send SubsFail (first)
1501 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1502 fparams1.Set(crereq1)
1503 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1504
archaggeafbf95f2021-04-14 08:54:05 +03001505 // E2t: internal delete
1506 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1507 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1508
Juha Hyttinen3944a222020-01-24 11:51:46 +02001509 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001510 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001511 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001512 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001513
1514 //Wait that subs is cleaned
1515 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1516
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001517 xappConn1.TestMsgChanEmpty(t)
1518 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001519 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001520 mainCtrl.wait_registry_empty(t, 10)
1521}
1522
1523//-----------------------------------------------------------------------------
1524// TestSubReqAndSubDelNoAnswerSameActionParallel
1525//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001526// stub stub stub
1527// +-------+ +-------+ +---------+ +---------+
1528// | xapp2 | | xapp1 | | submgr | | e2term |
1529// +-------+ +-------+ +---------+ +---------+
1530// | | | |
1531// | | | |
1532// | | | |
1533// | | SubReq1 | |
1534// | |------------->| |
1535// | | | |
1536// | | | SubReq1 |
1537// | | |------------->|
1538// | | SubReq2 | |
1539// |--------------------------->| |
1540// | | | |
1541// | | | SubReq1 |
1542// | | |------------->|
1543// | | | |
1544// | | | |
1545// | | | SubDelReq |
1546// | | |------------->|
1547// | | | |
1548// | | | SubDelResp |
1549// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001550//
1551//-----------------------------------------------------------------------------
1552func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001553 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001554
1555 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001556 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001557 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001558 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001559
Juha Hyttinen1683f912020-04-17 10:39:57 +03001560 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001561
1562 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001563 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001564 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001565 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001566 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001567 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001568
1569 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001570 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001571
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001572 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1573 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001574
1575 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001576 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001577
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001578 xappConn1.TestMsgChanEmpty(t)
1579 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001580 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001581 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001582}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001583
1584//----------------------------- Policy cases ---------------------------------
1585//-----------------------------------------------------------------------------
1586// TestSubReqPolicyAndSubDelOk
1587//
1588// stub stub
1589// +-------+ +---------+ +---------+
1590// | xapp | | submgr | | e2term |
1591// +-------+ +---------+ +---------+
1592// | | |
1593// | SubReq | |
1594// |------------->| |
1595// | | |
1596// | | SubReq |
1597// | |------------->|
1598// | | |
1599// | | SubResp |
1600// | |<-------------|
1601// | | |
1602// | SubResp | |
1603// |<-------------| |
1604// | | |
1605// | | |
1606// | SubDelReq | |
1607// |------------->| |
1608// | | |
1609// | | SubDelReq |
1610// | |------------->|
1611// | | |
1612// | | SubDelResp |
1613// | |<-------------|
1614// | | |
1615// | SubDelResp | |
1616// |<-------------| |
1617//
1618//-----------------------------------------------------------------------------
1619func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1620 CaseBegin("TestSubReqAndSubDelOk")
1621
1622 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1623 rparams1.Init()
1624 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1625 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1626
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001627 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1628 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001629 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1630 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001631 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001632
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001633 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001634 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001635
1636 //Wait that subs is cleaned
1637 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1638
1639 xappConn1.TestMsgChanEmpty(t)
1640 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001641 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001642 mainCtrl.wait_registry_empty(t, 10)
1643}
1644
1645//-----------------------------------------------------------------------------
1646// TestSubReqPolicyChangeAndSubDelOk
1647//
1648// stub stub
1649// +-------+ +---------+ +---------+
1650// | xapp | | submgr | | e2term |
1651// +-------+ +---------+ +---------+
1652// | | |
1653// | SubReq | |
1654// |------------->| |
1655// | | |
1656// | | SubReq |
1657// | |------------->|
1658// | | |
1659// | | SubResp |
1660// | |<-------------|
1661// | | |
1662// | SubResp | |
1663// |<-------------| |
1664// | | |
1665// | SubReq | |
1666// |------------->| |
1667// | | |
1668// | | SubReq |
1669// | |------------->|
1670// | | |
1671// | | SubResp |
1672// | |<-------------|
1673// | | |
1674// | SubResp | |
1675// |<-------------| |
1676// | | |
1677// | SubDelReq | |
1678// |------------->| |
1679// | | |
1680// | | SubDelReq |
1681// | |------------->|
1682// | | |
1683// | | SubDelResp |
1684// | |<-------------|
1685// | | |
1686// | SubDelResp | |
1687// |<-------------| |
1688//
1689//-----------------------------------------------------------------------------
1690
1691func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1692 CaseBegin("TestSubReqAndSubDelOk")
1693
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001694 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1695 rparams1.Init()
1696 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1697 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001698
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001699 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1700 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001701 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1702
1703 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001704 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001705 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1706 xappConn1.SendSubsReq(t, rparams1, cretrans)
1707
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001708 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1709 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001710 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1711 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001712 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001713
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001714 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001715 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001716
1717 //Wait that subs is cleaned
1718 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1719
1720 xappConn1.TestMsgChanEmpty(t)
1721 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001722 e2termConn1.TestMsgChanEmpty(t)
1723 mainCtrl.wait_registry_empty(t, 10)
1724}
1725
1726//-----------------------------------------------------------------------------
1727// TestSubReqAndSubDelOkTwoE2termParallel
1728//
1729// stub stub stub
1730// +-------+ +---------+ +---------+ +---------+
1731// | xapp | | submgr | | e2term1 | | e2term2 |
1732// +-------+ +---------+ +---------+ +---------+
1733// | | | |
1734// | | | |
1735// | | | |
1736// | SubReq1 | | |
1737// |------------->| | |
1738// | | | |
1739// | | SubReq1 | |
1740// | |------------->| |
1741// | | | |
1742// | SubReq2 | | |
1743// |------------->| | |
1744// | | | |
1745// | | SubReq2 | |
1746// | |---------------------------->|
1747// | | | |
1748// | | SubResp1 | |
1749// | |<-------------| |
1750// | SubResp1 | | |
1751// |<-------------| | |
1752// | | SubResp2 | |
1753// | |<----------------------------|
1754// | SubResp2 | | |
1755// |<-------------| | |
1756// | | | |
1757// | [SUBS 1 DELETE] | |
1758// | | | |
1759// | [SUBS 2 DELETE] | |
1760// | | | |
1761//
1762//-----------------------------------------------------------------------------
1763func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1764 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1765
1766 //Req1
1767 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1768 xappConn1.SendSubsReq(t, nil, cretrans1)
1769 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1770
1771 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1772 xappConn1.SendSubsReq(t, nil, cretrans2)
1773 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1774
1775 //Resp1
1776 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1777 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1778
1779 //Resp2
1780 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1781 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1782
1783 //Del1
1784 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1785 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1786 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1787 xappConn1.RecvSubsDelResp(t, deltrans1)
1788 //Wait that subs is cleaned
1789 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1790
1791 //Del2
1792 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1793 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1794 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1795 xappConn1.RecvSubsDelResp(t, deltrans2)
1796 //Wait that subs is cleaned
1797 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1798
1799 xappConn1.TestMsgChanEmpty(t)
1800 xappConn2.TestMsgChanEmpty(t)
1801 e2termConn1.TestMsgChanEmpty(t)
1802 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001803 mainCtrl.wait_registry_empty(t, 10)
1804}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001805
1806//-----------------------------------------------------------------------------
1807// TestSubReqInsertAndSubDelOk
1808//
1809// stub stub
1810// +-------+ +---------+ +---------+
1811// | xapp | | submgr | | e2term |
1812// +-------+ +---------+ +---------+
1813// | | |
1814// | SubReq | |
1815// |------------->| |
1816// | | |
1817// | | SubReq |
1818// | |------------->|
1819// | | |
1820// | | SubResp |
1821// | |<-------------|
1822// | | |
1823// | SubResp | |
1824// |<-------------| |
1825// | | |
1826// | | |
1827// | SubDelReq | |
1828// |------------->| |
1829// | | |
1830// | | SubDelReq |
1831// | |------------->|
1832// | | |
1833// | | SubDelResp |
1834// | |<-------------|
1835// | | |
1836// | SubDelResp | |
1837// |<-------------| |
1838//
1839//-----------------------------------------------------------------------------
1840func TestSubReqInsertAndSubDelOk(t *testing.T) {
1841 CaseBegin("TestInsertSubReqAndSubDelOk")
1842
1843 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1844 rparams1.Init()
1845 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1846 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1847
1848 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1849 e2termConn1.SendSubsResp(t, crereq, cremsg)
1850 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1851 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1852 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1853
1854 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1855 xappConn1.RecvSubsDelResp(t, deltrans)
1856
1857 //Wait that subs is cleaned
1858 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1859
1860 xappConn1.TestMsgChanEmpty(t)
1861 xappConn2.TestMsgChanEmpty(t)
1862 e2termConn1.TestMsgChanEmpty(t)
1863 mainCtrl.wait_registry_empty(t, 10)
1864}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02001865
1866//-----------------------------------------------------------------------------
1867// TestSubReqRetransmissionWithSameSubIdDiffXid
1868//
1869// This case simulates case where xApp restarts and starts sending same
1870// subscription requests which have already subscribed successfully
1871
1872// stub stub
1873// +-------+ +---------+ +---------+
1874// | xapp | | submgr | | e2term |
1875// +-------+ +---------+ +---------+
1876// | | |
1877// | SubReq | |
1878// |------------->| |
1879// | | |
1880// | | SubReq |
1881// | |------------->|
1882// | | |
1883// | | SubResp |
1884// | |<-------------|
1885// | | |
1886// | SubResp | |
1887// |<-------------| |
1888// | | |
1889// | xApp restart | |
1890// | | |
1891// | SubReq | |
1892// | (retrans with same xApp generated subid but diff xid)
1893// |------------->| |
1894// | | |
1895// | SubResp | |
1896// |<-------------| |
1897// | | |
1898// | [SUBS DELETE] |
1899// | | |
1900//
1901//-----------------------------------------------------------------------------
1902func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
1903 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
1904
1905 //Subs Create
1906 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1907 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1908 e2termConn1.SendSubsResp(t, crereq, cremsg)
1909 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1910
1911 // xApp restart here
1912 // --> artificial delay
1913 <-time.After(1 * time.Second)
1914
1915 //Subs Create
1916 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
1917 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1918
1919 //Subs Delete
1920 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1921 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1922 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1923 xappConn1.RecvSubsDelResp(t, deltrans)
1924
1925 //Wait that subs is cleaned
1926 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1927
1928 xappConn1.TestMsgChanEmpty(t)
1929 xappConn2.TestMsgChanEmpty(t)
1930 e2termConn1.TestMsgChanEmpty(t)
1931 mainCtrl.wait_registry_empty(t, 10)
1932}
Anssi Mannilac92b4212020-12-07 14:59:34 +02001933
1934//-----------------------------------------------------------------------------
1935// TestSubReqNokAndSubDelOkWithRestartInMiddle
1936//
1937// stub stub
1938// +-------+ +---------+ +---------+
1939// | xapp | | submgr | | e2term |
1940// +-------+ +---------+ +---------+
1941// | | |
1942// | SubReq | |
1943// |------------->| |
1944// | | |
1945// | | SubReq |
1946// | |------------->|
1947// | | |
1948// | | SubResp |
1949// | <----|
1950// | |
1951// | Submgr restart |
1952// | |
1953// | | |
1954// | | SubDelReq |
1955// | |------------->|
1956// | | |
1957// | | SubDelResp |
1958// | |<-------------|
1959// | | |
1960//
1961//-----------------------------------------------------------------------------
1962
1963func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
1964 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
1965
1966 // Remove possible existing subscrition
1967 mainCtrl.removeExistingSubscriptions(t)
1968
1969 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
1970 xappConn1.SendSubsReq(t, nil, nil)
1971 e2termConn1.RecvSubsReq(t)
1972 mainCtrl.SetResetTestFlag(t, false)
1973
1974 resp, _ := xapp.Subscription.QuerySubscriptions()
1975 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001976 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02001977 e2SubsId := uint32(resp[0].SubscriptionID)
1978 t.Logf("e2SubsId = %v", e2SubsId)
1979
archaggeafbf95f2021-04-14 08:54:05 +03001980 mainCtrl.SimulateRestart(t)
1981 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02001982
1983 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1984 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1985
1986 // Wait that subs is cleaned
1987 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1988
1989 xappConn1.TestMsgChanEmpty(t)
1990 xappConn2.TestMsgChanEmpty(t)
1991 e2termConn1.TestMsgChanEmpty(t)
1992 mainCtrl.wait_registry_empty(t, 10)
1993}
1994
1995//-----------------------------------------------------------------------------
1996// TestSubReqAndSubDelOkWithRestartInMiddle
1997//
1998// stub stub
1999// +-------+ +---------+ +---------+
2000// | xapp | | submgr | | e2term |
2001// +-------+ +---------+ +---------+
2002// | | |
2003// | SubReq | |
2004// |------------->| |
2005// | | |
2006// | | SubReq |
2007// | |------------->|
2008// | | |
2009// | | SubResp |
2010// | |<-------------|
2011// | | |
2012// | SubResp | |
2013// |<-------------| |
2014// | | |
2015// | |
2016// | Submgr restart |
2017// | |
2018// | SubDelReq | |
2019// |------------->| |
2020// | | |
2021// | | SubDelReq |
2022// | |------------->|
2023// | | |
2024// | | SubDelResp |
2025// | |<-------------|
2026// | | |
2027// | SubDelResp | |
2028// |<-------------| |
2029//
2030//-----------------------------------------------------------------------------
2031
2032func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2033 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2034
2035 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2036 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2037 e2termConn1.SendSubsResp(t, crereq, cremsg)
2038 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2039
2040 // Check subscription
2041 resp, _ := xapp.Subscription.QuerySubscriptions()
2042 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2043 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002044 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002045
2046 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002047 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002048
2049 // Check that subscription is restored correctly after restart
2050 resp, _ = xapp.Subscription.QuerySubscriptions()
2051 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2052 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002053 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002054
2055 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2056 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2057 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2058 xappConn1.RecvSubsDelResp(t, deltrans)
2059
2060 //Wait that subs is cleaned
2061 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2062
2063 xappConn1.TestMsgChanEmpty(t)
2064 xappConn2.TestMsgChanEmpty(t)
2065 e2termConn1.TestMsgChanEmpty(t)
2066 mainCtrl.wait_registry_empty(t, 10)
2067}
2068
2069//-----------------------------------------------------------------------------
2070// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2071//
2072// stub stub
2073// +-------+ +-------+ +---------+ +---------+
2074// | xapp2 | | xapp1 | | submgr | | e2term |
2075// +-------+ +-------+ +---------+ +---------+
2076// | | | |
2077// | | | |
2078// | | | |
2079// | | SubReq1 | |
2080// | |------------->| |
2081// | | | |
2082// | | | SubReq1 |
2083// | | |------------->|
2084// | | | SubResp1 |
2085// | | |<-------------|
2086// | | SubResp1 | |
2087// | |<-------------| |
2088// | | | |
2089// | |
2090// | submgr restart |
2091// | |
2092// | | | |
2093// | | | |
2094// | SubReq2 | |
2095// |--------------------------->| |
2096// | | | |
2097// | SubResp2 | |
2098// |<---------------------------| |
2099// | | | |
2100// | | SubDelReq 1 | |
2101// | |------------->| |
2102// | | | |
2103// | | SubDelResp 1 | |
2104// | |<-------------| |
2105// | | | |
2106// | | | |
2107// | |
2108// | submgr restart |
2109// | |
2110// | | | |
2111// | SubDelReq 2 | |
2112// |--------------------------->| |
2113// | | | |
2114// | | | SubDelReq 2 |
2115// | | |------------->|
2116// | | | |
2117// | | | SubDelReq 2 |
2118// | | |------------->|
2119// | | | |
2120// | SubDelResp 2 | |
2121// |<---------------------------| |
2122//
2123//-----------------------------------------------------------------------------
2124
2125func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2126 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2127
2128 //Req1
2129 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2130 rparams1.Init()
2131 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2132 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2133 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2134 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2135
2136 //Req2
2137 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2138 rparams2.Init()
2139 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2140 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2141
2142 // Check subscription
2143 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2144 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2145 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002146 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002147
2148 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002149 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002150
2151 // Check that subscription is restored correctly after restart
2152 resp, _ = xapp.Subscription.QuerySubscriptions()
2153 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2154 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002155 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002156
2157 //Del1
2158 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2159 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2160 xappConn1.RecvSubsDelResp(t, deltrans1)
2161 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2162
2163 mainCtrl.SimulateRestart(t)
2164 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2165
2166 //Del2
2167 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2168 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2169
2170 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2171 xappConn2.RecvSubsDelResp(t, deltrans2)
2172
2173 //Wait that subs is cleaned
2174 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2175
2176 xappConn1.TestMsgChanEmpty(t)
2177 xappConn2.TestMsgChanEmpty(t)
2178 e2termConn1.TestMsgChanEmpty(t)
2179 mainCtrl.wait_registry_empty(t, 10)
2180}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002181
archaggeafbf95f2021-04-14 08:54:05 +03002182//*****************************************************************************
2183// REST interface test cases
2184//*****************************************************************************
2185
Anssi Mannila47518ae2021-04-16 09:27:07 +03002186//-----------------------------------------------------------------------------
2187// Test debug GET and POST requests
2188//
2189// curl
2190// +-------+ +---------+
2191// | user | | submgr |
2192// +-------+ +---------+
2193// | |
2194// | GET/POST Req |
2195// |------------->|
2196// | Resp |
2197// |<-------------|
2198// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002199func TestGetSubscriptions(t *testing.T) {
2200
2201 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2202}
2203
2204func TestGetSymptomData(t *testing.T) {
2205
2206 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2207}
2208
2209func TestPostdeleteSubId(t *testing.T) {
2210
2211 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2212}
2213
2214func TestPostEmptyDb(t *testing.T) {
2215
2216 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2217}
archaggeafbf95f2021-04-14 08:54:05 +03002218
2219//-----------------------------------------------------------------------------
2220// TestRESTSubReqAndRouteNok
2221//
2222// stub stub
2223// +-------+ +---------+ +---------+
2224// | xapp | | submgr | | rtmgr |
2225// +-------+ +---------+ +---------+
2226// | | |
2227// | RESTSubReq | |
2228// |---------------->| |
2229// | | |
2230// | RESTSubResp | |
2231// |<----------------| |
2232// | | RouteCreate |
2233// | |------------->|
2234// | | |
2235// | | RouteCreate |
2236// | | status:400 |
2237// | |(Bad request) |
2238// | |<-------------|
2239// | RESTNotif | |
2240// |<----------------| |
2241// | | |
2242// | [SUBS INT DELETE] |
2243// | | |
2244// | RESTSubDelReq | |
2245// |---------------->| |
2246// | RESTSubDelResp | |
2247// |<----------------| |
2248//
2249//-----------------------------------------------------------------------------
2250func TestRESTSubReqAndRouteNok(t *testing.T) {
2251 CaseBegin("TestRESTSubReqAndRouteNok")
2252
2253 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2254 Counter{cSubReqFromXapp, 1},
2255 Counter{cRouteCreateFail, 1},
2256 Counter{cSubRespToXapp, 1},
2257 Counter{cSubDelReqFromXapp, 1},
2258 Counter{cSubDelRespToXapp, 1},
2259 })
2260
2261 const subReqCount int = 1
Markku Virtanenda34eec2021-05-20 08:22:04 +00002262 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2263 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002264 newSubsId := mainCtrl.get_registry_next_subid(t)
2265
2266 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002267 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002268 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenda34eec2021-05-20 08:22:04 +00002269 xappConn1.ExpectRESTNotification(t, restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002270 waiter.WaitResult(t)
2271
archaggeafbf95f2021-04-14 08:54:05 +03002272 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2273 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2274
2275 // Del
2276 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2277
2278 // Wait that subs is cleaned
2279 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2280 waitSubsCleanup(t, e2SubsId, 10)
2281 mainCtrl.VerifyCounterValues(t)
2282}
2283
2284func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2285 CaseBegin("TestSubReqAndRouteUpdateNok")
2286
2287 //Init counter check
2288 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2289 Counter{cSubReqFromXapp, 2},
2290 Counter{cSubReqToE2, 1},
2291 Counter{cSubRespFromE2, 1},
2292 Counter{cSubRespToXapp, 2},
2293 Counter{cRouteCreateUpdateFail, 1},
2294 Counter{cSubDelReqFromXapp, 1},
2295 Counter{cSubDelReqToE2, 1},
2296 Counter{cSubDelRespFromE2, 1},
2297 Counter{cSubDelRespToXapp, 1},
2298 })
2299
2300 var params *teststube2ap.RESTSubsReqParams = nil
2301
2302 //Subs Create
2303 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2304
2305 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2306
2307 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2308 waiter := rtmgrHttp.AllocNextEvent(false)
2309 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002310 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002311 params.SetMeid("RAN_NAME_1")
2312 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2313 xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
2314 xappConn2.ExpectRESTNotification(t, restSubId2)
2315 waiter.WaitResult(t)
2316 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2317 xappConn2.WaitRESTNotification(t, restSubId2)
2318
2319 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2320
2321 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2322
2323 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2324 //Wait that subs is cleaned
2325 waitSubsCleanup(t, e2SubsId, 10)
2326
2327 mainCtrl.VerifyCounterValues(t)
2328}
2329
2330func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2331 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2332
2333 // Init counter check
2334 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2335 Counter{cSubReqFromXapp, 1},
2336 Counter{cSubReqToE2, 1},
2337 Counter{cSubRespFromE2, 1},
2338 Counter{cSubRespToXapp, 1},
2339 Counter{cSubDelReqFromXapp, 1},
2340 Counter{cRouteDeleteFail, 1},
2341 Counter{cSubDelReqToE2, 1},
2342 Counter{cSubDelRespFromE2, 1},
2343 Counter{cSubDelRespToXapp, 1},
2344 })
2345
2346 var params *teststube2ap.RESTSubsReqParams = nil
2347
2348 //Subs Create
2349 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2350
2351 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2352
2353 waiter := rtmgrHttp.AllocNextEvent(false)
2354 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2355 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2356 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2357 waiter.WaitResult(t)
2358
2359 waitSubsCleanup(t, e2SubsId, 10)
2360
2361 mainCtrl.VerifyCounterValues(t)
2362}
2363
2364func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2365 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2366
2367 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2368 Counter{cSubReqFromXapp, 2},
2369 Counter{cSubReqToE2, 1},
2370 Counter{cSubRespFromE2, 1},
2371 Counter{cSubRespToXapp, 2},
2372 Counter{cSubDelReqFromXapp, 2},
2373 Counter{cRouteDeleteUpdateFail, 1},
2374 Counter{cSubDelReqToE2, 1},
2375 Counter{cSubDelRespFromE2, 1},
2376 Counter{cSubDelRespToXapp, 2},
2377 })
2378
2379 var params *teststube2ap.RESTSubsReqParams = nil
2380
2381 //Subs Create
2382 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2383
2384 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2385 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2386
2387 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2388
2389 //Del1, this shall fail on rtmgr side
2390 waiter := rtmgrHttp.AllocNextEvent(false)
2391 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2392 waiter.WaitResult(t)
2393
2394 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2395
2396 //Del2
2397 deleteXapp2Subscription(t, &restSubId2)
2398
2399 waitSubsCleanup(t, e2SubsId2, 10)
2400
2401 mainCtrl.VerifyCounterValues(t)
2402}
2403
2404//-----------------------------------------------------------------------------
2405// TestRESTSubReqRetransmission
2406//
2407// stub stub
2408// +-------+ +---------+ +---------+
2409// | xapp | | submgr | | e2term |
2410// +-------+ +---------+ +---------+
2411// | | |
2412// | RESTSubReq1 | |
2413// |---------------->| |
2414// | | |
2415// | RESTSubResp | |
2416// |<----------------| |
2417// | | SubReq1 |
2418// | |------------->|
2419// | | |
2420// | RESTSubReq2 | |
2421// | (retrans) | |
2422// |---------------->| |
2423// | | |
2424// | | SubReq2 |
2425// | |------------->|
2426// | RESTSubResp2 | |
2427// |<----------------| |
2428// | | SubResp1 |
2429// | |<-------------|
2430// | RESTNotif1 | |
2431// |<----------------| |
2432// | | SubResp1 |
2433// | |<-------------|
2434// | RESTNotif2 | |
2435// |<----------------| |
2436// | | |
2437// | [SUBS DELETE] |
2438// | | |
2439//
2440//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002441
archaggeafbf95f2021-04-14 08:54:05 +03002442func TestRESTSubReqRetransmission(t *testing.T) {
2443 CaseBegin("TestRESTSubReqRetransmission")
2444
2445 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2446 Counter{cSubReqFromXapp, 2},
2447 Counter{cSubReqToE2, 2},
2448 Counter{cSubRespFromE2, 2},
2449 Counter{cSubRespToXapp, 2},
2450 Counter{cSubDelReqFromXapp, 2},
2451 Counter{cSubDelReqToE2, 2},
2452 Counter{cSubDelRespFromE2, 2},
2453 Counter{cSubDelRespToXapp, 2},
2454 })
2455 // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests
2456 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2457 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2458
2459 // Subs Create
2460 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002461
2462 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2463 // gets into execution before the rtmgrg responds for the first one.
2464 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002465 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002466 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2467 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2468
2469 waiter.WaitResult(t)
2470
2471 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2472
2473 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2474 // the order is not significant he6re.
2475 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2476 e2termConn1.SendSubsResp(t, crereq, cremsg)
2477 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2478 e2termConn1.SendSubsResp(t, crereq, cremsg)
2479
2480 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2481 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2482 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2483 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2484
2485 // Del1
2486 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2487 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2488 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2489
archaggeafbf95f2021-04-14 08:54:05 +03002490 // Del2
2491 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
2492 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2493 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2494
Markku Virtanenda34eec2021-05-20 08:22:04 +00002495 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
2496
archaggeafbf95f2021-04-14 08:54:05 +03002497 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2498
2499 mainCtrl.VerifyCounterValues(t)
2500}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002501
archaggeafbf95f2021-04-14 08:54:05 +03002502func TestRESTSubDelReqRetransmission(t *testing.T) {
2503 CaseBegin("TestRESTSubDelReqRetransmission")
2504
2505 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2506 Counter{cSubReqFromXapp, 1},
2507 Counter{cSubReqToE2, 1},
2508 Counter{cSubRespFromE2, 1},
2509 Counter{cSubRespToXapp, 1},
2510 Counter{cSubDelReqFromXapp, 2},
2511 Counter{cSubDelReqToE2, 1},
2512 Counter{cSubDelRespFromE2, 1},
2513 Counter{cSubDelRespToXapp, 1},
2514 })
2515
2516 var params *teststube2ap.RESTSubsReqParams = nil
2517
2518 //Subs Create
2519 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2520
2521 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2522
2523 //Subs Delete
2524 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2525 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2526
2527 seqBef := mainCtrl.get_msgcounter(t)
2528 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2529 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
2530
2531 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2532
2533 waitSubsCleanup(t, e2SubsId, 10)
2534
2535 mainCtrl.VerifyCounterValues(t)
2536}
2537
2538//-----------------------------------------------------------------------------
2539// TestRESTSubReqDelReq
2540//
2541// stub stub
2542// +-------+ +---------+ +---------+
2543// | xapp | | submgr | | e2term |
2544// +-------+ +---------+ +---------+
2545// | | |
2546// | RESTSubReq | |
2547// |---------------->| |
2548// | | |
2549// | RESTSubResp | |
2550// |<----------------| |
2551// | | SubReq |
2552// | |------------->|
2553// | RESTSubDelReq | |
2554// |---------------->| |
2555// | RESTSubDelResp | |
2556// | unsuccess | |
2557// |<----------------| |
2558// | | SubResp |
2559// | |<-------------|
2560// | RESTNotif1 | |
2561// |<----------------| |
2562// | | |
2563// | [SUBS DELETE] |
2564// | | |
2565//
2566//-----------------------------------------------------------------------------
2567func TestRESTSubReqDelReq(t *testing.T) {
2568 CaseBegin("TestRESTSubReqDelReq")
2569
2570 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2571 Counter{cSubReqFromXapp, 1},
2572 Counter{cSubReqToE2, 1},
2573 Counter{cSubRespFromE2, 1},
2574 Counter{cSubRespToXapp, 1},
2575 Counter{cSubDelReqFromXapp, 2},
2576 Counter{cSubDelReqToE2, 1},
2577 Counter{cSubDelRespFromE2, 1},
2578 Counter{cSubDelRespToXapp, 1},
2579 })
2580
2581 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002582
2583 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002584 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002585 restSubId := xappConn1.SendRESTSubsReq(t, params)
2586
2587 // Del. This will fail as processing of the subscription
2588 // is still ongoing in submgr. Deletion is not allowed before
2589 // subscription creation has been completed.
2590 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2591 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2592 xappConn1.ExpectRESTNotification(t, restSubId)
2593 e2termConn1.SendSubsResp(t, crereq, cremsg)
2594 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2595
2596 // Retry del
2597 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2598
2599 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2600 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2601
2602 // Wait that subs is cleaned
2603 waitSubsCleanup(t, e2SubsId, 10)
2604 mainCtrl.VerifyCounterValues(t)
2605
2606}
2607
2608func TestRESTSubDelReqCollision(t *testing.T) {
2609 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
2610}
2611
2612func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
2613 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
2614
2615 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2616 Counter{cSubReqFromXapp, 2},
2617 Counter{cSubReqToE2, 2},
2618 Counter{cSubRespFromE2, 2},
2619 Counter{cSubRespToXapp, 2},
2620 Counter{cSubDelReqFromXapp, 2},
2621 Counter{cSubDelReqToE2, 2},
2622 Counter{cSubDelRespFromE2, 2},
2623 Counter{cSubDelRespToXapp, 2},
2624 })
2625
2626 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002627 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002628 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2629 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2630
2631 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002632 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002633 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2634 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2635
2636 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2637 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2638
2639 //XappConn1 receives both of the responses
2640 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2641
2642 //Resp1
2643 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2644 //Resp2
2645 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2646
2647 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2648 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2649 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2650 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2651
2652 //Del1
2653 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2654 //Del2
2655 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
2656
2657 //Wait that subs is cleaned
2658 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
2659 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2660
2661 mainCtrl.VerifyCounterValues(t)
2662
2663}
2664
2665func TestRESTSameSubsDiffRan(t *testing.T) {
2666 CaseBegin("TestRESTSameSubsDiffRan")
2667
2668 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2669 Counter{cSubReqFromXapp, 2},
2670 Counter{cSubReqToE2, 2},
2671 Counter{cSubRespFromE2, 2},
2672 Counter{cSubRespToXapp, 2},
2673 Counter{cSubDelReqFromXapp, 2},
2674 Counter{cSubDelReqToE2, 2},
2675 Counter{cSubDelRespFromE2, 2},
2676 Counter{cSubDelRespToXapp, 2},
2677 })
2678
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002679 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002680 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
2681 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2682
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002683 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002684 params.SetMeid("RAN_NAME_2")
2685 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
2686 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2687
2688 //Del1
2689 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2690 //Del2
2691 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
2692
2693 //Wait that subs is cleaned
2694 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2695 waitSubsCleanup(t, e2SubsId2, 10)
2696
2697 mainCtrl.VerifyCounterValues(t)
2698
2699}
2700
2701func TestRESTSubReqRetryInSubmgr(t *testing.T) {
2702 CaseBegin("TestRESTSubReqRetryInSubmgr start")
2703
2704 // Init counter check
2705 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2706 Counter{cSubReqFromXapp, 1},
2707 Counter{cSubReqToE2, 1},
2708 Counter{cSubReReqToE2, 1},
2709 Counter{cSubRespFromE2, 1},
2710 Counter{cSubRespToXapp, 1},
2711 Counter{cSubDelReqFromXapp, 1},
2712 Counter{cSubDelReqToE2, 1},
2713 Counter{cSubDelRespFromE2, 1},
2714 Counter{cSubDelRespToXapp, 1},
2715 })
2716
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002717 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002718 restSubId := xappConn1.SendRESTSubsReq(t, params)
2719
2720 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2721
2722 // Catch the first message and ignore it
2723 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2724 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
2725
2726 // The second request is being handled normally
2727 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2728 xappConn1.ExpectRESTNotification(t, restSubId)
2729 e2termConn1.SendSubsResp(t, crereq, cremsg)
2730 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2731
2732 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2733
2734 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2735
2736 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2737 //Wait that subs is cleaned
2738 waitSubsCleanup(t, e2SubsId, 10)
2739
2740 mainCtrl.VerifyCounterValues(t)
2741
2742}
2743
2744//-----------------------------------------------------------------------------
2745// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2746//
2747// stub stub
2748// +-------+ +---------+ +---------+
2749// | xapp | | submgr | | e2term |
2750// +-------+ +---------+ +---------+
2751// | | |
2752// | RESTSubReq | |
2753// |---------------->| |
2754// | | |
2755// | RESTSubResp | |
2756// |<----------------| |
2757// | | SubReq |
2758// | |------------->|
2759// | | |
2760// | | |
2761// | | SubReq |
2762// | |------------->|
2763// | | |
2764// | | SubDelReq |
2765// | |------------->|
2766// | | |
2767// | | |
2768// | | SubDelReq |
2769// | |------------->|
2770// | | |
2771// | | |
2772// | | SubDelResp |
2773// | |<-------------|
2774// | RESTNotif | |
2775// | unsuccess | |
2776// |<----------------| |
2777// | | |
2778// | [SUBS DELETE] |
2779// | | |
2780//
2781//-----------------------------------------------------------------------------
2782func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
2783 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
2784
2785 // Init counter check
2786 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2787 Counter{cSubReqFromXapp, 1},
2788 Counter{cSubReqToE2, 1},
2789 Counter{cSubReReqToE2, 1},
2790 Counter{cSubReqTimerExpiry, 2},
2791 Counter{cSubDelReqToE2, 1},
2792 Counter{cSubDelRespFromE2, 1},
2793 })
2794
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002795 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002796 restSubId := xappConn1.SendRESTSubsReq(t, params)
2797 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2798
2799 e2termConn1.RecvSubsReq(t)
2800 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2801
2802 e2termConn1.RecvSubsReq(t)
2803 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2804
2805 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2806 xappConn1.ExpectRESTNotification(t, restSubId)
2807 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2808 // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - TODO: Should we delete this?
2809 xappConn1.WaitRESTNotification(t, restSubId)
2810
2811 // Wait that subs is cleaned
2812 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
2813
2814 mainCtrl.VerifyCounterValues(t)
2815}
2816
2817func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
2818 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
2819
2820 // Init counter check
2821 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2822 Counter{cSubReqFromXapp, 1},
2823 Counter{cSubReqToE2, 1},
2824 Counter{cSubReReqToE2, 1},
2825 Counter{cSubReqTimerExpiry, 2},
2826 Counter{cSubDelReqToE2, 1},
2827 Counter{cSubDelReqTimerExpiry, 2},
2828 })
2829
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002830 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002831 restSubId := xappConn1.SendRESTSubsReq(t, params)
2832 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2833
2834 e2termConn1.RecvSubsReq(t)
2835 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2836
2837 e2termConn1.RecvSubsReq(t)
2838 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2839
2840 e2termConn1.RecvSubsDelReq(t)
2841 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
2842
2843 xappConn1.ExpectRESTNotification(t, restSubId)
2844 e2termConn1.RecvSubsDelReq(t)
2845 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
2846
2847 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2848
2849 waitSubsCleanup(t, e2SubsId, 10)
2850
2851 mainCtrl.VerifyCounterValues(t)
2852
2853}
2854
2855//-----------------------------------------------------------------------------
2856// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2857//
2858// stub stub
2859// +-------+ +---------+ +---------+
2860// | xapp | | submgr | | e2term |
2861// +-------+ +---------+ +---------+
2862// | | |
2863// | RESTSubReq | |
2864// |---------------->| |
2865// | | |
2866// | RESTSubResp | |
2867// |<----------------| |
2868// | | SubReq |
2869// | |------------->|
2870// | | |
2871// | | |
2872// | | SubReq |
2873// | |------------->|
2874// | | |
2875// | | SubDelReq |
2876// | |------------->|
2877// | | |
2878// | | |
2879// | | SubDelReq |
2880// | |------------->|
2881// | | |
2882// | | |
2883// | | SubDelResp |
2884// | |<-------------|
2885// | RESTNotif | |
2886// | unsuccess | |
2887// |<----------------| |
2888// | | |
2889// | [SUBS DELETE] |
2890// | | |
2891//
2892//-----------------------------------------------------------------------------
2893func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
2894 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
2895
2896 // Init counter check
2897 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2898 Counter{cSubReqFromXapp, 1},
2899 Counter{cSubReqToE2, 1},
2900 Counter{cSubReReqToE2, 1},
2901 Counter{cSubReqTimerExpiry, 2},
2902 Counter{cSubDelReqToE2, 1},
2903 Counter{cSubDelReReqToE2, 1},
2904 Counter{cSubDelReqTimerExpiry, 2},
2905 })
2906
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002907 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002908 restSubId := xappConn1.SendRESTSubsReq(t, params)
2909 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2910
2911 e2termConn1.RecvSubsReq(t)
2912 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2913
2914 e2termConn1.RecvSubsReq(t)
2915 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2916
2917 e2termConn1.RecvSubsDelReq(t)
2918 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
2919
2920 xappConn1.ExpectRESTNotification(t, restSubId)
2921 e2termConn1.RecvSubsDelReq(t)
2922 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
2923
2924 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2925
2926 waitSubsCleanup(t, e2SubsId, 10)
2927
2928 mainCtrl.VerifyCounterValues(t)
2929}
2930
2931//-----------------------------------------------------------------------------
2932// TestRESTSubReqSubFailRespInSubmgr
2933//
2934// stub stub
2935// +-------+ +---------+ +---------+
2936// | xapp | | submgr | | e2term |
2937// +-------+ +---------+ +---------+
2938// | | |
2939// | RESTSubReq | |
2940// |---------------->| |
2941// | | |
2942// | RESTSubResp | |
2943// |<----------------| |
2944// | | SubReq |
2945// | |------------->|
2946// | | |
2947// | | SubFail |
2948// | |<-------------|
2949// | | |
2950// | | SubDelReq |
2951// | |------------->|
2952// | | |
2953// | | SubDelResp |
2954// | |<-------------|
2955// | | |
2956// | RESTNotif | |
2957// | unsuccess | |
2958// |<----------------| |
2959// | | |
2960// | [SUBS DELETE] |
2961// | | |
2962//
2963//-----------------------------------------------------------------------------
2964func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
2965 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
2966
2967 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2968 Counter{cSubReqFromXapp, 1},
2969 Counter{cSubReqToE2, 1},
2970 Counter{cSubFailFromE2, 1},
2971 Counter{cSubRespToXapp, 1},
2972 Counter{cSubDelReqFromXapp, 1},
2973 })
2974
2975 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002976
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002977 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002978 restSubId := xappConn1.SendRESTSubsReq(t, params)
2979
2980 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2981 fparams1 := &teststube2ap.E2StubSubsFailParams{}
2982 fparams1.Set(crereq1)
2983 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
2984
2985 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2986 xappConn1.ExpectRESTNotification(t, restSubId)
2987 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2988 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2989 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2990
2991 // REST subscription sill there to be deleted
2992 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2993
2994 // Wait that subs is cleaned
2995 waitSubsCleanup(t, e2SubsId, 10)
2996
2997 mainCtrl.VerifyCounterValues(t)
2998
2999}
3000
3001//-----------------------------------------------------------------------------
3002// TestRESTSubDelReqRetryInSubmgr
3003//
3004// stub stub
3005// +-------+ +---------+ +---------+
3006// | xapp | | submgr | | e2term |
3007// +-------+ +---------+ +---------+
3008// | | |
3009// | [SUBS CREATE] |
3010// | | |
3011// | | |
3012// | RESTSubDelReq | |
3013// |---------------->| |
3014// | | |
3015// | RESTSubDelResp | |
3016// |<----------------| |
3017// | | SubDelReq |
3018// | |------------->|
3019// | | |
3020// | | SubDelReq |
3021// | |------------->|
3022// | | |
3023// | | SubDelResp |
3024// | |<-------------|
3025// | | |
3026//
3027//-----------------------------------------------------------------------------
3028func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3029 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3030
3031 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3032 Counter{cSubReqFromXapp, 1},
3033 Counter{cSubReqToE2, 1},
3034 Counter{cSubRespFromE2, 1},
3035 Counter{cSubRespToXapp, 1},
3036 Counter{cSubDelReqFromXapp, 1},
3037 Counter{cSubDelReqToE2, 1},
3038 Counter{cSubDelReReqToE2, 1},
3039 Counter{cSubDelRespFromE2, 1},
3040 Counter{cSubDelRespToXapp, 1},
3041 })
3042 // Req
3043 var params *teststube2ap.RESTSubsReqParams = nil
3044 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3045
3046 // Del
3047 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3048
3049 // E2t: Receive 1st SubsDelReq
3050 e2termConn1.RecvSubsDelReq(t)
3051
3052 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3053 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3054 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3055
3056 //Wait that subs is cleaned
3057 waitSubsCleanup(t, e2SubsId, 10)
3058
3059 mainCtrl.VerifyCounterValues(t)
3060}
3061
3062//-----------------------------------------------------------------------------
3063// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3064//
3065// stub stub
3066// +-------+ +---------+ +---------+
3067// | xapp | | submgr | | e2term |
3068// +-------+ +---------+ +---------+
3069// | | |
3070// | [SUBS CREATE] |
3071// | | |
3072// | | |
3073// | RESTSubDelReq | |
3074// |---------------->| |
3075// | | |
3076// | RESTSubDelResp | |
3077// |<----------------| |
3078// | | SubDelReq |
3079// | |------------->|
3080// | | |
3081// | | SubDelReq |
3082// | |------------->|
3083// | | |
3084// | | |
3085//
3086//-----------------------------------------------------------------------------
3087func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3088 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3089
3090 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3091 Counter{cSubReqFromXapp, 1},
3092 Counter{cSubReqToE2, 1},
3093 Counter{cSubRespFromE2, 1},
3094 Counter{cSubRespToXapp, 1},
3095 Counter{cSubDelReqFromXapp, 1},
3096 Counter{cSubDelReqToE2, 1},
3097 Counter{cSubDelReReqToE2, 1},
3098 Counter{cSubDelRespFromE2, 1},
3099 Counter{cSubDelRespToXapp, 1},
3100 })
3101
3102 // Req
3103 var params *teststube2ap.RESTSubsReqParams = nil
3104 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3105
3106 // Del
3107 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3108
3109 // E2t: Receive 1st SubsDelReq
3110 e2termConn1.RecvSubsDelReq(t)
3111
3112 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3113 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3114 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3115
3116 //Wait that subs is cleaned
3117 waitSubsCleanup(t, e2SubsId, 10)
3118
3119 mainCtrl.VerifyCounterValues(t)
3120}
3121
3122//-----------------------------------------------------------------------------
3123// TestRESTSubDelReqSubDelFailRespInSubmgr
3124//
3125// stub stub
3126// +-------+ +---------+ +---------+
3127// | xapp | | submgr | | e2term |
3128// +-------+ +---------+ +---------+
3129// | | |
3130// | [SUBS CREATE] |
3131// | | |
3132// | | |
3133// | RESTSubDelReq | |
3134// |---------------->| |
3135// | | |
3136// | RESTSubDelResp | |
3137// |<----------------| |
3138// | | SubDelReq |
3139// | |------------->|
3140// | | |
3141// | | SubDelFail |
3142// | |<-------------|
3143// | | |
3144//
3145//-----------------------------------------------------------------------------
3146func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3147 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3148
3149 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3150 Counter{cSubReqFromXapp, 1},
3151 Counter{cSubReqToE2, 1},
3152 Counter{cSubRespFromE2, 1},
3153 Counter{cSubRespToXapp, 1},
3154 Counter{cSubDelReqFromXapp, 1},
3155 Counter{cSubDelReqToE2, 1},
3156 Counter{cSubDelFailFromE2, 1},
3157 Counter{cSubDelRespToXapp, 1},
3158 })
3159
3160 // Req
3161 var params *teststube2ap.RESTSubsReqParams = nil
3162 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3163
3164 // Del
3165 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3166
3167 // E2t: Send receive SubsDelReq and send SubsDelFail
3168 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3169 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3170
3171 //Wait that subs is cleaned
3172 waitSubsCleanup(t, e2SubsId, 10)
3173
3174 mainCtrl.VerifyCounterValues(t)
3175}
3176
3177//-----------------------------------------------------------------------------
3178// TestRESTSubReqAndSubDelOkSameAction
3179//
3180// stub stub
3181// +-------+ +-------+ +---------+ +---------+
3182// | xapp2 | | xapp1 | | submgr | | e2term |
3183// +-------+ +-------+ +---------+ +---------+
3184// | | | |
3185// | | RESTSubReq1 | |
3186// | |---------------->| |
3187// | | | |
3188// | | RESTSubResp1 | |
3189// | |<----------------| |
3190// | | | |
3191// | | | SubReq1 |
3192// | | |------------->|
3193// | | | SubResp1 |
3194// | | |<-------------|
3195// | | RESTNotif1 | |
3196// | |<----------------| |
3197// | | | |
3198// | RESTSubReq2 | |
3199// |------------------------------>| |
3200// | | | |
3201// | RESTSubResp2 | |
3202// |<------------------------------| |
3203// | | | |
3204// | | RESTNotif2 | |
3205// |<------------------------------| |
3206// | | | |
3207// | | RESTSubDelReq1 | |
3208// | |---------------->| |
3209// | | | |
3210// | | RESTSubDelResp1 | |
3211// | |<----------------| |
3212// | | | |
3213// | RESTSubDelReq2 | |
3214// |------------------------------>| |
3215// | | | |
3216// | RESTSubDelResp2 | |
3217// |<------------------------------| |
3218// | | | |
3219// | | | SubDelReq2 |
3220// | | |------------->|
3221// | | | |
3222// | | | SubDelResp2 |
3223// | | |<-------------|
3224// | | | |
3225//
3226//-----------------------------------------------------------------------------
3227func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3228 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3229
3230 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3231 Counter{cSubReqFromXapp, 2},
3232 Counter{cSubReqToE2, 1},
3233 Counter{cSubRespFromE2, 1},
3234 Counter{cSubRespToXapp, 2},
3235 Counter{cMergedSubscriptions, 1},
3236 Counter{cUnmergedSubscriptions, 1},
3237 Counter{cSubDelReqFromXapp, 2},
3238 Counter{cSubDelReqToE2, 1},
3239 Counter{cSubDelRespFromE2, 1},
3240 Counter{cSubDelRespToXapp, 2},
3241 })
3242
3243 // Req1
3244 var params *teststube2ap.RESTSubsReqParams = nil
3245
3246 //Subs Create
3247 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3248 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3249
3250 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003251 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003252 params.SetMeid("RAN_NAME_1")
3253
3254 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
3255 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003256 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003257 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003258 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003259 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
3260 e2SubsId2 := <-xappConn2.RESTNotification
3261 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3262
3263 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3264
3265 // Del1
3266 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3267
3268 // Del2
3269 deleteXapp2Subscription(t, &restSubId2)
3270
3271 //Wait that subs is cleaned
3272 waitSubsCleanup(t, e2SubsId2, 10)
3273
3274 mainCtrl.VerifyCounterValues(t)
3275}
3276
3277//-----------------------------------------------------------------------------
3278// TestSubReqAndSubDelOkSameActionParallel
3279//
3280// stub stub stub
3281// +-------+ +-------+ +---------+ +---------+
3282// | xapp2 | | xapp1 | | submgr | | e2term |
3283// +-------+ +-------+ +---------+ +---------+
3284// | | | |
3285// | | | |
3286// | | | |
3287// | | SubReq1 | |
3288// | |------------->| |
3289// | | | |
3290// | | | SubReq1 |
3291// | | |------------->|
3292// | SubReq2 | |
3293// |--------------------------->| |
3294// | | | SubResp1 |
3295// | | |<-------------|
3296// | | SubResp1 | |
3297// | |<-------------| |
3298// | | | SubReq2 |
3299// | | |------------->|
3300// | | | |
3301// | | | SubResp2 |
3302// | | |<-------------|
3303// | SubResp2 | |
3304// |<---------------------------| |
3305// | | | |
3306// | | SubDelReq 1 | |
3307// | |------------->| |
3308// | | | |
3309// | | SubDelResp 1 | |
3310// | |<-------------| |
3311// | | | |
3312// | SubDelReq 2 | |
3313// |--------------------------->| |
3314// | | | |
3315// | | | SubDelReq 2 |
3316// | | |------------->|
3317// | | | |
3318// | | | SubDelReq 2 |
3319// | | |------------->|
3320// | | | |
3321// | SubDelResp 2 | |
3322// |<---------------------------| |
3323//
3324func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
3325 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
3326
3327 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3328 Counter{cSubReqFromXapp, 2},
3329 Counter{cSubReqToE2, 2},
3330 Counter{cSubRespFromE2, 2},
3331 Counter{cSubRespToXapp, 2},
3332 Counter{cSubDelReqFromXapp, 2},
3333 Counter{cSubDelReqToE2, 2},
3334 Counter{cSubDelRespFromE2, 2},
3335 Counter{cSubDelRespToXapp, 2},
3336 })
3337
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003338 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003339 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3340 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3341
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003342 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003343 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3344
3345 xappConn1.ExpectRESTNotification(t, restSubId1)
3346 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3347 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3348
3349 xappConn2.ExpectRESTNotification(t, restSubId2)
3350 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3351 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3352 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3353
3354 // Del1
3355 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3356 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3357 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3358 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3359
3360 // Del2
3361 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3362 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
3363 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
3364
3365 waitSubsCleanup(t, e2SubsId2, 10)
3366
3367 mainCtrl.VerifyCounterValues(t)
3368}
3369
3370//-----------------------------------------------------------------------------
3371// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
3372//
3373// stub stub stub
3374// +-------+ +-------+ +---------+ +---------+
3375// | xapp2 | | xapp1 | | submgr | | e2term |
3376// +-------+ +-------+ +---------+ +---------+
3377// | | | |
3378// | | | |
3379// | | | |
3380// | | RESTSubReq1 | |
3381// | |---------------->| |
3382// | | | |
3383// | | RESTSubResp1 | |
3384// | |<----------------| |
3385// | | | SubReq1 |
3386// | | |------------->|
3387// | RESTSubReq2 | |
3388// |------------------------------>| |
3389// | | | |
3390// | RESTSubDelResp2 | |
3391// |<------------------------------| |
3392// | | | SubReq1 |
3393// | | |------------->|
3394// | | | |
3395// | | | |
3396// | | | SubDelReq |
3397// | | |------------->|
3398// | | | |
3399// | | | SubDelResp |
3400// | | |<-------------|
3401// | | RESTNotif1 | |
3402// | | unsuccess | |
3403// | |<----------------| |
3404// | RESTNotif2 | |
3405// | | unsuccess | |
3406// |<------------------------------| |
3407// | | | |
3408// | | RESTSubDelReq1 | |
3409// | |---------------->| |
3410// | | | |
3411// | | RESTSubDelResp1 | |
3412// | |<----------------| |
3413// | | | |
3414// | RESTSubDelReq2 | |
3415// |------------------------------>| |
3416// | | | |
3417// | RESTSubDelResp2 | |
3418// |<------------------------------| |
3419//
3420//-----------------------------------------------------------------------------
3421func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
3422 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
3423
3424 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3425 Counter{cSubReqFromXapp, 2},
3426 Counter{cSubReqToE2, 1},
3427 Counter{cSubRespToXapp, 2},
3428 Counter{cSubDelReqFromXapp, 2},
3429 Counter{cSubDelReqToE2, 1},
3430 Counter{cSubDelRespFromE2, 1},
3431 Counter{cSubDelRespToXapp, 2},
3432 })
3433
3434 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003435
3436 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003437 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003438 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
3439 crereq1, _ := e2termConn1.RecvSubsReq(t)
3440
3441 // Req2
3442 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003443 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003444 params2.SetMeid("RAN_NAME_1")
3445 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3446 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3447
3448 //Req1 (retransmitted)
3449 e2termConn1.RecvSubsReq(t)
3450
3451 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00003452
3453 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03003454 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3455
Markku Virtanenda34eec2021-05-20 08:22:04 +00003456 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3457 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3458 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3459 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003460
3461 // Del1
3462 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3463
3464 // Del2
3465 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3466
Markku Virtanenda34eec2021-05-20 08:22:04 +00003467 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
3468
archaggeafbf95f2021-04-14 08:54:05 +03003469 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00003470 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003471
3472 mainCtrl.VerifyCounterValues(t)
3473}
3474
3475//-----------------------------------------------------------------------------
3476// TestRESTSubReqAndSubDelNokSameActionParallel
3477//
3478// stub stub stub
3479// +-------+ +-------+ +---------+ +---------+
3480// | xapp2 | | xapp1 | | submgr | | e2term |
3481// +-------+ +-------+ +---------+ +---------+
3482// | | | |
3483// | | | |
3484// | | | |
3485// | | RESTSubReq1 | |
3486// | |---------------->| |
3487// | | | |
3488// | | RESTSubResp1 | |
3489// | |<----------------| |
3490// | | | SubReq1 |
3491// | | |------------->|
3492// | RESTSubReq2 | |
3493// |------------------------------>| |
3494// | | | |
3495// | RESTSubDelResp2 | |
3496// |<------------------------------| |
3497// | | | SubFail1 |
3498// | | |<-------------|
3499// | | | |
3500// | | RESTNotif1 | |
3501// | | unsuccess | |
3502// | |<----------------| |
3503// | RESTNotif2 | |
3504// | | unsuccess | |
3505// |<------------------------------| |
3506// | | | SubDelReq |
3507// | | |------------->|
3508// | | | SubDelResp |
3509// | | |<-------------|
3510// | | | |
3511// | | RESTSubDelReq1 | |
3512// | |---------------->| |
3513// | | | |
3514// | | RESTSubDelResp1 | |
3515// | |<----------------| |
3516// | | | |
3517// | RESTSubDelReq2 | |
3518// |------------------------------>| |
3519// | | | |
3520// | RESTSubDelResp2 | |
3521// |<------------------------------| |
3522//
3523//-----------------------------------------------------------------------------
3524func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
3525 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
3526
3527 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3528 Counter{cSubReqFromXapp, 2},
3529 Counter{cSubReqToE2, 1},
3530 Counter{cSubFailFromE2, 1},
3531 Counter{cSubRespToXapp, 2},
3532 Counter{cSubDelReqFromXapp, 2},
3533 Counter{cSubDelReqToE2, 1},
3534 Counter{cSubDelRespFromE2, 1},
3535 Counter{cSubDelRespToXapp, 2},
3536 })
3537
3538 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003539
3540 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003541 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003542 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3543 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3544
3545 // Req2
3546 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003547 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003548 params2.SetMeid("RAN_NAME_1")
3549 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3550 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3551
3552 // E2t: send SubsFail (first)
3553 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3554 fparams1.Set(crereq1)
3555 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3556
3557 // E2t: internal delete
3558 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3559 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3560 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3561
3562 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3563 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3564 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3565 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3566
3567 // Del1
3568 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3569
3570 // Del2
3571 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3572
3573 //Wait that subs is cleaned
3574 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
3575 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3576
3577 mainCtrl.VerifyCounterValues(t)
3578}
3579
3580func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
3581 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3582
3583 // Init counter check
3584 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3585 Counter{cSubReqFromXapp, 1},
3586 Counter{cSubReqToE2, 1},
3587 Counter{cSubRespFromE2, 1},
3588 Counter{cSubRespToXapp, 1},
3589 Counter{cSubDelReqFromXapp, 1},
3590 Counter{cSubDelReqToE2, 1},
3591 Counter{cSubDelRespFromE2, 1},
3592 Counter{cSubDelRespToXapp, 1},
3593 })
3594
3595 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003596
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003597 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003598 restSubId := xappConn1.SendRESTSubsReq(t, params)
3599 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3600
3601 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3602 xappConn1.ExpectRESTNotification(t, restSubId)
3603 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3604 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3605 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
3606
3607 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3608 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3609 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3610
3611 // Wait that subs is cleaned
3612 waitSubsCleanup(t, e2SubsId, 10)
3613 mainCtrl.VerifyCounterValues(t)
3614}
3615
3616//-----------------------------------------------------------------------------
3617// TestRESTSubReqPolicyChangeAndSubDelOk
3618//
3619// stub stub
3620// +-------+ +---------+ +---------+
3621// | xapp | | submgr | | e2term |
3622// +-------+ +---------+ +---------+
3623// | | |
3624// | RESTSubReq | |
3625// |---------------->| |
3626// | | |
3627// | RESTSubResp | |
3628// |<----------------| |
3629// | | SubReq |
3630// | |------------->|
3631// | | |
3632// | | SubResp |
3633// | |<-------------|
3634// | | |
3635// | RESTNotif | |
3636// |<----------------| |
3637// | | |
3638// | RESTSubReq | |
3639// |---------------->| |
3640// | | |
3641// | RESTSubResp | |
3642// |<----------------| |
3643// | | SubReq |
3644// | |------------->|
3645// | | |
3646// | | SubResp |
3647// | |<-------------|
3648// | | |
3649// | RESTNotif | |
3650// |<----------------| |
3651// | | |
3652// | RESTSubDelReq | |
3653// |---------------->| |
3654// | | |
3655// | | SubDelReq |
3656// | |------------->|
3657// | | |
3658// | | SubDelResp |
3659// | |<-------------|
3660// | | |
3661// | RESTSubDelResp | |
3662// |<----------------| |
3663//
3664//-----------------------------------------------------------------------------
3665func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
3666 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3667
3668 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3669 Counter{cSubReqFromXapp, 2},
3670 Counter{cSubReqToE2, 2},
3671 Counter{cSubRespFromE2, 2},
3672 Counter{cSubRespToXapp, 2},
3673 Counter{cSubDelReqFromXapp, 1},
3674 Counter{cSubDelReqToE2, 1},
3675 Counter{cSubDelRespFromE2, 1},
3676 Counter{cSubDelRespToXapp, 1},
3677 })
3678
3679 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003680
3681 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003682 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003683 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3684
3685 // Policy change
3686 instanceId := int64(e2SubsId)
3687 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003688 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003689 params.SubsReqParams.SubscriptionDetails[0].InstanceID = &instanceId
3690 params.SetTimeToWait("w200ms")
3691 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3692
3693 // Del
3694 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3695
3696 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3697 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3698
3699 // Wait that subs is cleaned
3700 waitSubsCleanup(t, e2SubsId, 10)
3701 mainCtrl.VerifyCounterValues(t)
3702}
3703
3704//-----------------------------------------------------------------------------
3705// TestRESTSubReqAndSubDelOkTwoE2termParallel
3706//
3707// stub stub stub
3708// +-------+ +---------+ +---------+ +---------+
3709// | xapp | | submgr | | e2term1 | | e2term2 |
3710// +-------+ +---------+ +---------+ +---------+
3711// | | | |
3712// | | | |
3713// | | | |
3714// | RESTSubReq1 | | |
3715// |---------------->| | |
3716// | | | |
3717// | RESTSubResp1 | | |
3718// |<----------------| | |
3719// | | SubReq1 | |
3720// | |------------->| |
3721// | | | |
3722// | RESTSubReq2 | | |
3723// |---------------->| | |
3724// | | | |
3725// | RESTSubResp2 | | |
3726// |<----------------| | |
3727// | | SubReq2 | |
3728// | |---------------------------->|
3729// | | | |
3730// | | SubResp1 | |
3731// | |<-------------| |
3732// | RESTNotif1 | | |
3733// |<----------------| | |
3734// | | SubResp2 | |
3735// | |<----------------------------|
3736// | RESTNotif2 | | |
3737// |<----------------| | |
3738// | | | |
3739// | [SUBS 1 DELETE] | |
3740// | | | |
3741// | [SUBS 2 DELETE] | |
3742// | | | |
3743//
3744//-----------------------------------------------------------------------------
3745func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
3746 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
3747
3748 // Init counter check
3749 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3750 Counter{cSubReqFromXapp, 2},
3751 Counter{cSubReqToE2, 2},
3752 Counter{cSubRespFromE2, 2},
3753 Counter{cSubRespToXapp, 2},
3754 Counter{cSubDelReqFromXapp, 2},
3755 Counter{cSubDelReqToE2, 2},
3756 Counter{cSubDelRespFromE2, 2},
3757 Counter{cSubDelRespToXapp, 2},
3758 })
3759
3760 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003761
3762 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003763 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003764 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3765 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3766
3767 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003768 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003769 params.SetMeid("RAN_NAME_11")
3770 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
3771 // would not work as notification would not be received
3772 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3773 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
3774
3775 // Resp1
3776 xappConn1.ExpectRESTNotification(t, restSubId1)
3777 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3778 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3779 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
3780
3781 // Resp2
3782 xappConn2.ExpectRESTNotification(t, restSubId2)
3783 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
3784 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3785 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
3786
3787 // Delete1
3788 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3789 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3790 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3791
3792 // Wait that subs is cleaned
3793 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3794
3795 // Delete2
3796 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
3797 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
3798 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
3799
3800 // Wait that subs is cleaned
3801 waitSubsCleanup(t, e2SubsId2, 10)
3802
3803 mainCtrl.VerifyCounterValues(t)
3804}
3805
3806//-----------------------------------------------------------------------------
3807// TestRESTSubReqAsn1EncodeFail
3808//
3809// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
3810// stub stub
3811// +-------+ +---------+ +---------+
3812// | xapp | | submgr | | e2term |
3813// +-------+ +---------+ +---------+
3814// | | |
3815// | RESTSubReq | |
3816// |---------------->| |
3817// | | |
3818// | RESTSubResp | |
3819// |<----------------| |
3820// | RESTSubDelReq | |
3821// |---------------->| |
3822// | RESTSubDelResp | |
3823// | unsuccess | |
3824// |<----------------| |
3825// | | |
3826//
3827//-----------------------------------------------------------------------------
3828func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
3829 CaseBegin("TestRESTSubReqAsn1EncodeFail")
3830
3831 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
3832
3833}
3834
3835//-----------------------------------------------------------------------------
3836// TestRESTSubReqInsertAndSubDelOk
3837//
3838// stub stub
3839// +-------+ +---------+ +---------+
3840// | xapp | | submgr | | e2term |
3841// +-------+ +---------+ +---------+
3842// | | |
3843// | RestSubReq | |
3844// |---------------->| |
3845// | | |
3846// | RESTSubResp | |
3847// |<----------------| |
3848// | | |
3849// | | SubReq |
3850// | |------------->|
3851// | | |
3852// | | SubResp |
3853// | |<-------------|
3854// | RESTNotif | |
3855// |<----------------| |
3856// | ... | ... |
3857// | | |
3858// | RESTSubDelReq | |
3859// |---------------->| |
3860// | | |
3861// | | SubDelReq |
3862// | |------------->|
3863// | | |
3864// | | SubDelResp |
3865// | |<-------------|
3866// | | |
3867// | RESTSubDelResp| |
3868// |<----------------| |
3869//
3870//-----------------------------------------------------------------------------
3871func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
3872 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
3873
3874 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3875 Counter{cSubReqFromXapp, 1},
3876 Counter{cSubReqToE2, 1},
3877 Counter{cSubRespFromE2, 1},
3878 Counter{cSubRespToXapp, 1},
3879 Counter{cSubDelReqFromXapp, 1},
3880 Counter{cSubDelReqToE2, 1},
3881 Counter{cSubDelRespFromE2, 1},
3882 Counter{cSubDelRespToXapp, 1},
3883 })
3884
3885 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003886
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003887 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003888 params.SetSubActionTypes("insert")
3889
3890 // Req
3891 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3892
3893 // Del
3894 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3895
3896 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3897 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3898
3899 // Wait that subs is cleaned
3900 waitSubsCleanup(t, e2SubsId, 10)
3901 mainCtrl.VerifyCounterValues(t)
3902}
3903
3904//-----------------------------------------------------------------------------
3905// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
3906//
3907// stub stub
3908// +-------+ +---------+ +---------+
3909// | xapp | | submgr | | e2term |
3910// +-------+ +---------+ +---------+
3911// | | |
3912// | RESTSubReq | |
3913// |------------->| |
3914// | | |
3915// | | SubReq |
3916// | |------------->|
3917// | | |
3918// | | SubResp |
3919// | <----|
3920// | |
3921// | Submgr restart |
3922// | |
3923// | | |
3924// | | SubDelReq |
3925// | |------------->|
3926// | | |
3927// | | SubDelResp |
3928// | |<-------------|
3929// | | |
3930//
3931//-----------------------------------------------------------------------------
3932func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
3933 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
3934
3935 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3936 Counter{cSubReqFromXapp, 1},
3937 Counter{cSubReqToE2, 1},
3938 Counter{cSubDelReqFromXapp, 1},
3939 Counter{cSubDelReqToE2, 1},
3940 Counter{cSubDelRespFromE2, 1},
3941 })
3942
3943 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003944
3945 // Remove possible existing subscription
3946 mainCtrl.removeExistingSubscriptions(t)
3947
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003948 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003949
3950 //Req
3951 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
3952 restSubId := xappConn1.SendRESTSubsReq(t, params)
3953 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3954
3955 e2termConn1.RecvSubsReq(t)
3956
3957 mainCtrl.SetResetTestFlag(t, false)
3958
3959 mainCtrl.SimulateRestart(t)
3960 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
3961
3962 //Del
3963 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3964 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3965
3966 xappConn1.TestMsgChanEmpty(t)
3967 xappConn2.TestMsgChanEmpty(t)
3968 e2termConn1.TestMsgChanEmpty(t)
3969 mainCtrl.wait_registry_empty(t, 10)
3970
3971 mainCtrl.VerifyCounterValues(t)
3972}
3973
3974//-----------------------------------------------------------------------------
3975// TestRESTSubReqAndSubDelOkWithRestartInMiddle
3976//
3977// stub stub
3978// +-------+ +---------+ +---------+
3979// | xapp | | submgr | | e2term |
3980// +-------+ +---------+ +---------+
3981// | | |
3982// | RESTSubReq | |
3983// |---------------->| |
3984// | | |
3985// | RESTSubResp | |
3986// |<----------------| |
3987// | | SubReq |
3988// | |------------->|
3989// | | |
3990// | | SubResp |
3991// | |<-------------|
3992// | | |
3993// | RESTNotif | |
3994// |<----------------| |
3995// | | |
3996// | |
3997// | Submgr restart |
3998// | | |
3999// | RESTSubDelReq | |
4000// |---------------->| |
4001// | | |
4002// | | SubDelReq |
4003// | |------------->|
4004// | | |
4005// | | SubDelResp |
4006// | |<-------------|
4007// | | |
4008// | RESTSubDelResp | |
4009// |<----------------| |
4010//
4011//-----------------------------------------------------------------------------
4012func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4013 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4014
4015 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4016 Counter{cSubReqFromXapp, 1},
4017 Counter{cSubReqToE2, 1},
4018 Counter{cSubRespFromE2, 1},
4019 Counter{cSubRespToXapp, 1},
4020 Counter{cSubDelReqFromXapp, 1},
4021 Counter{cSubDelReqToE2, 1},
4022 Counter{cSubDelRespToXapp, 1},
4023 })
4024
4025 // Remove possible existing subscription
4026 mainCtrl.removeExistingSubscriptions(t)
4027
4028 var params *teststube2ap.RESTSubsReqParams = nil
4029
4030 // Create subscription
4031 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4032 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4033
4034 // Check subscription
4035 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4036
4037 // When SDL support for the REST Interface is added
4038 // the submgr restart statement below should be removed
4039 // from the comment.
4040
4041 // mainCtrl.SimulateRestart(t)
4042 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4043
4044 // Check subscription
4045 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4046
4047 // Delete subscription
4048 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4049
4050 //Wait that subs is cleaned
4051 waitSubsCleanup(t, e2SubsId, 10)
4052
4053 mainCtrl.VerifyCounterValues(t)
4054}
4055
4056//-----------------------------------------------------------------------------
4057// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4058//
4059// stub stub
4060// +-------+ +-------+ +---------+ +---------+
4061// | xapp2 | | xapp1 | | submgr | | e2term |
4062// +-------+ +-------+ +---------+ +---------+
4063// | | | |
4064// | | RESTSubReq1 | |
4065// | |---------------->| |
4066// | | | |
4067// | | RESTSubResp1 | |
4068// | |<----------------| |
4069// | | | |
4070// | | | SubReq1 |
4071// | | |------------->|
4072// | | | SubResp1 |
4073// | | |<-------------|
4074// | | RESTNotif1 | |
4075// | |<----------------| |
4076// | | | |
4077// | RESTSubReq2 | |
4078// |------------------------------>| |
4079// | | | |
4080// | RESTSubResp2 | |
4081// |<------------------------------| |
4082// | | | |
4083// | | RESTNotif2 | |
4084// |<------------------------------| |
4085// | | | |
4086// | | Submgr restart |
4087// | | | |
4088// | | RESTSubDelReq1 | |
4089// | |---------------->| |
4090// | | | |
4091// | | RESTSubDelResp1 | |
4092// | |<----------------| |
4093// | | | |
4094// | | Submgr restart |
4095// | | | |
4096// | RESTSubDelReq2 | |
4097// |------------------------------>| |
4098// | | | |
4099// | RESTSubDelResp2 | |
4100// |<------------------------------| |
4101// | | | |
4102// | | | SubDelReq2 |
4103// | | |------------->|
4104// | | | |
4105// | | | SubDelResp2 |
4106// | | |<-------------|
4107// | | | |
4108//
4109//-----------------------------------------------------------------------------
4110func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4111 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4112
4113 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4114 Counter{cSubReqFromXapp, 2},
4115 Counter{cSubReqToE2, 1},
4116 Counter{cSubRespFromE2, 1},
4117 Counter{cSubRespToXapp, 2},
4118 Counter{cMergedSubscriptions, 1},
4119 Counter{cUnmergedSubscriptions, 1},
4120 Counter{cSubDelReqFromXapp, 2},
4121 Counter{cSubDelReqToE2, 1},
4122 Counter{cSubDelRespFromE2, 1},
4123 Counter{cSubDelRespToXapp, 2},
4124 })
4125
4126 // Remove possible existing subscription
4127 mainCtrl.removeExistingSubscriptions(t)
4128
4129 var params *teststube2ap.RESTSubsReqParams = nil
4130
4131 // Create subscription 1
4132 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4133 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4134
4135 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004136 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004137 params.SetMeid("RAN_NAME_1")
4138 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4139 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
4140 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4141 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4142 e2SubsId2 := <-xappConn2.RESTNotification
4143 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4144
4145 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4146
4147 // When SDL support for the REST Interface is added
4148 // the submgr restart statement below should be removed
4149 // from the comment.
4150
4151 // mainCtrl.SimulateRestart(t)
4152 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4153
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004154 // Delete subscription 1, and wait until it has removed the first endpoint
4155 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004156 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004157 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004158
4159 // When SDL support for the REST Interface is added
4160 // the submgr restart statement below should be removed
4161 // from the comment.
4162
4163 // mainCtrl.SimulateRestart(t)
4164 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004165 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4166
4167 // Delete subscription 2
4168 deleteXapp2Subscription(t, &restSubId2)
4169
4170 //Wait that subs is cleaned
4171 waitSubsCleanup(t, e2SubsId2, 10)
4172
4173 mainCtrl.VerifyCounterValues(t)
4174}
4175
4176//-----------------------------------------------------------------------------
4177// TestRESTReportSubReqAndSubDelOk
4178//
4179// stub stub
4180// +-------+ +---------+ +---------+
4181// | xapp | | submgr | | e2term |
4182// +-------+ +---------+ +---------+
4183// | | |
4184// | RestSubReq | |
4185// |---------------->| |
4186// | | |
4187// | RESTSubResp | |
4188// |<----------------| |
4189// | | |
4190// | | SubReq |
4191// | |------------->|
4192// | | |
4193// | | SubResp |
4194// | |<-------------|
4195// | RESTNotif | |
4196// |<----------------| |
4197// | | SubReq |
4198// | |------------->|
4199// | | |
4200// | | SubResp |
4201// | |<-------------|
4202// | RESTNotif | |
4203// |<----------------| |
4204// | ... | ... |
4205// | | |
4206// | | |
4207// | RESTSubDelReq | |
4208// |---------------->| |
4209// | | |
4210// | | SubDelReq |
4211// | |------------->|
4212// | | |
4213// | | SubDelResp |
4214// | |<-------------|
4215// | | |
4216// | RESTSubDelResp| |
4217// |<----------------| |
4218//
4219//-----------------------------------------------------------------------------
4220func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
4221 CaseBegin("TestRESTReportSubReqAndSubDelOk")
4222 subReqCount := 1
archaggeafbf95f2021-04-14 08:54:05 +03004223 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004224 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004225}
4226
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004227func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
4228 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004229
4230 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004231 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004232 restSubId := xappConn1.SendRESTSubsReq(t, params)
4233
4234 var e2SubsId []uint32
4235 for i := 0; i < subReqCount; i++ {
4236 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4237 xappConn1.ExpectRESTNotification(t, restSubId)
4238
4239 e2termConn1.SendSubsResp(t, crereq, cremsg)
4240 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4241 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4242 e2SubsId = append(e2SubsId, instanceId)
4243 resp, _ := xapp.Subscription.QuerySubscriptions()
4244 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
4245 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
4246 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
4247
4248 }
4249
4250 // Del
4251 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4252
4253 for i := 0; i < subReqCount; i++ {
4254 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4255 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4256 }
4257
4258 // Wait that subs is cleaned
4259 for i := 0; i < subReqCount; i++ {
4260 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4261 }
4262
4263 xappConn1.TestMsgChanEmpty(t)
4264 e2termConn1.TestMsgChanEmpty(t)
4265 mainCtrl.wait_registry_empty(t, 10)
4266}
4267
4268/*
4269func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
4270 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
4271
4272 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004273 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004274 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004275
4276 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03004277 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004278 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004279}
4280*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004281func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
4282 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004283
4284 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004285 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004286 restSubId := xappConn1.SendRESTSubsReq(t, params)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004287 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004288 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
4289
4290 var e2SubsId []uint32
4291 for i := 0; i < subReqCount; i++ {
4292 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4293 xappConn1.ExpectRESTNotification(t, restSubId)
4294 e2termConn1.SendSubsResp(t, crereq, cremsg)
4295 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4296 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4297 e2SubsId = append(e2SubsId, instanceId)
4298 }
4299
4300 // Del
4301 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4302
4303 for i := 0; i < subReqCount; i++ {
4304 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4305 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4306 }
4307
4308 // Wait that subs is cleaned
4309 for i := 0; i < subReqCount; i++ {
4310 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4311 }
4312 xappConn1.TestMsgChanEmpty(t)
4313 e2termConn1.TestMsgChanEmpty(t)
4314 mainCtrl.wait_registry_empty(t, 10)
4315}
4316
archaggeafbf95f2021-04-14 08:54:05 +03004317func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
4318
4319 subReqCount := 2
4320
4321 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4322 Counter{cSubReqFromXapp, 1},
4323 Counter{cSubReqToE2, 2},
4324 Counter{cSubRespFromE2, 2},
4325 Counter{cSubRespToXapp, 2},
4326 Counter{cSubDelReqFromXapp, 1},
4327 Counter{cSubDelReqToE2, 2},
4328 Counter{cSubDelRespFromE2, 2},
4329 Counter{cSubDelRespToXapp, 1},
4330 })
4331
4332 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004333 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004334 restSubId := xappConn1.SendRESTSubsReq(t, params)
4335 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4336
4337 assert.Equal(t, len(e2SubsIds), 2)
4338
4339 // Del
4340 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4341 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4342
4343 xappConn1.TestMsgChanEmpty(t)
4344 e2termConn1.TestMsgChanEmpty(t)
4345 mainCtrl.wait_registry_empty(t, 10)
4346
4347 mainCtrl.VerifyCounterValues(t)
4348}
archaggeafbf95f2021-04-14 08:54:05 +03004349func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
4350
4351 subReqCount := 19
4352
4353 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4354 Counter{cSubReqFromXapp, 1},
4355 Counter{cSubReqToE2, 19},
4356 Counter{cSubRespFromE2, 19},
4357 Counter{cSubRespToXapp, 19},
4358 Counter{cSubDelReqFromXapp, 1},
4359 Counter{cSubDelReqToE2, 19},
4360 Counter{cSubDelRespFromE2, 19},
4361 Counter{cSubDelRespToXapp, 1},
4362 })
4363
4364 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004365 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004366 restSubId := xappConn1.SendRESTSubsReq(t, params)
4367 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4368
4369 assert.Equal(t, len(e2SubsIds), 19)
4370
4371 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4372 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4373
4374 xappConn1.TestMsgChanEmpty(t)
4375 e2termConn1.TestMsgChanEmpty(t)
4376 mainCtrl.wait_registry_empty(t, 10)
4377
4378 mainCtrl.VerifyCounterValues(t)
4379}
archaggeafbf95f2021-04-14 08:54:05 +03004380func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
4381
4382 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004383
4384 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4385 Counter{cSubReqFromXapp, 1},
4386 Counter{cSubReqToE2, uint64(subReqCount)},
4387 Counter{cSubRespFromE2, uint64(subReqCount)},
4388 Counter{cSubRespToXapp, uint64(subReqCount)},
4389 Counter{cSubDelReqFromXapp, 1},
4390 Counter{cSubDelReqToE2, uint64(subReqCount)},
4391 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4392 Counter{cSubDelRespToXapp, 1},
4393 })
4394
4395 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004396 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004397 restSubId := xappConn1.SendRESTSubsReq(t, params)
4398 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4399
4400 assert.Equal(t, len(e2SubsIds), subReqCount)
4401
4402 // Del
4403 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4404 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4405
4406 xappConn1.TestMsgChanEmpty(t)
4407 e2termConn1.TestMsgChanEmpty(t)
4408 mainCtrl.wait_registry_empty(t, 10)
4409
4410 mainCtrl.VerifyCounterValues(t)
4411}
Markku Virtanenda34eec2021-05-20 08:22:04 +00004412
archaggeafbf95f2021-04-14 08:54:05 +03004413func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
4414
4415 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004416
4417 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4418 Counter{cSubReqFromXapp, 1},
4419 Counter{cSubReqToE2, uint64(subReqCount)},
4420 Counter{cSubRespFromE2, uint64(subReqCount)},
4421 Counter{cSubRespToXapp, uint64(subReqCount)},
4422 Counter{cSubDelReqFromXapp, 1},
4423 Counter{cSubDelReqToE2, uint64(subReqCount)},
4424 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4425 Counter{cSubDelRespToXapp, 1},
4426 })
4427
4428 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004429 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004430 restSubId := xappConn1.SendRESTSubsReq(t, params)
4431 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4432
4433 assert.Equal(t, len(e2SubsIds), subReqCount)
4434
4435 // Del
4436 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4437 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4438
4439 xappConn1.TestMsgChanEmpty(t)
4440 e2termConn1.TestMsgChanEmpty(t)
4441 mainCtrl.wait_registry_empty(t, 10)
4442
4443 mainCtrl.VerifyCounterValues(t)
4444}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004445
archaggeafbf95f2021-04-14 08:54:05 +03004446func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
4447
4448 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03004449
4450 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4451 Counter{cSubReqFromXapp, 1},
4452 Counter{cSubReqToE2, uint64(subReqCount)},
4453 Counter{cSubRespFromE2, uint64(subReqCount)},
4454 Counter{cSubRespToXapp, uint64(subReqCount)},
4455 Counter{cSubDelReqFromXapp, 1},
4456 Counter{cSubDelReqToE2, uint64(subReqCount)},
4457 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4458 Counter{cSubDelRespToXapp, 1},
4459 })
4460
4461 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004462 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004463 restSubId := xappConn1.SendRESTSubsReq(t, params)
4464 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4465
4466 assert.Equal(t, len(e2SubsIds), subReqCount)
4467
4468 // Del
4469 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4470 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4471
4472 xappConn1.TestMsgChanEmpty(t)
4473 e2termConn1.TestMsgChanEmpty(t)
4474 mainCtrl.wait_registry_empty(t, 10)
4475
4476 mainCtrl.VerifyCounterValues(t)
4477}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004478
4479func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
4480 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
4481
4482 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4483 Counter{cSubReqFromXapp, 2},
4484 Counter{cSubReqToE2, 2},
4485 Counter{cSubRespFromE2, 2},
4486 Counter{cSubRespToXapp, 2},
4487 Counter{cSubDelReqFromXapp, 2},
4488 Counter{cSubDelReqToE2, 2},
4489 Counter{cSubDelRespFromE2, 2},
4490 Counter{cSubDelRespToXapp, 2},
4491 })
4492
4493 // Req1
4494 var params *teststube2ap.RESTSubsReqParams = nil
4495
4496 //Subs Create
4497 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4498 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4499
4500 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4501
4502 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004503 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004504 params.SetMeid("RAN_NAME_1")
4505 eventTriggerDefinition := "1234"
4506 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
4507
4508 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4509 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4510 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4511 xappConn2.ExpectRESTNotification(t, restSubId2)
4512 e2termConn1.SendSubsResp(t, crereq, cremsg)
4513 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4514
4515 deleteXapp1Subscription(t, &restSubId1)
4516 deleteXapp2Subscription(t, &restSubId2)
4517
4518 waitSubsCleanup(t, e2SubsId1, 10)
4519 waitSubsCleanup(t, e2SubsId2, 10)
4520
4521 mainCtrl.VerifyCounterValues(t)
4522
4523}
4524
4525func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
4526 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
4527
4528 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4529 Counter{cSubReqFromXapp, 2},
4530 Counter{cSubReqToE2, 2},
4531 Counter{cSubRespFromE2, 2},
4532 Counter{cSubRespToXapp, 2},
4533 Counter{cSubDelReqFromXapp, 2},
4534 Counter{cSubDelReqToE2, 2},
4535 Counter{cSubDelRespFromE2, 2},
4536 Counter{cSubDelRespToXapp, 2},
4537 })
4538
4539 // Req1
4540 var params *teststube2ap.RESTSubsReqParams = nil
4541
4542 //Subs Create
4543 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4544 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4545
4546 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4547
4548 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004549 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004550 params.SetMeid("RAN_NAME_1")
4551
4552 actionId := int64(1)
4553 actionType := "report"
4554 actionDefinition := "56781"
4555 subsequestActionType := "continue"
4556 timeToWait := "w10ms"
4557 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4558
4559 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4560 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4561 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4562 xappConn2.ExpectRESTNotification(t, restSubId2)
4563 e2termConn1.SendSubsResp(t, crereq, cremsg)
4564 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4565
4566 deleteXapp1Subscription(t, &restSubId1)
4567 deleteXapp2Subscription(t, &restSubId2)
4568
4569 waitSubsCleanup(t, e2SubsId1, 10)
4570 waitSubsCleanup(t, e2SubsId2, 10)
4571
4572 mainCtrl.VerifyCounterValues(t)
4573
4574}
4575
4576func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
4577 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
4578
4579 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4580 Counter{cSubReqFromXapp, 2},
4581 Counter{cSubReqToE2, 2},
4582 Counter{cSubRespFromE2, 2},
4583 Counter{cSubRespToXapp, 2},
4584 Counter{cSubDelReqFromXapp, 2},
4585 Counter{cSubDelReqToE2, 2},
4586 Counter{cSubDelRespFromE2, 2},
4587 Counter{cSubDelRespToXapp, 2},
4588 })
4589
4590 // Req1
4591 var params *teststube2ap.RESTSubsReqParams = nil
4592
4593 //Subs Create
4594 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4595 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4596
4597 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4598
4599 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004600 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004601 params.SetMeid("RAN_NAME_1")
4602 params.SetSubActionIDs(int64(2))
4603
4604 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4605 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4606 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4607 xappConn2.ExpectRESTNotification(t, restSubId2)
4608 e2termConn1.SendSubsResp(t, crereq, cremsg)
4609 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4610
4611 deleteXapp1Subscription(t, &restSubId1)
4612 deleteXapp2Subscription(t, &restSubId2)
4613
4614 waitSubsCleanup(t, e2SubsId1, 10)
4615 waitSubsCleanup(t, e2SubsId2, 10)
4616
4617 mainCtrl.VerifyCounterValues(t)
4618
4619}
4620
4621func TestRESTSubReqDiffActionType(t *testing.T) {
4622 CaseBegin("TestRESTSubReqDiffActionType")
4623
4624 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4625 Counter{cSubReqFromXapp, 2},
4626 Counter{cSubReqToE2, 2},
4627 Counter{cSubRespFromE2, 2},
4628 Counter{cSubRespToXapp, 2},
4629 Counter{cSubDelReqFromXapp, 2},
4630 Counter{cSubDelReqToE2, 2},
4631 Counter{cSubDelRespFromE2, 2},
4632 Counter{cSubDelRespToXapp, 2},
4633 })
4634
4635 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004636 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004637
4638 //Subs Create
4639 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4640 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4641
4642 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4643
4644 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004645 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004646 params.SetMeid("RAN_NAME_1")
4647
4648 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4649 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4650 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4651 xappConn2.ExpectRESTNotification(t, restSubId2)
4652 e2termConn1.SendSubsResp(t, crereq, cremsg)
4653 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4654
4655 deleteXapp1Subscription(t, &restSubId1)
4656 deleteXapp2Subscription(t, &restSubId2)
4657
4658 waitSubsCleanup(t, e2SubsId1, 10)
4659 waitSubsCleanup(t, e2SubsId2, 10)
4660
4661 mainCtrl.VerifyCounterValues(t)
4662
4663}
4664
4665func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
4666 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
4667
4668 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4669 Counter{cSubReqFromXapp, 2},
4670 Counter{cSubReqToE2, 2},
4671 Counter{cSubRespFromE2, 2},
4672 Counter{cSubRespToXapp, 2},
4673 Counter{cSubDelReqFromXapp, 2},
4674 Counter{cSubDelReqToE2, 2},
4675 Counter{cSubDelRespFromE2, 2},
4676 Counter{cSubDelRespToXapp, 2},
4677 })
4678
4679 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004680 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004681
4682 //Subs Create
4683 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4684 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4685
4686 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4687
4688 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004689 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004690 params.SetMeid("RAN_NAME_1")
4691
4692 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4693 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4694 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4695 xappConn2.ExpectRESTNotification(t, restSubId2)
4696 e2termConn1.SendSubsResp(t, crereq, cremsg)
4697 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4698
4699 deleteXapp1Subscription(t, &restSubId1)
4700 deleteXapp2Subscription(t, &restSubId2)
4701
4702 waitSubsCleanup(t, e2SubsId1, 10)
4703 waitSubsCleanup(t, e2SubsId2, 10)
4704
4705 mainCtrl.VerifyCounterValues(t)
4706
4707}
4708
4709func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
4710 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
4711
4712 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4713 Counter{cSubReqFromXapp, 2},
4714 Counter{cSubReqToE2, 2},
4715 Counter{cSubRespFromE2, 2},
4716 Counter{cSubRespToXapp, 2},
4717 Counter{cSubDelReqFromXapp, 2},
4718 Counter{cSubDelReqToE2, 2},
4719 Counter{cSubDelRespFromE2, 2},
4720 Counter{cSubDelRespToXapp, 2},
4721 })
4722
4723 // Req1
4724 var params *teststube2ap.RESTSubsReqParams = nil
4725
4726 //Subs Create
4727 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4728 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4729
4730 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4731
4732 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004733 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004734 params.SetMeid("RAN_NAME_1")
4735 actionDefinition := "5678"
4736 params.SetSubActionDefinition(actionDefinition)
4737
4738 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4739 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4740 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4741 xappConn2.ExpectRESTNotification(t, restSubId2)
4742 e2termConn1.SendSubsResp(t, crereq, cremsg)
4743 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4744
4745 deleteXapp1Subscription(t, &restSubId1)
4746 deleteXapp2Subscription(t, &restSubId2)
4747
4748 waitSubsCleanup(t, e2SubsId1, 10)
4749 waitSubsCleanup(t, e2SubsId2, 10)
4750
4751 mainCtrl.VerifyCounterValues(t)
4752
4753}
4754
4755func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
4756 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
4757
4758 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4759 Counter{cSubReqFromXapp, 2},
4760 Counter{cSubReqToE2, 2},
4761 Counter{cSubRespFromE2, 2},
4762 Counter{cSubRespToXapp, 2},
4763 Counter{cSubDelReqFromXapp, 2},
4764 Counter{cSubDelReqToE2, 2},
4765 Counter{cSubDelRespFromE2, 2},
4766 Counter{cSubDelRespToXapp, 2},
4767 })
4768
4769 // Req1
4770 var params *teststube2ap.RESTSubsReqParams = nil
4771
4772 //Subs Create
4773 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4774 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4775
4776 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4777
4778 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004779 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004780 params.SetMeid("RAN_NAME_1")
4781 actionDefinition := "56782"
4782 params.SetSubActionDefinition(actionDefinition)
4783
4784 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4785 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4786 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4787 xappConn2.ExpectRESTNotification(t, restSubId2)
4788 e2termConn1.SendSubsResp(t, crereq, cremsg)
4789 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4790
4791 deleteXapp1Subscription(t, &restSubId1)
4792 deleteXapp2Subscription(t, &restSubId2)
4793
4794 waitSubsCleanup(t, e2SubsId1, 10)
4795 waitSubsCleanup(t, e2SubsId2, 10)
4796
4797 mainCtrl.VerifyCounterValues(t)
4798
4799}
4800
4801func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
4802 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
4803
4804 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4805 Counter{cSubReqFromXapp, 2},
4806 Counter{cSubReqToE2, 2},
4807 Counter{cSubRespFromE2, 2},
4808 Counter{cSubRespToXapp, 2},
4809 Counter{cSubDelReqFromXapp, 2},
4810 Counter{cSubDelReqToE2, 2},
4811 Counter{cSubDelRespFromE2, 2},
4812 Counter{cSubDelRespToXapp, 2},
4813 })
4814
4815 // Req1
4816 var params *teststube2ap.RESTSubsReqParams = nil
4817
4818 //Subs Create
4819 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4820 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4821
4822 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4823
4824 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004825 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004826 params.SetMeid("RAN_NAME_1")
4827 params.SetTimeToWait("w200ms")
4828 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4829 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4830 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4831 xappConn2.ExpectRESTNotification(t, restSubId2)
4832 e2termConn1.SendSubsResp(t, crereq, cremsg)
4833 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4834
4835 deleteXapp1Subscription(t, &restSubId1)
4836 deleteXapp2Subscription(t, &restSubId2)
4837
4838 waitSubsCleanup(t, e2SubsId1, 10)
4839 waitSubsCleanup(t, e2SubsId2, 10)
4840
4841 mainCtrl.VerifyCounterValues(t)
4842
4843}
4844
Anssi Mannila51122392021-05-25 11:51:31 +03004845//-----------------------------------------------------------------------------
4846// TestRESTUnpackSubscriptionResponseDecodeFail
4847//
4848// stub stub
4849// +-------+ +---------+ +---------+
4850// | xapp | | submgr | | e2term |
4851// +-------+ +---------+ +---------+
4852// | | |
4853// | RestSubReq | |
4854// |---------------->| |
4855// | | |
4856// | RESTSubResp | |
4857// |<----------------| |
4858// | | |
4859// | | SubReq |
4860// | |------------->|
4861// | | |
4862// | | SubResp | ASN.1 decode fails
4863// | |<-------------|
4864// | | |
4865// | | SubReq |
4866// | |------------->|
4867// | | |
4868// | | SubFail | Duplicated action
4869// | |<-------------|
4870// | RESTNotif (fail)| |
4871// |<----------------| |
4872// | | SubDelReq |
4873// | |------------->|
4874// | | |
4875// | | SubDelResp |
4876// | |<-------------|
4877//
4878//-----------------------------------------------------------------------------
4879func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
4880 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
4881 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03004882
4883 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004884 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03004885 restSubId := xappConn1.SendRESTSubsReq(t, params)
4886
4887 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4888 // Decode of this response fails which will result resending original request
4889 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
4890
4891 _, cremsg = e2termConn1.RecvSubsReq(t)
4892
4893 xappConn1.ExpectRESTNotification(t, restSubId)
4894
4895 // Subscription already created in E2 Node.
4896 fparams := &teststube2ap.E2StubSubsFailParams{}
4897 fparams.Set(crereq)
4898 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
4899 e2termConn1.SendSubsFail(t, fparams, cremsg)
4900
4901 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4902 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4903
4904 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4905 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4906
4907 // Wait that subs is cleaned
4908 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
4909
4910 xappConn1.TestMsgChanEmpty(t)
4911 e2termConn1.TestMsgChanEmpty(t)
4912 mainCtrl.wait_registry_empty(t, 10)
4913}
4914
4915//-----------------------------------------------------------------------------
4916// TestRESTUnpackSubscriptionResponseUnknownInstanceId
4917//
4918// stub stub
4919// +-------+ +---------+ +---------+
4920// | xapp | | submgr | | e2term |
4921// +-------+ +---------+ +---------+
4922// | | |
4923// | RestSubReq | |
4924// |---------------->| |
4925// | | |
4926// | RESTSubResp | |
4927// |<----------------| |
4928// | | |
4929// | | SubReq |
4930// | |------------->|
4931// | | |
4932// | | SubResp | Unknown instanceId
4933// | |<-------------|
4934// | | |
4935// | | SubReq |
4936// | |------------->|
4937// | | |
4938// | | SubFail | Duplicated action
4939// | |<-------------|
4940// | RESTNotif (fail)| |
4941// |<----------------| |
4942// | | SubDelReq |
4943// | |------------->|
4944// | | |
4945// | | SubDelResp |
4946// | |<-------------|
4947//
4948//-----------------------------------------------------------------------------
4949func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
4950 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
4951 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03004952
4953 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004954 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03004955 restSubId := xappConn1.SendRESTSubsReq(t, params)
4956
4957 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4958
4959 // Unknown instanceId in this response which will result resending original request
4960 orgInstanceId := crereq.RequestId.InstanceId
4961 crereq.RequestId.InstanceId = 0
4962 e2termConn1.SendSubsResp(t, crereq, cremsg)
4963
4964 _, cremsg = e2termConn1.RecvSubsReq(t)
4965
4966 xappConn1.ExpectRESTNotification(t, restSubId)
4967
4968 // Subscription already created in E2 Node.
4969 fparams := &teststube2ap.E2StubSubsFailParams{}
4970 fparams.Set(crereq)
4971 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
4972 e2termConn1.SendSubsFail(t, fparams, cremsg)
4973
4974 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4975 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4976
4977 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4978 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4979
4980 // Wait that subs is cleaned
4981 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
4982
4983 xappConn1.TestMsgChanEmpty(t)
4984 e2termConn1.TestMsgChanEmpty(t)
4985 mainCtrl.wait_registry_empty(t, 10)
4986}
4987
4988//-----------------------------------------------------------------------------
4989// TestRESTUnpackSubscriptionResponseNoTransaction
4990//
4991// stub stub
4992// +-------+ +---------+ +---------+
4993// | xapp | | submgr | | e2term |
4994// +-------+ +---------+ +---------+
4995// | | |
4996// | RestSubReq | |
4997// |---------------->| |
4998// | | |
4999// | RESTSubResp | |
5000// |<----------------| |
5001// | | |
5002// | | SubReq |
5003// | |------------->|
5004// | | |
5005// | | SubResp | No transaction for the response
5006// | |<-------------|
5007// | | |
5008// | | SubReq |
5009// | |------------->|
5010// | | |
5011// | | SubFail | Duplicated action
5012// | |<-------------|
5013// | RESTNotif (fail)| |
5014// |<----------------| |
5015// | | SubDelReq |
5016// | |------------->|
5017// | | |
5018// | | SubDelResp |
5019// | |<-------------|
5020// | | |
5021// | | SubDelReq |
5022// | |------------->|
5023// | | |
5024// | | SubDelResp |
5025// | |<-------------|
5026//
5027//-----------------------------------------------------------------------------
5028func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
5029 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5030 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005031
5032 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005033 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005034 restSubId := xappConn1.SendRESTSubsReq(t, params)
5035
5036 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5037
5038 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5039 // No transaction exist for this response which will result resending original request
5040 e2termConn1.SendSubsResp(t, crereq, cremsg)
5041
5042 _, cremsg = e2termConn1.RecvSubsReq(t)
5043
5044 xappConn1.ExpectRESTNotification(t, restSubId)
5045
5046 // Subscription already created in E2 Node.
5047 fparams := &teststube2ap.E2StubSubsFailParams{}
5048 fparams.Set(crereq)
5049 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5050 e2termConn1.SendSubsFail(t, fparams, cremsg)
5051
5052 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5053 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5054
5055 // Resending happens because there no transaction
5056 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5057 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5058
5059 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5060 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5061
5062 // Wait that subs is cleaned
5063 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5064
5065 xappConn1.TestMsgChanEmpty(t)
5066 e2termConn1.TestMsgChanEmpty(t)
5067 mainCtrl.wait_registry_empty(t, 10)
5068
5069}
5070
5071//-----------------------------------------------------------------------------
5072// TestRESTUnpackSubscriptionFailureDecodeFail
5073//
5074// stub stub
5075// +-------+ +---------+ +---------+
5076// | xapp | | submgr | | e2term |
5077// +-------+ +---------+ +---------+
5078// | | |
5079// | RestSubReq | |
5080// |---------------->| |
5081// | | |
5082// | RESTSubResp | |
5083// |<----------------| |
5084// | | |
5085// | | SubReq |
5086// | |------------->|
5087// | | |
5088// | | SubFail | ASN.1 decode fails
5089// | |<-------------|
5090// | | |
5091// | | SubReq |
5092// | |------------->|
5093// | | |
5094// | | SubFail | Duplicated action
5095// | |<-------------|
5096// | RESTNotif (fail)| |
5097// |<----------------| |
5098// | | SubDelReq |
5099// | |------------->|
5100// | | |
5101// | | SubDelResp |
5102// | |<-------------|
5103//
5104//-----------------------------------------------------------------------------
5105func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
5106 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5107 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005108
5109 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005110 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005111 restSubId := xappConn1.SendRESTSubsReq(t, params)
5112
5113 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5114
5115 // Decode of this response fails which will result resending original request
5116 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5117
5118 _, cremsg = e2termConn1.RecvSubsReq(t)
5119
5120 xappConn1.ExpectRESTNotification(t, restSubId)
5121
5122 // Subscription already created in E2 Node.
5123 fparams := &teststube2ap.E2StubSubsFailParams{}
5124 fparams.Set(crereq)
5125 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5126 e2termConn1.SendSubsFail(t, fparams, cremsg)
5127
5128 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5129 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5130
5131 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5132 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5133
5134 // Wait that subs is cleaned
5135 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5136
5137 xappConn1.TestMsgChanEmpty(t)
5138 e2termConn1.TestMsgChanEmpty(t)
5139 mainCtrl.wait_registry_empty(t, 10)
5140}
5141
5142//-----------------------------------------------------------------------------
5143// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5144//
5145// stub stub
5146// +-------+ +---------+ +---------+
5147// | xapp | | submgr | | e2term |
5148// +-------+ +---------+ +---------+
5149// | | |
5150// | RestSubReq | |
5151// |---------------->| |
5152// | | |
5153// | RESTSubResp | |
5154// |<----------------| |
5155// | | |
5156// | | SubReq |
5157// | |------------->|
5158// | | |
5159// | | SubFail | Unknown instanceId
5160// | |<-------------|
5161// | | |
5162// | | SubReq |
5163// | |------------->|
5164// | | |
5165// | | SubFail | Duplicated action
5166// | |<-------------|
5167// | RESTNotif (fail)| |
5168// |<----------------| |
5169// | | SubDelReq |
5170// | |------------->|
5171// | | |
5172// | | SubDelResp |
5173// | |<-------------|
5174//
5175//-----------------------------------------------------------------------------
5176func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
5177 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
5178 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005179
5180 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005181 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005182 restSubId := xappConn1.SendRESTSubsReq(t, params)
5183
5184 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5185
5186 // Unknown instanceId in this response which will result resending original request
5187 fparams := &teststube2ap.E2StubSubsFailParams{}
5188 fparams.Set(crereq)
5189 fparams.Fail.RequestId.InstanceId = 0
5190 e2termConn1.SendSubsFail(t, fparams, cremsg)
5191
5192 _, cremsg = e2termConn1.RecvSubsReq(t)
5193
5194 xappConn1.ExpectRESTNotification(t, restSubId)
5195
5196 // Subscription already created in E2 Node.
5197 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5198 e2termConn1.SendSubsFail(t, fparams, cremsg)
5199
5200 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5201 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5202
5203 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5204 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5205
5206 // Wait that subs is cleaned
5207 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5208
5209 xappConn1.TestMsgChanEmpty(t)
5210 e2termConn1.TestMsgChanEmpty(t)
5211 mainCtrl.wait_registry_empty(t, 10)
5212}
5213
5214//-----------------------------------------------------------------------------
5215// TestRESTUnpackSubscriptionFailureNoTransaction
5216//
5217// stub stub
5218// +-------+ +---------+ +---------+
5219// | xapp | | submgr | | e2term |
5220// +-------+ +---------+ +---------+
5221// | | |
5222// | RestSubReq | |
5223// |---------------->| |
5224// | | |
5225// | RESTSubResp | |
5226// |<----------------| |
5227// | | |
5228// | | SubReq |
5229// | |------------->|
5230// | | |
5231// | | SubFail | No transaction for the response
5232// | |<-------------|
5233// | | |
5234// | | SubReq |
5235// | |------------->|
5236// | | |
5237// | | SubFail | Duplicated action
5238// | |<-------------|
5239// | RESTNotif (fail)| |
5240// |<----------------| |
5241// | | SubDelReq |
5242// | |------------->|
5243// | | |
5244// | | SubDelResp |
5245// | |<-------------|
5246//
5247//-----------------------------------------------------------------------------
5248func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
5249 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
5250 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005251
5252 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005253 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005254 restSubId := xappConn1.SendRESTSubsReq(t, params)
5255
5256 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5257
5258 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5259
5260 // No transaction exist for this response which will result resending original request
5261 fparams := &teststube2ap.E2StubSubsFailParams{}
5262 fparams.Set(crereq)
5263 e2termConn1.SendSubsFail(t, fparams, cremsg)
5264
5265 _, cremsg = e2termConn1.RecvSubsReq(t)
5266
5267 xappConn1.ExpectRESTNotification(t, restSubId)
5268
5269 // Subscription already created in E2 Node.
5270 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5271 e2termConn1.SendSubsFail(t, fparams, cremsg)
5272
5273 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5274 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5275
5276 // Resending happens because there no transaction
5277 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5278 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5279
5280 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5281 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5282
5283 // Wait that subs is cleaned
5284 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5285
5286 xappConn1.TestMsgChanEmpty(t)
5287 e2termConn1.TestMsgChanEmpty(t)
5288 mainCtrl.wait_registry_empty(t, 10)
5289}
5290
5291//-----------------------------------------------------------------------------
5292// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
5293//
5294// stub stub
5295// +-------+ +---------+ +---------+
5296// | xapp | | submgr | | e2term |
5297// +-------+ +---------+ +---------+
5298// | | |
5299// | [SUBS CREATE] |
5300// | | |
5301// | | |
5302// | RESTSubDelReq | |
5303// |---------------->| |
5304// | | |
5305// | RESTSubDelResp | |
5306// |<----------------| |
5307// | | |
5308// | | SubDelReq |
5309// | |------------->|
5310// | | |
5311// | | SubDelResp | ASN.1 decode fails
5312// | |<-------------|
5313// | | |
5314// | | SubDelReq |
5315// | |------------->|
5316// | | |
5317// | | SubDelFail | Subscription does exist any more
5318// | |<-------------|
5319// | | |
5320//
5321//-----------------------------------------------------------------------------
5322func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
5323 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
5324
5325 // Req
5326 var params *teststube2ap.RESTSubsReqParams = nil
5327 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5328
5329 // Del
5330 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5331
5332 // E2t: Receive 1st SubsDelReq
5333 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5334
5335 // Decode of this response fails which will result resending original request
5336 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
5337
5338 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5339 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5340
5341 // Subscription does not exist in in E2 Node.
5342 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5343
5344 // Wait that subs is cleaned
5345 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5346
5347 xappConn1.TestMsgChanEmpty(t)
5348 e2termConn1.TestMsgChanEmpty(t)
5349 mainCtrl.wait_registry_empty(t, 10)
5350}
5351
5352//-----------------------------------------------------------------------------
5353// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
5354//
5355// stub stub
5356// +-------+ +---------+ +---------+
5357// | xapp | | submgr | | e2term |
5358// +-------+ +---------+ +---------+
5359// | | |
5360// | [SUBS CREATE] |
5361// | | |
5362// | | |
5363// | RESTSubDelReq | |
5364// |---------------->| |
5365// | | |
5366// | RESTSubDelResp | |
5367// |<----------------| |
5368// | | |
5369// | | SubDelReq |
5370// | |------------->|
5371// | | |
5372// | | SubDelResp | Unknown instanceId
5373// | |<-------------|
5374// | | |
5375// | | SubDelReq |
5376// | |------------->|
5377// | | |
5378// | | SubDelFail | Subscription does exist any more
5379// | |<-------------|
5380//
5381//-----------------------------------------------------------------------------
5382func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
5383 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
5384
5385 // Req
5386 var params *teststube2ap.RESTSubsReqParams = nil
5387 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5388
5389 // Del
5390 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5391
5392 // E2t: Receive 1st SubsDelReq
5393 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5394
5395 // Unknown instanceId in this response which will result resending original request
5396 delreq.RequestId.InstanceId = 0
5397 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5398
5399 // E2t: Receive 2nd SubsDelReq
5400 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5401
5402 // Subscription does not exist in in E2 Node.
5403 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5404
5405 // Wait that subs is cleaned
5406 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5407
5408 xappConn1.TestMsgChanEmpty(t)
5409 e2termConn1.TestMsgChanEmpty(t)
5410 mainCtrl.wait_registry_empty(t, 10)
5411}
5412
5413//-----------------------------------------------------------------------------
5414// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
5415//
5416// stub stub
5417// +-------+ +---------+ +---------+
5418// | xapp | | submgr | | e2term |
5419// +-------+ +---------+ +---------+
5420// | | |
5421// | [SUBS CREATE] |
5422// | | |
5423// | | |
5424// | RESTSubDelReq | |
5425// |---------------->| |
5426// | | |
5427// | RESTSubDelResp | |
5428// |<----------------| |
5429// | | |
5430// | | SubDelReq |
5431// | |------------->|
5432// | | |
5433// | | SubDelResp | No transaction for the response
5434// | |<-------------|
5435// | | |
5436// | | SubDelReq |
5437// | |------------->|
5438// | | |
5439// | | SubDelFail | Subscription does exist any more
5440// | |<-------------|
5441//
5442//-----------------------------------------------------------------------------
5443func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
5444 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
5445
5446 // Req
5447 var params *teststube2ap.RESTSubsReqParams = nil
5448 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5449
5450 // Del
5451 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5452
5453 // E2t: Receive 1st SubsDelReq
5454 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5455
5456 mainCtrl.MakeTransactionNil(t, e2SubsId)
5457
5458 // No transaction exist for this response which will result resending original request
5459 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5460
5461 // E2t: Receive 2nd SubsDelReq
5462 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5463
5464 // Subscription does not exist in in E2 Node.
5465 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5466
5467 // Wait that subs is cleaned
5468 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5469
5470 xappConn1.TestMsgChanEmpty(t)
5471 e2termConn1.TestMsgChanEmpty(t)
5472 mainCtrl.wait_registry_empty(t, 10)
5473}
5474
5475//-----------------------------------------------------------------------------
5476// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
5477//
5478// stub stub
5479// +-------+ +---------+ +---------+
5480// | xapp | | submgr | | e2term |
5481// +-------+ +---------+ +---------+
5482// | | |
5483// | [SUBS CREATE] |
5484// | | |
5485// | | |
5486// | RESTSubDelReq | |
5487// |---------------->| |
5488// | | |
5489// | RESTSubDelResp | |
5490// |<----------------| |
5491// | | |
5492// | | SubDelReq |
5493// | |------------->|
5494// | | |
5495// | | SubDelFail | ASN.1 decode fails
5496// | |<-------------|
5497// | | |
5498// | | SubDelReq |
5499// | |------------->|
5500// | | |
5501// | | SubDelFail | Subscription does exist any more
5502// | |<-------------|
5503//
5504//-----------------------------------------------------------------------------
5505func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
5506 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
5507
5508 // Req
5509 var params *teststube2ap.RESTSubsReqParams = nil
5510 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5511
5512 // Del
5513 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5514
5515 // E2t: Receive 1st SubsDelReq
5516 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5517
5518 // Decode of this response fails which will result resending original request
5519 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
5520
5521 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5522 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5523
5524 // Subscription does not exist in in E2 Node.
5525 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5526
5527 // Wait that subs is cleaned
5528 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5529
5530 xappConn1.TestMsgChanEmpty(t)
5531 e2termConn1.TestMsgChanEmpty(t)
5532 mainCtrl.wait_registry_empty(t, 10)
5533}
5534
5535//-----------------------------------------------------------------------------
5536// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
5537//
5538// stub stub
5539// +-------+ +---------+ +---------+
5540// | xapp | | submgr | | e2term |
5541// +-------+ +---------+ +---------+
5542// | | |
5543// | [SUBS CREATE] |
5544// | | |
5545// | | |
5546// | RESTSubDelReq | |
5547// |---------------->| |
5548// | | |
5549// | RESTSubDelResp | |
5550// |<----------------| |
5551// | | |
5552// | | SubDelReq |
5553// | |------------->|
5554// | | |
5555// | | SubDelFail | Unknown instanceId
5556// | |<-------------|
5557// | | |
5558// | | SubDelReq |
5559// | |------------->|
5560// | | |
5561// | | SubDelFail | Subscription does exist any more
5562// | |<-------------|
5563//
5564//-----------------------------------------------------------------------------
5565func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
5566 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
5567
5568 // Req
5569 var params *teststube2ap.RESTSubsReqParams = nil
5570 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5571
5572 // Del
5573 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5574
5575 // E2t: Receive 1st SubsDelReq
5576 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5577
5578 // Unknown instanceId in this response which will result resending original request
5579 delreq.RequestId.InstanceId = 0
5580 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5581
5582 // E2t: Receive 2nd SubsDelReq
5583 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5584
5585 // Subscription does not exist in in E2 Node.
5586 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5587
5588 // Wait that subs is cleaned
5589 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5590
5591 xappConn1.TestMsgChanEmpty(t)
5592 e2termConn1.TestMsgChanEmpty(t)
5593 mainCtrl.wait_registry_empty(t, 10)
5594}
5595
5596//-----------------------------------------------------------------------------
5597// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
5598//
5599// stub stub
5600// +-------+ +---------+ +---------+
5601// | xapp | | submgr | | e2term |
5602// +-------+ +---------+ +---------+
5603// | | |
5604// | [SUBS CREATE] |
5605// | | |
5606// | | |
5607// | RESTSubDelReq | |
5608// |---------------->| |
5609// | | |
5610// | RESTSubDelResp | |
5611// |<----------------| |
5612// | | |
5613// | | SubDelReq |
5614// | |------------->|
5615// | | |
5616// | | SubDelFail | No transaction for the response
5617// | |<-------------|
5618// | | |
5619// | | SubDelReq |
5620// | |------------->|
5621// | | |
5622// | | SubDelFail | Subscription does exist any more
5623// | |<-------------|
5624//
5625//-----------------------------------------------------------------------------
5626func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
5627 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
5628
5629 // Req
5630 var params *teststube2ap.RESTSubsReqParams = nil
5631 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5632
5633 // Del
5634 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5635
5636 // E2t: Receive 1st SubsDelReq
5637 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5638
5639 mainCtrl.MakeTransactionNil(t, e2SubsId)
5640
5641 // No transaction exist for this response which will result resending original request
5642 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5643
5644 // E2t: Receive 2nd SubsDelReq
5645 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5646
5647 // Subscription does not exist in in E2 Node.
5648 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5649
5650 // Wait that subs is cleaned
5651 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5652
5653 xappConn1.TestMsgChanEmpty(t)
5654 e2termConn1.TestMsgChanEmpty(t)
5655 mainCtrl.wait_registry_empty(t, 10)
5656}
5657
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005658//-----------------------------------------------------------------------------
5659// TestRESTSubReqFailAsn1PackSubReqError
5660//
5661// stub stub
5662// +-------+ +---------+ +---------+
5663// | xapp | | submgr | | e2term |
5664// +-------+ +---------+ +---------+
5665// | | |
5666// | RESTSubReq | |
5667// |---------------->| |
5668// | | |
5669// | RESTSubResp | |
5670// |<----------------| |
5671// | | |
5672// | ASN.1 encode fails |
5673// | | |
5674// | | SubDelReq |
5675// | |------------->|
5676// | | |
5677// | | SubDelFail |
5678// | |<-------------|
5679// | | |
5680// | RESTNotif | |
5681// | unsuccess | |
5682// |<----------------| |
5683// | | |
5684// | [SUBS DELETE] |
5685// | | |
5686//
5687//-----------------------------------------------------------------------------
5688func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
5689
5690 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5691 Counter{cSubReqFromXapp, 1},
5692 Counter{cSubDelReqToE2, 1},
5693 Counter{cSubDelFailFromE2, 1},
5694 Counter{cSubRespToXapp, 1},
5695 })
5696
5697 subReqCount := 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005698
5699 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005700 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005701 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
5702
5703 // Req
5704 restSubId := xappConn1.SendRESTSubsReq(t, params)
5705 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5706
5707 // E2t: Receive SubsDelReq
5708 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5709 xappConn1.ExpectRESTNotification(t, restSubId)
5710
5711 // Subscription does not exist in in E2 Node.
5712 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5713
5714 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5715 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
5716
5717 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
5718 // Wait that subs is cleaned
5719 waitSubsCleanup(t, e2SubsId, 10)
5720 mainCtrl.VerifyCounterValues(t)
5721}
5722
archaggeafbf95f2021-04-14 08:54:05 +03005723////////////////////////////////////////////////////////////////////////////////////
5724// Services for UT cases
5725////////////////////////////////////////////////////////////////////////////////////
5726const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005727const host string = "localhost"
5728
5729func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
5730 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005731 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005732 }
5733 restSubId := fromXappConn.SendRESTSubsReq(t, params)
5734 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5735
5736 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
5737 fromXappConn.ExpectRESTNotification(t, restSubId)
5738 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
5739 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
5740 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5741
5742 return restSubId, e2SubsId
5743}
5744
5745func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
5746
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005747 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005748 if meid != "" {
5749 params.SetMeid(meid)
5750 }
5751 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
5752 restSubId := xappConn2.SendRESTSubsReq(t, params)
5753 xappConn2.ExpectRESTNotification(t, restSubId)
5754 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5755 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
5756 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5757
5758 return restSubId, e2SubsId
5759}
5760
5761func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005762 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005763 restSubId := xappConn1.SendRESTSubsReq(t, params)
5764 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
5765
5766 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5767 xappConn1.ExpectRESTNotification(t, restSubId)
5768 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5769 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5770 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5771
5772 return restSubId, e2SubsId
5773}
5774
5775func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005776 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005777 restSubId := xappConn1.SendRESTSubsReq(t, params)
5778
5779 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5780 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5781 fparams1.Set(crereq1)
5782 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5783
5784 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5785 xappConn1.ExpectRESTNotification(t, restSubId)
5786 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5787 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5788 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
5789
5790 return restSubId, e2SubsId
5791}
5792
5793func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
5794 fromXappConn.SendRESTSubsDelReq(t, restSubId)
5795 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
5796 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
5797}
5798
5799func deleteXapp1Subscription(t *testing.T, restSubId *string) {
5800 xappConn1.SendRESTSubsDelReq(t, restSubId)
5801 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5802 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5803}
5804
5805func deleteXapp2Subscription(t *testing.T, restSubId *string) {
5806 xappConn2.SendRESTSubsDelReq(t, restSubId)
5807 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5808 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5809}
5810
5811func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
5812 resp, _ := xapp.Subscription.QuerySubscriptions()
5813 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
5814 assert.Equal(t, resp[0].Meid, meid)
5815 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
5816}
5817
5818func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
5819 //Wait that subs is cleaned
5820 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
5821
5822 xappConn1.TestMsgChanEmpty(t)
5823 xappConn2.TestMsgChanEmpty(t)
5824 e2termConn1.TestMsgChanEmpty(t)
5825 mainCtrl.wait_registry_empty(t, timeout)
5826}
5827
5828func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
5829
5830 var e2SubsId []uint32
5831
5832 for i := 0; i < count; i++ {
5833 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
5834 crereq, cremsg := toE2termConn.RecvSubsReq(t)
5835 fromXappConn.ExpectRESTNotification(t, restSubId)
5836 toE2termConn.SendSubsResp(t, crereq, cremsg)
5837 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
5838 e2SubsId = append(e2SubsId, instanceId)
5839 xapp.Logger.Info("TEST: %v", e2SubsId)
5840 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
5841 <-time.After(100 * time.Millisecond)
5842 }
5843 return e2SubsId
5844}
5845
5846func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
5847
5848 for i := 0; i < len(e2SubsIds); i++ {
5849 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
5850 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
5851 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
5852 <-time.After(1 * time.Second)
5853 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
5854 <-time.After(100 * time.Millisecond)
5855 }
5856
5857 // Wait that subs is cleaned
5858 for i := 0; i < len(e2SubsIds); i++ {
5859 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
5860 }
5861
5862}