blob: 4f93f20cd12699aa3d721c1b5de2a9712ba9cb20 [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 (
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +000023 "strings"
Anssi Mannila4abf1802021-01-28 13:06:46 +020024 "testing"
25 "time"
26
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020027 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000028 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020029 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020030 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
31 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020032)
33
Markku Virtanenac8bde42021-05-25 09:54:42 +000034func TestSuiteSetup(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +000035 // The effect of this call shall endure thgough the UT suite!
36 // If this causes any issues, the previout interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000037 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000038 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
39
40 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Markku Virtanenac8bde42021-05-25 09:54:42 +000041}
42
43//-----------------------------------------------------------------------------
44// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
45//
46// stub stub stub
47// +-------+ +---------+ +---------+ +---------+
48// | xapp | | submgr | | e2term | | rtmgr |
49// +-------+ +---------+ +---------+ +---------+
50// | | | |
51// | RESTSubReq | | |
52// |---------------->| | |
53// | | RouteCreate | |
54// | |--------------------------->| // The order of these events may vary
55// | | | |
56// | RESTSubResp | | | // The order of these events may vary
57// |<----------------| | |
58// | | RouteResponse| |
59// | |<---------------------------| // The order of these events may vary
60// | | | |
61// | | SubReq | |
62// | |------------->| | // The order of these events may vary
63// | | | |
64// | | SubResp | |
65// | |<-------------| |
66// | RESTNotif1 | | |
67// |<----------------| | |
68// | | | |
69// | RESTSubDelReq | | |
70// |---------------->| | |
71// | | SubDelReq | |
72// | |------------->| |
73// | | | |
74// | RESTSubDelResp| | |
75// |<----------------| | |
76// | | | |
77// | | SubDelResp | |
78// | |<-------------| |
79// | | | |
80// | | | |
81//
82//-----------------------------------------------------------------------------
83func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +000084
85 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
86
87 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
88
89 waitSubsCleanup(t, e2SubsId, 10)
90}
91
Juha Hyttinenfa015662020-01-24 10:05:18 +020092//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +000093// TestRESTSubReqAndE1apDeleteReqPackingError
94//
95// stub stub stub
96// +-------+ +---------+ +---------+ +---------+
97// | xapp | | submgr | | e2term | | rtmgr |
98// +-------+ +---------+ +---------+ +---------+
99// | | | |
100// | RESTSubReq | | |
101// |---------------->| | |
102// | | RouteCreate | |
103// | |--------------------------->| // The order of these events may vary
104// | | | |
105// | RESTSubResp | | | // The order of these events may vary
106// |<----------------| | |
107// | | RouteResponse| |
108// | |<---------------------------| // The order of these events may vary
109// | | | |
110// | | SubReq | |
111// | |------------->| | // The order of these events may vary
112// | | | |
113// | | SubResp | |
114// | |<-------------| |
115// | RESTNotif1 | | |
116// |<----------------| | |
117// | | | |
118// | RESTSubDelReq | | |
119// |---------------->| | |
120// | | | |
121// | RESTSubDelResp| | |
122// |<----------------| | |
123// | | | |
124// | | | |
125//
126//-----------------------------------------------------------------------------
127func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
128
129 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
130
131 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
132 xappConn1.SendRESTSubsDelReq(t, &restSubId)
133 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
134
135 waitSubsCleanup(t, e2SubsId, 10)
136}
137
138//-----------------------------------------------------------------------------
139// TestRESTSubReqAndE1apDeleteRespUnpackingError
140//
141// stub stub stub
142// +-------+ +---------+ +---------+ +---------+
143// | xapp | | submgr | | e2term | | rtmgr |
144// +-------+ +---------+ +---------+ +---------+
145// | | | |
146// | RESTSubReq | | |
147// |---------------->| | |
148// | | RouteCreate | |
149// | |--------------------------->| // The order of these events may vary
150// | | | |
151// | RESTSubResp | | | // The order of these events may vary
152// |<----------------| | |
153// | | RouteResponse| |
154// | |<---------------------------| // The order of these events may vary
155// | | | |
156// | | SubReq | |
157// | |------------->| | // The order of these events may vary
158// | | | |
159// | | SubResp | |
160// | |<-------------| |
161// | RESTNotif1 | | |
162// |<----------------| | |
163// | | | |
164// | RESTSubDelReq | | |
165// |---------------->| | |
166// | | SubDelReq | |
167// | |------------->| |
168// | | | |
169// | RESTSubDelResp| | |
170// |<----------------| | | // The order of these events may vary
171// | | | |
172// | | SubDelResp | |
173// | |<-------------| | // 1.st NOK
174// | | | |
175// | | SubDelReq | |
176// | |------------->| |
177// | | | |
178// | | SubDelResp | |
179// | |<-------------| | // 2.nd NOK
180//
181//-----------------------------------------------------------------------------
182
183func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
184
185 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
186
187 xappConn1.SendRESTSubsDelReq(t, &restSubId)
188 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
189 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
190 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
191
192 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
193 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
194
195 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
196
197 waitSubsCleanup(t, e2SubsId, 10)
198}
199
200//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200201// TestSubReqAndRouteNok
202//
203// stub stub
204// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200205// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200206// +-------+ +---------+ +---------+
207// | | |
208// | SubReq | |
209// |------------->| |
210// | | |
211// | | RouteCreate |
212// | |------------->|
213// | | |
214// | | RouteCreate |
215// | | status:400 |
216// | |<-------------|
217// | | |
218// | [SUBS INT DELETE] |
219// | | |
220//
221//-----------------------------------------------------------------------------
222
223func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200224 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200225
Anssi Mannila4abf1802021-01-28 13:06:46 +0200226 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200227 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
228 Counter{cSubReqFromXapp, 1},
229 Counter{cRouteCreateFail, 1},
230 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200231
Juha Hyttinenfa015662020-01-24 10:05:18 +0200232 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300233 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200234 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200235 waiter.WaitResult(t)
236
237 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200238 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200239
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200240 xappConn1.TestMsgChanEmpty(t)
241 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200242 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200243 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200244
245 <-time.After(1 * time.Second)
246 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200247}
248
249//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200250// TestSubReqAndRouteUpdateNok
251
252// stub stub
253// +-------+ +-------+ +---------+ +---------+
254// | xapp2 | | xapp1 | | submgr | | rtmgr |
255// +-------+ +-------+ +---------+ +---------+
256// | | | |
257// | [SUBS CREATE] | |
258// | | | |
259// | | | |
260// | | | |
261// | SubReq (mergeable) | |
262// |--------------------------->| | |
263// | | | |
264// | | | RouteUpdate |
265// | | |------------->|
266// | | | |
267// | | | RouteUpdate |
268// | | | status:400 |
269// | | |<-------------|
270// | | | |
271// | [SUBS INT DELETE] | |
272// | | | |
273// | | | |
274// | [SUBS DELETE] | |
275// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300276
Anssi Mannila4abf1802021-01-28 13:06:46 +0200277func TestSubReqAndRouteUpdateNok(t *testing.T) {
278 CaseBegin("TestSubReqAndRouteUpdateNok")
279
280 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200281 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
282 Counter{cSubReqFromXapp, 2},
283 Counter{cSubReqToE2, 1},
284 Counter{cSubRespFromE2, 1},
285 Counter{cSubRespToXapp, 1},
286 Counter{cRouteCreateUpdateFail, 1},
287 Counter{cSubDelReqFromXapp, 1},
288 Counter{cSubDelReqToE2, 1},
289 Counter{cSubDelRespFromE2, 1},
290 Counter{cSubDelRespToXapp, 1},
291 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200292
293 cretrans := xappConn1.SendSubsReq(t, nil, nil)
294 crereq, cremsg := e2termConn1.RecvSubsReq(t)
295 e2termConn1.SendSubsResp(t, crereq, cremsg)
296 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
297
298 resp, _ := xapp.Subscription.QuerySubscriptions()
299 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
300 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300301 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200302
303 waiter := rtmgrHttp.AllocNextEvent(false)
304 newSubsId := mainCtrl.get_registry_next_subid(t)
305 xappConn2.SendSubsReq(t, nil, nil)
306 waiter.WaitResult(t)
307
308 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
309 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
310
311 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
312 xappConn1.RecvSubsDelResp(t, deltrans)
313
314 //Wait that subs is cleaned
315 mainCtrl.wait_subs_clean(t, newSubsId, 10)
316 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
317
318 xappConn1.TestMsgChanEmpty(t)
319 xappConn2.TestMsgChanEmpty(t)
320 e2termConn1.TestMsgChanEmpty(t)
321 mainCtrl.wait_registry_empty(t, 10)
322
323 mainCtrl.VerifyCounterValues(t)
324}
325
326//-----------------------------------------------------------------------------
327// TestSubDelReqAndRouteDeleteNok
328//
329// stub stub
330// +-------+ +---------+ +---------+ +---------+
331// | xapp | | submgr | | e2term | | rtmgr |
332// +-------+ +---------+ +---------+ +---------+
333// | | | |
334// | [SUBS CREATE] | |
335// | | | |
336// | | | |
337// | | | |
338// | SubDelReq | | |
339// |------------->| | |
340// | | SubDelReq | |
341// | |------------->| |
342// | | SubDelRsp | |
343// | |<-------------| |
344// | SubDelRsp | | |
345// |<-------------| | |
346// | | RouteDelete | |
347// | |---------------------------->|
348// | | | |
349// | | RouteDelete | |
350// | | status:400 | |
351// | |<----------------------------|
352// | | | |
353func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
354 CaseBegin("TestSubDelReqAndRouteDeleteNok")
355
356 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200357 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
358 Counter{cSubReqFromXapp, 1},
359 Counter{cSubReqToE2, 1},
360 Counter{cSubRespFromE2, 1},
361 Counter{cSubRespToXapp, 1},
362 Counter{cSubDelReqFromXapp, 1},
363 Counter{cRouteDeleteFail, 1},
364 Counter{cSubDelReqToE2, 1},
365 Counter{cSubDelRespFromE2, 1},
366 Counter{cSubDelRespToXapp, 1},
367 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200368
369 cretrans := xappConn1.SendSubsReq(t, nil, nil)
370 crereq, cremsg := e2termConn1.RecvSubsReq(t)
371 e2termConn1.SendSubsResp(t, crereq, cremsg)
372 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
373
374 resp, _ := xapp.Subscription.QuerySubscriptions()
375 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
376 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300377 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200378
379 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
380 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
381
382 waiter := rtmgrHttp.AllocNextEvent(false)
383 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
384 waiter.WaitResult(t)
385
386 xappConn1.RecvSubsDelResp(t, deltrans)
387
388 //Wait that subs is cleaned
389 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
390
391 xappConn1.TestMsgChanEmpty(t)
392 xappConn2.TestMsgChanEmpty(t)
393 e2termConn1.TestMsgChanEmpty(t)
394 mainCtrl.wait_registry_empty(t, 10)
395
396 mainCtrl.VerifyCounterValues(t)
397}
398
399//-----------------------------------------------------------------------------
400// TestSubMergeDelAndRouteUpdateNok
401// stub stub
402// +-------+ +-------+ +---------+ +---------+
403// | xapp2 | | xapp1 | | submgr | | e2term |
404// +-------+ +-------+ +---------+ +---------+
405// | | | |
406// | | | |
407// | | | |
408// | | SubReq1 | |
409// | |------------->| |
410// | | | |
411// | | | SubReq1 |
412// | | |------------->|
413// | | | SubResp1 |
414// | | |<-------------|
415// | | SubResp1 | |
416// | |<-------------| |
417// | | | |
418// | SubReq2 | |
419// |--------------------------->| |
420// | | | |
421// | SubResp2 | |
422// |<---------------------------| |
423// | | | |
424// | | SubDelReq 1 | |
425// | |------------->| |
426// | | | RouteUpdate |
427// | | |-----> rtmgr |
428// | | | |
429// | | | RouteUpdate |
430// | | | status:400 |
431// | | |<----- rtmgr |
432// | | | |
433// | | SubDelResp 1 | |
434// | |<-------------| |
435// | | | |
436// | SubDelReq 2 | |
437// |--------------------------->| |
438// | | | |
439// | | | SubDelReq 2 |
440// | | |------------->|
441// | | | |
442// | | | SubDelReq 2 |
443// | | |------------->|
444// | | | |
445// | SubDelResp 2 | |
446// |<---------------------------| |
447//
448//-----------------------------------------------------------------------------
449func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
450 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
451
452 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200453 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
454 Counter{cSubReqFromXapp, 2},
455 Counter{cSubReqToE2, 1},
456 Counter{cSubRespFromE2, 1},
457 Counter{cSubRespToXapp, 2},
458 Counter{cSubDelReqFromXapp, 2},
459 Counter{cRouteDeleteUpdateFail, 1},
460 Counter{cSubDelReqToE2, 1},
461 Counter{cSubDelRespFromE2, 1},
462 Counter{cSubDelRespToXapp, 2},
463 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200464
465 //Req1
466 rparams1 := &teststube2ap.E2StubSubsReqParams{}
467 rparams1.Init()
468 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
469 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
470 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
471 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
472
473 //Req2
474 rparams2 := &teststube2ap.E2StubSubsReqParams{}
475 rparams2.Init()
476 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
477 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
478
479 resp, _ := xapp.Subscription.QuerySubscriptions()
480 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
481 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300482 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200483
484 //Del1
485 waiter := rtmgrHttp.AllocNextEvent(false)
486 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
487 waiter.WaitResult(t)
488
489 xappConn1.RecvSubsDelResp(t, deltrans1)
490
491 //Del2
492 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
493 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
494 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
495 xappConn2.RecvSubsDelResp(t, deltrans2)
496 //Wait that subs is cleaned
497 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
498
499 xappConn1.TestMsgChanEmpty(t)
500 xappConn2.TestMsgChanEmpty(t)
501 e2termConn1.TestMsgChanEmpty(t)
502 mainCtrl.wait_registry_empty(t, 10)
503
504 mainCtrl.VerifyCounterValues(t)
505}
506
507//-----------------------------------------------------------------------------
508
509//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200510// TestSubReqAndSubDelOk
511//
512// stub stub
513// +-------+ +---------+ +---------+
514// | xapp | | submgr | | e2term |
515// +-------+ +---------+ +---------+
516// | | |
517// | SubReq | |
518// |------------->| |
519// | | |
520// | | SubReq |
521// | |------------->|
522// | | |
523// | | SubResp |
524// | |<-------------|
525// | | |
526// | SubResp | |
527// |<-------------| |
528// | | |
529// | | |
530// | SubDelReq | |
531// |------------->| |
532// | | |
533// | | SubDelReq |
534// | |------------->|
535// | | |
536// | | SubDelResp |
537// | |<-------------|
538// | | |
539// | SubDelResp | |
540// |<-------------| |
541//
542//-----------------------------------------------------------------------------
543func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200544 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200545
Anssi Mannila4abf1802021-01-28 13:06:46 +0200546 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200547 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
548 Counter{cSubReqFromXapp, 1},
549 Counter{cSubReqToE2, 1},
550 Counter{cSubRespFromE2, 1},
551 Counter{cSubRespToXapp, 1},
552 Counter{cSubDelReqFromXapp, 1},
553 Counter{cSubDelReqToE2, 1},
554 Counter{cSubDelRespFromE2, 1},
555 Counter{cSubDelRespToXapp, 1},
556 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200557
558 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200559 crereq, cremsg := e2termConn1.RecvSubsReq(t)
560 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200561 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200562
563 resp, _ := xapp.Subscription.QuerySubscriptions()
564 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
565 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300566 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200567
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200568 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200569 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200570
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200571 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200572 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200573
574 //Wait that subs is cleaned
575 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
576
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200577 xappConn1.TestMsgChanEmpty(t)
578 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200579 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200580 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200581
582 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200583}
584
585//-----------------------------------------------------------------------------
586// TestSubReqRetransmission
587//
588// stub stub
589// +-------+ +---------+ +---------+
590// | xapp | | submgr | | e2term |
591// +-------+ +---------+ +---------+
592// | | |
593// | SubReq | |
594// |------------->| |
595// | | |
596// | | SubReq |
597// | |------------->|
598// | | |
599// | SubReq | |
600// | (retrans) | |
601// |------------->| |
602// | | |
603// | | SubResp |
604// | |<-------------|
605// | | |
606// | SubResp | |
607// |<-------------| |
608// | | |
609// | [SUBS DELETE] |
610// | | |
611//
612//-----------------------------------------------------------------------------
613func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200614 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200615
616 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200617 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200618 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200619
620 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200621 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200622 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
623
Juha Hyttinen1683f912020-04-17 10:39:57 +0300624 // hack as there is no real way to see has message be handled.
625 // Previuos counter check just tells that is has been received by submgr
626 // --> artificial delay
627 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200628 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200629 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200630
631 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200632 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200633 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
634 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200635 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200636
637 //Wait that subs is cleaned
638 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
639
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200640 xappConn1.TestMsgChanEmpty(t)
641 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200642 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200643 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200644}
645
646//-----------------------------------------------------------------------------
647// TestSubDelReqRetransmission
648//
649// stub stub
650// +-------+ +---------+ +---------+
651// | xapp | | submgr | | e2term |
652// +-------+ +---------+ +---------+
653// | | |
654// | [SUBS CREATE] |
655// | | |
656// | | |
657// | SubDelReq | |
658// |------------->| |
659// | | |
660// | | SubDelReq |
661// | |------------->|
662// | | |
663// | SubDelReq | |
664// | (same sub) | |
665// | (same xid) | |
666// |------------->| |
667// | | |
668// | | SubDelResp |
669// | |<-------------|
670// | | |
671// | SubDelResp | |
672// |<-------------| |
673//
674//-----------------------------------------------------------------------------
675func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200676 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200677
678 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200679 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200680 crereq, cremsg := e2termConn1.RecvSubsReq(t)
681 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200682 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200683
684 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200685 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200686 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200687
688 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200689 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200690 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
691
Juha Hyttinen1683f912020-04-17 10:39:57 +0300692 // hack as there is no real way to see has message be handled.
693 // Previuos counter check just tells that is has been received by submgr
694 // --> artificial delay
695 <-time.After(1 * time.Second)
696
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200697 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200698 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200699
700 //Wait that subs is cleaned
701 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
702
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200703 xappConn1.TestMsgChanEmpty(t)
704 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200705 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200706 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200707}
708
709//-----------------------------------------------------------------------------
710// TestSubDelReqCollision
711//
712// stub stub
713// +-------+ +---------+ +---------+
714// | xapp | | submgr | | e2term |
715// +-------+ +---------+ +---------+
716// | | |
717// | [SUBS CREATE] |
718// | | |
719// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200720// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200721// |------------->| |
722// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200723// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200724// | |------------->|
725// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200726// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200727// | (same sub) | |
728// | (diff xid) | |
729// |------------->| |
730// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200731// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200732// | |<-------------|
733// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200734// | SubDelResp 1 | |
735// |<-------------| |
736// | | |
737// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200738// |<-------------| |
739//
740//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200741
Juha Hyttinenfa015662020-01-24 10:05:18 +0200742func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200743 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200744
745 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200746 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200747 crereq, cremsg := e2termConn1.RecvSubsReq(t)
748 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200749 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200750
751 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200752 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200753 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200754
Juha Hyttinen3944a222020-01-24 11:51:46 +0200755 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200756 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200757 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
758 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200759 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
760
Juha Hyttinen1683f912020-04-17 10:39:57 +0300761 // hack as there is no real way to see has message be handled.
762 // Previuos counter check just tells that is has been received by submgr
763 // --> artificial delay
764 <-time.After(1 * time.Second)
765
Juha Hyttinen3944a222020-01-24 11:51:46 +0200766 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200767 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200768
769 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200770 xappConn1.RecvSubsDelResp(t, nil)
771 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200772
773 //Wait that subs is cleaned
774 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
775
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200776 xappConn1.TestMsgChanEmpty(t)
777 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200778 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200779 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200780}
781
782//-----------------------------------------------------------------------------
783// TestSubReqAndSubDelOkTwoParallel
784//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200785// stub stub stub
786// +-------+ +-------+ +---------+ +---------+
787// | xapp | | xapp | | submgr | | e2term |
788// +-------+ +-------+ +---------+ +---------+
789// | | | |
790// | | | |
791// | | | |
792// | | SubReq1 | |
793// | |------------->| |
794// | | | |
795// | | | SubReq1 |
796// | | |------------->|
797// | | | |
798// | SubReq2 | |
799// |------------------------>| |
800// | | | |
801// | | | SubReq2 |
802// | | |------------->|
803// | | | |
804// | | | SubResp1 |
805// | | |<-------------|
806// | | SubResp1 | |
807// | |<-------------| |
808// | | | |
809// | | | SubResp2 |
810// | | |<-------------|
811// | SubResp2 | |
812// |<------------------------| |
813// | | | |
814// | | [SUBS 1 DELETE] |
815// | | | |
816// | | [SUBS 2 DELETE] |
817// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200818//
819//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +0300820
Juha Hyttinenfa015662020-01-24 10:05:18 +0200821func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200822 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200823
824 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200825 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200826 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200827 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200828 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200829
830 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200831 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200832 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300833
834 rparams2.Req.EventTriggerDefinition.Data.Length = 1
835 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
836 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
837
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200838 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200839 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200840
841 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200842 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200843 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200844
845 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200846 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200847 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200848
849 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200850 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200851 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
852 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200853 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200854 //Wait that subs is cleaned
855 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
856
857 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200858 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200859 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
860 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200861 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200862 //Wait that subs is cleaned
863 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
864
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200865 xappConn1.TestMsgChanEmpty(t)
866 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200867 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200868 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200869}
870
871//-----------------------------------------------------------------------------
872// TestSameSubsDiffRan
873// Same subscription to different RANs
874//
875// stub stub
876// +-------+ +---------+ +---------+
877// | xapp | | submgr | | e2term |
878// +-------+ +---------+ +---------+
879// | | |
880// | | |
881// | | |
882// | SubReq(r1) | |
883// |------------->| |
884// | | |
885// | | SubReq(r1) |
886// | |------------->|
887// | | |
888// | | SubResp(r1) |
889// | |<-------------|
890// | | |
891// | SubResp(r1) | |
892// |<-------------| |
893// | | |
894// | SubReq(r2) | |
895// |------------->| |
896// | | |
897// | | SubReq(r2) |
898// | |------------->|
899// | | |
900// | | SubResp(r2) |
901// | |<-------------|
902// | | |
903// | SubResp(r2) | |
904// |<-------------| |
905// | | |
906// | [SUBS r1 DELETE] |
907// | | |
908// | [SUBS r2 DELETE] |
909// | | |
910//
911//-----------------------------------------------------------------------------
912func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200913 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200914
915 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200916 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
917 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200918 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
919 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200920 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200921
922 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200923 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
924 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200925 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
926 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200927 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200928
929 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200930 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
931 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200932 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
933 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200934 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200935 //Wait that subs is cleaned
936 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
937
938 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200939 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
940 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200941 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
942 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200943 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200944 //Wait that subs is cleaned
945 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
946
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200947 xappConn1.TestMsgChanEmpty(t)
948 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200949 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200950 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200951}
952
953//-----------------------------------------------------------------------------
954// TestSubReqRetryInSubmgr
955//
956// stub stub
957// +-------+ +---------+ +---------+
958// | xapp | | submgr | | e2term |
959// +-------+ +---------+ +---------+
960// | | |
961// | SubReq | |
962// |------------->| |
963// | | |
964// | | SubReq |
965// | |------------->|
966// | | |
967// | | |
968// | | SubReq |
969// | |------------->|
970// | | |
971// | | SubResp |
972// | |<-------------|
973// | | |
974// | SubResp | |
975// |<-------------| |
976// | | |
977// | [SUBS DELETE] |
978// | | |
979//
980//-----------------------------------------------------------------------------
981
982func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200983 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200984
985 // Init counter check
986 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
987 Counter{cSubReqFromXapp, 1},
988 Counter{cSubReqToE2, 1},
989 Counter{cSubReReqToE2, 1},
990 Counter{cSubRespFromE2, 1},
991 Counter{cSubRespToXapp, 1},
992 Counter{cSubDelReqFromXapp, 1},
993 Counter{cSubDelReqToE2, 1},
994 Counter{cSubDelRespFromE2, 1},
995 Counter{cSubDelRespToXapp, 1},
996 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200997
998 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200999 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001000
1001 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001002 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001003
1004 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001005 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1006 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001007
1008 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001009 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001010
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001011 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001012 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1013 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001014 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001015
1016 // Wait that subs is cleaned
1017 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1018
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001019 xappConn1.TestMsgChanEmpty(t)
1020 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001021 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001022 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001023
1024 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001025}
1026
1027//-----------------------------------------------------------------------------
1028// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1029//
1030// stub stub
1031// +-------+ +---------+ +---------+
1032// | xapp | | submgr | | e2term |
1033// +-------+ +---------+ +---------+
1034// | | |
1035// | SubReq | |
1036// |------------->| |
1037// | | |
1038// | | SubReq |
1039// | |------------->|
1040// | | |
1041// | | |
1042// | | SubReq |
1043// | |------------->|
1044// | | |
1045// | | SubDelReq |
1046// | |------------->|
1047// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001048// | | SubDelResp |
1049// | |<-------------|
1050// | | |
1051//
1052//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001053func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001054 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001055
1056 // Init counter check
1057 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1058 Counter{cSubReqFromXapp, 1},
1059 Counter{cSubReqToE2, 1},
1060 Counter{cSubReReqToE2, 1},
1061 Counter{cSubReqTimerExpiry, 2},
1062 Counter{cSubDelReqToE2, 1},
1063 Counter{cSubDelRespFromE2, 1},
1064 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001065
1066 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001067 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001068
1069 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001070 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001071
1072 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001073 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001074
1075 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001076 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1077 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001078
1079 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001080 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001081
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001082 xappConn1.TestMsgChanEmpty(t)
1083 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001084 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001085 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001086
1087 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001088}
1089
1090//-----------------------------------------------------------------------------
1091// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1092//
1093// stub stub
1094// +-------+ +---------+ +---------+
1095// | xapp | | submgr | | e2term |
1096// +-------+ +---------+ +---------+
1097// | | |
1098// | SubReq | |
1099// |------------->| |
1100// | | |
1101// | | SubReq |
1102// | |------------->|
1103// | | |
1104// | | |
1105// | | SubReq |
1106// | |------------->|
1107// | | |
1108// | | SubDelReq |
1109// | |------------->|
1110// | | |
1111// | | |
1112// | | SubDelReq |
1113// | |------------->|
1114// | | |
1115// | | |
1116//
1117//-----------------------------------------------------------------------------
1118
1119func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001120 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001121
1122 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1123 Counter{cSubReqFromXapp, 1},
1124 Counter{cSubReqToE2, 1},
1125 Counter{cSubReReqToE2, 1},
1126 Counter{cSubReqTimerExpiry, 2},
1127 Counter{cSubDelReqToE2, 1},
1128 Counter{cSubDelReReqToE2, 1},
1129 Counter{cSubDelReqTimerExpiry, 2},
1130 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001131
1132 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001133 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001134
1135 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001136 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001137
1138 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001139 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001140
1141 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001142 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001143
1144 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001145 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001146
1147 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001148 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001149
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001150 xappConn1.TestMsgChanEmpty(t)
1151 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001152 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001153 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001154
1155 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001156}
1157
1158//-----------------------------------------------------------------------------
1159// TestSubReqSubFailRespInSubmgr
1160//
1161// stub stub
1162// +-------+ +---------+ +---------+
1163// | xapp | | submgr | | e2term |
1164// +-------+ +---------+ +---------+
1165// | | |
1166// | SubReq | |
1167// |------------->| |
1168// | | |
1169// | | SubReq |
1170// | |------------->|
1171// | | |
1172// | | SubFail |
1173// | |<-------------|
1174// | | |
archaggeafbf95f2021-04-14 08:54:05 +03001175// | | SubDelReq |
1176// | |------------->|
1177// | | |
1178// | | SubDelResp |
1179// | |<-------------|
1180// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001181// | SubFail | |
1182// |<-------------| |
1183// | | |
1184//
1185//-----------------------------------------------------------------------------
1186
1187func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001188 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001189
1190 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1191 Counter{cSubReqFromXapp, 1},
1192 Counter{cSubReqToE2, 1},
1193 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001194 Counter{cSubFailToXapp, 1},
1195 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001196
1197 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001198 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001199
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001200 // E2t: Receive SubsReq and send SubsFail (first)
1201 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1202 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1203 fparams1.Set(crereq1)
1204 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1205
archaggeafbf95f2021-04-14 08:54:05 +03001206 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1207 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1208 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1209
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001210 // Xapp: Receive SubsFail
1211 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1212
1213 // Wait that subs is cleaned
1214 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1215
1216 xappConn1.TestMsgChanEmpty(t)
1217 xappConn2.TestMsgChanEmpty(t)
1218 e2termConn1.TestMsgChanEmpty(t)
1219 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001220
1221 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001222}
1223
1224//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001225// TestSubDelReqRetryInSubmgr
1226//
1227// stub stub
1228// +-------+ +---------+ +---------+
1229// | xapp | | submgr | | e2term |
1230// +-------+ +---------+ +---------+
1231// | | |
1232// | [SUBS CREATE] |
1233// | | |
1234// | | |
1235// | SubDelReq | |
1236// |------------->| |
1237// | | |
1238// | | SubDelReq |
1239// | |------------->|
1240// | | |
1241// | | SubDelReq |
1242// | |------------->|
1243// | | |
1244// | | SubDelResp |
1245// | |<-------------|
1246// | | |
1247// | SubDelResp | |
1248// |<-------------| |
1249//
1250//-----------------------------------------------------------------------------
1251
1252func TestSubDelReqRetryInSubmgr(t *testing.T) {
1253
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001254 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001255
1256 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001257 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001258 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1259 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001260 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001261
1262 // Subs Delete
1263 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001264 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001265
1266 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001267 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001268
1269 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001270 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1271 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001272
1273 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001274 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001275
1276 // Wait that subs is cleaned
1277 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1278
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001279 xappConn1.TestMsgChanEmpty(t)
1280 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001281 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001282 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001283}
1284
1285//-----------------------------------------------------------------------------
1286// TestSubDelReqTwoRetriesNoRespInSubmgr
1287//
1288// stub stub
1289// +-------+ +---------+ +---------+
1290// | xapp | | submgr | | e2term |
1291// +-------+ +---------+ +---------+
1292// | | |
1293// | [SUBS CREATE] |
1294// | | |
1295// | | |
1296// | SubDelReq | |
1297// |------------->| |
1298// | | |
1299// | | SubDelReq |
1300// | |------------->|
1301// | | |
1302// | | SubDelReq |
1303// | |------------->|
1304// | | |
1305// | | |
1306// | SubDelResp | |
1307// |<-------------| |
1308//
1309//-----------------------------------------------------------------------------
1310
1311func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1312
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001313 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001314
1315 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001316 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001317 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1318 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001319 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001320
1321 // Subs Delete
1322 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001323 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001324
1325 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001326 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001327
1328 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001329 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001330
1331 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001332 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001333
1334 // Wait that subs is cleaned
1335 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1336
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001337 xappConn1.TestMsgChanEmpty(t)
1338 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001339 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001340 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001341}
1342
1343//-----------------------------------------------------------------------------
1344// TestSubDelReqSubDelFailRespInSubmgr
1345//
1346// stub stub
1347// +-------+ +---------+ +---------+
1348// | xapp | | submgr | | e2term |
1349// +-------+ +---------+ +---------+
1350// | | |
1351// | [SUBS CREATE] |
1352// | | |
1353// | | |
1354// | SubDelReq | |
1355// |------------->| |
1356// | | |
1357// | | SubDelReq |
1358// | |------------->|
1359// | | |
1360// | | SubDelFail |
1361// | |<-------------|
1362// | | |
1363// | SubDelResp | |
1364// |<-------------| |
1365// | | |
1366//
1367//-----------------------------------------------------------------------------
1368
1369func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001370 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001371
1372 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1373 Counter{cSubReqFromXapp, 1},
1374 Counter{cSubReqToE2, 1},
1375 Counter{cSubRespFromE2, 1},
1376 Counter{cSubRespToXapp, 1},
1377 Counter{cSubDelReqFromXapp, 1},
1378 Counter{cSubDelReqToE2, 1},
1379 Counter{cSubDelFailFromE2, 1},
1380 Counter{cSubDelRespToXapp, 1},
1381 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001382
1383 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001384 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001385 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1386 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001387 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001388
1389 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001390 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001391
1392 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001393 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1394 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001395
1396 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001397 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001398
1399 // Wait that subs is cleaned
1400 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1401
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001402 xappConn1.TestMsgChanEmpty(t)
1403 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001404 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001405 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001406
1407 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001408}
1409
1410//-----------------------------------------------------------------------------
1411// TestSubReqAndSubDelOkSameAction
1412//
1413// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001414// +-------+ +-------+ +---------+ +---------+
1415// | xapp2 | | xapp1 | | submgr | | e2term |
1416// +-------+ +-------+ +---------+ +---------+
1417// | | | |
1418// | | | |
1419// | | | |
1420// | | SubReq1 | |
1421// | |------------->| |
1422// | | | |
1423// | | | SubReq1 |
1424// | | |------------->|
1425// | | | SubResp1 |
1426// | | |<-------------|
1427// | | SubResp1 | |
1428// | |<-------------| |
1429// | | | |
1430// | SubReq2 | |
1431// |--------------------------->| |
1432// | | | |
1433// | SubResp2 | |
1434// |<---------------------------| |
1435// | | | |
1436// | | SubDelReq 1 | |
1437// | |------------->| |
1438// | | | |
1439// | | SubDelResp 1 | |
1440// | |<-------------| |
1441// | | | |
1442// | SubDelReq 2 | |
1443// |--------------------------->| |
1444// | | | |
1445// | | | SubDelReq 2 |
1446// | | |------------->|
1447// | | | |
1448// | | | SubDelReq 2 |
1449// | | |------------->|
1450// | | | |
1451// | SubDelResp 2 | |
1452// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001453//
1454//-----------------------------------------------------------------------------
1455func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001456 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001457
Anssi Mannila4abf1802021-01-28 13:06:46 +02001458 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001459 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1460 Counter{cSubReqFromXapp, 2},
1461 Counter{cSubReqToE2, 1},
1462 Counter{cSubRespFromE2, 1},
1463 Counter{cSubRespToXapp, 2},
1464 Counter{cMergedSubscriptions, 1},
1465 Counter{cUnmergedSubscriptions, 1},
1466 Counter{cSubDelReqFromXapp, 2},
1467 Counter{cSubDelReqToE2, 1},
1468 Counter{cSubDelRespFromE2, 1},
1469 Counter{cSubDelRespToXapp, 2},
1470 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001471
Juha Hyttinen3944a222020-01-24 11:51:46 +02001472 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001473 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001474 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001475 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001476 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1477 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001478 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001479
1480 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001481 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001482 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001483 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001484 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1485 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001486 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001487
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001488 resp, _ := xapp.Subscription.QuerySubscriptions()
1489 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1490 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001491 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001492
Juha Hyttinen3944a222020-01-24 11:51:46 +02001493 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001494 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001495 //e2termConn1.RecvSubsDelReq(t)
1496 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001497 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001498 //Wait that subs is cleaned
1499 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1500
1501 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001502 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001503 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1504 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001505 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001506 //Wait that subs is cleaned
1507 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1508
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001509 xappConn1.TestMsgChanEmpty(t)
1510 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001511 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001512 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001513
1514 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001515}
1516
1517//-----------------------------------------------------------------------------
1518// TestSubReqAndSubDelOkSameActionParallel
1519//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001520// stub stub stub
1521// +-------+ +-------+ +---------+ +---------+
1522// | xapp2 | | xapp1 | | submgr | | e2term |
1523// +-------+ +-------+ +---------+ +---------+
1524// | | | |
1525// | | | |
1526// | | | |
1527// | | SubReq1 | |
1528// | |------------->| |
1529// | | | |
1530// | | | SubReq1 |
1531// | | |------------->|
1532// | SubReq2 | |
1533// |--------------------------->| |
1534// | | | SubResp1 |
1535// | | |<-------------|
1536// | | SubResp1 | |
1537// | |<-------------| |
1538// | | | |
1539// | SubResp2 | |
1540// |<---------------------------| |
1541// | | | |
1542// | | SubDelReq 1 | |
1543// | |------------->| |
1544// | | | |
1545// | | SubDelResp 1 | |
1546// | |<-------------| |
1547// | | | |
1548// | SubDelReq 2 | |
1549// |--------------------------->| |
1550// | | | |
1551// | | | SubDelReq 2 |
1552// | | |------------->|
1553// | | | |
1554// | | | SubDelReq 2 |
1555// | | |------------->|
1556// | | | |
1557// | SubDelResp 2 | |
1558// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001559//
1560//-----------------------------------------------------------------------------
1561func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001562 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001563
1564 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001565 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001566 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001567 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001568 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001569
1570 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001571 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001572 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001573 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001574
1575 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001576 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001577 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001578
1579 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001580 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001581
1582 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001583 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1584 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001585
1586 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001587 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001588 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1589 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001590 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001591
1592 //Wait that subs is cleaned
1593 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1594
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001595 xappConn1.TestMsgChanEmpty(t)
1596 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001597 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001598 mainCtrl.wait_registry_empty(t, 10)
1599}
1600
1601//-----------------------------------------------------------------------------
1602// TestSubReqAndSubDelNokSameActionParallel
1603//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001604// stub stub stub
1605// +-------+ +-------+ +---------+ +---------+
1606// | xapp2 | | xapp1 | | submgr | | e2term |
1607// +-------+ +-------+ +---------+ +---------+
1608// | | | |
1609// | | | |
1610// | | | |
1611// | | SubReq1 | |
1612// | |------------->| |
1613// | | | |
1614// | | | SubReq1 |
1615// | | |------------->|
1616// | SubReq2 | |
1617// |--------------------------->| |
1618// | | | SubFail1 |
1619// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001620// | | | |
archaggeafbf95f2021-04-14 08:54:05 +03001621// | | | SubDelReq |
1622// | | |------------->|
1623// | | | SubDelResp |
1624// | | |<-------------|
1625// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001626// | | SubFail1 | |
1627// | |<-------------| |
1628// | | | |
1629// | SubFail2 | |
1630// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001631//
1632//-----------------------------------------------------------------------------
1633func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001634 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001635
1636 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001637 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001638 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001639 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001640
1641 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001642 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001643
1644 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001645 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001646 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001647 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001648 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001649 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001650
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001651 // E2t: send SubsFail (first)
1652 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1653 fparams1.Set(crereq1)
1654 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1655
archaggeafbf95f2021-04-14 08:54:05 +03001656 // E2t: internal delete
1657 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1658 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1659
Juha Hyttinen3944a222020-01-24 11:51:46 +02001660 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001661 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001662 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001663 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001664
1665 //Wait that subs is cleaned
1666 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1667
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001668 xappConn1.TestMsgChanEmpty(t)
1669 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001670 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001671 mainCtrl.wait_registry_empty(t, 10)
1672}
1673
1674//-----------------------------------------------------------------------------
1675// TestSubReqAndSubDelNoAnswerSameActionParallel
1676//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001677// stub stub stub
1678// +-------+ +-------+ +---------+ +---------+
1679// | xapp2 | | xapp1 | | submgr | | e2term |
1680// +-------+ +-------+ +---------+ +---------+
1681// | | | |
1682// | | | |
1683// | | | |
1684// | | SubReq1 | |
1685// | |------------->| |
1686// | | | |
1687// | | | SubReq1 |
1688// | | |------------->|
1689// | | SubReq2 | |
1690// |--------------------------->| |
1691// | | | |
1692// | | | SubReq1 |
1693// | | |------------->|
1694// | | | |
1695// | | | |
1696// | | | SubDelReq |
1697// | | |------------->|
1698// | | | |
1699// | | | SubDelResp |
1700// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001701//
1702//-----------------------------------------------------------------------------
1703func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001704 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001705
1706 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001707 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001708 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001709 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001710
Juha Hyttinen1683f912020-04-17 10:39:57 +03001711 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001712
1713 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001714 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001715 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001716 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001717 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001718 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001719
1720 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001721 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001722
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001723 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1724 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001725
1726 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001727 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001728
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001729 xappConn1.TestMsgChanEmpty(t)
1730 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001731 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001732 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001733}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001734
1735//----------------------------- Policy cases ---------------------------------
1736//-----------------------------------------------------------------------------
1737// TestSubReqPolicyAndSubDelOk
1738//
1739// stub stub
1740// +-------+ +---------+ +---------+
1741// | xapp | | submgr | | e2term |
1742// +-------+ +---------+ +---------+
1743// | | |
1744// | SubReq | |
1745// |------------->| |
1746// | | |
1747// | | SubReq |
1748// | |------------->|
1749// | | |
1750// | | SubResp |
1751// | |<-------------|
1752// | | |
1753// | SubResp | |
1754// |<-------------| |
1755// | | |
1756// | | |
1757// | SubDelReq | |
1758// |------------->| |
1759// | | |
1760// | | SubDelReq |
1761// | |------------->|
1762// | | |
1763// | | SubDelResp |
1764// | |<-------------|
1765// | | |
1766// | SubDelResp | |
1767// |<-------------| |
1768//
1769//-----------------------------------------------------------------------------
1770func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1771 CaseBegin("TestSubReqAndSubDelOk")
1772
1773 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1774 rparams1.Init()
1775 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1776 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1777
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001778 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1779 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001780 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1781 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001782 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001783
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001784 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001785 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001786
1787 //Wait that subs is cleaned
1788 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1789
1790 xappConn1.TestMsgChanEmpty(t)
1791 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001792 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001793 mainCtrl.wait_registry_empty(t, 10)
1794}
1795
1796//-----------------------------------------------------------------------------
1797// TestSubReqPolicyChangeAndSubDelOk
1798//
1799// stub stub
1800// +-------+ +---------+ +---------+
1801// | xapp | | submgr | | e2term |
1802// +-------+ +---------+ +---------+
1803// | | |
1804// | SubReq | |
1805// |------------->| |
1806// | | |
1807// | | SubReq |
1808// | |------------->|
1809// | | |
1810// | | SubResp |
1811// | |<-------------|
1812// | | |
1813// | SubResp | |
1814// |<-------------| |
1815// | | |
1816// | SubReq | |
1817// |------------->| |
1818// | | |
1819// | | SubReq |
1820// | |------------->|
1821// | | |
1822// | | SubResp |
1823// | |<-------------|
1824// | | |
1825// | SubResp | |
1826// |<-------------| |
1827// | | |
1828// | SubDelReq | |
1829// |------------->| |
1830// | | |
1831// | | SubDelReq |
1832// | |------------->|
1833// | | |
1834// | | SubDelResp |
1835// | |<-------------|
1836// | | |
1837// | SubDelResp | |
1838// |<-------------| |
1839//
1840//-----------------------------------------------------------------------------
1841
1842func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1843 CaseBegin("TestSubReqAndSubDelOk")
1844
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001845 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1846 rparams1.Init()
1847 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1848 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001849
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001850 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1851 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001852 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1853
1854 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001855 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001856 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1857 xappConn1.SendSubsReq(t, rparams1, cretrans)
1858
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001859 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1860 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001861 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1862 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001863 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001864
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001865 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001866 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001867
1868 //Wait that subs is cleaned
1869 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1870
1871 xappConn1.TestMsgChanEmpty(t)
1872 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001873 e2termConn1.TestMsgChanEmpty(t)
1874 mainCtrl.wait_registry_empty(t, 10)
1875}
1876
1877//-----------------------------------------------------------------------------
1878// TestSubReqAndSubDelOkTwoE2termParallel
1879//
1880// stub stub stub
1881// +-------+ +---------+ +---------+ +---------+
1882// | xapp | | submgr | | e2term1 | | e2term2 |
1883// +-------+ +---------+ +---------+ +---------+
1884// | | | |
1885// | | | |
1886// | | | |
1887// | SubReq1 | | |
1888// |------------->| | |
1889// | | | |
1890// | | SubReq1 | |
1891// | |------------->| |
1892// | | | |
1893// | SubReq2 | | |
1894// |------------->| | |
1895// | | | |
1896// | | SubReq2 | |
1897// | |---------------------------->|
1898// | | | |
1899// | | SubResp1 | |
1900// | |<-------------| |
1901// | SubResp1 | | |
1902// |<-------------| | |
1903// | | SubResp2 | |
1904// | |<----------------------------|
1905// | SubResp2 | | |
1906// |<-------------| | |
1907// | | | |
1908// | [SUBS 1 DELETE] | |
1909// | | | |
1910// | [SUBS 2 DELETE] | |
1911// | | | |
1912//
1913//-----------------------------------------------------------------------------
1914func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1915 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1916
1917 //Req1
1918 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1919 xappConn1.SendSubsReq(t, nil, cretrans1)
1920 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1921
1922 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1923 xappConn1.SendSubsReq(t, nil, cretrans2)
1924 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1925
1926 //Resp1
1927 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1928 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1929
1930 //Resp2
1931 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1932 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1933
1934 //Del1
1935 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1936 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1937 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1938 xappConn1.RecvSubsDelResp(t, deltrans1)
1939 //Wait that subs is cleaned
1940 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1941
1942 //Del2
1943 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1944 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1945 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1946 xappConn1.RecvSubsDelResp(t, deltrans2)
1947 //Wait that subs is cleaned
1948 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1949
1950 xappConn1.TestMsgChanEmpty(t)
1951 xappConn2.TestMsgChanEmpty(t)
1952 e2termConn1.TestMsgChanEmpty(t)
1953 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001954 mainCtrl.wait_registry_empty(t, 10)
1955}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001956
1957//-----------------------------------------------------------------------------
1958// TestSubReqInsertAndSubDelOk
1959//
1960// stub stub
1961// +-------+ +---------+ +---------+
1962// | xapp | | submgr | | e2term |
1963// +-------+ +---------+ +---------+
1964// | | |
1965// | SubReq | |
1966// |------------->| |
1967// | | |
1968// | | SubReq |
1969// | |------------->|
1970// | | |
1971// | | SubResp |
1972// | |<-------------|
1973// | | |
1974// | SubResp | |
1975// |<-------------| |
1976// | | |
1977// | | |
1978// | SubDelReq | |
1979// |------------->| |
1980// | | |
1981// | | SubDelReq |
1982// | |------------->|
1983// | | |
1984// | | SubDelResp |
1985// | |<-------------|
1986// | | |
1987// | SubDelResp | |
1988// |<-------------| |
1989//
1990//-----------------------------------------------------------------------------
1991func TestSubReqInsertAndSubDelOk(t *testing.T) {
1992 CaseBegin("TestInsertSubReqAndSubDelOk")
1993
1994 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1995 rparams1.Init()
1996 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1997 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1998
1999 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2000 e2termConn1.SendSubsResp(t, crereq, cremsg)
2001 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2002 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2003 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2004
2005 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2006 xappConn1.RecvSubsDelResp(t, deltrans)
2007
2008 //Wait that subs is cleaned
2009 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2010
2011 xappConn1.TestMsgChanEmpty(t)
2012 xappConn2.TestMsgChanEmpty(t)
2013 e2termConn1.TestMsgChanEmpty(t)
2014 mainCtrl.wait_registry_empty(t, 10)
2015}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002016
2017//-----------------------------------------------------------------------------
2018// TestSubReqRetransmissionWithSameSubIdDiffXid
2019//
2020// This case simulates case where xApp restarts and starts sending same
2021// subscription requests which have already subscribed successfully
2022
2023// stub stub
2024// +-------+ +---------+ +---------+
2025// | xapp | | submgr | | e2term |
2026// +-------+ +---------+ +---------+
2027// | | |
2028// | SubReq | |
2029// |------------->| |
2030// | | |
2031// | | SubReq |
2032// | |------------->|
2033// | | |
2034// | | SubResp |
2035// | |<-------------|
2036// | | |
2037// | SubResp | |
2038// |<-------------| |
2039// | | |
2040// | xApp restart | |
2041// | | |
2042// | SubReq | |
2043// | (retrans with same xApp generated subid but diff xid)
2044// |------------->| |
2045// | | |
2046// | SubResp | |
2047// |<-------------| |
2048// | | |
2049// | [SUBS DELETE] |
2050// | | |
2051//
2052//-----------------------------------------------------------------------------
2053func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2054 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2055
2056 //Subs Create
2057 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2058 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2059 e2termConn1.SendSubsResp(t, crereq, cremsg)
2060 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2061
2062 // xApp restart here
2063 // --> artificial delay
2064 <-time.After(1 * time.Second)
2065
2066 //Subs Create
2067 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2068 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2069
2070 //Subs Delete
2071 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2072 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2073 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2074 xappConn1.RecvSubsDelResp(t, deltrans)
2075
2076 //Wait that subs is cleaned
2077 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2078
2079 xappConn1.TestMsgChanEmpty(t)
2080 xappConn2.TestMsgChanEmpty(t)
2081 e2termConn1.TestMsgChanEmpty(t)
2082 mainCtrl.wait_registry_empty(t, 10)
2083}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002084
2085//-----------------------------------------------------------------------------
2086// TestSubReqNokAndSubDelOkWithRestartInMiddle
2087//
2088// stub stub
2089// +-------+ +---------+ +---------+
2090// | xapp | | submgr | | e2term |
2091// +-------+ +---------+ +---------+
2092// | | |
2093// | SubReq | |
2094// |------------->| |
2095// | | |
2096// | | SubReq |
2097// | |------------->|
2098// | | |
2099// | | SubResp |
2100// | <----|
2101// | |
2102// | Submgr restart |
2103// | |
2104// | | |
2105// | | SubDelReq |
2106// | |------------->|
2107// | | |
2108// | | SubDelResp |
2109// | |<-------------|
2110// | | |
2111//
2112//-----------------------------------------------------------------------------
2113
2114func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2115 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2116
2117 // Remove possible existing subscrition
2118 mainCtrl.removeExistingSubscriptions(t)
2119
2120 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2121 xappConn1.SendSubsReq(t, nil, nil)
2122 e2termConn1.RecvSubsReq(t)
2123 mainCtrl.SetResetTestFlag(t, false)
2124
2125 resp, _ := xapp.Subscription.QuerySubscriptions()
2126 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002127 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002128 e2SubsId := uint32(resp[0].SubscriptionID)
2129 t.Logf("e2SubsId = %v", e2SubsId)
2130
archaggeafbf95f2021-04-14 08:54:05 +03002131 mainCtrl.SimulateRestart(t)
2132 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002133
2134 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2135 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2136
2137 // Wait that subs is cleaned
2138 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2139
2140 xappConn1.TestMsgChanEmpty(t)
2141 xappConn2.TestMsgChanEmpty(t)
2142 e2termConn1.TestMsgChanEmpty(t)
2143 mainCtrl.wait_registry_empty(t, 10)
2144}
2145
2146//-----------------------------------------------------------------------------
2147// TestSubReqAndSubDelOkWithRestartInMiddle
2148//
2149// stub stub
2150// +-------+ +---------+ +---------+
2151// | xapp | | submgr | | e2term |
2152// +-------+ +---------+ +---------+
2153// | | |
2154// | SubReq | |
2155// |------------->| |
2156// | | |
2157// | | SubReq |
2158// | |------------->|
2159// | | |
2160// | | SubResp |
2161// | |<-------------|
2162// | | |
2163// | SubResp | |
2164// |<-------------| |
2165// | | |
2166// | |
2167// | Submgr restart |
2168// | |
2169// | SubDelReq | |
2170// |------------->| |
2171// | | |
2172// | | SubDelReq |
2173// | |------------->|
2174// | | |
2175// | | SubDelResp |
2176// | |<-------------|
2177// | | |
2178// | SubDelResp | |
2179// |<-------------| |
2180//
2181//-----------------------------------------------------------------------------
2182
2183func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2184 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2185
2186 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2187 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2188 e2termConn1.SendSubsResp(t, crereq, cremsg)
2189 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2190
2191 // Check subscription
2192 resp, _ := xapp.Subscription.QuerySubscriptions()
2193 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2194 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002195 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002196
2197 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002198 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002199
2200 // Check that subscription is restored correctly after restart
2201 resp, _ = xapp.Subscription.QuerySubscriptions()
2202 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2203 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002204 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002205
2206 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2207 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2208 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2209 xappConn1.RecvSubsDelResp(t, deltrans)
2210
2211 //Wait that subs is cleaned
2212 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2213
2214 xappConn1.TestMsgChanEmpty(t)
2215 xappConn2.TestMsgChanEmpty(t)
2216 e2termConn1.TestMsgChanEmpty(t)
2217 mainCtrl.wait_registry_empty(t, 10)
2218}
2219
2220//-----------------------------------------------------------------------------
2221// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2222//
2223// stub stub
2224// +-------+ +-------+ +---------+ +---------+
2225// | xapp2 | | xapp1 | | submgr | | e2term |
2226// +-------+ +-------+ +---------+ +---------+
2227// | | | |
2228// | | | |
2229// | | | |
2230// | | SubReq1 | |
2231// | |------------->| |
2232// | | | |
2233// | | | SubReq1 |
2234// | | |------------->|
2235// | | | SubResp1 |
2236// | | |<-------------|
2237// | | SubResp1 | |
2238// | |<-------------| |
2239// | | | |
2240// | |
2241// | submgr restart |
2242// | |
2243// | | | |
2244// | | | |
2245// | SubReq2 | |
2246// |--------------------------->| |
2247// | | | |
2248// | SubResp2 | |
2249// |<---------------------------| |
2250// | | | |
2251// | | SubDelReq 1 | |
2252// | |------------->| |
2253// | | | |
2254// | | SubDelResp 1 | |
2255// | |<-------------| |
2256// | | | |
2257// | | | |
2258// | |
2259// | submgr restart |
2260// | |
2261// | | | |
2262// | SubDelReq 2 | |
2263// |--------------------------->| |
2264// | | | |
2265// | | | SubDelReq 2 |
2266// | | |------------->|
2267// | | | |
2268// | | | SubDelReq 2 |
2269// | | |------------->|
2270// | | | |
2271// | SubDelResp 2 | |
2272// |<---------------------------| |
2273//
2274//-----------------------------------------------------------------------------
2275
2276func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2277 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2278
2279 //Req1
2280 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2281 rparams1.Init()
2282 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2283 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2284 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2285 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2286
2287 //Req2
2288 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2289 rparams2.Init()
2290 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2291 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2292
2293 // Check subscription
2294 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2295 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2296 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002297 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002298
2299 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002300 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002301
2302 // Check that subscription is restored correctly after restart
2303 resp, _ = xapp.Subscription.QuerySubscriptions()
2304 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2305 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002306 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002307
2308 //Del1
2309 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2310 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2311 xappConn1.RecvSubsDelResp(t, deltrans1)
2312 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2313
2314 mainCtrl.SimulateRestart(t)
2315 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2316
2317 //Del2
2318 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2319 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2320
2321 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2322 xappConn2.RecvSubsDelResp(t, deltrans2)
2323
2324 //Wait that subs is cleaned
2325 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2326
2327 xappConn1.TestMsgChanEmpty(t)
2328 xappConn2.TestMsgChanEmpty(t)
2329 e2termConn1.TestMsgChanEmpty(t)
2330 mainCtrl.wait_registry_empty(t, 10)
2331}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002332
archaggeafbf95f2021-04-14 08:54:05 +03002333//*****************************************************************************
2334// REST interface test cases
2335//*****************************************************************************
2336
Anssi Mannila47518ae2021-04-16 09:27:07 +03002337//-----------------------------------------------------------------------------
2338// Test debug GET and POST requests
2339//
2340// curl
2341// +-------+ +---------+
2342// | user | | submgr |
2343// +-------+ +---------+
2344// | |
2345// | GET/POST Req |
2346// |------------->|
2347// | Resp |
2348// |<-------------|
2349// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002350func TestGetSubscriptions(t *testing.T) {
2351
2352 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2353}
2354
2355func TestGetSymptomData(t *testing.T) {
2356
2357 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2358}
2359
2360func TestPostdeleteSubId(t *testing.T) {
2361
2362 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2363}
2364
2365func TestPostEmptyDb(t *testing.T) {
2366
2367 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2368}
archaggeafbf95f2021-04-14 08:54:05 +03002369
2370//-----------------------------------------------------------------------------
2371// TestRESTSubReqAndRouteNok
2372//
2373// stub stub
2374// +-------+ +---------+ +---------+
2375// | xapp | | submgr | | rtmgr |
2376// +-------+ +---------+ +---------+
2377// | | |
2378// | RESTSubReq | |
2379// |---------------->| |
2380// | | |
2381// | RESTSubResp | |
2382// |<----------------| |
2383// | | RouteCreate |
2384// | |------------->|
2385// | | |
2386// | | RouteCreate |
2387// | | status:400 |
2388// | |(Bad request) |
2389// | |<-------------|
2390// | RESTNotif | |
2391// |<----------------| |
2392// | | |
2393// | [SUBS INT DELETE] |
2394// | | |
2395// | RESTSubDelReq | |
2396// |---------------->| |
2397// | RESTSubDelResp | |
2398// |<----------------| |
2399//
2400//-----------------------------------------------------------------------------
2401func TestRESTSubReqAndRouteNok(t *testing.T) {
2402 CaseBegin("TestRESTSubReqAndRouteNok")
2403
2404 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002405 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002406 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002407 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002408 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002409 Counter{cRestSubDelReqFromXapp, 1},
2410 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002411 })
2412
2413 const subReqCount int = 1
Markku Virtanenda34eec2021-05-20 08:22:04 +00002414 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2415 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002416 newSubsId := mainCtrl.get_registry_next_subid(t)
2417
2418 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002419 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002420 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenda34eec2021-05-20 08:22:04 +00002421 xappConn1.ExpectRESTNotification(t, restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002422 waiter.WaitResult(t)
2423
archaggeafbf95f2021-04-14 08:54:05 +03002424 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2425 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2426
2427 // Del
2428 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2429
2430 // Wait that subs is cleaned
2431 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2432 waitSubsCleanup(t, e2SubsId, 10)
2433 mainCtrl.VerifyCounterValues(t)
2434}
2435
2436func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2437 CaseBegin("TestSubReqAndRouteUpdateNok")
2438
2439 //Init counter check
2440 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002441 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002442 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002443 Counter{cSubReqToE2, 1},
2444 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002445 Counter{cRestSubNotifToXapp, 1},
2446 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002447 Counter{cRouteCreateUpdateFail, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002448 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002449 Counter{cSubDelReqToE2, 1},
2450 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002451 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002452 })
2453
2454 var params *teststube2ap.RESTSubsReqParams = nil
2455
2456 //Subs Create
2457 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2458
2459 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2460
2461 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2462 waiter := rtmgrHttp.AllocNextEvent(false)
2463 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002464 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002465 params.SetMeid("RAN_NAME_1")
2466 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2467 xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
2468 xappConn2.ExpectRESTNotification(t, restSubId2)
2469 waiter.WaitResult(t)
2470 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2471 xappConn2.WaitRESTNotification(t, restSubId2)
2472
2473 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2474
2475 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2476
2477 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2478 //Wait that subs is cleaned
2479 waitSubsCleanup(t, e2SubsId, 10)
2480
2481 mainCtrl.VerifyCounterValues(t)
2482}
2483
2484func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2485 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2486
2487 // Init counter check
2488 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002489 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002490 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002491 Counter{cSubReqToE2, 1},
2492 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002493 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002494 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002495 Counter{cRouteDeleteFail, 1},
2496 Counter{cSubDelReqToE2, 1},
2497 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002498 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002499 })
2500
2501 var params *teststube2ap.RESTSubsReqParams = nil
2502
2503 //Subs Create
2504 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2505
2506 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2507
2508 waiter := rtmgrHttp.AllocNextEvent(false)
2509 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2510 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2511 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2512 waiter.WaitResult(t)
2513
2514 waitSubsCleanup(t, e2SubsId, 10)
2515
2516 mainCtrl.VerifyCounterValues(t)
2517}
2518
2519func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2520 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2521
2522 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002523 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002524 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002525 Counter{cSubReqToE2, 1},
2526 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002527 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002528 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002529 Counter{cRouteDeleteUpdateFail, 1},
2530 Counter{cSubDelReqToE2, 1},
2531 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002532 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002533 })
2534
2535 var params *teststube2ap.RESTSubsReqParams = nil
2536
2537 //Subs Create
2538 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2539
2540 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2541 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2542
2543 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2544
2545 //Del1, this shall fail on rtmgr side
2546 waiter := rtmgrHttp.AllocNextEvent(false)
2547 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2548 waiter.WaitResult(t)
2549
2550 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2551
2552 //Del2
2553 deleteXapp2Subscription(t, &restSubId2)
2554
2555 waitSubsCleanup(t, e2SubsId2, 10)
2556
2557 mainCtrl.VerifyCounterValues(t)
2558}
2559
2560//-----------------------------------------------------------------------------
2561// TestRESTSubReqRetransmission
2562//
2563// stub stub
2564// +-------+ +---------+ +---------+
2565// | xapp | | submgr | | e2term |
2566// +-------+ +---------+ +---------+
2567// | | |
2568// | RESTSubReq1 | |
2569// |---------------->| |
2570// | | |
2571// | RESTSubResp | |
2572// |<----------------| |
2573// | | SubReq1 |
2574// | |------------->|
2575// | | |
2576// | RESTSubReq2 | |
2577// | (retrans) | |
2578// |---------------->| |
2579// | | |
2580// | | SubReq2 |
2581// | |------------->|
2582// | RESTSubResp2 | |
2583// |<----------------| |
2584// | | SubResp1 |
2585// | |<-------------|
2586// | RESTNotif1 | |
2587// |<----------------| |
2588// | | SubResp1 |
2589// | |<-------------|
2590// | RESTNotif2 | |
2591// |<----------------| |
2592// | | |
2593// | [SUBS DELETE] |
2594// | | |
2595//
2596//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002597
archaggeafbf95f2021-04-14 08:54:05 +03002598func TestRESTSubReqRetransmission(t *testing.T) {
2599 CaseBegin("TestRESTSubReqRetransmission")
2600
2601 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002602 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002603 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002604 Counter{cSubReqToE2, 2},
2605 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002606 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002607 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002608 Counter{cSubDelReqToE2, 2},
2609 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002610 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002611 })
2612 // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests
2613 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2614 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2615
2616 // Subs Create
2617 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002618
2619 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2620 // gets into execution before the rtmgrg responds for the first one.
2621 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002622 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002623 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2624 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2625
2626 waiter.WaitResult(t)
2627
2628 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2629
2630 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2631 // the order is not significant he6re.
2632 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2633 e2termConn1.SendSubsResp(t, crereq, cremsg)
2634 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2635 e2termConn1.SendSubsResp(t, crereq, cremsg)
2636
2637 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2638 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2639 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2640 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2641
2642 // Del1
2643 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2644 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2645 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2646
archaggeafbf95f2021-04-14 08:54:05 +03002647 // Del2
2648 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
2649 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2650 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2651
Markku Virtanenda34eec2021-05-20 08:22:04 +00002652 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
2653
archaggeafbf95f2021-04-14 08:54:05 +03002654 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2655
2656 mainCtrl.VerifyCounterValues(t)
2657}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002658
archaggeafbf95f2021-04-14 08:54:05 +03002659func TestRESTSubDelReqRetransmission(t *testing.T) {
2660 CaseBegin("TestRESTSubDelReqRetransmission")
2661
2662 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002663 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002664 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002665 Counter{cSubReqToE2, 1},
2666 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002667 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002668 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002669 Counter{cSubDelReqToE2, 1},
2670 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002671 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002672 })
2673
2674 var params *teststube2ap.RESTSubsReqParams = nil
2675
2676 //Subs Create
2677 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2678
2679 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2680
2681 //Subs Delete
2682 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2683 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2684
2685 seqBef := mainCtrl.get_msgcounter(t)
2686 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2687 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
2688
2689 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2690
2691 waitSubsCleanup(t, e2SubsId, 10)
2692
2693 mainCtrl.VerifyCounterValues(t)
2694}
2695
2696//-----------------------------------------------------------------------------
2697// TestRESTSubReqDelReq
2698//
2699// stub stub
2700// +-------+ +---------+ +---------+
2701// | xapp | | submgr | | e2term |
2702// +-------+ +---------+ +---------+
2703// | | |
2704// | RESTSubReq | |
2705// |---------------->| |
2706// | | |
2707// | RESTSubResp | |
2708// |<----------------| |
2709// | | SubReq |
2710// | |------------->|
2711// | RESTSubDelReq | |
2712// |---------------->| |
2713// | RESTSubDelResp | |
2714// | unsuccess | |
2715// |<----------------| |
2716// | | SubResp |
2717// | |<-------------|
2718// | RESTNotif1 | |
2719// |<----------------| |
2720// | | |
2721// | [SUBS DELETE] |
2722// | | |
2723//
2724//-----------------------------------------------------------------------------
2725func TestRESTSubReqDelReq(t *testing.T) {
2726 CaseBegin("TestRESTSubReqDelReq")
2727
2728 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002729 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002730 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002731 Counter{cSubReqToE2, 1},
2732 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002733 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002734 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002735 Counter{cSubDelReqToE2, 1},
2736 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002737 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002738 })
2739
2740 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002741
2742 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002743 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002744 restSubId := xappConn1.SendRESTSubsReq(t, params)
2745
2746 // Del. This will fail as processing of the subscription
2747 // is still ongoing in submgr. Deletion is not allowed before
2748 // subscription creation has been completed.
2749 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2750 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2751 xappConn1.ExpectRESTNotification(t, restSubId)
2752 e2termConn1.SendSubsResp(t, crereq, cremsg)
2753 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2754
2755 // Retry del
2756 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2757
2758 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2759 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2760
2761 // Wait that subs is cleaned
2762 waitSubsCleanup(t, e2SubsId, 10)
2763 mainCtrl.VerifyCounterValues(t)
2764
2765}
2766
2767func TestRESTSubDelReqCollision(t *testing.T) {
2768 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
2769}
2770
2771func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
2772 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
2773
2774 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002775 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002776 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002777 Counter{cSubReqToE2, 2},
2778 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002779 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002780 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002781 Counter{cSubDelReqToE2, 2},
2782 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002783 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002784 })
2785
2786 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002787 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002788 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2789 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2790
2791 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002792 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002793 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2794 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2795
2796 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2797 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2798
2799 //XappConn1 receives both of the responses
2800 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2801
2802 //Resp1
2803 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2804 //Resp2
2805 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2806
2807 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2808 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2809 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2810 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2811
2812 //Del1
2813 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2814 //Del2
2815 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
2816
2817 //Wait that subs is cleaned
2818 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
2819 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2820
2821 mainCtrl.VerifyCounterValues(t)
2822
2823}
2824
2825func TestRESTSameSubsDiffRan(t *testing.T) {
2826 CaseBegin("TestRESTSameSubsDiffRan")
2827
2828 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002829 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002830 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002831 Counter{cSubReqToE2, 2},
2832 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002833 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002834 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002835 Counter{cSubDelReqToE2, 2},
2836 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002837 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002838 })
2839
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002840 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002841 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
2842 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2843
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002844 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002845 params.SetMeid("RAN_NAME_2")
2846 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
2847 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2848
2849 //Del1
2850 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2851 //Del2
2852 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
2853
2854 //Wait that subs is cleaned
2855 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2856 waitSubsCleanup(t, e2SubsId2, 10)
2857
2858 mainCtrl.VerifyCounterValues(t)
2859
2860}
2861
2862func TestRESTSubReqRetryInSubmgr(t *testing.T) {
2863 CaseBegin("TestRESTSubReqRetryInSubmgr start")
2864
2865 // Init counter check
2866 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002867 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002868 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002869 Counter{cSubReqToE2, 1},
2870 Counter{cSubReReqToE2, 1},
2871 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002872 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002873 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002874 Counter{cSubDelReqToE2, 1},
2875 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002876 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002877 })
2878
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002879 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002880 restSubId := xappConn1.SendRESTSubsReq(t, params)
2881
2882 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2883
2884 // Catch the first message and ignore it
2885 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2886 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
2887
2888 // The second request is being handled normally
2889 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2890 xappConn1.ExpectRESTNotification(t, restSubId)
2891 e2termConn1.SendSubsResp(t, crereq, cremsg)
2892 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2893
2894 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2895
2896 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2897
2898 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2899 //Wait that subs is cleaned
2900 waitSubsCleanup(t, e2SubsId, 10)
2901
2902 mainCtrl.VerifyCounterValues(t)
2903
2904}
2905
2906//-----------------------------------------------------------------------------
2907// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2908//
2909// stub stub
2910// +-------+ +---------+ +---------+
2911// | xapp | | submgr | | e2term |
2912// +-------+ +---------+ +---------+
2913// | | |
2914// | RESTSubReq | |
2915// |---------------->| |
2916// | | |
2917// | RESTSubResp | |
2918// |<----------------| |
2919// | | SubReq |
2920// | |------------->|
2921// | | |
2922// | | |
2923// | | SubReq |
2924// | |------------->|
2925// | | |
2926// | | SubDelReq |
2927// | |------------->|
2928// | | |
2929// | | |
2930// | | SubDelReq |
2931// | |------------->|
2932// | | |
2933// | | |
2934// | | SubDelResp |
2935// | |<-------------|
2936// | RESTNotif | |
2937// | unsuccess | |
2938// |<----------------| |
2939// | | |
2940// | [SUBS DELETE] |
2941// | | |
2942//
2943//-----------------------------------------------------------------------------
2944func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
2945 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
2946
2947 // Init counter check
2948 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002949 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002950 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002951 Counter{cSubReqToE2, 1},
2952 Counter{cSubReReqToE2, 1},
2953 Counter{cSubReqTimerExpiry, 2},
2954 Counter{cSubDelReqToE2, 1},
2955 Counter{cSubDelRespFromE2, 1},
2956 })
2957
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002958 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002959 restSubId := xappConn1.SendRESTSubsReq(t, params)
2960 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2961
2962 e2termConn1.RecvSubsReq(t)
2963 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2964
2965 e2termConn1.RecvSubsReq(t)
2966 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2967
2968 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2969 xappConn1.ExpectRESTNotification(t, restSubId)
2970 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2971 // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - TODO: Should we delete this?
2972 xappConn1.WaitRESTNotification(t, restSubId)
2973
2974 // Wait that subs is cleaned
2975 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
2976
2977 mainCtrl.VerifyCounterValues(t)
2978}
2979
2980func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
2981 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
2982
2983 // Init counter check
2984 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002985 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002986 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002987 Counter{cSubReqToE2, 1},
2988 Counter{cSubReReqToE2, 1},
2989 Counter{cSubReqTimerExpiry, 2},
2990 Counter{cSubDelReqToE2, 1},
2991 Counter{cSubDelReqTimerExpiry, 2},
2992 })
2993
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002994 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002995 restSubId := xappConn1.SendRESTSubsReq(t, params)
2996 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2997
2998 e2termConn1.RecvSubsReq(t)
2999 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3000
3001 e2termConn1.RecvSubsReq(t)
3002 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3003
3004 e2termConn1.RecvSubsDelReq(t)
3005 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3006
3007 xappConn1.ExpectRESTNotification(t, restSubId)
3008 e2termConn1.RecvSubsDelReq(t)
3009 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3010
3011 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3012
3013 waitSubsCleanup(t, e2SubsId, 10)
3014
3015 mainCtrl.VerifyCounterValues(t)
3016
3017}
3018
3019//-----------------------------------------------------------------------------
3020// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3021//
3022// stub stub
3023// +-------+ +---------+ +---------+
3024// | xapp | | submgr | | e2term |
3025// +-------+ +---------+ +---------+
3026// | | |
3027// | RESTSubReq | |
3028// |---------------->| |
3029// | | |
3030// | RESTSubResp | |
3031// |<----------------| |
3032// | | SubReq |
3033// | |------------->|
3034// | | |
3035// | | |
3036// | | SubReq |
3037// | |------------->|
3038// | | |
3039// | | SubDelReq |
3040// | |------------->|
3041// | | |
3042// | | |
3043// | | SubDelReq |
3044// | |------------->|
3045// | | |
3046// | | |
3047// | | SubDelResp |
3048// | |<-------------|
3049// | RESTNotif | |
3050// | unsuccess | |
3051// |<----------------| |
3052// | | |
3053// | [SUBS DELETE] |
3054// | | |
3055//
3056//-----------------------------------------------------------------------------
3057func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3058 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3059
3060 // Init counter check
3061 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003062 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003063 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003064 Counter{cSubReqToE2, 1},
3065 Counter{cSubReReqToE2, 1},
3066 Counter{cSubReqTimerExpiry, 2},
3067 Counter{cSubDelReqToE2, 1},
3068 Counter{cSubDelReReqToE2, 1},
3069 Counter{cSubDelReqTimerExpiry, 2},
3070 })
3071
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003072 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003073 restSubId := xappConn1.SendRESTSubsReq(t, params)
3074 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3075
3076 e2termConn1.RecvSubsReq(t)
3077 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3078
3079 e2termConn1.RecvSubsReq(t)
3080 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3081
3082 e2termConn1.RecvSubsDelReq(t)
3083 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3084
3085 xappConn1.ExpectRESTNotification(t, restSubId)
3086 e2termConn1.RecvSubsDelReq(t)
3087 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3088
3089 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3090
3091 waitSubsCleanup(t, e2SubsId, 10)
3092
3093 mainCtrl.VerifyCounterValues(t)
3094}
3095
3096//-----------------------------------------------------------------------------
3097// TestRESTSubReqSubFailRespInSubmgr
3098//
3099// stub stub
3100// +-------+ +---------+ +---------+
3101// | xapp | | submgr | | e2term |
3102// +-------+ +---------+ +---------+
3103// | | |
3104// | RESTSubReq | |
3105// |---------------->| |
3106// | | |
3107// | RESTSubResp | |
3108// |<----------------| |
3109// | | SubReq |
3110// | |------------->|
3111// | | |
3112// | | SubFail |
3113// | |<-------------|
3114// | | |
3115// | | SubDelReq |
3116// | |------------->|
3117// | | |
3118// | | SubDelResp |
3119// | |<-------------|
3120// | | |
3121// | RESTNotif | |
3122// | unsuccess | |
3123// |<----------------| |
3124// | | |
3125// | [SUBS DELETE] |
3126// | | |
3127//
3128//-----------------------------------------------------------------------------
3129func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3130 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3131
3132 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003133 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003134 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003135 Counter{cSubReqToE2, 1},
3136 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003137 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003138 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003139 })
3140
3141 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003142
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003143 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003144 restSubId := xappConn1.SendRESTSubsReq(t, params)
3145
3146 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3147 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3148 fparams1.Set(crereq1)
3149 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3150
3151 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3152 xappConn1.ExpectRESTNotification(t, restSubId)
3153 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3154 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3155 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
3156
3157 // REST subscription sill there to be deleted
3158 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3159
3160 // Wait that subs is cleaned
3161 waitSubsCleanup(t, e2SubsId, 10)
3162
3163 mainCtrl.VerifyCounterValues(t)
3164
3165}
3166
3167//-----------------------------------------------------------------------------
3168// TestRESTSubDelReqRetryInSubmgr
3169//
3170// stub stub
3171// +-------+ +---------+ +---------+
3172// | xapp | | submgr | | e2term |
3173// +-------+ +---------+ +---------+
3174// | | |
3175// | [SUBS CREATE] |
3176// | | |
3177// | | |
3178// | RESTSubDelReq | |
3179// |---------------->| |
3180// | | |
3181// | RESTSubDelResp | |
3182// |<----------------| |
3183// | | SubDelReq |
3184// | |------------->|
3185// | | |
3186// | | SubDelReq |
3187// | |------------->|
3188// | | |
3189// | | SubDelResp |
3190// | |<-------------|
3191// | | |
3192//
3193//-----------------------------------------------------------------------------
3194func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3195 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3196
3197 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003198 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003199 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003200 Counter{cSubReqToE2, 1},
3201 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003202 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003203 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003204 Counter{cSubDelReqToE2, 1},
3205 Counter{cSubDelReReqToE2, 1},
3206 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003207 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003208 })
3209 // Req
3210 var params *teststube2ap.RESTSubsReqParams = nil
3211 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3212
3213 // Del
3214 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3215
3216 // E2t: Receive 1st SubsDelReq
3217 e2termConn1.RecvSubsDelReq(t)
3218
3219 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3220 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3221 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3222
3223 //Wait that subs is cleaned
3224 waitSubsCleanup(t, e2SubsId, 10)
3225
3226 mainCtrl.VerifyCounterValues(t)
3227}
3228
3229//-----------------------------------------------------------------------------
3230// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3231//
3232// stub stub
3233// +-------+ +---------+ +---------+
3234// | xapp | | submgr | | e2term |
3235// +-------+ +---------+ +---------+
3236// | | |
3237// | [SUBS CREATE] |
3238// | | |
3239// | | |
3240// | RESTSubDelReq | |
3241// |---------------->| |
3242// | | |
3243// | RESTSubDelResp | |
3244// |<----------------| |
3245// | | SubDelReq |
3246// | |------------->|
3247// | | |
3248// | | SubDelReq |
3249// | |------------->|
3250// | | |
3251// | | |
3252//
3253//-----------------------------------------------------------------------------
3254func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3255 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3256
3257 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003258 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003259 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003260 Counter{cSubReqToE2, 1},
3261 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003262 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003263 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003264 Counter{cSubDelReqToE2, 1},
3265 Counter{cSubDelReReqToE2, 1},
3266 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003267 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003268 })
3269
3270 // Req
3271 var params *teststube2ap.RESTSubsReqParams = nil
3272 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3273
3274 // Del
3275 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3276
3277 // E2t: Receive 1st SubsDelReq
3278 e2termConn1.RecvSubsDelReq(t)
3279
3280 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3281 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3282 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3283
3284 //Wait that subs is cleaned
3285 waitSubsCleanup(t, e2SubsId, 10)
3286
3287 mainCtrl.VerifyCounterValues(t)
3288}
3289
3290//-----------------------------------------------------------------------------
3291// TestRESTSubDelReqSubDelFailRespInSubmgr
3292//
3293// stub stub
3294// +-------+ +---------+ +---------+
3295// | xapp | | submgr | | e2term |
3296// +-------+ +---------+ +---------+
3297// | | |
3298// | [SUBS CREATE] |
3299// | | |
3300// | | |
3301// | RESTSubDelReq | |
3302// |---------------->| |
3303// | | |
3304// | RESTSubDelResp | |
3305// |<----------------| |
3306// | | SubDelReq |
3307// | |------------->|
3308// | | |
3309// | | SubDelFail |
3310// | |<-------------|
3311// | | |
3312//
3313//-----------------------------------------------------------------------------
3314func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3315 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3316
3317 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003318 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003319 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003320 Counter{cSubReqToE2, 1},
3321 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003322 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003323 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003324 Counter{cSubDelReqToE2, 1},
3325 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003326 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003327 })
3328
3329 // Req
3330 var params *teststube2ap.RESTSubsReqParams = nil
3331 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3332
3333 // Del
3334 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3335
3336 // E2t: Send receive SubsDelReq and send SubsDelFail
3337 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3338 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3339
3340 //Wait that subs is cleaned
3341 waitSubsCleanup(t, e2SubsId, 10)
3342
3343 mainCtrl.VerifyCounterValues(t)
3344}
3345
3346//-----------------------------------------------------------------------------
3347// TestRESTSubReqAndSubDelOkSameAction
3348//
3349// stub stub
3350// +-------+ +-------+ +---------+ +---------+
3351// | xapp2 | | xapp1 | | submgr | | e2term |
3352// +-------+ +-------+ +---------+ +---------+
3353// | | | |
3354// | | RESTSubReq1 | |
3355// | |---------------->| |
3356// | | | |
3357// | | RESTSubResp1 | |
3358// | |<----------------| |
3359// | | | |
3360// | | | SubReq1 |
3361// | | |------------->|
3362// | | | SubResp1 |
3363// | | |<-------------|
3364// | | RESTNotif1 | |
3365// | |<----------------| |
3366// | | | |
3367// | RESTSubReq2 | |
3368// |------------------------------>| |
3369// | | | |
3370// | RESTSubResp2 | |
3371// |<------------------------------| |
3372// | | | |
3373// | | RESTNotif2 | |
3374// |<------------------------------| |
3375// | | | |
3376// | | RESTSubDelReq1 | |
3377// | |---------------->| |
3378// | | | |
3379// | | RESTSubDelResp1 | |
3380// | |<----------------| |
3381// | | | |
3382// | RESTSubDelReq2 | |
3383// |------------------------------>| |
3384// | | | |
3385// | RESTSubDelResp2 | |
3386// |<------------------------------| |
3387// | | | |
3388// | | | SubDelReq2 |
3389// | | |------------->|
3390// | | | |
3391// | | | SubDelResp2 |
3392// | | |<-------------|
3393// | | | |
3394//
3395//-----------------------------------------------------------------------------
3396func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3397 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3398
3399 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003400 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003401 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003402 Counter{cSubReqToE2, 1},
3403 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003404 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003405 Counter{cMergedSubscriptions, 1},
3406 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003407 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003408 Counter{cSubDelReqToE2, 1},
3409 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003410 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003411 })
3412
3413 // Req1
3414 var params *teststube2ap.RESTSubsReqParams = nil
3415
3416 //Subs Create
3417 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3418 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3419
3420 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003421 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003422 params.SetMeid("RAN_NAME_1")
3423
3424 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
3425 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003426 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003427 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003428 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003429 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
3430 e2SubsId2 := <-xappConn2.RESTNotification
3431 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3432
3433 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3434
3435 // Del1
3436 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3437
3438 // Del2
3439 deleteXapp2Subscription(t, &restSubId2)
3440
3441 //Wait that subs is cleaned
3442 waitSubsCleanup(t, e2SubsId2, 10)
3443
3444 mainCtrl.VerifyCounterValues(t)
3445}
3446
3447//-----------------------------------------------------------------------------
3448// TestSubReqAndSubDelOkSameActionParallel
3449//
3450// stub stub stub
3451// +-------+ +-------+ +---------+ +---------+
3452// | xapp2 | | xapp1 | | submgr | | e2term |
3453// +-------+ +-------+ +---------+ +---------+
3454// | | | |
3455// | | | |
3456// | | | |
3457// | | SubReq1 | |
3458// | |------------->| |
3459// | | | |
3460// | | | SubReq1 |
3461// | | |------------->|
3462// | SubReq2 | |
3463// |--------------------------->| |
3464// | | | SubResp1 |
3465// | | |<-------------|
3466// | | SubResp1 | |
3467// | |<-------------| |
3468// | | | SubReq2 |
3469// | | |------------->|
3470// | | | |
3471// | | | SubResp2 |
3472// | | |<-------------|
3473// | SubResp2 | |
3474// |<---------------------------| |
3475// | | | |
3476// | | SubDelReq 1 | |
3477// | |------------->| |
3478// | | | |
3479// | | SubDelResp 1 | |
3480// | |<-------------| |
3481// | | | |
3482// | SubDelReq 2 | |
3483// |--------------------------->| |
3484// | | | |
3485// | | | SubDelReq 2 |
3486// | | |------------->|
3487// | | | |
3488// | | | SubDelReq 2 |
3489// | | |------------->|
3490// | | | |
3491// | SubDelResp 2 | |
3492// |<---------------------------| |
3493//
3494func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
3495 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
3496
3497 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003498 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003499 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003500 Counter{cSubReqToE2, 2},
3501 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003502 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003503 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003504 Counter{cSubDelReqToE2, 2},
3505 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003506 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003507 })
3508
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003509 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003510 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3511 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3512
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003513 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003514 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3515
3516 xappConn1.ExpectRESTNotification(t, restSubId1)
3517 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3518 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3519
3520 xappConn2.ExpectRESTNotification(t, restSubId2)
3521 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3522 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3523 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3524
3525 // Del1
3526 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3527 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3528 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3529 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3530
3531 // Del2
3532 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3533 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
3534 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
3535
3536 waitSubsCleanup(t, e2SubsId2, 10)
3537
3538 mainCtrl.VerifyCounterValues(t)
3539}
3540
3541//-----------------------------------------------------------------------------
3542// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
3543//
3544// stub stub stub
3545// +-------+ +-------+ +---------+ +---------+
3546// | xapp2 | | xapp1 | | submgr | | e2term |
3547// +-------+ +-------+ +---------+ +---------+
3548// | | | |
3549// | | | |
3550// | | | |
3551// | | RESTSubReq1 | |
3552// | |---------------->| |
3553// | | | |
3554// | | RESTSubResp1 | |
3555// | |<----------------| |
3556// | | | SubReq1 |
3557// | | |------------->|
3558// | RESTSubReq2 | |
3559// |------------------------------>| |
3560// | | | |
3561// | RESTSubDelResp2 | |
3562// |<------------------------------| |
3563// | | | SubReq1 |
3564// | | |------------->|
3565// | | | |
3566// | | | |
3567// | | | SubDelReq |
3568// | | |------------->|
3569// | | | |
3570// | | | SubDelResp |
3571// | | |<-------------|
3572// | | RESTNotif1 | |
3573// | | unsuccess | |
3574// | |<----------------| |
3575// | RESTNotif2 | |
3576// | | unsuccess | |
3577// |<------------------------------| |
3578// | | | |
3579// | | RESTSubDelReq1 | |
3580// | |---------------->| |
3581// | | | |
3582// | | RESTSubDelResp1 | |
3583// | |<----------------| |
3584// | | | |
3585// | RESTSubDelReq2 | |
3586// |------------------------------>| |
3587// | | | |
3588// | RESTSubDelResp2 | |
3589// |<------------------------------| |
3590//
3591//-----------------------------------------------------------------------------
3592func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
3593 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
3594
3595 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003596 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003597 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003598 Counter{cSubReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003599 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003600 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003601 Counter{cSubDelReqToE2, 1},
3602 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003603 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003604 })
3605
3606 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003607
3608 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003609 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003610 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
3611 crereq1, _ := e2termConn1.RecvSubsReq(t)
3612
3613 // Req2
3614 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003615 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003616 params2.SetMeid("RAN_NAME_1")
3617 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3618 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3619
3620 //Req1 (retransmitted)
3621 e2termConn1.RecvSubsReq(t)
3622
3623 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00003624
3625 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03003626 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3627
Markku Virtanenda34eec2021-05-20 08:22:04 +00003628 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3629 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3630 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3631 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003632
3633 // Del1
3634 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3635
3636 // Del2
3637 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3638
Markku Virtanenda34eec2021-05-20 08:22:04 +00003639 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
3640
archaggeafbf95f2021-04-14 08:54:05 +03003641 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00003642 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003643
3644 mainCtrl.VerifyCounterValues(t)
3645}
3646
3647//-----------------------------------------------------------------------------
3648// TestRESTSubReqAndSubDelNokSameActionParallel
3649//
3650// stub stub stub
3651// +-------+ +-------+ +---------+ +---------+
3652// | xapp2 | | xapp1 | | submgr | | e2term |
3653// +-------+ +-------+ +---------+ +---------+
3654// | | | |
3655// | | | |
3656// | | | |
3657// | | RESTSubReq1 | |
3658// | |---------------->| |
3659// | | | |
3660// | | RESTSubResp1 | |
3661// | |<----------------| |
3662// | | | SubReq1 |
3663// | | |------------->|
3664// | RESTSubReq2 | |
3665// |------------------------------>| |
3666// | | | |
3667// | RESTSubDelResp2 | |
3668// |<------------------------------| |
3669// | | | SubFail1 |
3670// | | |<-------------|
3671// | | | |
3672// | | RESTNotif1 | |
3673// | | unsuccess | |
3674// | |<----------------| |
3675// | RESTNotif2 | |
3676// | | unsuccess | |
3677// |<------------------------------| |
3678// | | | SubDelReq |
3679// | | |------------->|
3680// | | | SubDelResp |
3681// | | |<-------------|
3682// | | | |
3683// | | RESTSubDelReq1 | |
3684// | |---------------->| |
3685// | | | |
3686// | | RESTSubDelResp1 | |
3687// | |<----------------| |
3688// | | | |
3689// | RESTSubDelReq2 | |
3690// |------------------------------>| |
3691// | | | |
3692// | RESTSubDelResp2 | |
3693// |<------------------------------| |
3694//
3695//-----------------------------------------------------------------------------
3696func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
3697 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
3698
3699 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003700 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003701 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003702 Counter{cSubReqToE2, 1},
3703 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003704 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003705 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003706 Counter{cSubDelReqToE2, 1},
3707 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003708 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003709 })
3710
3711 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003712
3713 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003714 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003715 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3716 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3717
3718 // Req2
3719 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003720 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003721 params2.SetMeid("RAN_NAME_1")
3722 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3723 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3724
3725 // E2t: send SubsFail (first)
3726 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3727 fparams1.Set(crereq1)
3728 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3729
3730 // E2t: internal delete
3731 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3732 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3733 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3734
3735 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3736 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3737 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3738 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3739
3740 // Del1
3741 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3742
3743 // Del2
3744 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3745
3746 //Wait that subs is cleaned
3747 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
3748 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3749
3750 mainCtrl.VerifyCounterValues(t)
3751}
3752
3753func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
3754 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3755
3756 // Init counter check
3757 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003758 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003759 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003760 Counter{cSubReqToE2, 1},
3761 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003762 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003763 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003764 Counter{cSubDelReqToE2, 1},
3765 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003766 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003767 })
3768
3769 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003770
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003771 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003772 restSubId := xappConn1.SendRESTSubsReq(t, params)
3773 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3774
3775 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3776 xappConn1.ExpectRESTNotification(t, restSubId)
3777 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3778 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3779 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
3780
3781 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3782 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3783 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3784
3785 // Wait that subs is cleaned
3786 waitSubsCleanup(t, e2SubsId, 10)
3787 mainCtrl.VerifyCounterValues(t)
3788}
3789
3790//-----------------------------------------------------------------------------
3791// TestRESTSubReqPolicyChangeAndSubDelOk
3792//
3793// stub stub
3794// +-------+ +---------+ +---------+
3795// | xapp | | submgr | | e2term |
3796// +-------+ +---------+ +---------+
3797// | | |
3798// | RESTSubReq | |
3799// |---------------->| |
3800// | | |
3801// | RESTSubResp | |
3802// |<----------------| |
3803// | | SubReq |
3804// | |------------->|
3805// | | |
3806// | | SubResp |
3807// | |<-------------|
3808// | | |
3809// | RESTNotif | |
3810// |<----------------| |
3811// | | |
3812// | RESTSubReq | |
3813// |---------------->| |
3814// | | |
3815// | RESTSubResp | |
3816// |<----------------| |
3817// | | SubReq |
3818// | |------------->|
3819// | | |
3820// | | SubResp |
3821// | |<-------------|
3822// | | |
3823// | RESTNotif | |
3824// |<----------------| |
3825// | | |
3826// | RESTSubDelReq | |
3827// |---------------->| |
3828// | | |
3829// | | SubDelReq |
3830// | |------------->|
3831// | | |
3832// | | SubDelResp |
3833// | |<-------------|
3834// | | |
3835// | RESTSubDelResp | |
3836// |<----------------| |
3837//
3838//-----------------------------------------------------------------------------
3839func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
3840 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3841
3842 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003843 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003844 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003845 Counter{cSubReqToE2, 2},
3846 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003847 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003848 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003849 Counter{cSubDelReqToE2, 1},
3850 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003851 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003852 })
3853
3854 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003855
3856 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003857 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003858 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3859
3860 // Policy change
archaggeafbf95f2021-04-14 08:54:05 +03003861 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00003862
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003863 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00003864 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003865 params.SetTimeToWait("w200ms")
3866 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3867
3868 // Del
3869 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3870
3871 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3872 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3873
3874 // Wait that subs is cleaned
3875 waitSubsCleanup(t, e2SubsId, 10)
3876 mainCtrl.VerifyCounterValues(t)
3877}
3878
3879//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00003880// TestRESTSubReqPolicyChangeNOk
3881//
3882// stub stub
3883// +-------+ +---------+ +---------+
3884// | xapp | | submgr | | e2term |
3885// +-------+ +---------+ +---------+
3886// | | |
3887// | RESTSubReq | |
3888// |---------------->| |
3889// | | |
3890// | RESTSubResp | |
3891// |<----------------| |
3892// | | SubReq |
3893// | |------------->|
3894// | | |
3895// | | SubResp |
3896// | |<-------------|
3897// | | |
3898// | RESTNotif | |
3899// |<----------------| |
3900// | | |
3901// | RESTSubReq | |
3902// |---------------->| |
3903// | | |
3904// | RESTSubUpdateFail |
3905// | | |
3906// | RESTSubDelReq | |
3907// |---------------->| |
3908// | | |
3909// | | SubDelReq |
3910// | |------------->|
3911// | | |
3912// | | SubDelResp |
3913// | |<-------------|
3914// | | |
3915// | RESTSubDelResp | |
3916// |<----------------| |
3917//
3918//-----------------------------------------------------------------------------
3919func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
3920 CaseBegin("TestRESTSubReqPolicyChangeNOk")
3921
3922 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3923 Counter{cRestSubReqFromXapp, 2},
3924 Counter{cRestSubRespToXapp, 1},
3925 Counter{cSubReqToE2, 1},
3926 Counter{cSubRespFromE2, 1},
3927 Counter{cRestSubNotifToXapp, 1},
3928 Counter{cRestSubFailToXapp, 1},
3929 Counter{cRestSubDelReqFromXapp, 1},
3930 Counter{cSubDelReqToE2, 1},
3931 Counter{cSubDelRespFromE2, 1},
3932 Counter{cRestSubDelRespToXapp, 1},
3933 })
3934
3935 const subReqCount int = 1
3936
3937 // Req
3938 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
3939 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3940
3941 // Policy change
3942
3943 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
3944
3945 restSubIdUpd := strings.ToUpper(restSubId)
3946 params.SetSubscriptionID(&restSubIdUpd)
3947 params.SetTimeToWait("w200ms")
3948
3949 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
3950 assert.Equal(t, restSubId2, "")
3951
3952 // Del
3953 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3954
3955 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3956 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3957
3958 // Wait that subs is cleaned
3959 waitSubsCleanup(t, e2SubsId, 10)
3960 mainCtrl.VerifyCounterValues(t)
3961}
3962
3963//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03003964// TestRESTSubReqAndSubDelOkTwoE2termParallel
3965//
3966// stub stub stub
3967// +-------+ +---------+ +---------+ +---------+
3968// | xapp | | submgr | | e2term1 | | e2term2 |
3969// +-------+ +---------+ +---------+ +---------+
3970// | | | |
3971// | | | |
3972// | | | |
3973// | RESTSubReq1 | | |
3974// |---------------->| | |
3975// | | | |
3976// | RESTSubResp1 | | |
3977// |<----------------| | |
3978// | | SubReq1 | |
3979// | |------------->| |
3980// | | | |
3981// | RESTSubReq2 | | |
3982// |---------------->| | |
3983// | | | |
3984// | RESTSubResp2 | | |
3985// |<----------------| | |
3986// | | SubReq2 | |
3987// | |---------------------------->|
3988// | | | |
3989// | | SubResp1 | |
3990// | |<-------------| |
3991// | RESTNotif1 | | |
3992// |<----------------| | |
3993// | | SubResp2 | |
3994// | |<----------------------------|
3995// | RESTNotif2 | | |
3996// |<----------------| | |
3997// | | | |
3998// | [SUBS 1 DELETE] | |
3999// | | | |
4000// | [SUBS 2 DELETE] | |
4001// | | | |
4002//
4003//-----------------------------------------------------------------------------
4004func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4005 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4006
4007 // Init counter check
4008 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004009 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004010 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004011 Counter{cSubReqToE2, 2},
4012 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004013 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004014 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004015 Counter{cSubDelReqToE2, 2},
4016 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004017 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004018 })
4019
4020 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004021
4022 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004023 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004024 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4025 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4026
4027 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004028 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004029 params.SetMeid("RAN_NAME_11")
4030 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4031 // would not work as notification would not be received
4032 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4033 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4034
4035 // Resp1
4036 xappConn1.ExpectRESTNotification(t, restSubId1)
4037 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4038 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4039 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
4040
4041 // Resp2
4042 xappConn2.ExpectRESTNotification(t, restSubId2)
4043 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4044 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4045 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
4046
4047 // Delete1
4048 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4049 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4050 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4051
4052 // Wait that subs is cleaned
4053 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4054
4055 // Delete2
4056 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4057 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4058 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4059
4060 // Wait that subs is cleaned
4061 waitSubsCleanup(t, e2SubsId2, 10)
4062
4063 mainCtrl.VerifyCounterValues(t)
4064}
4065
4066//-----------------------------------------------------------------------------
4067// TestRESTSubReqAsn1EncodeFail
4068//
4069// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4070// stub stub
4071// +-------+ +---------+ +---------+
4072// | xapp | | submgr | | e2term |
4073// +-------+ +---------+ +---------+
4074// | | |
4075// | RESTSubReq | |
4076// |---------------->| |
4077// | | |
4078// | RESTSubResp | |
4079// |<----------------| |
4080// | RESTSubDelReq | |
4081// |---------------->| |
4082// | RESTSubDelResp | |
4083// | unsuccess | |
4084// |<----------------| |
4085// | | |
4086//
4087//-----------------------------------------------------------------------------
4088func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4089 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4090
4091 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
4092
4093}
4094
4095//-----------------------------------------------------------------------------
4096// TestRESTSubReqInsertAndSubDelOk
4097//
4098// stub stub
4099// +-------+ +---------+ +---------+
4100// | xapp | | submgr | | e2term |
4101// +-------+ +---------+ +---------+
4102// | | |
4103// | RestSubReq | |
4104// |---------------->| |
4105// | | |
4106// | RESTSubResp | |
4107// |<----------------| |
4108// | | |
4109// | | SubReq |
4110// | |------------->|
4111// | | |
4112// | | SubResp |
4113// | |<-------------|
4114// | RESTNotif | |
4115// |<----------------| |
4116// | ... | ... |
4117// | | |
4118// | RESTSubDelReq | |
4119// |---------------->| |
4120// | | |
4121// | | SubDelReq |
4122// | |------------->|
4123// | | |
4124// | | SubDelResp |
4125// | |<-------------|
4126// | | |
4127// | RESTSubDelResp| |
4128// |<----------------| |
4129//
4130//-----------------------------------------------------------------------------
4131func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4132 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4133
4134 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004135 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004136 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004137 Counter{cSubReqToE2, 1},
4138 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004139 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004140 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004141 Counter{cSubDelReqToE2, 1},
4142 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004143 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004144 })
4145
4146 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004147
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004148 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004149 params.SetSubActionTypes("insert")
4150
4151 // Req
4152 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4153
4154 // Del
4155 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4156
4157 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4158 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4159
4160 // Wait that subs is cleaned
4161 waitSubsCleanup(t, e2SubsId, 10)
4162 mainCtrl.VerifyCounterValues(t)
4163}
4164
4165//-----------------------------------------------------------------------------
4166// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4167//
4168// stub stub
4169// +-------+ +---------+ +---------+
4170// | xapp | | submgr | | e2term |
4171// +-------+ +---------+ +---------+
4172// | | |
4173// | RESTSubReq | |
4174// |------------->| |
4175// | | |
4176// | | SubReq |
4177// | |------------->|
4178// | | |
4179// | | SubResp |
4180// | <----|
4181// | |
4182// | Submgr restart |
4183// | |
4184// | | |
4185// | | SubDelReq |
4186// | |------------->|
4187// | | |
4188// | | SubDelResp |
4189// | |<-------------|
4190// | | |
4191//
4192//-----------------------------------------------------------------------------
4193func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4194 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4195
4196 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004197 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004198 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004199 Counter{cSubReqToE2, 1},
4200 Counter{cSubDelReqFromXapp, 1},
4201 Counter{cSubDelReqToE2, 1},
4202 Counter{cSubDelRespFromE2, 1},
4203 })
4204
4205 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004206
4207 // Remove possible existing subscription
4208 mainCtrl.removeExistingSubscriptions(t)
4209
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004210 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004211
4212 //Req
4213 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
4214 restSubId := xappConn1.SendRESTSubsReq(t, params)
4215 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4216
4217 e2termConn1.RecvSubsReq(t)
4218
4219 mainCtrl.SetResetTestFlag(t, false)
4220
4221 mainCtrl.SimulateRestart(t)
4222 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4223
4224 //Del
4225 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4226 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4227
4228 xappConn1.TestMsgChanEmpty(t)
4229 xappConn2.TestMsgChanEmpty(t)
4230 e2termConn1.TestMsgChanEmpty(t)
4231 mainCtrl.wait_registry_empty(t, 10)
4232
4233 mainCtrl.VerifyCounterValues(t)
4234}
4235
4236//-----------------------------------------------------------------------------
4237// TestRESTSubReqAndSubDelOkWithRestartInMiddle
4238//
4239// stub stub
4240// +-------+ +---------+ +---------+
4241// | xapp | | submgr | | e2term |
4242// +-------+ +---------+ +---------+
4243// | | |
4244// | RESTSubReq | |
4245// |---------------->| |
4246// | | |
4247// | RESTSubResp | |
4248// |<----------------| |
4249// | | SubReq |
4250// | |------------->|
4251// | | |
4252// | | SubResp |
4253// | |<-------------|
4254// | | |
4255// | RESTNotif | |
4256// |<----------------| |
4257// | | |
4258// | |
4259// | Submgr restart |
4260// | | |
4261// | RESTSubDelReq | |
4262// |---------------->| |
4263// | | |
4264// | | SubDelReq |
4265// | |------------->|
4266// | | |
4267// | | SubDelResp |
4268// | |<-------------|
4269// | | |
4270// | RESTSubDelResp | |
4271// |<----------------| |
4272//
4273//-----------------------------------------------------------------------------
4274func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4275 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4276
4277 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004278 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004279 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004280 Counter{cSubReqToE2, 1},
4281 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004282 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004283 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004284 Counter{cSubDelReqToE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004285 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004286 })
4287
4288 // Remove possible existing subscription
4289 mainCtrl.removeExistingSubscriptions(t)
4290
4291 var params *teststube2ap.RESTSubsReqParams = nil
4292
4293 // Create subscription
4294 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4295 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4296
4297 // Check subscription
4298 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4299
4300 // When SDL support for the REST Interface is added
4301 // the submgr restart statement below should be removed
4302 // from the comment.
4303
4304 // mainCtrl.SimulateRestart(t)
4305 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4306
4307 // Check subscription
4308 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4309
4310 // Delete subscription
4311 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4312
4313 //Wait that subs is cleaned
4314 waitSubsCleanup(t, e2SubsId, 10)
4315
4316 mainCtrl.VerifyCounterValues(t)
4317}
4318
4319//-----------------------------------------------------------------------------
4320// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4321//
4322// stub stub
4323// +-------+ +-------+ +---------+ +---------+
4324// | xapp2 | | xapp1 | | submgr | | e2term |
4325// +-------+ +-------+ +---------+ +---------+
4326// | | | |
4327// | | RESTSubReq1 | |
4328// | |---------------->| |
4329// | | | |
4330// | | RESTSubResp1 | |
4331// | |<----------------| |
4332// | | | |
4333// | | | SubReq1 |
4334// | | |------------->|
4335// | | | SubResp1 |
4336// | | |<-------------|
4337// | | RESTNotif1 | |
4338// | |<----------------| |
4339// | | | |
4340// | RESTSubReq2 | |
4341// |------------------------------>| |
4342// | | | |
4343// | RESTSubResp2 | |
4344// |<------------------------------| |
4345// | | | |
4346// | | RESTNotif2 | |
4347// |<------------------------------| |
4348// | | | |
4349// | | Submgr restart |
4350// | | | |
4351// | | RESTSubDelReq1 | |
4352// | |---------------->| |
4353// | | | |
4354// | | RESTSubDelResp1 | |
4355// | |<----------------| |
4356// | | | |
4357// | | Submgr restart |
4358// | | | |
4359// | RESTSubDelReq2 | |
4360// |------------------------------>| |
4361// | | | |
4362// | RESTSubDelResp2 | |
4363// |<------------------------------| |
4364// | | | |
4365// | | | SubDelReq2 |
4366// | | |------------->|
4367// | | | |
4368// | | | SubDelResp2 |
4369// | | |<-------------|
4370// | | | |
4371//
4372//-----------------------------------------------------------------------------
4373func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4374 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4375
4376 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004377 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004378 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004379 Counter{cSubReqToE2, 1},
4380 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004381 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004382 Counter{cMergedSubscriptions, 1},
4383 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004384 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004385 Counter{cSubDelReqToE2, 1},
4386 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004387 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004388 })
4389
4390 // Remove possible existing subscription
4391 mainCtrl.removeExistingSubscriptions(t)
4392
4393 var params *teststube2ap.RESTSubsReqParams = nil
4394
4395 // Create subscription 1
4396 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4397 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4398
4399 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004400 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004401 params.SetMeid("RAN_NAME_1")
4402 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4403 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
4404 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4405 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4406 e2SubsId2 := <-xappConn2.RESTNotification
4407 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4408
4409 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4410
4411 // When SDL support for the REST Interface is added
4412 // the submgr restart statement below should be removed
4413 // from the comment.
4414
4415 // mainCtrl.SimulateRestart(t)
4416 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4417
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004418 // Delete subscription 1, and wait until it has removed the first endpoint
4419 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004420 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004421 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004422
4423 // When SDL support for the REST Interface is added
4424 // the submgr restart statement below should be removed
4425 // from the comment.
4426
4427 // mainCtrl.SimulateRestart(t)
4428 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004429 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4430
4431 // Delete subscription 2
4432 deleteXapp2Subscription(t, &restSubId2)
4433
4434 //Wait that subs is cleaned
4435 waitSubsCleanup(t, e2SubsId2, 10)
4436
4437 mainCtrl.VerifyCounterValues(t)
4438}
4439
4440//-----------------------------------------------------------------------------
4441// TestRESTReportSubReqAndSubDelOk
4442//
4443// stub stub
4444// +-------+ +---------+ +---------+
4445// | xapp | | submgr | | e2term |
4446// +-------+ +---------+ +---------+
4447// | | |
4448// | RestSubReq | |
4449// |---------------->| |
4450// | | |
4451// | RESTSubResp | |
4452// |<----------------| |
4453// | | |
4454// | | SubReq |
4455// | |------------->|
4456// | | |
4457// | | SubResp |
4458// | |<-------------|
4459// | RESTNotif | |
4460// |<----------------| |
4461// | | SubReq |
4462// | |------------->|
4463// | | |
4464// | | SubResp |
4465// | |<-------------|
4466// | RESTNotif | |
4467// |<----------------| |
4468// | ... | ... |
4469// | | |
4470// | | |
4471// | RESTSubDelReq | |
4472// |---------------->| |
4473// | | |
4474// | | SubDelReq |
4475// | |------------->|
4476// | | |
4477// | | SubDelResp |
4478// | |<-------------|
4479// | | |
4480// | RESTSubDelResp| |
4481// |<----------------| |
4482//
4483//-----------------------------------------------------------------------------
4484func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
4485 CaseBegin("TestRESTReportSubReqAndSubDelOk")
4486 subReqCount := 1
archaggeafbf95f2021-04-14 08:54:05 +03004487 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004488 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004489}
4490
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004491func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
4492 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004493
4494 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004495 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004496 restSubId := xappConn1.SendRESTSubsReq(t, params)
4497
4498 var e2SubsId []uint32
4499 for i := 0; i < subReqCount; i++ {
4500 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4501 xappConn1.ExpectRESTNotification(t, restSubId)
4502
4503 e2termConn1.SendSubsResp(t, crereq, cremsg)
4504 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4505 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4506 e2SubsId = append(e2SubsId, instanceId)
4507 resp, _ := xapp.Subscription.QuerySubscriptions()
4508 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
4509 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
4510 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
4511
4512 }
4513
4514 // Del
4515 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4516
4517 for i := 0; i < subReqCount; i++ {
4518 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4519 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4520 }
4521
4522 // Wait that subs is cleaned
4523 for i := 0; i < subReqCount; i++ {
4524 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4525 }
4526
4527 xappConn1.TestMsgChanEmpty(t)
4528 e2termConn1.TestMsgChanEmpty(t)
4529 mainCtrl.wait_registry_empty(t, 10)
4530}
4531
4532/*
4533func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
4534 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
4535
4536 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004537 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004538 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004539
4540 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03004541 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004542 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004543}
4544*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004545func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
4546 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004547
4548 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004549 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004550 restSubId := xappConn1.SendRESTSubsReq(t, params)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004551 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004552 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
4553
4554 var e2SubsId []uint32
4555 for i := 0; i < subReqCount; i++ {
4556 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4557 xappConn1.ExpectRESTNotification(t, restSubId)
4558 e2termConn1.SendSubsResp(t, crereq, cremsg)
4559 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4560 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4561 e2SubsId = append(e2SubsId, instanceId)
4562 }
4563
4564 // Del
4565 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4566
4567 for i := 0; i < subReqCount; i++ {
4568 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4569 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4570 }
4571
4572 // Wait that subs is cleaned
4573 for i := 0; i < subReqCount; i++ {
4574 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4575 }
4576 xappConn1.TestMsgChanEmpty(t)
4577 e2termConn1.TestMsgChanEmpty(t)
4578 mainCtrl.wait_registry_empty(t, 10)
4579}
4580
archaggeafbf95f2021-04-14 08:54:05 +03004581func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
4582
4583 subReqCount := 2
4584
4585 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004586 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004587 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004588 Counter{cSubReqToE2, 2},
4589 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004590 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004591 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004592 Counter{cSubDelReqToE2, 2},
4593 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004594 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004595 })
4596
4597 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004598 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004599 restSubId := xappConn1.SendRESTSubsReq(t, params)
4600 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4601
4602 assert.Equal(t, len(e2SubsIds), 2)
4603
4604 // Del
4605 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4606 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4607
4608 xappConn1.TestMsgChanEmpty(t)
4609 e2termConn1.TestMsgChanEmpty(t)
4610 mainCtrl.wait_registry_empty(t, 10)
4611
4612 mainCtrl.VerifyCounterValues(t)
4613}
archaggeafbf95f2021-04-14 08:54:05 +03004614func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
4615
4616 subReqCount := 19
4617
4618 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004619 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004620 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004621 Counter{cSubReqToE2, 19},
4622 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004623 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004624 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004625 Counter{cSubDelReqToE2, 19},
4626 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004627 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004628 })
4629
4630 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004631 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004632 restSubId := xappConn1.SendRESTSubsReq(t, params)
4633 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4634
4635 assert.Equal(t, len(e2SubsIds), 19)
4636
4637 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4638 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4639
4640 xappConn1.TestMsgChanEmpty(t)
4641 e2termConn1.TestMsgChanEmpty(t)
4642 mainCtrl.wait_registry_empty(t, 10)
4643
4644 mainCtrl.VerifyCounterValues(t)
4645}
archaggeafbf95f2021-04-14 08:54:05 +03004646func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
4647
4648 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004649
4650 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004651 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004652 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004653 Counter{cSubReqToE2, uint64(subReqCount)},
4654 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004655 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004656 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004657 Counter{cSubDelReqToE2, uint64(subReqCount)},
4658 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004659 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004660 })
4661
4662 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004663 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004664 restSubId := xappConn1.SendRESTSubsReq(t, params)
4665 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4666
4667 assert.Equal(t, len(e2SubsIds), subReqCount)
4668
4669 // Del
4670 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4671 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4672
4673 xappConn1.TestMsgChanEmpty(t)
4674 e2termConn1.TestMsgChanEmpty(t)
4675 mainCtrl.wait_registry_empty(t, 10)
4676
4677 mainCtrl.VerifyCounterValues(t)
4678}
Markku Virtanenda34eec2021-05-20 08:22:04 +00004679
archaggeafbf95f2021-04-14 08:54:05 +03004680func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
4681
4682 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004683
4684 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004685 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004686 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004687 Counter{cSubReqToE2, uint64(subReqCount)},
4688 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004689 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004690 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004691 Counter{cSubDelReqToE2, uint64(subReqCount)},
4692 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004693 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004694 })
4695
4696 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004697 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004698 restSubId := xappConn1.SendRESTSubsReq(t, params)
4699 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4700
4701 assert.Equal(t, len(e2SubsIds), subReqCount)
4702
4703 // Del
4704 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4705 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4706
4707 xappConn1.TestMsgChanEmpty(t)
4708 e2termConn1.TestMsgChanEmpty(t)
4709 mainCtrl.wait_registry_empty(t, 10)
4710
4711 mainCtrl.VerifyCounterValues(t)
4712}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004713
archaggeafbf95f2021-04-14 08:54:05 +03004714func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
4715
4716 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03004717
4718 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004719 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004720 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004721 Counter{cSubReqToE2, uint64(subReqCount)},
4722 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004723 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004724 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004725 Counter{cSubDelReqToE2, uint64(subReqCount)},
4726 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004727 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004728 })
4729
4730 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004731 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004732 restSubId := xappConn1.SendRESTSubsReq(t, params)
4733 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4734
4735 assert.Equal(t, len(e2SubsIds), subReqCount)
4736
4737 // Del
4738 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4739 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4740
4741 xappConn1.TestMsgChanEmpty(t)
4742 e2termConn1.TestMsgChanEmpty(t)
4743 mainCtrl.wait_registry_empty(t, 10)
4744
4745 mainCtrl.VerifyCounterValues(t)
4746}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004747
4748func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
4749 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
4750
4751 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004752 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004753 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004754 Counter{cSubReqToE2, 2},
4755 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004756 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004757 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004758 Counter{cSubDelReqToE2, 2},
4759 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004760 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004761 })
4762
4763 // Req1
4764 var params *teststube2ap.RESTSubsReqParams = nil
4765
4766 //Subs Create
4767 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4768 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4769
4770 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4771
4772 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004773 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004774 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00004775 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004776 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
4777
4778 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4779 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4780 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4781 xappConn2.ExpectRESTNotification(t, restSubId2)
4782 e2termConn1.SendSubsResp(t, crereq, cremsg)
4783 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4784
4785 deleteXapp1Subscription(t, &restSubId1)
4786 deleteXapp2Subscription(t, &restSubId2)
4787
4788 waitSubsCleanup(t, e2SubsId1, 10)
4789 waitSubsCleanup(t, e2SubsId2, 10)
4790
4791 mainCtrl.VerifyCounterValues(t)
4792
4793}
4794
4795func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
4796 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
4797
4798 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004799 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004800 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004801 Counter{cSubReqToE2, 2},
4802 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004803 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004804 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004805 Counter{cSubDelReqToE2, 2},
4806 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004807 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004808 })
4809
4810 // Req1
4811 var params *teststube2ap.RESTSubsReqParams = nil
4812
4813 //Subs Create
4814 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4815 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4816
4817 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4818
4819 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004820 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004821 params.SetMeid("RAN_NAME_1")
4822
4823 actionId := int64(1)
4824 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00004825 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004826 subsequestActionType := "continue"
4827 timeToWait := "w10ms"
4828 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4829
4830 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4831 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4832 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4833 xappConn2.ExpectRESTNotification(t, restSubId2)
4834 e2termConn1.SendSubsResp(t, crereq, cremsg)
4835 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4836
4837 deleteXapp1Subscription(t, &restSubId1)
4838 deleteXapp2Subscription(t, &restSubId2)
4839
4840 waitSubsCleanup(t, e2SubsId1, 10)
4841 waitSubsCleanup(t, e2SubsId2, 10)
4842
4843 mainCtrl.VerifyCounterValues(t)
4844
4845}
4846
4847func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
4848 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
4849
4850 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004851 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004852 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004853 Counter{cSubReqToE2, 2},
4854 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004855 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004856 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004857 Counter{cSubDelReqToE2, 2},
4858 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004859 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004860 })
4861
4862 // Req1
4863 var params *teststube2ap.RESTSubsReqParams = nil
4864
4865 //Subs Create
4866 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4867 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4868
4869 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4870
4871 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004872 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004873 params.SetMeid("RAN_NAME_1")
4874 params.SetSubActionIDs(int64(2))
4875
4876 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4877 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4878 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4879 xappConn2.ExpectRESTNotification(t, restSubId2)
4880 e2termConn1.SendSubsResp(t, crereq, cremsg)
4881 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4882
4883 deleteXapp1Subscription(t, &restSubId1)
4884 deleteXapp2Subscription(t, &restSubId2)
4885
4886 waitSubsCleanup(t, e2SubsId1, 10)
4887 waitSubsCleanup(t, e2SubsId2, 10)
4888
4889 mainCtrl.VerifyCounterValues(t)
4890
4891}
4892
4893func TestRESTSubReqDiffActionType(t *testing.T) {
4894 CaseBegin("TestRESTSubReqDiffActionType")
4895
4896 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004897 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004898 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004899 Counter{cSubReqToE2, 2},
4900 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004901 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004902 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004903 Counter{cSubDelReqToE2, 2},
4904 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004905 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004906 })
4907
4908 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004909 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004910
4911 //Subs Create
4912 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4913 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4914
4915 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4916
4917 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004918 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004919 params.SetMeid("RAN_NAME_1")
4920
4921 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4922 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4923 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4924 xappConn2.ExpectRESTNotification(t, restSubId2)
4925 e2termConn1.SendSubsResp(t, crereq, cremsg)
4926 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4927
4928 deleteXapp1Subscription(t, &restSubId1)
4929 deleteXapp2Subscription(t, &restSubId2)
4930
4931 waitSubsCleanup(t, e2SubsId1, 10)
4932 waitSubsCleanup(t, e2SubsId2, 10)
4933
4934 mainCtrl.VerifyCounterValues(t)
4935
4936}
4937
4938func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
4939 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
4940
4941 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004942 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004943 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004944 Counter{cSubReqToE2, 2},
4945 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004946 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004947 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004948 Counter{cSubDelReqToE2, 2},
4949 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004950 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004951 })
4952
4953 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004954 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004955
4956 //Subs Create
4957 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4958 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4959
4960 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4961
4962 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004963 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004964 params.SetMeid("RAN_NAME_1")
4965
4966 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4967 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4968 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4969 xappConn2.ExpectRESTNotification(t, restSubId2)
4970 e2termConn1.SendSubsResp(t, crereq, cremsg)
4971 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4972
4973 deleteXapp1Subscription(t, &restSubId1)
4974 deleteXapp2Subscription(t, &restSubId2)
4975
4976 waitSubsCleanup(t, e2SubsId1, 10)
4977 waitSubsCleanup(t, e2SubsId2, 10)
4978
4979 mainCtrl.VerifyCounterValues(t)
4980
4981}
4982
4983func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
4984 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
4985
4986 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004987 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004988 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004989 Counter{cSubReqToE2, 2},
4990 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004991 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004992 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004993 Counter{cSubDelReqToE2, 2},
4994 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004995 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004996 })
4997
4998 // Req1
4999 var params *teststube2ap.RESTSubsReqParams = nil
5000
5001 //Subs Create
5002 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5003 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5004
5005 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5006
5007 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005008 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005009 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005010 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005011 params.SetSubActionDefinition(actionDefinition)
5012
5013 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5014 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5015 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5016 xappConn2.ExpectRESTNotification(t, restSubId2)
5017 e2termConn1.SendSubsResp(t, crereq, cremsg)
5018 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5019
5020 deleteXapp1Subscription(t, &restSubId1)
5021 deleteXapp2Subscription(t, &restSubId2)
5022
5023 waitSubsCleanup(t, e2SubsId1, 10)
5024 waitSubsCleanup(t, e2SubsId2, 10)
5025
5026 mainCtrl.VerifyCounterValues(t)
5027
5028}
5029
5030func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5031 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5032
5033 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005034 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005035 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005036 Counter{cSubReqToE2, 2},
5037 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005038 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005039 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005040 Counter{cSubDelReqToE2, 2},
5041 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005042 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005043 })
5044
5045 // Req1
5046 var params *teststube2ap.RESTSubsReqParams = nil
5047
5048 //Subs Create
5049 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5050 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5051
5052 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5053
5054 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005055 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005056 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005057 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005058 params.SetSubActionDefinition(actionDefinition)
5059
5060 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5061 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5062 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5063 xappConn2.ExpectRESTNotification(t, restSubId2)
5064 e2termConn1.SendSubsResp(t, crereq, cremsg)
5065 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5066
5067 deleteXapp1Subscription(t, &restSubId1)
5068 deleteXapp2Subscription(t, &restSubId2)
5069
5070 waitSubsCleanup(t, e2SubsId1, 10)
5071 waitSubsCleanup(t, e2SubsId2, 10)
5072
5073 mainCtrl.VerifyCounterValues(t)
5074
5075}
5076
5077func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5078 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5079
5080 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005081 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005082 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005083 Counter{cSubReqToE2, 2},
5084 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005085 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005086 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005087 Counter{cSubDelReqToE2, 2},
5088 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005089 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005090 })
5091
5092 // Req1
5093 var params *teststube2ap.RESTSubsReqParams = nil
5094
5095 //Subs Create
5096 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5097 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5098
5099 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5100
5101 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005102 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005103 params.SetMeid("RAN_NAME_1")
5104 params.SetTimeToWait("w200ms")
5105 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5106 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5107 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5108 xappConn2.ExpectRESTNotification(t, restSubId2)
5109 e2termConn1.SendSubsResp(t, crereq, cremsg)
5110 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5111
5112 deleteXapp1Subscription(t, &restSubId1)
5113 deleteXapp2Subscription(t, &restSubId2)
5114
5115 waitSubsCleanup(t, e2SubsId1, 10)
5116 waitSubsCleanup(t, e2SubsId2, 10)
5117
5118 mainCtrl.VerifyCounterValues(t)
5119
5120}
5121
Anssi Mannila51122392021-05-25 11:51:31 +03005122//-----------------------------------------------------------------------------
5123// TestRESTUnpackSubscriptionResponseDecodeFail
5124//
5125// stub stub
5126// +-------+ +---------+ +---------+
5127// | xapp | | submgr | | e2term |
5128// +-------+ +---------+ +---------+
5129// | | |
5130// | RestSubReq | |
5131// |---------------->| |
5132// | | |
5133// | RESTSubResp | |
5134// |<----------------| |
5135// | | |
5136// | | SubReq |
5137// | |------------->|
5138// | | |
5139// | | SubResp | ASN.1 decode fails
5140// | |<-------------|
5141// | | |
5142// | | SubReq |
5143// | |------------->|
5144// | | |
5145// | | SubFail | Duplicated action
5146// | |<-------------|
5147// | RESTNotif (fail)| |
5148// |<----------------| |
5149// | | SubDelReq |
5150// | |------------->|
5151// | | |
5152// | | SubDelResp |
5153// | |<-------------|
5154//
5155//-----------------------------------------------------------------------------
5156func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
5157 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5158 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005159
5160 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005161 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005162 restSubId := xappConn1.SendRESTSubsReq(t, params)
5163
5164 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5165 // Decode of this response fails which will result resending original request
5166 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5167
5168 _, cremsg = e2termConn1.RecvSubsReq(t)
5169
5170 xappConn1.ExpectRESTNotification(t, restSubId)
5171
5172 // Subscription already created in E2 Node.
5173 fparams := &teststube2ap.E2StubSubsFailParams{}
5174 fparams.Set(crereq)
5175 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5176 e2termConn1.SendSubsFail(t, fparams, cremsg)
5177
5178 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5179 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5180
5181 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5182 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5183
5184 // Wait that subs is cleaned
5185 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5186
5187 xappConn1.TestMsgChanEmpty(t)
5188 e2termConn1.TestMsgChanEmpty(t)
5189 mainCtrl.wait_registry_empty(t, 10)
5190}
5191
5192//-----------------------------------------------------------------------------
5193// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5194//
5195// stub stub
5196// +-------+ +---------+ +---------+
5197// | xapp | | submgr | | e2term |
5198// +-------+ +---------+ +---------+
5199// | | |
5200// | RestSubReq | |
5201// |---------------->| |
5202// | | |
5203// | RESTSubResp | |
5204// |<----------------| |
5205// | | |
5206// | | SubReq |
5207// | |------------->|
5208// | | |
5209// | | SubResp | Unknown instanceId
5210// | |<-------------|
5211// | | |
5212// | | SubReq |
5213// | |------------->|
5214// | | |
5215// | | SubFail | Duplicated action
5216// | |<-------------|
5217// | RESTNotif (fail)| |
5218// |<----------------| |
5219// | | SubDelReq |
5220// | |------------->|
5221// | | |
5222// | | SubDelResp |
5223// | |<-------------|
5224//
5225//-----------------------------------------------------------------------------
5226func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
5227 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5228 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005229
5230 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005231 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005232 restSubId := xappConn1.SendRESTSubsReq(t, params)
5233
5234 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5235
5236 // Unknown instanceId in this response which will result resending original request
5237 orgInstanceId := crereq.RequestId.InstanceId
5238 crereq.RequestId.InstanceId = 0
5239 e2termConn1.SendSubsResp(t, crereq, cremsg)
5240
5241 _, cremsg = e2termConn1.RecvSubsReq(t)
5242
5243 xappConn1.ExpectRESTNotification(t, restSubId)
5244
5245 // Subscription already created in E2 Node.
5246 fparams := &teststube2ap.E2StubSubsFailParams{}
5247 fparams.Set(crereq)
5248 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5249 e2termConn1.SendSubsFail(t, fparams, cremsg)
5250
5251 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5252 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5253
5254 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5255 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5256
5257 // Wait that subs is cleaned
5258 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
5259
5260 xappConn1.TestMsgChanEmpty(t)
5261 e2termConn1.TestMsgChanEmpty(t)
5262 mainCtrl.wait_registry_empty(t, 10)
5263}
5264
5265//-----------------------------------------------------------------------------
5266// TestRESTUnpackSubscriptionResponseNoTransaction
5267//
5268// stub stub
5269// +-------+ +---------+ +---------+
5270// | xapp | | submgr | | e2term |
5271// +-------+ +---------+ +---------+
5272// | | |
5273// | RestSubReq | |
5274// |---------------->| |
5275// | | |
5276// | RESTSubResp | |
5277// |<----------------| |
5278// | | |
5279// | | SubReq |
5280// | |------------->|
5281// | | |
5282// | | SubResp | No transaction for the response
5283// | |<-------------|
5284// | | |
5285// | | SubReq |
5286// | |------------->|
5287// | | |
5288// | | SubFail | Duplicated action
5289// | |<-------------|
5290// | RESTNotif (fail)| |
5291// |<----------------| |
5292// | | SubDelReq |
5293// | |------------->|
5294// | | |
5295// | | SubDelResp |
5296// | |<-------------|
5297// | | |
5298// | | SubDelReq |
5299// | |------------->|
5300// | | |
5301// | | SubDelResp |
5302// | |<-------------|
5303//
5304//-----------------------------------------------------------------------------
5305func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
5306 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5307 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005308
5309 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005310 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005311 restSubId := xappConn1.SendRESTSubsReq(t, params)
5312
5313 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5314
5315 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5316 // No transaction exist for this response which will result resending original request
5317 e2termConn1.SendSubsResp(t, crereq, cremsg)
5318
5319 _, cremsg = e2termConn1.RecvSubsReq(t)
5320
5321 xappConn1.ExpectRESTNotification(t, restSubId)
5322
5323 // Subscription already created in E2 Node.
5324 fparams := &teststube2ap.E2StubSubsFailParams{}
5325 fparams.Set(crereq)
5326 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5327 e2termConn1.SendSubsFail(t, fparams, cremsg)
5328
5329 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5330 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5331
5332 // Resending happens because there no transaction
5333 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5334 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5335
5336 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5337 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5338
5339 // Wait that subs is cleaned
5340 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5341
5342 xappConn1.TestMsgChanEmpty(t)
5343 e2termConn1.TestMsgChanEmpty(t)
5344 mainCtrl.wait_registry_empty(t, 10)
5345
5346}
5347
5348//-----------------------------------------------------------------------------
5349// TestRESTUnpackSubscriptionFailureDecodeFail
5350//
5351// stub stub
5352// +-------+ +---------+ +---------+
5353// | xapp | | submgr | | e2term |
5354// +-------+ +---------+ +---------+
5355// | | |
5356// | RestSubReq | |
5357// |---------------->| |
5358// | | |
5359// | RESTSubResp | |
5360// |<----------------| |
5361// | | |
5362// | | SubReq |
5363// | |------------->|
5364// | | |
5365// | | SubFail | ASN.1 decode fails
5366// | |<-------------|
5367// | | |
5368// | | SubReq |
5369// | |------------->|
5370// | | |
5371// | | SubFail | Duplicated action
5372// | |<-------------|
5373// | RESTNotif (fail)| |
5374// |<----------------| |
5375// | | SubDelReq |
5376// | |------------->|
5377// | | |
5378// | | SubDelResp |
5379// | |<-------------|
5380//
5381//-----------------------------------------------------------------------------
5382func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
5383 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5384 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005385
5386 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005387 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005388 restSubId := xappConn1.SendRESTSubsReq(t, params)
5389
5390 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5391
5392 // Decode of this response fails which will result resending original request
5393 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5394
5395 _, cremsg = e2termConn1.RecvSubsReq(t)
5396
5397 xappConn1.ExpectRESTNotification(t, restSubId)
5398
5399 // Subscription already created in E2 Node.
5400 fparams := &teststube2ap.E2StubSubsFailParams{}
5401 fparams.Set(crereq)
5402 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5403 e2termConn1.SendSubsFail(t, fparams, cremsg)
5404
5405 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5406 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5407
5408 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5409 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5410
5411 // Wait that subs is cleaned
5412 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5413
5414 xappConn1.TestMsgChanEmpty(t)
5415 e2termConn1.TestMsgChanEmpty(t)
5416 mainCtrl.wait_registry_empty(t, 10)
5417}
5418
5419//-----------------------------------------------------------------------------
5420// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5421//
5422// stub stub
5423// +-------+ +---------+ +---------+
5424// | xapp | | submgr | | e2term |
5425// +-------+ +---------+ +---------+
5426// | | |
5427// | RestSubReq | |
5428// |---------------->| |
5429// | | |
5430// | RESTSubResp | |
5431// |<----------------| |
5432// | | |
5433// | | SubReq |
5434// | |------------->|
5435// | | |
5436// | | SubFail | Unknown instanceId
5437// | |<-------------|
5438// | | |
5439// | | SubReq |
5440// | |------------->|
5441// | | |
5442// | | SubFail | Duplicated action
5443// | |<-------------|
5444// | RESTNotif (fail)| |
5445// |<----------------| |
5446// | | SubDelReq |
5447// | |------------->|
5448// | | |
5449// | | SubDelResp |
5450// | |<-------------|
5451//
5452//-----------------------------------------------------------------------------
5453func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
5454 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
5455 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005456
5457 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005458 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005459 restSubId := xappConn1.SendRESTSubsReq(t, params)
5460
5461 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5462
5463 // Unknown instanceId in this response which will result resending original request
5464 fparams := &teststube2ap.E2StubSubsFailParams{}
5465 fparams.Set(crereq)
5466 fparams.Fail.RequestId.InstanceId = 0
5467 e2termConn1.SendSubsFail(t, fparams, cremsg)
5468
5469 _, cremsg = e2termConn1.RecvSubsReq(t)
5470
5471 xappConn1.ExpectRESTNotification(t, restSubId)
5472
5473 // Subscription already created in E2 Node.
5474 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5475 e2termConn1.SendSubsFail(t, fparams, cremsg)
5476
5477 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5478 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5479
5480 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5481 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5482
5483 // Wait that subs is cleaned
5484 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5485
5486 xappConn1.TestMsgChanEmpty(t)
5487 e2termConn1.TestMsgChanEmpty(t)
5488 mainCtrl.wait_registry_empty(t, 10)
5489}
5490
5491//-----------------------------------------------------------------------------
5492// TestRESTUnpackSubscriptionFailureNoTransaction
5493//
5494// stub stub
5495// +-------+ +---------+ +---------+
5496// | xapp | | submgr | | e2term |
5497// +-------+ +---------+ +---------+
5498// | | |
5499// | RestSubReq | |
5500// |---------------->| |
5501// | | |
5502// | RESTSubResp | |
5503// |<----------------| |
5504// | | |
5505// | | SubReq |
5506// | |------------->|
5507// | | |
5508// | | SubFail | No transaction for the response
5509// | |<-------------|
5510// | | |
5511// | | SubReq |
5512// | |------------->|
5513// | | |
5514// | | SubFail | Duplicated action
5515// | |<-------------|
5516// | RESTNotif (fail)| |
5517// |<----------------| |
5518// | | SubDelReq |
5519// | |------------->|
5520// | | |
5521// | | SubDelResp |
5522// | |<-------------|
5523//
5524//-----------------------------------------------------------------------------
5525func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
5526 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
5527 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005528
5529 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005530 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005531 restSubId := xappConn1.SendRESTSubsReq(t, params)
5532
5533 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5534
5535 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5536
5537 // No transaction exist for this response which will result resending original request
5538 fparams := &teststube2ap.E2StubSubsFailParams{}
5539 fparams.Set(crereq)
5540 e2termConn1.SendSubsFail(t, fparams, cremsg)
5541
5542 _, cremsg = e2termConn1.RecvSubsReq(t)
5543
5544 xappConn1.ExpectRESTNotification(t, restSubId)
5545
5546 // Subscription already created in E2 Node.
5547 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5548 e2termConn1.SendSubsFail(t, fparams, cremsg)
5549
5550 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5551 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5552
5553 // Resending happens because there no transaction
5554 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5555 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5556
5557 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5558 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5559
5560 // Wait that subs is cleaned
5561 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5562
5563 xappConn1.TestMsgChanEmpty(t)
5564 e2termConn1.TestMsgChanEmpty(t)
5565 mainCtrl.wait_registry_empty(t, 10)
5566}
5567
5568//-----------------------------------------------------------------------------
5569// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
5570//
5571// stub stub
5572// +-------+ +---------+ +---------+
5573// | xapp | | submgr | | e2term |
5574// +-------+ +---------+ +---------+
5575// | | |
5576// | [SUBS CREATE] |
5577// | | |
5578// | | |
5579// | RESTSubDelReq | |
5580// |---------------->| |
5581// | | |
5582// | RESTSubDelResp | |
5583// |<----------------| |
5584// | | |
5585// | | SubDelReq |
5586// | |------------->|
5587// | | |
5588// | | SubDelResp | ASN.1 decode fails
5589// | |<-------------|
5590// | | |
5591// | | SubDelReq |
5592// | |------------->|
5593// | | |
5594// | | SubDelFail | Subscription does exist any more
5595// | |<-------------|
5596// | | |
5597//
5598//-----------------------------------------------------------------------------
5599func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
5600 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
5601
5602 // Req
5603 var params *teststube2ap.RESTSubsReqParams = nil
5604 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5605
5606 // Del
5607 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5608
5609 // E2t: Receive 1st SubsDelReq
5610 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5611
5612 // Decode of this response fails which will result resending original request
5613 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
5614
5615 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5616 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5617
5618 // Subscription does not exist in in E2 Node.
5619 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5620
5621 // Wait that subs is cleaned
5622 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5623
5624 xappConn1.TestMsgChanEmpty(t)
5625 e2termConn1.TestMsgChanEmpty(t)
5626 mainCtrl.wait_registry_empty(t, 10)
5627}
5628
5629//-----------------------------------------------------------------------------
5630// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
5631//
5632// stub stub
5633// +-------+ +---------+ +---------+
5634// | xapp | | submgr | | e2term |
5635// +-------+ +---------+ +---------+
5636// | | |
5637// | [SUBS CREATE] |
5638// | | |
5639// | | |
5640// | RESTSubDelReq | |
5641// |---------------->| |
5642// | | |
5643// | RESTSubDelResp | |
5644// |<----------------| |
5645// | | |
5646// | | SubDelReq |
5647// | |------------->|
5648// | | |
5649// | | SubDelResp | Unknown instanceId
5650// | |<-------------|
5651// | | |
5652// | | SubDelReq |
5653// | |------------->|
5654// | | |
5655// | | SubDelFail | Subscription does exist any more
5656// | |<-------------|
5657//
5658//-----------------------------------------------------------------------------
5659func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
5660 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
5661
5662 // Req
5663 var params *teststube2ap.RESTSubsReqParams = nil
5664 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5665
5666 // Del
5667 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5668
5669 // E2t: Receive 1st SubsDelReq
5670 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5671
5672 // Unknown instanceId in this response which will result resending original request
5673 delreq.RequestId.InstanceId = 0
5674 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5675
5676 // E2t: Receive 2nd SubsDelReq
5677 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5678
5679 // Subscription does not exist in in E2 Node.
5680 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5681
5682 // Wait that subs is cleaned
5683 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5684
5685 xappConn1.TestMsgChanEmpty(t)
5686 e2termConn1.TestMsgChanEmpty(t)
5687 mainCtrl.wait_registry_empty(t, 10)
5688}
5689
5690//-----------------------------------------------------------------------------
5691// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
5692//
5693// stub stub
5694// +-------+ +---------+ +---------+
5695// | xapp | | submgr | | e2term |
5696// +-------+ +---------+ +---------+
5697// | | |
5698// | [SUBS CREATE] |
5699// | | |
5700// | | |
5701// | RESTSubDelReq | |
5702// |---------------->| |
5703// | | |
5704// | RESTSubDelResp | |
5705// |<----------------| |
5706// | | |
5707// | | SubDelReq |
5708// | |------------->|
5709// | | |
5710// | | SubDelResp | No transaction for the response
5711// | |<-------------|
5712// | | |
5713// | | SubDelReq |
5714// | |------------->|
5715// | | |
5716// | | SubDelFail | Subscription does exist any more
5717// | |<-------------|
5718//
5719//-----------------------------------------------------------------------------
5720func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
5721 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
5722
5723 // Req
5724 var params *teststube2ap.RESTSubsReqParams = nil
5725 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5726
5727 // Del
5728 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5729
5730 // E2t: Receive 1st SubsDelReq
5731 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5732
5733 mainCtrl.MakeTransactionNil(t, e2SubsId)
5734
5735 // No transaction exist for this response which will result resending original request
5736 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5737
5738 // E2t: Receive 2nd SubsDelReq
5739 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5740
5741 // Subscription does not exist in in E2 Node.
5742 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5743
5744 // Wait that subs is cleaned
5745 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5746
5747 xappConn1.TestMsgChanEmpty(t)
5748 e2termConn1.TestMsgChanEmpty(t)
5749 mainCtrl.wait_registry_empty(t, 10)
5750}
5751
5752//-----------------------------------------------------------------------------
5753// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
5754//
5755// stub stub
5756// +-------+ +---------+ +---------+
5757// | xapp | | submgr | | e2term |
5758// +-------+ +---------+ +---------+
5759// | | |
5760// | [SUBS CREATE] |
5761// | | |
5762// | | |
5763// | RESTSubDelReq | |
5764// |---------------->| |
5765// | | |
5766// | RESTSubDelResp | |
5767// |<----------------| |
5768// | | |
5769// | | SubDelReq |
5770// | |------------->|
5771// | | |
5772// | | SubDelFail | ASN.1 decode fails
5773// | |<-------------|
5774// | | |
5775// | | SubDelReq |
5776// | |------------->|
5777// | | |
5778// | | SubDelFail | Subscription does exist any more
5779// | |<-------------|
5780//
5781//-----------------------------------------------------------------------------
5782func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
5783 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
5784
5785 // Req
5786 var params *teststube2ap.RESTSubsReqParams = nil
5787 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5788
5789 // Del
5790 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5791
5792 // E2t: Receive 1st SubsDelReq
5793 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5794
5795 // Decode of this response fails which will result resending original request
5796 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
5797
5798 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5799 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5800
5801 // Subscription does not exist in in E2 Node.
5802 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5803
5804 // Wait that subs is cleaned
5805 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5806
5807 xappConn1.TestMsgChanEmpty(t)
5808 e2termConn1.TestMsgChanEmpty(t)
5809 mainCtrl.wait_registry_empty(t, 10)
5810}
5811
5812//-----------------------------------------------------------------------------
5813// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
5814//
5815// stub stub
5816// +-------+ +---------+ +---------+
5817// | xapp | | submgr | | e2term |
5818// +-------+ +---------+ +---------+
5819// | | |
5820// | [SUBS CREATE] |
5821// | | |
5822// | | |
5823// | RESTSubDelReq | |
5824// |---------------->| |
5825// | | |
5826// | RESTSubDelResp | |
5827// |<----------------| |
5828// | | |
5829// | | SubDelReq |
5830// | |------------->|
5831// | | |
5832// | | SubDelFail | Unknown instanceId
5833// | |<-------------|
5834// | | |
5835// | | SubDelReq |
5836// | |------------->|
5837// | | |
5838// | | SubDelFail | Subscription does exist any more
5839// | |<-------------|
5840//
5841//-----------------------------------------------------------------------------
5842func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
5843 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
5844
5845 // Req
5846 var params *teststube2ap.RESTSubsReqParams = nil
5847 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5848
5849 // Del
5850 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5851
5852 // E2t: Receive 1st SubsDelReq
5853 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5854
5855 // Unknown instanceId in this response which will result resending original request
5856 delreq.RequestId.InstanceId = 0
5857 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5858
5859 // E2t: Receive 2nd SubsDelReq
5860 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5861
5862 // Subscription does not exist in in E2 Node.
5863 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5864
5865 // Wait that subs is cleaned
5866 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5867
5868 xappConn1.TestMsgChanEmpty(t)
5869 e2termConn1.TestMsgChanEmpty(t)
5870 mainCtrl.wait_registry_empty(t, 10)
5871}
5872
5873//-----------------------------------------------------------------------------
5874// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
5875//
5876// stub stub
5877// +-------+ +---------+ +---------+
5878// | xapp | | submgr | | e2term |
5879// +-------+ +---------+ +---------+
5880// | | |
5881// | [SUBS CREATE] |
5882// | | |
5883// | | |
5884// | RESTSubDelReq | |
5885// |---------------->| |
5886// | | |
5887// | RESTSubDelResp | |
5888// |<----------------| |
5889// | | |
5890// | | SubDelReq |
5891// | |------------->|
5892// | | |
5893// | | SubDelFail | No transaction for the response
5894// | |<-------------|
5895// | | |
5896// | | SubDelReq |
5897// | |------------->|
5898// | | |
5899// | | SubDelFail | Subscription does exist any more
5900// | |<-------------|
5901//
5902//-----------------------------------------------------------------------------
5903func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
5904 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
5905
5906 // Req
5907 var params *teststube2ap.RESTSubsReqParams = nil
5908 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5909
5910 // Del
5911 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5912
5913 // E2t: Receive 1st SubsDelReq
5914 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5915
5916 mainCtrl.MakeTransactionNil(t, e2SubsId)
5917
5918 // No transaction exist for this response which will result resending original request
5919 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5920
5921 // E2t: Receive 2nd SubsDelReq
5922 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5923
5924 // Subscription does not exist in in E2 Node.
5925 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5926
5927 // Wait that subs is cleaned
5928 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5929
5930 xappConn1.TestMsgChanEmpty(t)
5931 e2termConn1.TestMsgChanEmpty(t)
5932 mainCtrl.wait_registry_empty(t, 10)
5933}
5934
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005935//-----------------------------------------------------------------------------
5936// TestRESTSubReqFailAsn1PackSubReqError
5937//
5938// stub stub
5939// +-------+ +---------+ +---------+
5940// | xapp | | submgr | | e2term |
5941// +-------+ +---------+ +---------+
5942// | | |
5943// | RESTSubReq | |
5944// |---------------->| |
5945// | | |
5946// | RESTSubResp | |
5947// |<----------------| |
5948// | | |
5949// | ASN.1 encode fails |
5950// | | |
5951// | | SubDelReq |
5952// | |------------->|
5953// | | |
5954// | | SubDelFail |
5955// | |<-------------|
5956// | | |
5957// | RESTNotif | |
5958// | unsuccess | |
5959// |<----------------| |
5960// | | |
5961// | [SUBS DELETE] |
5962// | | |
5963//
5964//-----------------------------------------------------------------------------
5965func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
5966
5967 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005968 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005969 Counter{cRestSubRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005970 Counter{cSubDelReqToE2, 1},
5971 Counter{cSubDelFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005972 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005973 })
5974
5975 subReqCount := 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005976
5977 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005978 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005979 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
5980
5981 // Req
5982 restSubId := xappConn1.SendRESTSubsReq(t, params)
5983 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5984
5985 // E2t: Receive SubsDelReq
5986 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5987 xappConn1.ExpectRESTNotification(t, restSubId)
5988
5989 // Subscription does not exist in in E2 Node.
5990 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5991
5992 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5993 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
5994
5995 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
5996 // Wait that subs is cleaned
5997 waitSubsCleanup(t, e2SubsId, 10)
5998 mainCtrl.VerifyCounterValues(t)
5999}
6000
archaggeafbf95f2021-04-14 08:54:05 +03006001////////////////////////////////////////////////////////////////////////////////////
6002// Services for UT cases
6003////////////////////////////////////////////////////////////////////////////////////
6004const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006005const host string = "localhost"
6006
6007func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
6008 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006009 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006010 }
6011 restSubId := fromXappConn.SendRESTSubsReq(t, params)
6012 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6013
6014 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
6015 fromXappConn.ExpectRESTNotification(t, restSubId)
6016 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
6017 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
6018 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6019
6020 return restSubId, e2SubsId
6021}
6022
6023func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
6024
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006025 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006026 if meid != "" {
6027 params.SetMeid(meid)
6028 }
6029 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
6030 restSubId := xappConn2.SendRESTSubsReq(t, params)
6031 xappConn2.ExpectRESTNotification(t, restSubId)
6032 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6033 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
6034 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6035
6036 return restSubId, e2SubsId
6037}
6038
6039func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006040 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006041 restSubId := xappConn1.SendRESTSubsReq(t, params)
6042 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
6043
6044 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6045 xappConn1.ExpectRESTNotification(t, restSubId)
6046 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6047 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6048 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6049
6050 return restSubId, e2SubsId
6051}
6052
6053func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006054 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006055 restSubId := xappConn1.SendRESTSubsReq(t, params)
6056
6057 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6058 fparams1 := &teststube2ap.E2StubSubsFailParams{}
6059 fparams1.Set(crereq1)
6060 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
6061
6062 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
6063 xappConn1.ExpectRESTNotification(t, restSubId)
6064 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
6065 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6066 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
6067
6068 return restSubId, e2SubsId
6069}
6070
6071func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
6072 fromXappConn.SendRESTSubsDelReq(t, restSubId)
6073 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6074 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6075}
6076
6077func deleteXapp1Subscription(t *testing.T, restSubId *string) {
6078 xappConn1.SendRESTSubsDelReq(t, restSubId)
6079 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6080 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6081}
6082
6083func deleteXapp2Subscription(t *testing.T, restSubId *string) {
6084 xappConn2.SendRESTSubsDelReq(t, restSubId)
6085 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6086 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6087}
6088
6089func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
6090 resp, _ := xapp.Subscription.QuerySubscriptions()
6091 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
6092 assert.Equal(t, resp[0].Meid, meid)
6093 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
6094}
6095
6096func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
6097 //Wait that subs is cleaned
6098 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
6099
6100 xappConn1.TestMsgChanEmpty(t)
6101 xappConn2.TestMsgChanEmpty(t)
6102 e2termConn1.TestMsgChanEmpty(t)
6103 mainCtrl.wait_registry_empty(t, timeout)
6104}
6105
6106func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
6107
6108 var e2SubsId []uint32
6109
6110 for i := 0; i < count; i++ {
6111 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
6112 crereq, cremsg := toE2termConn.RecvSubsReq(t)
6113 fromXappConn.ExpectRESTNotification(t, restSubId)
6114 toE2termConn.SendSubsResp(t, crereq, cremsg)
6115 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
6116 e2SubsId = append(e2SubsId, instanceId)
6117 xapp.Logger.Info("TEST: %v", e2SubsId)
6118 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
6119 <-time.After(100 * time.Millisecond)
6120 }
6121 return e2SubsId
6122}
6123
6124func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
6125
6126 for i := 0; i < len(e2SubsIds); i++ {
6127 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
6128 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6129 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6130 <-time.After(1 * time.Second)
6131 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
6132 <-time.After(100 * time.Millisecond)
6133 }
6134
6135 // Wait that subs is cleaned
6136 for i := 0; i < len(e2SubsIds); i++ {
6137 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
6138 }
6139
6140}