blob: a19ccabd66839a82d79e180ce1527c1744bca515 [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 Virtanenb642a192021-06-09 09:08:14 +000041
42 restDuplicateCtrl.Init()
43
Markku Virtanenac8bde42021-05-25 09:54:42 +000044}
45
46//-----------------------------------------------------------------------------
47// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
48//
49// stub stub stub
50// +-------+ +---------+ +---------+ +---------+
51// | xapp | | submgr | | e2term | | rtmgr |
52// +-------+ +---------+ +---------+ +---------+
53// | | | |
54// | RESTSubReq | | |
55// |---------------->| | |
56// | | RouteCreate | |
57// | |--------------------------->| // The order of these events may vary
58// | | | |
59// | RESTSubResp | | | // The order of these events may vary
60// |<----------------| | |
61// | | RouteResponse| |
62// | |<---------------------------| // The order of these events may vary
63// | | | |
64// | | SubReq | |
65// | |------------->| | // The order of these events may vary
66// | | | |
67// | | SubResp | |
68// | |<-------------| |
69// | RESTNotif1 | | |
70// |<----------------| | |
71// | | | |
72// | RESTSubDelReq | | |
73// |---------------->| | |
74// | | SubDelReq | |
75// | |------------->| |
76// | | | |
77// | RESTSubDelResp| | |
78// |<----------------| | |
79// | | | |
80// | | SubDelResp | |
81// | |<-------------| |
82// | | | |
83// | | | |
84//
85//-----------------------------------------------------------------------------
86func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +000087
88 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
89
90 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
91
92 waitSubsCleanup(t, e2SubsId, 10)
93}
94
Juha Hyttinenfa015662020-01-24 10:05:18 +020095//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +000096// TestRESTSubReqAndE1apDeleteReqPackingError
97//
98// stub stub stub
99// +-------+ +---------+ +---------+ +---------+
100// | xapp | | submgr | | e2term | | rtmgr |
101// +-------+ +---------+ +---------+ +---------+
102// | | | |
103// | RESTSubReq | | |
104// |---------------->| | |
105// | | RouteCreate | |
106// | |--------------------------->| // The order of these events may vary
107// | | | |
108// | RESTSubResp | | | // The order of these events may vary
109// |<----------------| | |
110// | | RouteResponse| |
111// | |<---------------------------| // The order of these events may vary
112// | | | |
113// | | SubReq | |
114// | |------------->| | // The order of these events may vary
115// | | | |
116// | | SubResp | |
117// | |<-------------| |
118// | RESTNotif1 | | |
119// |<----------------| | |
120// | | | |
121// | RESTSubDelReq | | |
122// |---------------->| | |
123// | | | |
124// | RESTSubDelResp| | |
125// |<----------------| | |
126// | | | |
127// | | | |
128//
129//-----------------------------------------------------------------------------
130func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
131
132 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
133
134 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
135 xappConn1.SendRESTSubsDelReq(t, &restSubId)
136 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
137
138 waitSubsCleanup(t, e2SubsId, 10)
139}
140
141//-----------------------------------------------------------------------------
142// TestRESTSubReqAndE1apDeleteRespUnpackingError
143//
144// stub stub stub
145// +-------+ +---------+ +---------+ +---------+
146// | xapp | | submgr | | e2term | | rtmgr |
147// +-------+ +---------+ +---------+ +---------+
148// | | | |
149// | RESTSubReq | | |
150// |---------------->| | |
151// | | RouteCreate | |
152// | |--------------------------->| // The order of these events may vary
153// | | | |
154// | RESTSubResp | | | // The order of these events may vary
155// |<----------------| | |
156// | | RouteResponse| |
157// | |<---------------------------| // The order of these events may vary
158// | | | |
159// | | SubReq | |
160// | |------------->| | // The order of these events may vary
161// | | | |
162// | | SubResp | |
163// | |<-------------| |
164// | RESTNotif1 | | |
165// |<----------------| | |
166// | | | |
167// | RESTSubDelReq | | |
168// |---------------->| | |
169// | | SubDelReq | |
170// | |------------->| |
171// | | | |
172// | RESTSubDelResp| | |
173// |<----------------| | | // The order of these events may vary
174// | | | |
175// | | SubDelResp | |
176// | |<-------------| | // 1.st NOK
177// | | | |
178// | | SubDelReq | |
179// | |------------->| |
180// | | | |
181// | | SubDelResp | |
182// | |<-------------| | // 2.nd NOK
183//
184//-----------------------------------------------------------------------------
185
186func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
187
188 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
189
190 xappConn1.SendRESTSubsDelReq(t, &restSubId)
191 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
192 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
193 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
194
195 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
196 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
197
198 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
199
200 waitSubsCleanup(t, e2SubsId, 10)
201}
202
203//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200204// TestSubReqAndRouteNok
205//
206// stub stub
207// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200208// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200209// +-------+ +---------+ +---------+
210// | | |
211// | SubReq | |
212// |------------->| |
213// | | |
214// | | RouteCreate |
215// | |------------->|
216// | | |
217// | | RouteCreate |
218// | | status:400 |
219// | |<-------------|
220// | | |
221// | [SUBS INT DELETE] |
222// | | |
223//
224//-----------------------------------------------------------------------------
225
226func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200227 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200228
Anssi Mannila4abf1802021-01-28 13:06:46 +0200229 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200230 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
231 Counter{cSubReqFromXapp, 1},
232 Counter{cRouteCreateFail, 1},
233 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200234
Juha Hyttinenfa015662020-01-24 10:05:18 +0200235 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300236 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200237 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200238 waiter.WaitResult(t)
239
240 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200241 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200242
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200243 xappConn1.TestMsgChanEmpty(t)
244 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200245 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200246 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200247
248 <-time.After(1 * time.Second)
249 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200250}
251
252//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200253// TestSubReqAndRouteUpdateNok
254
255// stub stub
256// +-------+ +-------+ +---------+ +---------+
257// | xapp2 | | xapp1 | | submgr | | rtmgr |
258// +-------+ +-------+ +---------+ +---------+
259// | | | |
260// | [SUBS CREATE] | |
261// | | | |
262// | | | |
263// | | | |
264// | SubReq (mergeable) | |
265// |--------------------------->| | |
266// | | | |
267// | | | RouteUpdate |
268// | | |------------->|
269// | | | |
270// | | | RouteUpdate |
271// | | | status:400 |
272// | | |<-------------|
273// | | | |
274// | [SUBS INT DELETE] | |
275// | | | |
276// | | | |
277// | [SUBS DELETE] | |
278// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300279
Anssi Mannila4abf1802021-01-28 13:06:46 +0200280func TestSubReqAndRouteUpdateNok(t *testing.T) {
281 CaseBegin("TestSubReqAndRouteUpdateNok")
282
283 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200284 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
285 Counter{cSubReqFromXapp, 2},
286 Counter{cSubReqToE2, 1},
287 Counter{cSubRespFromE2, 1},
288 Counter{cSubRespToXapp, 1},
289 Counter{cRouteCreateUpdateFail, 1},
290 Counter{cSubDelReqFromXapp, 1},
291 Counter{cSubDelReqToE2, 1},
292 Counter{cSubDelRespFromE2, 1},
293 Counter{cSubDelRespToXapp, 1},
294 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200295
296 cretrans := xappConn1.SendSubsReq(t, nil, nil)
297 crereq, cremsg := e2termConn1.RecvSubsReq(t)
298 e2termConn1.SendSubsResp(t, crereq, cremsg)
299 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
300
301 resp, _ := xapp.Subscription.QuerySubscriptions()
302 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
303 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300304 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200305
306 waiter := rtmgrHttp.AllocNextEvent(false)
307 newSubsId := mainCtrl.get_registry_next_subid(t)
308 xappConn2.SendSubsReq(t, nil, nil)
309 waiter.WaitResult(t)
310
311 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
312 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
313
314 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
315 xappConn1.RecvSubsDelResp(t, deltrans)
316
317 //Wait that subs is cleaned
318 mainCtrl.wait_subs_clean(t, newSubsId, 10)
319 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
320
321 xappConn1.TestMsgChanEmpty(t)
322 xappConn2.TestMsgChanEmpty(t)
323 e2termConn1.TestMsgChanEmpty(t)
324 mainCtrl.wait_registry_empty(t, 10)
325
326 mainCtrl.VerifyCounterValues(t)
327}
328
329//-----------------------------------------------------------------------------
330// TestSubDelReqAndRouteDeleteNok
331//
332// stub stub
333// +-------+ +---------+ +---------+ +---------+
334// | xapp | | submgr | | e2term | | rtmgr |
335// +-------+ +---------+ +---------+ +---------+
336// | | | |
337// | [SUBS CREATE] | |
338// | | | |
339// | | | |
340// | | | |
341// | SubDelReq | | |
342// |------------->| | |
343// | | SubDelReq | |
344// | |------------->| |
345// | | SubDelRsp | |
346// | |<-------------| |
347// | SubDelRsp | | |
348// |<-------------| | |
349// | | RouteDelete | |
350// | |---------------------------->|
351// | | | |
352// | | RouteDelete | |
353// | | status:400 | |
354// | |<----------------------------|
355// | | | |
356func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
357 CaseBegin("TestSubDelReqAndRouteDeleteNok")
358
359 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200360 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
361 Counter{cSubReqFromXapp, 1},
362 Counter{cSubReqToE2, 1},
363 Counter{cSubRespFromE2, 1},
364 Counter{cSubRespToXapp, 1},
365 Counter{cSubDelReqFromXapp, 1},
366 Counter{cRouteDeleteFail, 1},
367 Counter{cSubDelReqToE2, 1},
368 Counter{cSubDelRespFromE2, 1},
369 Counter{cSubDelRespToXapp, 1},
370 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200371
372 cretrans := xappConn1.SendSubsReq(t, nil, nil)
373 crereq, cremsg := e2termConn1.RecvSubsReq(t)
374 e2termConn1.SendSubsResp(t, crereq, cremsg)
375 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
376
377 resp, _ := xapp.Subscription.QuerySubscriptions()
378 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
379 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300380 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200381
382 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
383 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
384
385 waiter := rtmgrHttp.AllocNextEvent(false)
386 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
387 waiter.WaitResult(t)
388
389 xappConn1.RecvSubsDelResp(t, deltrans)
390
391 //Wait that subs is cleaned
392 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
393
394 xappConn1.TestMsgChanEmpty(t)
395 xappConn2.TestMsgChanEmpty(t)
396 e2termConn1.TestMsgChanEmpty(t)
397 mainCtrl.wait_registry_empty(t, 10)
398
399 mainCtrl.VerifyCounterValues(t)
400}
401
402//-----------------------------------------------------------------------------
403// TestSubMergeDelAndRouteUpdateNok
404// stub stub
405// +-------+ +-------+ +---------+ +---------+
406// | xapp2 | | xapp1 | | submgr | | e2term |
407// +-------+ +-------+ +---------+ +---------+
408// | | | |
409// | | | |
410// | | | |
411// | | SubReq1 | |
412// | |------------->| |
413// | | | |
414// | | | SubReq1 |
415// | | |------------->|
416// | | | SubResp1 |
417// | | |<-------------|
418// | | SubResp1 | |
419// | |<-------------| |
420// | | | |
421// | SubReq2 | |
422// |--------------------------->| |
423// | | | |
424// | SubResp2 | |
425// |<---------------------------| |
426// | | | |
427// | | SubDelReq 1 | |
428// | |------------->| |
429// | | | RouteUpdate |
430// | | |-----> rtmgr |
431// | | | |
432// | | | RouteUpdate |
433// | | | status:400 |
434// | | |<----- rtmgr |
435// | | | |
436// | | SubDelResp 1 | |
437// | |<-------------| |
438// | | | |
439// | SubDelReq 2 | |
440// |--------------------------->| |
441// | | | |
442// | | | SubDelReq 2 |
443// | | |------------->|
444// | | | |
445// | | | SubDelReq 2 |
446// | | |------------->|
447// | | | |
448// | SubDelResp 2 | |
449// |<---------------------------| |
450//
451//-----------------------------------------------------------------------------
452func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
453 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
454
455 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200456 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
457 Counter{cSubReqFromXapp, 2},
458 Counter{cSubReqToE2, 1},
459 Counter{cSubRespFromE2, 1},
460 Counter{cSubRespToXapp, 2},
461 Counter{cSubDelReqFromXapp, 2},
462 Counter{cRouteDeleteUpdateFail, 1},
463 Counter{cSubDelReqToE2, 1},
464 Counter{cSubDelRespFromE2, 1},
465 Counter{cSubDelRespToXapp, 2},
466 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200467
468 //Req1
469 rparams1 := &teststube2ap.E2StubSubsReqParams{}
470 rparams1.Init()
471 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
472 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
473 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
474 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
475
476 //Req2
477 rparams2 := &teststube2ap.E2StubSubsReqParams{}
478 rparams2.Init()
479 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
480 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
481
482 resp, _ := xapp.Subscription.QuerySubscriptions()
483 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
484 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300485 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200486
487 //Del1
488 waiter := rtmgrHttp.AllocNextEvent(false)
489 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
490 waiter.WaitResult(t)
491
492 xappConn1.RecvSubsDelResp(t, deltrans1)
493
494 //Del2
495 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
496 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
497 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
498 xappConn2.RecvSubsDelResp(t, deltrans2)
499 //Wait that subs is cleaned
500 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
501
502 xappConn1.TestMsgChanEmpty(t)
503 xappConn2.TestMsgChanEmpty(t)
504 e2termConn1.TestMsgChanEmpty(t)
505 mainCtrl.wait_registry_empty(t, 10)
506
507 mainCtrl.VerifyCounterValues(t)
508}
509
510//-----------------------------------------------------------------------------
511
512//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200513// TestSubReqAndSubDelOk
514//
515// stub stub
516// +-------+ +---------+ +---------+
517// | xapp | | submgr | | e2term |
518// +-------+ +---------+ +---------+
519// | | |
520// | SubReq | |
521// |------------->| |
522// | | |
523// | | SubReq |
524// | |------------->|
525// | | |
526// | | SubResp |
527// | |<-------------|
528// | | |
529// | SubResp | |
530// |<-------------| |
531// | | |
532// | | |
533// | SubDelReq | |
534// |------------->| |
535// | | |
536// | | SubDelReq |
537// | |------------->|
538// | | |
539// | | SubDelResp |
540// | |<-------------|
541// | | |
542// | SubDelResp | |
543// |<-------------| |
544//
545//-----------------------------------------------------------------------------
546func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200547 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200548
Anssi Mannila4abf1802021-01-28 13:06:46 +0200549 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200550 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
551 Counter{cSubReqFromXapp, 1},
552 Counter{cSubReqToE2, 1},
553 Counter{cSubRespFromE2, 1},
554 Counter{cSubRespToXapp, 1},
555 Counter{cSubDelReqFromXapp, 1},
556 Counter{cSubDelReqToE2, 1},
557 Counter{cSubDelRespFromE2, 1},
558 Counter{cSubDelRespToXapp, 1},
559 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200560
561 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200562 crereq, cremsg := e2termConn1.RecvSubsReq(t)
563 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200564 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200565
566 resp, _ := xapp.Subscription.QuerySubscriptions()
567 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
568 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300569 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200570
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200571 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200572 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200573
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200574 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200575 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200576
577 //Wait that subs is cleaned
578 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
579
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200580 xappConn1.TestMsgChanEmpty(t)
581 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200582 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200583 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200584
585 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200586}
587
588//-----------------------------------------------------------------------------
589// TestSubReqRetransmission
590//
591// stub stub
592// +-------+ +---------+ +---------+
593// | xapp | | submgr | | e2term |
594// +-------+ +---------+ +---------+
595// | | |
596// | SubReq | |
597// |------------->| |
598// | | |
599// | | SubReq |
600// | |------------->|
601// | | |
602// | SubReq | |
603// | (retrans) | |
604// |------------->| |
605// | | |
606// | | SubResp |
607// | |<-------------|
608// | | |
609// | SubResp | |
610// |<-------------| |
611// | | |
612// | [SUBS DELETE] |
613// | | |
614//
615//-----------------------------------------------------------------------------
616func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200617 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200618
619 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200620 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200621 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200622
623 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200624 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200625 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
626
Juha Hyttinen1683f912020-04-17 10:39:57 +0300627 // hack as there is no real way to see has message be handled.
628 // Previuos counter check just tells that is has been received by submgr
629 // --> artificial delay
630 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200631 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200632 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200633
634 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200635 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200636 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
637 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200638 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200639
640 //Wait that subs is cleaned
641 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
642
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200643 xappConn1.TestMsgChanEmpty(t)
644 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200645 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200646 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200647}
648
649//-----------------------------------------------------------------------------
650// TestSubDelReqRetransmission
651//
652// stub stub
653// +-------+ +---------+ +---------+
654// | xapp | | submgr | | e2term |
655// +-------+ +---------+ +---------+
656// | | |
657// | [SUBS CREATE] |
658// | | |
659// | | |
660// | SubDelReq | |
661// |------------->| |
662// | | |
663// | | SubDelReq |
664// | |------------->|
665// | | |
666// | SubDelReq | |
667// | (same sub) | |
668// | (same xid) | |
669// |------------->| |
670// | | |
671// | | SubDelResp |
672// | |<-------------|
673// | | |
674// | SubDelResp | |
675// |<-------------| |
676//
677//-----------------------------------------------------------------------------
678func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200679 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200680
681 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200682 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200683 crereq, cremsg := e2termConn1.RecvSubsReq(t)
684 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200685 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200686
687 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200688 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200689 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200690
691 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200692 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200693 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
694
Juha Hyttinen1683f912020-04-17 10:39:57 +0300695 // hack as there is no real way to see has message be handled.
696 // Previuos counter check just tells that is has been received by submgr
697 // --> artificial delay
698 <-time.After(1 * time.Second)
699
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200700 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200701 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200702
703 //Wait that subs is cleaned
704 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
705
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200706 xappConn1.TestMsgChanEmpty(t)
707 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200708 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200709 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200710}
711
712//-----------------------------------------------------------------------------
713// TestSubDelReqCollision
714//
715// stub stub
716// +-------+ +---------+ +---------+
717// | xapp | | submgr | | e2term |
718// +-------+ +---------+ +---------+
719// | | |
720// | [SUBS CREATE] |
721// | | |
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 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200727// | |------------->|
728// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200729// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200730// | (same sub) | |
731// | (diff xid) | |
732// |------------->| |
733// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200734// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200735// | |<-------------|
736// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200737// | SubDelResp 1 | |
738// |<-------------| |
739// | | |
740// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200741// |<-------------| |
742//
743//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200744
Juha Hyttinenfa015662020-01-24 10:05:18 +0200745func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200746 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200747
748 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200749 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200750 crereq, cremsg := e2termConn1.RecvSubsReq(t)
751 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200752 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200753
754 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200755 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200756 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200757
Juha Hyttinen3944a222020-01-24 11:51:46 +0200758 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200759 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200760 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
761 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200762 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
763
Juha Hyttinen1683f912020-04-17 10:39:57 +0300764 // hack as there is no real way to see has message be handled.
765 // Previuos counter check just tells that is has been received by submgr
766 // --> artificial delay
767 <-time.After(1 * time.Second)
768
Juha Hyttinen3944a222020-01-24 11:51:46 +0200769 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200770 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200771
772 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200773 xappConn1.RecvSubsDelResp(t, nil)
774 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200775
776 //Wait that subs is cleaned
777 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
778
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200779 xappConn1.TestMsgChanEmpty(t)
780 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200781 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200782 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200783}
784
785//-----------------------------------------------------------------------------
786// TestSubReqAndSubDelOkTwoParallel
787//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200788// stub stub stub
789// +-------+ +-------+ +---------+ +---------+
790// | xapp | | xapp | | submgr | | e2term |
791// +-------+ +-------+ +---------+ +---------+
792// | | | |
793// | | | |
794// | | | |
795// | | SubReq1 | |
796// | |------------->| |
797// | | | |
798// | | | SubReq1 |
799// | | |------------->|
800// | | | |
801// | SubReq2 | |
802// |------------------------>| |
803// | | | |
804// | | | SubReq2 |
805// | | |------------->|
806// | | | |
807// | | | SubResp1 |
808// | | |<-------------|
809// | | SubResp1 | |
810// | |<-------------| |
811// | | | |
812// | | | SubResp2 |
813// | | |<-------------|
814// | SubResp2 | |
815// |<------------------------| |
816// | | | |
817// | | [SUBS 1 DELETE] |
818// | | | |
819// | | [SUBS 2 DELETE] |
820// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200821//
822//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +0300823
Juha Hyttinenfa015662020-01-24 10:05:18 +0200824func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200825 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200826
827 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200828 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200829 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200830 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200831 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200832
833 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200834 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200835 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300836
837 rparams2.Req.EventTriggerDefinition.Data.Length = 1
838 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
839 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
840
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200841 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200842 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200843
844 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200845 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200846 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200847
848 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200849 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200850 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200851
852 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200853 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200854 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
855 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200856 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200857 //Wait that subs is cleaned
858 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
859
860 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200861 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200862 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
863 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200864 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200865 //Wait that subs is cleaned
866 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
867
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200868 xappConn1.TestMsgChanEmpty(t)
869 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200870 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200871 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200872}
873
874//-----------------------------------------------------------------------------
875// TestSameSubsDiffRan
876// Same subscription to different RANs
877//
878// stub stub
879// +-------+ +---------+ +---------+
880// | xapp | | submgr | | e2term |
881// +-------+ +---------+ +---------+
882// | | |
883// | | |
884// | | |
885// | SubReq(r1) | |
886// |------------->| |
887// | | |
888// | | SubReq(r1) |
889// | |------------->|
890// | | |
891// | | SubResp(r1) |
892// | |<-------------|
893// | | |
894// | SubResp(r1) | |
895// |<-------------| |
896// | | |
897// | SubReq(r2) | |
898// |------------->| |
899// | | |
900// | | SubReq(r2) |
901// | |------------->|
902// | | |
903// | | SubResp(r2) |
904// | |<-------------|
905// | | |
906// | SubResp(r2) | |
907// |<-------------| |
908// | | |
909// | [SUBS r1 DELETE] |
910// | | |
911// | [SUBS r2 DELETE] |
912// | | |
913//
914//-----------------------------------------------------------------------------
915func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200916 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200917
918 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200919 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
920 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200921 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
922 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200923 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200924
925 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200926 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
927 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200928 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
929 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200930 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200931
932 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200933 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
934 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200935 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
936 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200937 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200938 //Wait that subs is cleaned
939 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
940
941 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200942 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
943 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200944 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
945 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200946 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200947 //Wait that subs is cleaned
948 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
949
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200950 xappConn1.TestMsgChanEmpty(t)
951 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200952 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200953 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200954}
955
956//-----------------------------------------------------------------------------
957// TestSubReqRetryInSubmgr
958//
959// stub stub
960// +-------+ +---------+ +---------+
961// | xapp | | submgr | | e2term |
962// +-------+ +---------+ +---------+
963// | | |
964// | SubReq | |
965// |------------->| |
966// | | |
967// | | SubReq |
968// | |------------->|
969// | | |
970// | | |
971// | | SubReq |
972// | |------------->|
973// | | |
974// | | SubResp |
975// | |<-------------|
976// | | |
977// | SubResp | |
978// |<-------------| |
979// | | |
980// | [SUBS DELETE] |
981// | | |
982//
983//-----------------------------------------------------------------------------
984
985func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200986 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200987
988 // Init counter check
989 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
990 Counter{cSubReqFromXapp, 1},
991 Counter{cSubReqToE2, 1},
992 Counter{cSubReReqToE2, 1},
993 Counter{cSubRespFromE2, 1},
994 Counter{cSubRespToXapp, 1},
995 Counter{cSubDelReqFromXapp, 1},
996 Counter{cSubDelReqToE2, 1},
997 Counter{cSubDelRespFromE2, 1},
998 Counter{cSubDelRespToXapp, 1},
999 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001000
1001 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001002 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001003
1004 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001005 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001006
1007 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001008 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1009 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001010
1011 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001012 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001013
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001014 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001015 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1016 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001017 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001018
1019 // Wait that subs is cleaned
1020 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1021
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001022 xappConn1.TestMsgChanEmpty(t)
1023 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001024 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001025 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001026
1027 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001028}
1029
1030//-----------------------------------------------------------------------------
1031// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1032//
1033// stub stub
1034// +-------+ +---------+ +---------+
1035// | xapp | | submgr | | e2term |
1036// +-------+ +---------+ +---------+
1037// | | |
1038// | SubReq | |
1039// |------------->| |
1040// | | |
1041// | | SubReq |
1042// | |------------->|
1043// | | |
1044// | | |
1045// | | SubReq |
1046// | |------------->|
1047// | | |
1048// | | SubDelReq |
1049// | |------------->|
1050// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001051// | | SubDelResp |
1052// | |<-------------|
1053// | | |
1054//
1055//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001056func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001057 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001058
1059 // Init counter check
1060 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1061 Counter{cSubReqFromXapp, 1},
1062 Counter{cSubReqToE2, 1},
1063 Counter{cSubReReqToE2, 1},
1064 Counter{cSubReqTimerExpiry, 2},
1065 Counter{cSubDelReqToE2, 1},
1066 Counter{cSubDelRespFromE2, 1},
1067 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001068
1069 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001070 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001071
1072 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001073 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001074
1075 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001076 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001077
1078 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001079 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1080 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001081
1082 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001083 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001084
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001085 xappConn1.TestMsgChanEmpty(t)
1086 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001087 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001088 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001089
1090 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001091}
1092
1093//-----------------------------------------------------------------------------
1094// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1095//
1096// stub stub
1097// +-------+ +---------+ +---------+
1098// | xapp | | submgr | | e2term |
1099// +-------+ +---------+ +---------+
1100// | | |
1101// | SubReq | |
1102// |------------->| |
1103// | | |
1104// | | SubReq |
1105// | |------------->|
1106// | | |
1107// | | |
1108// | | SubReq |
1109// | |------------->|
1110// | | |
1111// | | SubDelReq |
1112// | |------------->|
1113// | | |
1114// | | |
1115// | | SubDelReq |
1116// | |------------->|
1117// | | |
1118// | | |
1119//
1120//-----------------------------------------------------------------------------
1121
1122func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001123 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001124
1125 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1126 Counter{cSubReqFromXapp, 1},
1127 Counter{cSubReqToE2, 1},
1128 Counter{cSubReReqToE2, 1},
1129 Counter{cSubReqTimerExpiry, 2},
1130 Counter{cSubDelReqToE2, 1},
1131 Counter{cSubDelReReqToE2, 1},
1132 Counter{cSubDelReqTimerExpiry, 2},
1133 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001134
1135 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001136 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001137
1138 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001139 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001140
1141 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001142 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001143
1144 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001145 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001146
1147 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001148 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001149
1150 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001151 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001152
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001153 xappConn1.TestMsgChanEmpty(t)
1154 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001155 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001156 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001157
1158 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001159}
1160
1161//-----------------------------------------------------------------------------
1162// TestSubReqSubFailRespInSubmgr
1163//
1164// stub stub
1165// +-------+ +---------+ +---------+
1166// | xapp | | submgr | | e2term |
1167// +-------+ +---------+ +---------+
1168// | | |
1169// | SubReq | |
1170// |------------->| |
1171// | | |
1172// | | SubReq |
1173// | |------------->|
1174// | | |
1175// | | SubFail |
1176// | |<-------------|
1177// | | |
archaggeafbf95f2021-04-14 08:54:05 +03001178// | | SubDelReq |
1179// | |------------->|
1180// | | |
1181// | | SubDelResp |
1182// | |<-------------|
1183// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001184// | SubFail | |
1185// |<-------------| |
1186// | | |
1187//
1188//-----------------------------------------------------------------------------
1189
1190func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001191 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001192
1193 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1194 Counter{cSubReqFromXapp, 1},
1195 Counter{cSubReqToE2, 1},
1196 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001197 Counter{cSubFailToXapp, 1},
1198 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001199
1200 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001201 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001202
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001203 // E2t: Receive SubsReq and send SubsFail (first)
1204 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1205 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1206 fparams1.Set(crereq1)
1207 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1208
archaggeafbf95f2021-04-14 08:54:05 +03001209 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1210 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1211 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1212
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001213 // Xapp: Receive SubsFail
1214 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1215
1216 // Wait that subs is cleaned
1217 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1218
1219 xappConn1.TestMsgChanEmpty(t)
1220 xappConn2.TestMsgChanEmpty(t)
1221 e2termConn1.TestMsgChanEmpty(t)
1222 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001223
1224 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001225}
1226
1227//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001228// TestSubDelReqRetryInSubmgr
1229//
1230// stub stub
1231// +-------+ +---------+ +---------+
1232// | xapp | | submgr | | e2term |
1233// +-------+ +---------+ +---------+
1234// | | |
1235// | [SUBS CREATE] |
1236// | | |
1237// | | |
1238// | SubDelReq | |
1239// |------------->| |
1240// | | |
1241// | | SubDelReq |
1242// | |------------->|
1243// | | |
1244// | | SubDelReq |
1245// | |------------->|
1246// | | |
1247// | | SubDelResp |
1248// | |<-------------|
1249// | | |
1250// | SubDelResp | |
1251// |<-------------| |
1252//
1253//-----------------------------------------------------------------------------
1254
1255func TestSubDelReqRetryInSubmgr(t *testing.T) {
1256
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001257 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001258
1259 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001260 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001261 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1262 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001263 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001264
1265 // Subs Delete
1266 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001267 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001268
1269 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001270 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001271
1272 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001273 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1274 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001275
1276 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001277 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001278
1279 // Wait that subs is cleaned
1280 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1281
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001282 xappConn1.TestMsgChanEmpty(t)
1283 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001284 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001285 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001286}
1287
1288//-----------------------------------------------------------------------------
1289// TestSubDelReqTwoRetriesNoRespInSubmgr
1290//
1291// stub stub
1292// +-------+ +---------+ +---------+
1293// | xapp | | submgr | | e2term |
1294// +-------+ +---------+ +---------+
1295// | | |
1296// | [SUBS CREATE] |
1297// | | |
1298// | | |
1299// | SubDelReq | |
1300// |------------->| |
1301// | | |
1302// | | SubDelReq |
1303// | |------------->|
1304// | | |
1305// | | SubDelReq |
1306// | |------------->|
1307// | | |
1308// | | |
1309// | SubDelResp | |
1310// |<-------------| |
1311//
1312//-----------------------------------------------------------------------------
1313
1314func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1315
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001316 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001317
1318 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001319 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001320 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1321 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001322 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001323
1324 // Subs Delete
1325 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001326 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001327
1328 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001329 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001330
1331 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001332 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001333
1334 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001335 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001336
1337 // Wait that subs is cleaned
1338 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1339
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001340 xappConn1.TestMsgChanEmpty(t)
1341 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001342 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001343 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001344}
1345
1346//-----------------------------------------------------------------------------
1347// TestSubDelReqSubDelFailRespInSubmgr
1348//
1349// stub stub
1350// +-------+ +---------+ +---------+
1351// | xapp | | submgr | | e2term |
1352// +-------+ +---------+ +---------+
1353// | | |
1354// | [SUBS CREATE] |
1355// | | |
1356// | | |
1357// | SubDelReq | |
1358// |------------->| |
1359// | | |
1360// | | SubDelReq |
1361// | |------------->|
1362// | | |
1363// | | SubDelFail |
1364// | |<-------------|
1365// | | |
1366// | SubDelResp | |
1367// |<-------------| |
1368// | | |
1369//
1370//-----------------------------------------------------------------------------
1371
1372func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001373 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001374
1375 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1376 Counter{cSubReqFromXapp, 1},
1377 Counter{cSubReqToE2, 1},
1378 Counter{cSubRespFromE2, 1},
1379 Counter{cSubRespToXapp, 1},
1380 Counter{cSubDelReqFromXapp, 1},
1381 Counter{cSubDelReqToE2, 1},
1382 Counter{cSubDelFailFromE2, 1},
1383 Counter{cSubDelRespToXapp, 1},
1384 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001385
1386 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001387 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001388 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1389 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001390 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001391
1392 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001393 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001394
1395 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001396 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1397 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001398
1399 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001400 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001401
1402 // Wait that subs is cleaned
1403 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1404
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001405 xappConn1.TestMsgChanEmpty(t)
1406 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001407 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001408 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001409
1410 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001411}
1412
1413//-----------------------------------------------------------------------------
1414// TestSubReqAndSubDelOkSameAction
1415//
1416// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001417// +-------+ +-------+ +---------+ +---------+
1418// | xapp2 | | xapp1 | | submgr | | e2term |
1419// +-------+ +-------+ +---------+ +---------+
1420// | | | |
1421// | | | |
1422// | | | |
1423// | | SubReq1 | |
1424// | |------------->| |
1425// | | | |
1426// | | | SubReq1 |
1427// | | |------------->|
1428// | | | SubResp1 |
1429// | | |<-------------|
1430// | | SubResp1 | |
1431// | |<-------------| |
1432// | | | |
1433// | SubReq2 | |
1434// |--------------------------->| |
1435// | | | |
1436// | SubResp2 | |
1437// |<---------------------------| |
1438// | | | |
1439// | | SubDelReq 1 | |
1440// | |------------->| |
1441// | | | |
1442// | | SubDelResp 1 | |
1443// | |<-------------| |
1444// | | | |
1445// | SubDelReq 2 | |
1446// |--------------------------->| |
1447// | | | |
1448// | | | SubDelReq 2 |
1449// | | |------------->|
1450// | | | |
1451// | | | SubDelReq 2 |
1452// | | |------------->|
1453// | | | |
1454// | SubDelResp 2 | |
1455// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001456//
1457//-----------------------------------------------------------------------------
1458func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001459 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001460
Anssi Mannila4abf1802021-01-28 13:06:46 +02001461 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001462 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1463 Counter{cSubReqFromXapp, 2},
1464 Counter{cSubReqToE2, 1},
1465 Counter{cSubRespFromE2, 1},
1466 Counter{cSubRespToXapp, 2},
1467 Counter{cMergedSubscriptions, 1},
1468 Counter{cUnmergedSubscriptions, 1},
1469 Counter{cSubDelReqFromXapp, 2},
1470 Counter{cSubDelReqToE2, 1},
1471 Counter{cSubDelRespFromE2, 1},
1472 Counter{cSubDelRespToXapp, 2},
1473 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001474
Juha Hyttinen3944a222020-01-24 11:51:46 +02001475 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001476 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001477 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001478 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001479 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1480 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001481 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001482
1483 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001484 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001485 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001486 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001487 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1488 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001489 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001490
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001491 resp, _ := xapp.Subscription.QuerySubscriptions()
1492 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1493 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001494 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001495
Juha Hyttinen3944a222020-01-24 11:51:46 +02001496 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001497 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001498 //e2termConn1.RecvSubsDelReq(t)
1499 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001500 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001501 //Wait that subs is cleaned
1502 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1503
1504 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001505 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001506 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1507 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001508 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001509 //Wait that subs is cleaned
1510 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1511
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001512 xappConn1.TestMsgChanEmpty(t)
1513 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001514 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001515 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001516
1517 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001518}
1519
1520//-----------------------------------------------------------------------------
1521// TestSubReqAndSubDelOkSameActionParallel
1522//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001523// stub stub stub
1524// +-------+ +-------+ +---------+ +---------+
1525// | xapp2 | | xapp1 | | submgr | | e2term |
1526// +-------+ +-------+ +---------+ +---------+
1527// | | | |
1528// | | | |
1529// | | | |
1530// | | SubReq1 | |
1531// | |------------->| |
1532// | | | |
1533// | | | SubReq1 |
1534// | | |------------->|
1535// | SubReq2 | |
1536// |--------------------------->| |
1537// | | | SubResp1 |
1538// | | |<-------------|
1539// | | SubResp1 | |
1540// | |<-------------| |
1541// | | | |
1542// | SubResp2 | |
1543// |<---------------------------| |
1544// | | | |
1545// | | SubDelReq 1 | |
1546// | |------------->| |
1547// | | | |
1548// | | SubDelResp 1 | |
1549// | |<-------------| |
1550// | | | |
1551// | SubDelReq 2 | |
1552// |--------------------------->| |
1553// | | | |
1554// | | | SubDelReq 2 |
1555// | | |------------->|
1556// | | | |
1557// | | | SubDelReq 2 |
1558// | | |------------->|
1559// | | | |
1560// | SubDelResp 2 | |
1561// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001562//
1563//-----------------------------------------------------------------------------
1564func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001565 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001566
1567 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001568 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001569 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001570 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001571 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001572
1573 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001574 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001575 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001576 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001577
1578 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001579 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001580 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001581
1582 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001583 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001584
1585 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001586 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1587 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001588
1589 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001590 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001591 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1592 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001593 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001594
1595 //Wait that subs is cleaned
1596 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1597
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001598 xappConn1.TestMsgChanEmpty(t)
1599 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001600 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001601 mainCtrl.wait_registry_empty(t, 10)
1602}
1603
1604//-----------------------------------------------------------------------------
1605// TestSubReqAndSubDelNokSameActionParallel
1606//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001607// stub stub stub
1608// +-------+ +-------+ +---------+ +---------+
1609// | xapp2 | | xapp1 | | submgr | | e2term |
1610// +-------+ +-------+ +---------+ +---------+
1611// | | | |
1612// | | | |
1613// | | | |
1614// | | SubReq1 | |
1615// | |------------->| |
1616// | | | |
1617// | | | SubReq1 |
1618// | | |------------->|
1619// | SubReq2 | |
1620// |--------------------------->| |
1621// | | | SubFail1 |
1622// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001623// | | | |
archaggeafbf95f2021-04-14 08:54:05 +03001624// | | | SubDelReq |
1625// | | |------------->|
1626// | | | SubDelResp |
1627// | | |<-------------|
1628// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001629// | | SubFail1 | |
1630// | |<-------------| |
1631// | | | |
1632// | SubFail2 | |
1633// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001634//
1635//-----------------------------------------------------------------------------
1636func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001637 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001638
1639 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001640 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001641 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001642 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001643
1644 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001645 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001646
1647 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001648 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001649 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001650 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001651 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001652 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001653
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001654 // E2t: send SubsFail (first)
1655 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1656 fparams1.Set(crereq1)
1657 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1658
archaggeafbf95f2021-04-14 08:54:05 +03001659 // E2t: internal delete
1660 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1661 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1662
Juha Hyttinen3944a222020-01-24 11:51:46 +02001663 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001664 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001665 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001666 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001667
1668 //Wait that subs is cleaned
1669 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1670
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001671 xappConn1.TestMsgChanEmpty(t)
1672 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001673 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001674 mainCtrl.wait_registry_empty(t, 10)
1675}
1676
1677//-----------------------------------------------------------------------------
1678// TestSubReqAndSubDelNoAnswerSameActionParallel
1679//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001680// stub stub stub
1681// +-------+ +-------+ +---------+ +---------+
1682// | xapp2 | | xapp1 | | submgr | | e2term |
1683// +-------+ +-------+ +---------+ +---------+
1684// | | | |
1685// | | | |
1686// | | | |
1687// | | SubReq1 | |
1688// | |------------->| |
1689// | | | |
1690// | | | SubReq1 |
1691// | | |------------->|
1692// | | SubReq2 | |
1693// |--------------------------->| |
1694// | | | |
1695// | | | SubReq1 |
1696// | | |------------->|
1697// | | | |
1698// | | | |
1699// | | | SubDelReq |
1700// | | |------------->|
1701// | | | |
1702// | | | SubDelResp |
1703// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001704//
1705//-----------------------------------------------------------------------------
1706func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001707 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001708
1709 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001710 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001711 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001712 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001713
Juha Hyttinen1683f912020-04-17 10:39:57 +03001714 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001715
1716 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001717 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001718 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001719 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001720 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001721 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001722
1723 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001724 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001725
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001726 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1727 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001728
1729 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001730 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001731
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001732 xappConn1.TestMsgChanEmpty(t)
1733 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001734 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001735 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001736}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001737
1738//----------------------------- Policy cases ---------------------------------
1739//-----------------------------------------------------------------------------
1740// TestSubReqPolicyAndSubDelOk
1741//
1742// stub stub
1743// +-------+ +---------+ +---------+
1744// | xapp | | submgr | | e2term |
1745// +-------+ +---------+ +---------+
1746// | | |
1747// | SubReq | |
1748// |------------->| |
1749// | | |
1750// | | SubReq |
1751// | |------------->|
1752// | | |
1753// | | SubResp |
1754// | |<-------------|
1755// | | |
1756// | SubResp | |
1757// |<-------------| |
1758// | | |
1759// | | |
1760// | SubDelReq | |
1761// |------------->| |
1762// | | |
1763// | | SubDelReq |
1764// | |------------->|
1765// | | |
1766// | | SubDelResp |
1767// | |<-------------|
1768// | | |
1769// | SubDelResp | |
1770// |<-------------| |
1771//
1772//-----------------------------------------------------------------------------
1773func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1774 CaseBegin("TestSubReqAndSubDelOk")
1775
1776 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1777 rparams1.Init()
1778 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1779 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1780
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001781 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1782 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001783 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1784 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001785 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001786
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001787 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001788 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001789
1790 //Wait that subs is cleaned
1791 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1792
1793 xappConn1.TestMsgChanEmpty(t)
1794 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001795 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001796 mainCtrl.wait_registry_empty(t, 10)
1797}
1798
1799//-----------------------------------------------------------------------------
1800// TestSubReqPolicyChangeAndSubDelOk
1801//
1802// stub stub
1803// +-------+ +---------+ +---------+
1804// | xapp | | submgr | | e2term |
1805// +-------+ +---------+ +---------+
1806// | | |
1807// | SubReq | |
1808// |------------->| |
1809// | | |
1810// | | SubReq |
1811// | |------------->|
1812// | | |
1813// | | SubResp |
1814// | |<-------------|
1815// | | |
1816// | SubResp | |
1817// |<-------------| |
1818// | | |
1819// | SubReq | |
1820// |------------->| |
1821// | | |
1822// | | SubReq |
1823// | |------------->|
1824// | | |
1825// | | SubResp |
1826// | |<-------------|
1827// | | |
1828// | SubResp | |
1829// |<-------------| |
1830// | | |
1831// | SubDelReq | |
1832// |------------->| |
1833// | | |
1834// | | SubDelReq |
1835// | |------------->|
1836// | | |
1837// | | SubDelResp |
1838// | |<-------------|
1839// | | |
1840// | SubDelResp | |
1841// |<-------------| |
1842//
1843//-----------------------------------------------------------------------------
1844
1845func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1846 CaseBegin("TestSubReqAndSubDelOk")
1847
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001848 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1849 rparams1.Init()
1850 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1851 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001852
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001853 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1854 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001855 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1856
1857 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001858 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001859 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1860 xappConn1.SendSubsReq(t, rparams1, cretrans)
1861
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001862 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1863 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001864 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1865 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001866 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001867
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001868 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001869 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001870
1871 //Wait that subs is cleaned
1872 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1873
1874 xappConn1.TestMsgChanEmpty(t)
1875 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001876 e2termConn1.TestMsgChanEmpty(t)
1877 mainCtrl.wait_registry_empty(t, 10)
1878}
1879
1880//-----------------------------------------------------------------------------
1881// TestSubReqAndSubDelOkTwoE2termParallel
1882//
1883// stub stub stub
1884// +-------+ +---------+ +---------+ +---------+
1885// | xapp | | submgr | | e2term1 | | e2term2 |
1886// +-------+ +---------+ +---------+ +---------+
1887// | | | |
1888// | | | |
1889// | | | |
1890// | SubReq1 | | |
1891// |------------->| | |
1892// | | | |
1893// | | SubReq1 | |
1894// | |------------->| |
1895// | | | |
1896// | SubReq2 | | |
1897// |------------->| | |
1898// | | | |
1899// | | SubReq2 | |
1900// | |---------------------------->|
1901// | | | |
1902// | | SubResp1 | |
1903// | |<-------------| |
1904// | SubResp1 | | |
1905// |<-------------| | |
1906// | | SubResp2 | |
1907// | |<----------------------------|
1908// | SubResp2 | | |
1909// |<-------------| | |
1910// | | | |
1911// | [SUBS 1 DELETE] | |
1912// | | | |
1913// | [SUBS 2 DELETE] | |
1914// | | | |
1915//
1916//-----------------------------------------------------------------------------
1917func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1918 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1919
1920 //Req1
1921 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1922 xappConn1.SendSubsReq(t, nil, cretrans1)
1923 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1924
1925 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1926 xappConn1.SendSubsReq(t, nil, cretrans2)
1927 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1928
1929 //Resp1
1930 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1931 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1932
1933 //Resp2
1934 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1935 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1936
1937 //Del1
1938 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1939 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1940 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1941 xappConn1.RecvSubsDelResp(t, deltrans1)
1942 //Wait that subs is cleaned
1943 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1944
1945 //Del2
1946 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1947 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1948 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1949 xappConn1.RecvSubsDelResp(t, deltrans2)
1950 //Wait that subs is cleaned
1951 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1952
1953 xappConn1.TestMsgChanEmpty(t)
1954 xappConn2.TestMsgChanEmpty(t)
1955 e2termConn1.TestMsgChanEmpty(t)
1956 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001957 mainCtrl.wait_registry_empty(t, 10)
1958}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001959
1960//-----------------------------------------------------------------------------
1961// TestSubReqInsertAndSubDelOk
1962//
1963// stub stub
1964// +-------+ +---------+ +---------+
1965// | xapp | | submgr | | e2term |
1966// +-------+ +---------+ +---------+
1967// | | |
1968// | SubReq | |
1969// |------------->| |
1970// | | |
1971// | | SubReq |
1972// | |------------->|
1973// | | |
1974// | | SubResp |
1975// | |<-------------|
1976// | | |
1977// | SubResp | |
1978// |<-------------| |
1979// | | |
1980// | | |
1981// | SubDelReq | |
1982// |------------->| |
1983// | | |
1984// | | SubDelReq |
1985// | |------------->|
1986// | | |
1987// | | SubDelResp |
1988// | |<-------------|
1989// | | |
1990// | SubDelResp | |
1991// |<-------------| |
1992//
1993//-----------------------------------------------------------------------------
1994func TestSubReqInsertAndSubDelOk(t *testing.T) {
1995 CaseBegin("TestInsertSubReqAndSubDelOk")
1996
1997 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1998 rparams1.Init()
1999 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2000 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2001
2002 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2003 e2termConn1.SendSubsResp(t, crereq, cremsg)
2004 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2005 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2006 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2007
2008 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2009 xappConn1.RecvSubsDelResp(t, deltrans)
2010
2011 //Wait that subs is cleaned
2012 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2013
2014 xappConn1.TestMsgChanEmpty(t)
2015 xappConn2.TestMsgChanEmpty(t)
2016 e2termConn1.TestMsgChanEmpty(t)
2017 mainCtrl.wait_registry_empty(t, 10)
2018}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002019
2020//-----------------------------------------------------------------------------
2021// TestSubReqRetransmissionWithSameSubIdDiffXid
2022//
2023// This case simulates case where xApp restarts and starts sending same
2024// subscription requests which have already subscribed successfully
2025
2026// stub stub
2027// +-------+ +---------+ +---------+
2028// | xapp | | submgr | | e2term |
2029// +-------+ +---------+ +---------+
2030// | | |
2031// | SubReq | |
2032// |------------->| |
2033// | | |
2034// | | SubReq |
2035// | |------------->|
2036// | | |
2037// | | SubResp |
2038// | |<-------------|
2039// | | |
2040// | SubResp | |
2041// |<-------------| |
2042// | | |
2043// | xApp restart | |
2044// | | |
2045// | SubReq | |
2046// | (retrans with same xApp generated subid but diff xid)
2047// |------------->| |
2048// | | |
2049// | SubResp | |
2050// |<-------------| |
2051// | | |
2052// | [SUBS DELETE] |
2053// | | |
2054//
2055//-----------------------------------------------------------------------------
2056func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2057 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2058
2059 //Subs Create
2060 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2061 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2062 e2termConn1.SendSubsResp(t, crereq, cremsg)
2063 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2064
2065 // xApp restart here
2066 // --> artificial delay
2067 <-time.After(1 * time.Second)
2068
2069 //Subs Create
2070 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2071 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2072
2073 //Subs Delete
2074 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2075 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2076 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2077 xappConn1.RecvSubsDelResp(t, deltrans)
2078
2079 //Wait that subs is cleaned
2080 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2081
2082 xappConn1.TestMsgChanEmpty(t)
2083 xappConn2.TestMsgChanEmpty(t)
2084 e2termConn1.TestMsgChanEmpty(t)
2085 mainCtrl.wait_registry_empty(t, 10)
2086}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002087
2088//-----------------------------------------------------------------------------
2089// TestSubReqNokAndSubDelOkWithRestartInMiddle
2090//
2091// stub stub
2092// +-------+ +---------+ +---------+
2093// | xapp | | submgr | | e2term |
2094// +-------+ +---------+ +---------+
2095// | | |
2096// | SubReq | |
2097// |------------->| |
2098// | | |
2099// | | SubReq |
2100// | |------------->|
2101// | | |
2102// | | SubResp |
2103// | <----|
2104// | |
2105// | Submgr restart |
2106// | |
2107// | | |
2108// | | SubDelReq |
2109// | |------------->|
2110// | | |
2111// | | SubDelResp |
2112// | |<-------------|
2113// | | |
2114//
2115//-----------------------------------------------------------------------------
2116
2117func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2118 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2119
2120 // Remove possible existing subscrition
2121 mainCtrl.removeExistingSubscriptions(t)
2122
2123 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2124 xappConn1.SendSubsReq(t, nil, nil)
2125 e2termConn1.RecvSubsReq(t)
2126 mainCtrl.SetResetTestFlag(t, false)
2127
2128 resp, _ := xapp.Subscription.QuerySubscriptions()
2129 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002130 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002131 e2SubsId := uint32(resp[0].SubscriptionID)
2132 t.Logf("e2SubsId = %v", e2SubsId)
2133
archaggeafbf95f2021-04-14 08:54:05 +03002134 mainCtrl.SimulateRestart(t)
2135 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002136
2137 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2138 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2139
2140 // Wait that subs is cleaned
2141 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2142
2143 xappConn1.TestMsgChanEmpty(t)
2144 xappConn2.TestMsgChanEmpty(t)
2145 e2termConn1.TestMsgChanEmpty(t)
2146 mainCtrl.wait_registry_empty(t, 10)
2147}
2148
2149//-----------------------------------------------------------------------------
2150// TestSubReqAndSubDelOkWithRestartInMiddle
2151//
2152// stub stub
2153// +-------+ +---------+ +---------+
2154// | xapp | | submgr | | e2term |
2155// +-------+ +---------+ +---------+
2156// | | |
2157// | SubReq | |
2158// |------------->| |
2159// | | |
2160// | | SubReq |
2161// | |------------->|
2162// | | |
2163// | | SubResp |
2164// | |<-------------|
2165// | | |
2166// | SubResp | |
2167// |<-------------| |
2168// | | |
2169// | |
2170// | Submgr restart |
2171// | |
2172// | SubDelReq | |
2173// |------------->| |
2174// | | |
2175// | | SubDelReq |
2176// | |------------->|
2177// | | |
2178// | | SubDelResp |
2179// | |<-------------|
2180// | | |
2181// | SubDelResp | |
2182// |<-------------| |
2183//
2184//-----------------------------------------------------------------------------
2185
2186func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2187 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2188
2189 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2190 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2191 e2termConn1.SendSubsResp(t, crereq, cremsg)
2192 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2193
2194 // Check subscription
2195 resp, _ := xapp.Subscription.QuerySubscriptions()
2196 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2197 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002198 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002199
2200 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002201 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002202
2203 // Check that subscription is restored correctly after restart
2204 resp, _ = xapp.Subscription.QuerySubscriptions()
2205 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2206 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002207 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002208
2209 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2210 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2211 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2212 xappConn1.RecvSubsDelResp(t, deltrans)
2213
2214 //Wait that subs is cleaned
2215 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2216
2217 xappConn1.TestMsgChanEmpty(t)
2218 xappConn2.TestMsgChanEmpty(t)
2219 e2termConn1.TestMsgChanEmpty(t)
2220 mainCtrl.wait_registry_empty(t, 10)
2221}
2222
2223//-----------------------------------------------------------------------------
2224// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2225//
2226// stub stub
2227// +-------+ +-------+ +---------+ +---------+
2228// | xapp2 | | xapp1 | | submgr | | e2term |
2229// +-------+ +-------+ +---------+ +---------+
2230// | | | |
2231// | | | |
2232// | | | |
2233// | | SubReq1 | |
2234// | |------------->| |
2235// | | | |
2236// | | | SubReq1 |
2237// | | |------------->|
2238// | | | SubResp1 |
2239// | | |<-------------|
2240// | | SubResp1 | |
2241// | |<-------------| |
2242// | | | |
2243// | |
2244// | submgr restart |
2245// | |
2246// | | | |
2247// | | | |
2248// | SubReq2 | |
2249// |--------------------------->| |
2250// | | | |
2251// | SubResp2 | |
2252// |<---------------------------| |
2253// | | | |
2254// | | SubDelReq 1 | |
2255// | |------------->| |
2256// | | | |
2257// | | SubDelResp 1 | |
2258// | |<-------------| |
2259// | | | |
2260// | | | |
2261// | |
2262// | submgr restart |
2263// | |
2264// | | | |
2265// | SubDelReq 2 | |
2266// |--------------------------->| |
2267// | | | |
2268// | | | SubDelReq 2 |
2269// | | |------------->|
2270// | | | |
2271// | | | SubDelReq 2 |
2272// | | |------------->|
2273// | | | |
2274// | SubDelResp 2 | |
2275// |<---------------------------| |
2276//
2277//-----------------------------------------------------------------------------
2278
2279func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2280 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2281
2282 //Req1
2283 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2284 rparams1.Init()
2285 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2286 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2287 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2288 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2289
2290 //Req2
2291 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2292 rparams2.Init()
2293 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2294 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2295
2296 // Check subscription
2297 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2298 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2299 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002300 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002301
2302 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002303 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002304
2305 // Check that subscription is restored correctly after restart
2306 resp, _ = xapp.Subscription.QuerySubscriptions()
2307 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2308 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002309 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002310
2311 //Del1
2312 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2313 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2314 xappConn1.RecvSubsDelResp(t, deltrans1)
2315 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2316
2317 mainCtrl.SimulateRestart(t)
2318 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2319
2320 //Del2
2321 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2322 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2323
2324 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2325 xappConn2.RecvSubsDelResp(t, deltrans2)
2326
2327 //Wait that subs is cleaned
2328 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2329
2330 xappConn1.TestMsgChanEmpty(t)
2331 xappConn2.TestMsgChanEmpty(t)
2332 e2termConn1.TestMsgChanEmpty(t)
2333 mainCtrl.wait_registry_empty(t, 10)
2334}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002335
archaggeafbf95f2021-04-14 08:54:05 +03002336//*****************************************************************************
2337// REST interface test cases
2338//*****************************************************************************
2339
Anssi Mannila47518ae2021-04-16 09:27:07 +03002340//-----------------------------------------------------------------------------
2341// Test debug GET and POST requests
2342//
2343// curl
2344// +-------+ +---------+
2345// | user | | submgr |
2346// +-------+ +---------+
2347// | |
2348// | GET/POST Req |
2349// |------------->|
2350// | Resp |
2351// |<-------------|
2352// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002353func TestGetSubscriptions(t *testing.T) {
2354
2355 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2356}
2357
2358func TestGetSymptomData(t *testing.T) {
2359
2360 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2361}
2362
2363func TestPostdeleteSubId(t *testing.T) {
2364
2365 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2366}
2367
2368func TestPostEmptyDb(t *testing.T) {
2369
2370 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2371}
archaggeafbf95f2021-04-14 08:54:05 +03002372
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002373func TestGetRestSubscriptions(t *testing.T) {
2374
2375 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2376}
2377
archaggeafbf95f2021-04-14 08:54:05 +03002378//-----------------------------------------------------------------------------
2379// TestRESTSubReqAndRouteNok
2380//
2381// stub stub
2382// +-------+ +---------+ +---------+
2383// | xapp | | submgr | | rtmgr |
2384// +-------+ +---------+ +---------+
2385// | | |
2386// | RESTSubReq | |
2387// |---------------->| |
2388// | | |
2389// | RESTSubResp | |
2390// |<----------------| |
2391// | | RouteCreate |
2392// | |------------->|
2393// | | |
2394// | | RouteCreate |
2395// | | status:400 |
2396// | |(Bad request) |
2397// | |<-------------|
2398// | RESTNotif | |
2399// |<----------------| |
2400// | | |
2401// | [SUBS INT DELETE] |
2402// | | |
2403// | RESTSubDelReq | |
2404// |---------------->| |
2405// | RESTSubDelResp | |
2406// |<----------------| |
2407//
2408//-----------------------------------------------------------------------------
2409func TestRESTSubReqAndRouteNok(t *testing.T) {
2410 CaseBegin("TestRESTSubReqAndRouteNok")
2411
2412 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002413 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002414 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002415 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002416 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002417 Counter{cRestSubDelReqFromXapp, 1},
2418 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002419 })
2420
2421 const subReqCount int = 1
Markku Virtanenda34eec2021-05-20 08:22:04 +00002422 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2423 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002424 newSubsId := mainCtrl.get_registry_next_subid(t)
2425
2426 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002427 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002428 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002429 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002430 waiter.WaitResult(t)
2431
archaggeafbf95f2021-04-14 08:54:05 +03002432 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2433 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2434
2435 // Del
2436 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2437
2438 // Wait that subs is cleaned
2439 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2440 waitSubsCleanup(t, e2SubsId, 10)
2441 mainCtrl.VerifyCounterValues(t)
2442}
2443
2444func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2445 CaseBegin("TestSubReqAndRouteUpdateNok")
2446
2447 //Init counter check
2448 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002449 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002450 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002451 Counter{cSubReqToE2, 1},
2452 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002453 Counter{cRestSubNotifToXapp, 1},
2454 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002455 Counter{cRouteCreateUpdateFail, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002456 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002457 Counter{cSubDelReqToE2, 1},
2458 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002459 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002460 })
2461
2462 var params *teststube2ap.RESTSubsReqParams = nil
2463
2464 //Subs Create
2465 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2466
2467 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2468
2469 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2470 waiter := rtmgrHttp.AllocNextEvent(false)
2471 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002472 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002473 params.SetMeid("RAN_NAME_1")
2474 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2475 xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002476 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002477 waiter.WaitResult(t)
2478 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2479 xappConn2.WaitRESTNotification(t, restSubId2)
2480
2481 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2482
2483 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2484
2485 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2486 //Wait that subs is cleaned
2487 waitSubsCleanup(t, e2SubsId, 10)
2488
2489 mainCtrl.VerifyCounterValues(t)
2490}
2491
2492func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2493 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2494
2495 // Init counter check
2496 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002497 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002498 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002499 Counter{cSubReqToE2, 1},
2500 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002501 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002502 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002503 Counter{cRouteDeleteFail, 1},
2504 Counter{cSubDelReqToE2, 1},
2505 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002506 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002507 })
2508
2509 var params *teststube2ap.RESTSubsReqParams = nil
2510
2511 //Subs Create
2512 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2513
2514 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2515
2516 waiter := rtmgrHttp.AllocNextEvent(false)
2517 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2518 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2519 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2520 waiter.WaitResult(t)
2521
2522 waitSubsCleanup(t, e2SubsId, 10)
2523
2524 mainCtrl.VerifyCounterValues(t)
2525}
2526
2527func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2528 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2529
2530 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002531 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002532 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002533 Counter{cSubReqToE2, 1},
2534 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002535 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002536 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002537 Counter{cRouteDeleteUpdateFail, 1},
2538 Counter{cSubDelReqToE2, 1},
2539 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002540 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002541 })
2542
2543 var params *teststube2ap.RESTSubsReqParams = nil
2544
2545 //Subs Create
2546 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2547
2548 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2549 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2550
2551 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2552
2553 //Del1, this shall fail on rtmgr side
2554 waiter := rtmgrHttp.AllocNextEvent(false)
2555 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2556 waiter.WaitResult(t)
2557
2558 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2559
2560 //Del2
2561 deleteXapp2Subscription(t, &restSubId2)
2562
2563 waitSubsCleanup(t, e2SubsId2, 10)
2564
2565 mainCtrl.VerifyCounterValues(t)
2566}
2567
2568//-----------------------------------------------------------------------------
2569// TestRESTSubReqRetransmission
2570//
2571// stub stub
2572// +-------+ +---------+ +---------+
2573// | xapp | | submgr | | e2term |
2574// +-------+ +---------+ +---------+
2575// | | |
2576// | RESTSubReq1 | |
2577// |---------------->| |
2578// | | |
2579// | RESTSubResp | |
2580// |<----------------| |
2581// | | SubReq1 |
2582// | |------------->|
2583// | | |
2584// | RESTSubReq2 | |
2585// | (retrans) | |
2586// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002587// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002588// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002589// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002590// | | SubResp1 |
2591// | |<-------------|
2592// | RESTNotif1 | |
2593// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002594// | | |
2595// | [SUBS DELETE] |
2596// | | |
2597//
2598//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002599
archaggeafbf95f2021-04-14 08:54:05 +03002600func TestRESTSubReqRetransmission(t *testing.T) {
2601 CaseBegin("TestRESTSubReqRetransmission")
2602
2603 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002604 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002605 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002606 Counter{cSubReqToE2, 1},
2607 Counter{cSubRespFromE2, 1},
2608 Counter{cRestSubNotifToXapp, 1},
2609 Counter{cRestSubDelReqFromXapp, 1},
2610 Counter{cSubDelReqToE2, 1},
2611 Counter{cSubDelRespFromE2, 1},
2612 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002613 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002614 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002615 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2616 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2617
2618 // Subs Create
2619 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002620
2621 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2622 // gets into execution before the rtmgrg responds for the first one.
2623 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002624 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002625 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenb642a192021-06-09 09:08:14 +00002626 xappConn2.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002627
2628 waiter.WaitResult(t)
2629
Markku Virtanenb642a192021-06-09 09:08:14 +00002630 xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
archaggeafbf95f2021-04-14 08:54:05 +03002631
2632 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2633 // the order is not significant he6re.
2634 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2635 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002636
2637 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2638 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03002639
2640 // Del1
2641 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2642 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2643 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2644
Markku Virtanenb642a192021-06-09 09:08:14 +00002645 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002646
2647 mainCtrl.VerifyCounterValues(t)
2648}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002649
Markku Virtanen42723e22021-06-15 10:09:23 +03002650//-----------------------------------------------------------------------------
2651// stub stub stub
2652// +-------+ +---------+ +---------+ +---------+
2653// | xapp | | submgr | | e2term | | rtmgr |
2654// +-------+ +---------+ +---------+ +---------+
2655// | | | |
2656// | RESTSubReq | | |
2657// |---------------->| | |
2658// | RESTSubResp | | |
2659// |<----------------| | |
2660// | | RouteCreate | |
2661// | |--------------------------->|
2662// | | RouteResponse| |
2663// | |<---------------------------| // The order of these events may vary
2664// | | SubReq | |
2665// | |------------->| | // The order of these events may vary
2666// | | SubResp | |
2667// | |<-------------| |
2668// | RESTNotif1 | | |
2669// |<----------------| | |
2670// | RESTSubReq | | |
2671// | [RETRANS1] | | |
2672// |---------------->| | |
2673// | RESTNotif1 | | |
2674// |<----------------| | |
2675// | RESTSubReq | | |
2676// | [RETRANS2] | | |
2677// |---------------->| | |
2678// | RESTNotif1 | | |
2679// |<----------------| | |
2680// | RESTSubDelReq | | |
2681// |---------------->| | |
2682// | | SubDelReq | |
2683// | |------------->| |
2684// | RESTSubDelResp| | |
2685// |<----------------| | |
2686// | | SubDelResp | |
2687// | |<-------------| |
2688// | | | |
2689//
2690//-----------------------------------------------------------------------------
2691
2692func TestRESTSubReqRetransmissionV2(t *testing.T) {
2693 CaseBegin("TestRESTSubReqRetransmissionV2")
2694
2695 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2696 Counter{cRestSubReqFromXapp, 3},
2697 Counter{cRestSubRespToXapp, 3},
2698 Counter{cSubReqToE2, 1},
2699 Counter{cSubRespFromE2, 1},
2700 Counter{cRestSubNotifToXapp, 3},
2701 Counter{cRestSubDelReqFromXapp, 1},
2702 Counter{cSubDelReqToE2, 1},
2703 Counter{cSubDelRespFromE2, 1},
2704 Counter{cRestSubDelRespToXapp, 1},
2705 })
2706
2707 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2708
2709 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2710
2711 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2712
2713 //1.st resend
2714 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2715
2716 assert.Equal(t, restSubId_resend, restSubId)
2717
2718 <-time.After(100 * time.Millisecond)
2719
2720 //2.nd resend
2721 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2722
2723 assert.Equal(t, restSubId_resend2, restSubId)
2724
2725 <-time.After(100 * time.Millisecond)
2726
2727 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2728
2729 waitSubsCleanup(t, e2SubsId, 10)
2730
2731 //Wait that subs is cleaned
2732 mainCtrl.VerifyCounterValues(t)
2733}
2734
2735//-----------------------------------------------------------------------------
2736// stub stub stub
2737// +-------+ +---------+ +---------+ +---------+
2738// | xapp | | submgr | | e2term | | rtmgr |
2739// +-------+ +---------+ +---------+ +---------+
2740// | | | |
2741// | RESTSubReq | | |
2742// |---------------->| | |
2743// | RESTSubResp | | |
2744// |<----------------| | |
2745// | | RouteCreate | |
2746// | |--------------------------->|
2747// | | RouteResponse| |
2748// | |<---------------------------| // The order of these events may vary
2749// | | SubReq | |
2750// | |------------->| | // The order of these events may vary
2751// | | SubResp | |
2752// | |<-------------| |
2753// | RESTNotif1 | | |
2754// |<----------------| | |
2755// | RESTSubReq | | |
2756// | [RETRANS, with RESTsubsId] | |
2757// |---------------->| | |
2758// | RESTNotif1 | | |
2759// |<----------------| | |
2760// | RESTSubReq | | |
2761// | [RETRANS, without RESTsubsId] | |
2762// |---------------->| | |
2763// | RESTNotif1 | | |
2764// |<----------------| | |
2765// | RESTSubDelReq | | |
2766// |---------------->| | |
2767// | | SubDelReq | |
2768// | |------------->| |
2769// | RESTSubDelResp| | |
2770// |<----------------| | |
2771// | | SubDelResp | |
2772// | |<-------------| |
2773// | | | |
2774//
2775//-----------------------------------------------------------------------------
2776func TestRESTSubReqRetransmissionV3(t *testing.T) {
2777 CaseBegin("TestRESTSubReqRetransmissionV3")
2778
2779 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2780 Counter{cRestSubReqFromXapp, 3},
2781 Counter{cRestSubRespToXapp, 3},
2782 Counter{cSubReqToE2, 1},
2783 Counter{cSubRespFromE2, 1},
2784 Counter{cRestSubNotifToXapp, 3},
2785 Counter{cRestSubDelReqFromXapp, 1},
2786 Counter{cSubDelReqToE2, 1},
2787 Counter{cSubDelRespFromE2, 1},
2788 Counter{cRestSubDelRespToXapp, 1},
2789 })
2790
2791 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2792
2793 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2794
2795 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2796
2797 <-time.After(100 * time.Millisecond)
2798
2799 //1.st resend with subscription ID
2800 params.SetSubscriptionID(&restSubId)
2801 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2802
2803 assert.Equal(t, restSubId_resend, restSubId)
2804
2805 <-time.After(100 * time.Millisecond)
2806
2807 //2.nd resend without subscription ID (faking app restart)
2808 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
2809 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2810
2811 assert.Equal(t, restSubId_resend2, restSubId)
2812
2813 <-time.After(100 * time.Millisecond)
2814
2815 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2816
2817 waitSubsCleanup(t, e2SubsId, 10)
2818
2819 //Wait that subs is cleaned
2820 mainCtrl.VerifyCounterValues(t)
2821}
2822
2823//-----------------------------------------------------------------------------
2824// stub stub stub
2825// +-------+ +---------+ +---------+ +---------+
2826// | xapp | | submgr | | e2term | | rtmgr |
2827// +-------+ +---------+ +---------+ +---------+
2828// | | | |
2829// | RESTSubReq | | |
2830// |---------------->| | |
2831// | RESTSubResp | | |
2832// |<----------------| | |
2833// | | RouteCreate | |
2834// | |--------------------------->|
2835// | | RouteResponse| |
2836// | |<---------------------------|
2837// | | SubReq | |
2838// | |------------->| |
2839// | | SubResp | |
2840// | |<-------------| |
2841// | RESTNotif1 | | |
2842// |<----------------| | |
2843// | RESTSubReq | | |
2844// | [with RestSUbsId + one additional e2 subDetail]
2845// |---------------->| | |
2846// | RESTNotif1 | | |
2847// | [for initial e2 subDetail] | |
2848// |<----------------| | |
2849// | | RouteCreate | |
2850// | |--------------------------->|
2851// | | RouteResponse| |
2852// | |<---------------------------|
2853// | | SubReq | |
2854// | |------------->| |
2855// | | SubResp | |
2856// | |<-------------| |
2857// | RESTNotif1 | | |
2858// |<----------------| | |
2859// | RESTSubReq | | |
2860// | [with RESTsubsId initial request] |
2861// |---------------->| | |
2862// | RESTNotif1 | | |
2863// |<----------------| | |
2864// | RESTSubDelReq | | |
2865// |---------------->| | |
2866// | RESTSubDelResp| | |
2867// |<----------------| | |
2868// | | SubDelReq | |
2869// | |------------->| |
2870// | | SubDelResp | |
2871// | |<-------------| |
2872// | | SubDelReq | |
2873// | |------------->| |
2874// | | SubDelResp | |
2875// | |<-------------| |
2876// | | | |
2877//
2878//-----------------------------------------------------------------------------
2879
2880func TestRESTSubReqRetransmissionV4(t *testing.T) {
2881 CaseBegin("TestRESTSubReqRetransmissionV4")
2882
2883 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2884 Counter{cRestSubReqFromXapp, 3},
2885 Counter{cRestSubRespToXapp, 3},
2886 Counter{cSubReqToE2, 2},
2887 Counter{cSubRespFromE2, 2},
2888 Counter{cRestSubNotifToXapp, 4},
2889 Counter{cRestSubDelReqFromXapp, 1},
2890 Counter{cSubDelReqToE2, 2},
2891 Counter{cSubDelRespFromE2, 2},
2892 Counter{cRestSubDelRespToXapp, 1},
2893 })
2894
2895 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2896
2897 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2898
2899 <-time.After(100 * time.Millisecond)
2900
2901 // Send modified requst, this time with e2 subscriptions.
2902 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
2903 params2.SetSubscriptionID(&restSubId)
2904
2905 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
2906 xappConn1.WaitRESTNotificationForAnySubscriptionId(t)
2907 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
2908 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
2909
2910 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2911
2912 xappConn1.ExpectRESTNotification(t, restSubId_resend)
2913 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2914 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
2915 assert.NotEqual(t, e2SubsId2, 0)
2916
2917 <-time.After(100 * time.Millisecond)
2918
2919 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
2920 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
2921 params.SetSubscriptionID(&restSubId)
2922 xappConn1.WaitRESTNotificationForAnySubscriptionId(t)
2923 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
2924 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2925 assert.Equal(t, restSubId_resend, restSubId_resend2)
2926
2927 // Delete both e2 subscriptions
2928 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2929 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
2930 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
2931
2932 waitSubsCleanup(t, e2SubsId, 10)
2933
2934 //Wait that subs is cleaned
2935 mainCtrl.VerifyCounterValues(t)
2936}
2937
2938//-----------------------------------------------------------------------------
2939// stub stub stub
2940// +-------+ +---------+ +---------+ +---------+
2941// | xapp | | submgr | | e2term | | rtmgr |
2942// +-------+ +---------+ +---------+ +---------+
2943// | | | |
2944// | RESTSubReq | | |
2945// |---------------->| | |
2946// | RESTSubResp | | |
2947// |<----------------| | |
2948// | | RouteCreate | |
2949// | |--------------------------->|
2950// | | RouteResponse| |
2951// | |<---------------------------|
2952// | | SubReq | |
2953// | |------------->| |
2954// | | SubResp | |
2955// | |<-------------| |
2956// | RESTNotif1 | | |
2957// |<----------------| | |
2958// | RESTSubReq | | |
2959// | [with RestSUbsId + one additional e2 subDetail]
2960// |---------------->| | |
2961// | RESTNotif1 | | |
2962// | [for initial e2 subDetail] | |
2963// |<----------------| | |
2964// | | RouteCreate | |
2965// | |--------------------------->|
2966// | | RouteResponse| |
2967// | |<---------------------------|
2968// | | SubReq | |
2969// | |------------->| |
2970// | | SubResp | |
2971// | |<-------------| |
2972// | RESTNotif1 | | |
2973// |<----------------| | |
2974// | RESTSubReq | | |
2975// | [without RESTsubsId initial request] |
2976// |---------------->| | |
2977// | RESTNotif1 | | |
2978// |<----------------| | |
2979// | RESTSubDelReq | | |
2980// |---------------->| | |
2981// | RESTSubDelResp| | |
2982// |<----------------| | |
2983// | | SubDelReq | |
2984// | |------------->| |
2985// | | SubDelResp | |
2986// | |<-------------| |
2987// | | SubDelReq | |
2988// | |------------->| |
2989// | | SubDelResp | |
2990// | |<-------------| |
2991// | | | |
2992//
2993//-----------------------------------------------------------------------------
2994
2995func TestRESTSubReqRetransmissionV5(t *testing.T) {
2996 CaseBegin("TestRESTSubReqRetransmissionV5")
2997
2998 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2999 Counter{cRestSubReqFromXapp, 3},
3000 Counter{cRestSubRespToXapp, 3},
3001 Counter{cSubReqToE2, 2},
3002 Counter{cSubRespFromE2, 2},
3003 Counter{cRestSubNotifToXapp, 4},
3004 Counter{cRestSubDelReqFromXapp, 1},
3005 Counter{cSubDelReqToE2, 2},
3006 Counter{cSubDelRespFromE2, 2},
3007 Counter{cRestSubDelRespToXapp, 1},
3008 })
3009
3010 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3011
3012 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3013
3014 <-time.After(100 * time.Millisecond)
3015
3016 // Send modified requst, this time with e2 subscriptions.
3017 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3018 params2.SetSubscriptionID(&restSubId)
3019
3020 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3021 xappConn1.WaitRESTNotificationForAnySubscriptionId(t)
3022 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3023 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3024
3025 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3026
3027 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3028 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3029 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3030 assert.NotEqual(t, e2SubsId2, 0)
3031
3032 <-time.After(100 * time.Millisecond)
3033
3034 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3035 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3036 xappConn1.WaitRESTNotificationForAnySubscriptionId(t)
3037 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3038 // md5sum shall find the original request
3039 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3040 assert.Equal(t, restSubId_resend, restSubId_resend2)
3041
3042 // Delete both e2 subscriptions
3043 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3044 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3045 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3046
3047 waitSubsCleanup(t, e2SubsId, 10)
3048
3049 //Wait that subs is cleaned
3050 mainCtrl.VerifyCounterValues(t)
3051}
3052
3053//-----------------------------------------------------------------------------
3054// stub stub stub
3055// +-------+ +---------+ +---------+ +---------+
3056// | xapp | | submgr | | e2term | | rtmgr |
3057// +-------+ +---------+ +---------+ +---------+
3058// | | | |
3059// | RESTSubReq | | |
3060// |---------------->| | |
3061// | RESTSubResp | | |
3062// |<----------------| | |
3063// | | RouteCreate | |
3064// | |--------------------------->|
3065// | | RouteResponse| |
3066// | |<---------------------------|
3067// | | SubReq | |
3068// | |------------->| |
3069// | | SubResp | |
3070// | |<-------------| |
3071// | RESTNotif1 | | |
3072// |<----------------| | |
3073// | RESTSubReq | | |
3074// | [with RestSUbsId + one additional e2 subDetail]
3075// |---------------->| | |
3076// | RESTNotif1 | | |
3077// | [for initial e2 subDetail] | |
3078// |<----------------| | |
3079// | | RouteCreate | |
3080// | |--------------------------->|
3081// | | RouteResponse| |
3082// | |<---------------------------|
3083// | | SubReq | |
3084// | |------------->| |
3085// | | SubResp | |
3086// | |<-------------| |
3087// | RESTNotif1 | | |
3088// |<----------------| | |
3089// | RESTSubDelReq | | |
3090// |---------------->| | |
3091// | RESTSubDelResp| | |
3092// |<----------------| | |
3093// | | SubDelReq | |
3094// | |------------->| |
3095// | | SubDelResp | |
3096// | |<-------------| |
3097// | | SubDelReq | |
3098// | |------------->| |
3099// | | SubDelResp | |
3100// | |<-------------| |
3101// | RESTSubReq | | |
3102// | [with RESTsubsId initial request] |
3103// |---------------->| | |
3104// | RESTSubResp | | |
3105// |<----------------| | |
3106// | | RouteCreate | |
3107// | |--------------------------->|
3108// | | RouteResponse| |
3109// | |<---------------------------|
3110// | | SubReq | |
3111// | |------------->| |
3112// | | SubResp | |
3113// | |<-------------| |
3114// | RESTNotif1 | | |
3115// |<----------------| | |
3116// | | | |
3117//
3118//-----------------------------------------------------------------------------
3119func TestRESTSubReqRetransmissionV6(t *testing.T) {
3120 CaseBegin("TestRESTSubReqRetransmissionV6")
3121
3122 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3123 Counter{cRestSubReqFromXapp, 3},
3124 Counter{cRestSubRespToXapp, 3},
3125 Counter{cSubReqToE2, 3},
3126 Counter{cSubRespFromE2, 3},
3127 Counter{cRestSubNotifToXapp, 4},
3128 Counter{cRestSubDelReqFromXapp, 2},
3129 Counter{cSubDelReqToE2, 3},
3130 Counter{cSubDelRespFromE2, 3},
3131 Counter{cRestSubDelRespToXapp, 2},
3132 })
3133
3134 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3135
3136 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3137
3138 <-time.After(100 * time.Millisecond)
3139
3140 // Send modified requst, this time with e2 subscriptions.
3141 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3142 params2.SetSubscriptionID(&restSubId)
3143
3144 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3145 xappConn1.WaitRESTNotificationForAnySubscriptionId(t)
3146 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3147 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3148
3149 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3150
3151 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3152 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3153 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3154 assert.NotEqual(t, e2SubsId2, 0)
3155
3156 <-time.After(100 * time.Millisecond)
3157
3158 // Delete both e2 subscriptions
3159 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3160 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3161 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3162
3163 waitSubsCleanup(t, e2SubsId, 10)
3164
3165 // Resend the original request, we shall find it's previous md5sum/restsubs
3166 // but the restsubscription has been already removed. This shall trigger a
3167 // fresh create.
3168 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3169
3170 <-time.After(100 * time.Millisecond)
3171
3172 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3173
3174 waitSubsCleanup(t, e2SubsId, 10)
3175
3176 //Wait that subs is cleaned
3177 mainCtrl.VerifyCounterValues(t)
3178}
3179
archaggeafbf95f2021-04-14 08:54:05 +03003180func TestRESTSubDelReqRetransmission(t *testing.T) {
3181 CaseBegin("TestRESTSubDelReqRetransmission")
3182
3183 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003184 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003185 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003186 Counter{cSubReqToE2, 1},
3187 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003188 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003189 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003190 Counter{cSubDelReqToE2, 1},
3191 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003192 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003193 })
3194
3195 var params *teststube2ap.RESTSubsReqParams = nil
3196
3197 //Subs Create
3198 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3199
3200 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3201
3202 //Subs Delete
3203 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3204 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3205
3206 seqBef := mainCtrl.get_msgcounter(t)
3207 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3208 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3209
3210 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3211
3212 waitSubsCleanup(t, e2SubsId, 10)
3213
3214 mainCtrl.VerifyCounterValues(t)
3215}
3216
3217//-----------------------------------------------------------------------------
3218// TestRESTSubReqDelReq
3219//
3220// stub stub
3221// +-------+ +---------+ +---------+
3222// | xapp | | submgr | | e2term |
3223// +-------+ +---------+ +---------+
3224// | | |
3225// | RESTSubReq | |
3226// |---------------->| |
3227// | | |
3228// | RESTSubResp | |
3229// |<----------------| |
3230// | | SubReq |
3231// | |------------->|
3232// | RESTSubDelReq | |
3233// |---------------->| |
3234// | RESTSubDelResp | |
3235// | unsuccess | |
3236// |<----------------| |
3237// | | SubResp |
3238// | |<-------------|
3239// | RESTNotif1 | |
3240// |<----------------| |
3241// | | |
3242// | [SUBS DELETE] |
3243// | | |
3244//
3245//-----------------------------------------------------------------------------
3246func TestRESTSubReqDelReq(t *testing.T) {
3247 CaseBegin("TestRESTSubReqDelReq")
3248
3249 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003250 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003251 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003252 Counter{cSubReqToE2, 1},
3253 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003254 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003255 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003256 Counter{cSubDelReqToE2, 1},
3257 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003258 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003259 })
3260
3261 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003262
3263 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003264 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003265 restSubId := xappConn1.SendRESTSubsReq(t, params)
3266
3267 // Del. This will fail as processing of the subscription
3268 // is still ongoing in submgr. Deletion is not allowed before
3269 // subscription creation has been completed.
3270 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3271 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3272 xappConn1.ExpectRESTNotification(t, restSubId)
3273 e2termConn1.SendSubsResp(t, crereq, cremsg)
3274 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3275
3276 // Retry del
3277 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3278
3279 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3280 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3281
3282 // Wait that subs is cleaned
3283 waitSubsCleanup(t, e2SubsId, 10)
3284 mainCtrl.VerifyCounterValues(t)
3285
3286}
3287
3288func TestRESTSubDelReqCollision(t *testing.T) {
3289 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3290}
3291
3292func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3293 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3294
3295 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003296 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003297 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003298 Counter{cSubReqToE2, 2},
3299 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003300 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003301 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003302 Counter{cSubDelReqToE2, 2},
3303 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003304 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003305 })
3306
3307 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003308 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003309 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3310 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
3311
3312 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003313 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003314 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3315 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
3316
3317 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3318 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3319
3320 //XappConn1 receives both of the responses
3321 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3322
3323 //Resp1
3324 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3325 //Resp2
3326 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3327
3328 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3329 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3330 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3331 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3332
3333 //Del1
3334 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3335 //Del2
3336 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3337
3338 //Wait that subs is cleaned
3339 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3340 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3341
3342 mainCtrl.VerifyCounterValues(t)
3343
3344}
3345
3346func TestRESTSameSubsDiffRan(t *testing.T) {
3347 CaseBegin("TestRESTSameSubsDiffRan")
3348
3349 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003350 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003351 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003352 Counter{cSubReqToE2, 2},
3353 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003354 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003355 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003356 Counter{cSubDelReqToE2, 2},
3357 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003358 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003359 })
3360
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003361 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003362 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3363 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
3364
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003365 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003366 params.SetMeid("RAN_NAME_2")
3367 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
3368 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
3369
3370 //Del1
3371 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3372 //Del2
3373 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3374
3375 //Wait that subs is cleaned
3376 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3377 waitSubsCleanup(t, e2SubsId2, 10)
3378
3379 mainCtrl.VerifyCounterValues(t)
3380
3381}
3382
3383func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3384 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3385
3386 // Init counter check
3387 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003388 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003389 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003390 Counter{cSubReqToE2, 1},
3391 Counter{cSubReReqToE2, 1},
3392 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003393 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003394 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003395 Counter{cSubDelReqToE2, 1},
3396 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003397 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003398 })
3399
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003400 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003401 restSubId := xappConn1.SendRESTSubsReq(t, params)
3402
3403 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3404
3405 // Catch the first message and ignore it
3406 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3407 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
3408
3409 // The second request is being handled normally
3410 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3411 xappConn1.ExpectRESTNotification(t, restSubId)
3412 e2termConn1.SendSubsResp(t, crereq, cremsg)
3413 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3414
3415 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3416
3417 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3418
3419 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3420 //Wait that subs is cleaned
3421 waitSubsCleanup(t, e2SubsId, 10)
3422
3423 mainCtrl.VerifyCounterValues(t)
3424
3425}
3426
3427//-----------------------------------------------------------------------------
3428// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3429//
3430// stub stub
3431// +-------+ +---------+ +---------+
3432// | xapp | | submgr | | e2term |
3433// +-------+ +---------+ +---------+
3434// | | |
3435// | RESTSubReq | |
3436// |---------------->| |
3437// | | |
3438// | RESTSubResp | |
3439// |<----------------| |
3440// | | SubReq |
3441// | |------------->|
3442// | | |
3443// | | |
3444// | | SubReq |
3445// | |------------->|
3446// | | |
3447// | | SubDelReq |
3448// | |------------->|
3449// | | |
3450// | | |
3451// | | SubDelReq |
3452// | |------------->|
3453// | | |
3454// | | |
3455// | | SubDelResp |
3456// | |<-------------|
3457// | RESTNotif | |
3458// | unsuccess | |
3459// |<----------------| |
3460// | | |
3461// | [SUBS DELETE] |
3462// | | |
3463//
3464//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003465
archaggeafbf95f2021-04-14 08:54:05 +03003466func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3467 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3468
3469 // Init counter check
3470 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003471 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003472 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003473 Counter{cSubReqToE2, 1},
3474 Counter{cSubReReqToE2, 1},
3475 Counter{cSubReqTimerExpiry, 2},
3476 Counter{cSubDelReqToE2, 1},
3477 Counter{cSubDelRespFromE2, 1},
3478 })
3479
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003480 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003481 restSubId := xappConn1.SendRESTSubsReq(t, params)
3482 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3483
3484 e2termConn1.RecvSubsReq(t)
3485 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3486
3487 e2termConn1.RecvSubsReq(t)
3488 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3489
3490 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003491 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003492 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003493 xappConn1.WaitRESTNotification(t, restSubId)
3494
3495 // Wait that subs is cleaned
3496 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
3497
3498 mainCtrl.VerifyCounterValues(t)
3499}
3500
3501func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3502 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3503
3504 // Init counter check
3505 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003506 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003507 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003508 Counter{cSubReqToE2, 1},
3509 Counter{cSubReReqToE2, 1},
3510 Counter{cSubReqTimerExpiry, 2},
3511 Counter{cSubDelReqToE2, 1},
3512 Counter{cSubDelReqTimerExpiry, 2},
3513 })
3514
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003515 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003516 restSubId := xappConn1.SendRESTSubsReq(t, params)
3517 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3518
3519 e2termConn1.RecvSubsReq(t)
3520 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3521
3522 e2termConn1.RecvSubsReq(t)
3523 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3524
3525 e2termConn1.RecvSubsDelReq(t)
3526 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3527
Markku Virtanen55d2a282021-06-04 14:46:56 +03003528 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003529 e2termConn1.RecvSubsDelReq(t)
3530 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3531
3532 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3533
3534 waitSubsCleanup(t, e2SubsId, 10)
3535
3536 mainCtrl.VerifyCounterValues(t)
3537
3538}
3539
3540//-----------------------------------------------------------------------------
3541// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3542//
3543// stub stub
3544// +-------+ +---------+ +---------+
3545// | xapp | | submgr | | e2term |
3546// +-------+ +---------+ +---------+
3547// | | |
3548// | RESTSubReq | |
3549// |---------------->| |
3550// | | |
3551// | RESTSubResp | |
3552// |<----------------| |
3553// | | SubReq |
3554// | |------------->|
3555// | | |
3556// | | |
3557// | | SubReq |
3558// | |------------->|
3559// | | |
3560// | | SubDelReq |
3561// | |------------->|
3562// | | |
3563// | | |
3564// | | SubDelReq |
3565// | |------------->|
3566// | | |
3567// | | |
3568// | | SubDelResp |
3569// | |<-------------|
3570// | RESTNotif | |
3571// | unsuccess | |
3572// |<----------------| |
3573// | | |
3574// | [SUBS DELETE] |
3575// | | |
3576//
3577//-----------------------------------------------------------------------------
3578func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3579 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3580
3581 // Init counter check
3582 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003583 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003584 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003585 Counter{cSubReqToE2, 1},
3586 Counter{cSubReReqToE2, 1},
3587 Counter{cSubReqTimerExpiry, 2},
3588 Counter{cSubDelReqToE2, 1},
3589 Counter{cSubDelReReqToE2, 1},
3590 Counter{cSubDelReqTimerExpiry, 2},
3591 })
3592
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003593 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003594 restSubId := xappConn1.SendRESTSubsReq(t, params)
3595 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3596
3597 e2termConn1.RecvSubsReq(t)
3598 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3599
3600 e2termConn1.RecvSubsReq(t)
3601 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3602
3603 e2termConn1.RecvSubsDelReq(t)
3604 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3605
Markku Virtanen55d2a282021-06-04 14:46:56 +03003606 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003607 e2termConn1.RecvSubsDelReq(t)
3608 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3609
3610 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3611
3612 waitSubsCleanup(t, e2SubsId, 10)
3613
3614 mainCtrl.VerifyCounterValues(t)
3615}
3616
3617//-----------------------------------------------------------------------------
3618// TestRESTSubReqSubFailRespInSubmgr
3619//
3620// stub stub
3621// +-------+ +---------+ +---------+
3622// | xapp | | submgr | | e2term |
3623// +-------+ +---------+ +---------+
3624// | | |
3625// | RESTSubReq | |
3626// |---------------->| |
3627// | | |
3628// | RESTSubResp | |
3629// |<----------------| |
3630// | | SubReq |
3631// | |------------->|
3632// | | |
3633// | | SubFail |
3634// | |<-------------|
3635// | | |
3636// | | SubDelReq |
3637// | |------------->|
3638// | | |
3639// | | SubDelResp |
3640// | |<-------------|
3641// | | |
3642// | RESTNotif | |
3643// | unsuccess | |
3644// |<----------------| |
3645// | | |
3646// | [SUBS DELETE] |
3647// | | |
3648//
3649//-----------------------------------------------------------------------------
3650func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3651 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3652
3653 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003654 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003655 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003656 Counter{cSubReqToE2, 1},
3657 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003658 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003659 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003660 })
3661
3662 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003663
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003664 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003665 restSubId := xappConn1.SendRESTSubsReq(t, params)
3666
3667 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3668 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3669 fparams1.Set(crereq1)
3670 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3671
3672 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003673 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003674 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3675 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3676 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
3677
3678 // REST subscription sill there to be deleted
3679 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3680
3681 // Wait that subs is cleaned
3682 waitSubsCleanup(t, e2SubsId, 10)
3683
3684 mainCtrl.VerifyCounterValues(t)
3685
3686}
3687
3688//-----------------------------------------------------------------------------
3689// TestRESTSubDelReqRetryInSubmgr
3690//
3691// stub stub
3692// +-------+ +---------+ +---------+
3693// | xapp | | submgr | | e2term |
3694// +-------+ +---------+ +---------+
3695// | | |
3696// | [SUBS CREATE] |
3697// | | |
3698// | | |
3699// | RESTSubDelReq | |
3700// |---------------->| |
3701// | | |
3702// | RESTSubDelResp | |
3703// |<----------------| |
3704// | | SubDelReq |
3705// | |------------->|
3706// | | |
3707// | | SubDelReq |
3708// | |------------->|
3709// | | |
3710// | | SubDelResp |
3711// | |<-------------|
3712// | | |
3713//
3714//-----------------------------------------------------------------------------
3715func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3716 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3717
3718 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003719 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003720 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003721 Counter{cSubReqToE2, 1},
3722 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003723 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003724 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003725 Counter{cSubDelReqToE2, 1},
3726 Counter{cSubDelReReqToE2, 1},
3727 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003728 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003729 })
3730 // Req
3731 var params *teststube2ap.RESTSubsReqParams = nil
3732 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3733
3734 // Del
3735 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3736
3737 // E2t: Receive 1st SubsDelReq
3738 e2termConn1.RecvSubsDelReq(t)
3739
3740 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3741 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3742 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3743
3744 //Wait that subs is cleaned
3745 waitSubsCleanup(t, e2SubsId, 10)
3746
3747 mainCtrl.VerifyCounterValues(t)
3748}
3749
3750//-----------------------------------------------------------------------------
3751// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3752//
3753// stub stub
3754// +-------+ +---------+ +---------+
3755// | xapp | | submgr | | e2term |
3756// +-------+ +---------+ +---------+
3757// | | |
3758// | [SUBS CREATE] |
3759// | | |
3760// | | |
3761// | RESTSubDelReq | |
3762// |---------------->| |
3763// | | |
3764// | RESTSubDelResp | |
3765// |<----------------| |
3766// | | SubDelReq |
3767// | |------------->|
3768// | | |
3769// | | SubDelReq |
3770// | |------------->|
3771// | | |
3772// | | |
3773//
3774//-----------------------------------------------------------------------------
3775func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3776 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3777
3778 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003779 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003780 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003781 Counter{cSubReqToE2, 1},
3782 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003783 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003784 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003785 Counter{cSubDelReqToE2, 1},
3786 Counter{cSubDelReReqToE2, 1},
3787 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003788 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003789 })
3790
3791 // Req
3792 var params *teststube2ap.RESTSubsReqParams = nil
3793 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3794
3795 // Del
3796 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3797
3798 // E2t: Receive 1st SubsDelReq
3799 e2termConn1.RecvSubsDelReq(t)
3800
3801 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3802 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3803 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3804
3805 //Wait that subs is cleaned
3806 waitSubsCleanup(t, e2SubsId, 10)
3807
3808 mainCtrl.VerifyCounterValues(t)
3809}
3810
3811//-----------------------------------------------------------------------------
3812// TestRESTSubDelReqSubDelFailRespInSubmgr
3813//
3814// stub stub
3815// +-------+ +---------+ +---------+
3816// | xapp | | submgr | | e2term |
3817// +-------+ +---------+ +---------+
3818// | | |
3819// | [SUBS CREATE] |
3820// | | |
3821// | | |
3822// | RESTSubDelReq | |
3823// |---------------->| |
3824// | | |
3825// | RESTSubDelResp | |
3826// |<----------------| |
3827// | | SubDelReq |
3828// | |------------->|
3829// | | |
3830// | | SubDelFail |
3831// | |<-------------|
3832// | | |
3833//
3834//-----------------------------------------------------------------------------
3835func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3836 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3837
3838 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003839 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003840 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003841 Counter{cSubReqToE2, 1},
3842 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003843 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003844 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003845 Counter{cSubDelReqToE2, 1},
3846 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003847 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003848 })
3849
3850 // Req
3851 var params *teststube2ap.RESTSubsReqParams = nil
3852 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3853
3854 // Del
3855 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3856
3857 // E2t: Send receive SubsDelReq and send SubsDelFail
3858 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3859 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3860
3861 //Wait that subs is cleaned
3862 waitSubsCleanup(t, e2SubsId, 10)
3863
3864 mainCtrl.VerifyCounterValues(t)
3865}
3866
3867//-----------------------------------------------------------------------------
3868// TestRESTSubReqAndSubDelOkSameAction
3869//
3870// stub stub
3871// +-------+ +-------+ +---------+ +---------+
3872// | xapp2 | | xapp1 | | submgr | | e2term |
3873// +-------+ +-------+ +---------+ +---------+
3874// | | | |
3875// | | RESTSubReq1 | |
3876// | |---------------->| |
3877// | | | |
3878// | | RESTSubResp1 | |
3879// | |<----------------| |
3880// | | | |
3881// | | | SubReq1 |
3882// | | |------------->|
3883// | | | SubResp1 |
3884// | | |<-------------|
3885// | | RESTNotif1 | |
3886// | |<----------------| |
3887// | | | |
3888// | RESTSubReq2 | |
3889// |------------------------------>| |
3890// | | | |
3891// | RESTSubResp2 | |
3892// |<------------------------------| |
3893// | | | |
3894// | | RESTNotif2 | |
3895// |<------------------------------| |
3896// | | | |
3897// | | RESTSubDelReq1 | |
3898// | |---------------->| |
3899// | | | |
3900// | | RESTSubDelResp1 | |
3901// | |<----------------| |
3902// | | | |
3903// | RESTSubDelReq2 | |
3904// |------------------------------>| |
3905// | | | |
3906// | RESTSubDelResp2 | |
3907// |<------------------------------| |
3908// | | | |
3909// | | | SubDelReq2 |
3910// | | |------------->|
3911// | | | |
3912// | | | SubDelResp2 |
3913// | | |<-------------|
3914// | | | |
3915//
3916//-----------------------------------------------------------------------------
3917func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3918 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3919
3920 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003921 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003922 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003923 Counter{cSubReqToE2, 1},
3924 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003925 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003926 Counter{cMergedSubscriptions, 1},
3927 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003928 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003929 Counter{cSubDelReqToE2, 1},
3930 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003931 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003932 })
3933
3934 // Req1
3935 var params *teststube2ap.RESTSubsReqParams = nil
3936
3937 //Subs Create
3938 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3939 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3940
3941 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003942 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003943 params.SetMeid("RAN_NAME_1")
3944
3945 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
3946 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003947 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003948 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003949 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003950 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
3951 e2SubsId2 := <-xappConn2.RESTNotification
3952 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3953
3954 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3955
3956 // Del1
3957 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3958
3959 // Del2
3960 deleteXapp2Subscription(t, &restSubId2)
3961
3962 //Wait that subs is cleaned
3963 waitSubsCleanup(t, e2SubsId2, 10)
3964
3965 mainCtrl.VerifyCounterValues(t)
3966}
3967
3968//-----------------------------------------------------------------------------
3969// TestSubReqAndSubDelOkSameActionParallel
3970//
3971// stub stub stub
3972// +-------+ +-------+ +---------+ +---------+
3973// | xapp2 | | xapp1 | | submgr | | e2term |
3974// +-------+ +-------+ +---------+ +---------+
3975// | | | |
3976// | | | |
3977// | | | |
3978// | | SubReq1 | |
3979// | |------------->| |
3980// | | | |
3981// | | | SubReq1 |
3982// | | |------------->|
3983// | SubReq2 | |
3984// |--------------------------->| |
3985// | | | SubResp1 |
3986// | | |<-------------|
3987// | | SubResp1 | |
3988// | |<-------------| |
3989// | | | SubReq2 |
3990// | | |------------->|
3991// | | | |
3992// | | | SubResp2 |
3993// | | |<-------------|
3994// | SubResp2 | |
3995// |<---------------------------| |
3996// | | | |
3997// | | SubDelReq 1 | |
3998// | |------------->| |
3999// | | | |
4000// | | SubDelResp 1 | |
4001// | |<-------------| |
4002// | | | |
4003// | SubDelReq 2 | |
4004// |--------------------------->| |
4005// | | | |
4006// | | | SubDelReq 2 |
4007// | | |------------->|
4008// | | | |
4009// | | | SubDelReq 2 |
4010// | | |------------->|
4011// | | | |
4012// | SubDelResp 2 | |
4013// |<---------------------------| |
4014//
4015func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4016 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4017
4018 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004019 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004020 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004021 Counter{cSubReqToE2, 2},
4022 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004023 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004024 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004025 Counter{cSubDelReqToE2, 2},
4026 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004027 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004028 })
4029
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004030 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004031 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4032 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4033
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004034 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004035 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4036
4037 xappConn1.ExpectRESTNotification(t, restSubId1)
4038 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4039 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4040
4041 xappConn2.ExpectRESTNotification(t, restSubId2)
4042 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4043 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4044 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4045
4046 // Del1
4047 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4048 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4049 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4050 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4051
4052 // Del2
4053 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4054 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4055 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4056
4057 waitSubsCleanup(t, e2SubsId2, 10)
4058
4059 mainCtrl.VerifyCounterValues(t)
4060}
4061
4062//-----------------------------------------------------------------------------
4063// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4064//
4065// stub stub stub
4066// +-------+ +-------+ +---------+ +---------+
4067// | xapp2 | | xapp1 | | submgr | | e2term |
4068// +-------+ +-------+ +---------+ +---------+
4069// | | | |
4070// | | | |
4071// | | | |
4072// | | RESTSubReq1 | |
4073// | |---------------->| |
4074// | | | |
4075// | | RESTSubResp1 | |
4076// | |<----------------| |
4077// | | | SubReq1 |
4078// | | |------------->|
4079// | RESTSubReq2 | |
4080// |------------------------------>| |
4081// | | | |
4082// | RESTSubDelResp2 | |
4083// |<------------------------------| |
4084// | | | SubReq1 |
4085// | | |------------->|
4086// | | | |
4087// | | | |
4088// | | | SubDelReq |
4089// | | |------------->|
4090// | | | |
4091// | | | SubDelResp |
4092// | | |<-------------|
4093// | | RESTNotif1 | |
4094// | | unsuccess | |
4095// | |<----------------| |
4096// | RESTNotif2 | |
4097// | | unsuccess | |
4098// |<------------------------------| |
4099// | | | |
4100// | | RESTSubDelReq1 | |
4101// | |---------------->| |
4102// | | | |
4103// | | RESTSubDelResp1 | |
4104// | |<----------------| |
4105// | | | |
4106// | RESTSubDelReq2 | |
4107// |------------------------------>| |
4108// | | | |
4109// | RESTSubDelResp2 | |
4110// |<------------------------------| |
4111//
4112//-----------------------------------------------------------------------------
4113func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4114 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4115
4116 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004117 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004118 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004119 Counter{cSubReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004120 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004121 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004122 Counter{cSubDelReqToE2, 1},
4123 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004124 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004125 })
4126
4127 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004128
4129 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004130 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004131 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4132 crereq1, _ := e2termConn1.RecvSubsReq(t)
4133
4134 // Req2
4135 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004136 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004137 params2.SetMeid("RAN_NAME_1")
4138 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4139 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4140
4141 //Req1 (retransmitted)
4142 e2termConn1.RecvSubsReq(t)
4143
4144 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004145
4146 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004147 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4148
Markku Virtanenda34eec2021-05-20 08:22:04 +00004149 e2SubsIdA := <-xappConn1.ListedRESTNotifications
4150 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
4151 e2SubsIdB := <-xappConn1.ListedRESTNotifications
4152 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004153
4154 // Del1
4155 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4156
4157 // Del2
4158 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4159
Markku Virtanenda34eec2021-05-20 08:22:04 +00004160 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4161
archaggeafbf95f2021-04-14 08:54:05 +03004162 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004163 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004164
4165 mainCtrl.VerifyCounterValues(t)
4166}
4167
4168//-----------------------------------------------------------------------------
4169// TestRESTSubReqAndSubDelNokSameActionParallel
4170//
4171// stub stub stub
4172// +-------+ +-------+ +---------+ +---------+
4173// | xapp2 | | xapp1 | | submgr | | e2term |
4174// +-------+ +-------+ +---------+ +---------+
4175// | | | |
4176// | | | |
4177// | | | |
4178// | | RESTSubReq1 | |
4179// | |---------------->| |
4180// | | | |
4181// | | RESTSubResp1 | |
4182// | |<----------------| |
4183// | | | SubReq1 |
4184// | | |------------->|
4185// | RESTSubReq2 | |
4186// |------------------------------>| |
4187// | | | |
4188// | RESTSubDelResp2 | |
4189// |<------------------------------| |
4190// | | | SubFail1 |
4191// | | |<-------------|
4192// | | | |
4193// | | RESTNotif1 | |
4194// | | unsuccess | |
4195// | |<----------------| |
4196// | RESTNotif2 | |
4197// | | unsuccess | |
4198// |<------------------------------| |
4199// | | | SubDelReq |
4200// | | |------------->|
4201// | | | SubDelResp |
4202// | | |<-------------|
4203// | | | |
4204// | | RESTSubDelReq1 | |
4205// | |---------------->| |
4206// | | | |
4207// | | RESTSubDelResp1 | |
4208// | |<----------------| |
4209// | | | |
4210// | RESTSubDelReq2 | |
4211// |------------------------------>| |
4212// | | | |
4213// | RESTSubDelResp2 | |
4214// |<------------------------------| |
4215//
4216//-----------------------------------------------------------------------------
4217func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4218 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4219
4220 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004221 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004222 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004223 Counter{cSubReqToE2, 1},
4224 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004225 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004226 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004227 Counter{cSubDelReqToE2, 1},
4228 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004229 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004230 })
4231
4232 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004233
4234 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004235 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004236 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4237 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4238
4239 // Req2
4240 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004241 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004242 params2.SetMeid("RAN_NAME_1")
4243 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4244 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4245
4246 // E2t: send SubsFail (first)
4247 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4248 fparams1.Set(crereq1)
4249 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4250
4251 // E2t: internal delete
4252 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4253 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4254 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4255
4256 e2SubsIdA := <-xappConn1.ListedRESTNotifications
4257 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
4258 e2SubsIdB := <-xappConn1.ListedRESTNotifications
4259 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
4260
4261 // Del1
4262 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4263
4264 // Del2
4265 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4266
4267 //Wait that subs is cleaned
4268 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4269 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4270
4271 mainCtrl.VerifyCounterValues(t)
4272}
4273
4274func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4275 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4276
4277 // Init counter check
4278 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004279 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004280 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004281 Counter{cSubReqToE2, 1},
4282 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004283 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004284 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004285 Counter{cSubDelReqToE2, 1},
4286 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004287 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004288 })
4289
4290 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004291
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004292 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004293 restSubId := xappConn1.SendRESTSubsReq(t, params)
4294 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
4295
4296 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4297 xappConn1.ExpectRESTNotification(t, restSubId)
4298 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4299 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4300 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
4301
4302 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4303 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4304 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4305
4306 // Wait that subs is cleaned
4307 waitSubsCleanup(t, e2SubsId, 10)
4308 mainCtrl.VerifyCounterValues(t)
4309}
4310
4311//-----------------------------------------------------------------------------
4312// TestRESTSubReqPolicyChangeAndSubDelOk
4313//
4314// stub stub
4315// +-------+ +---------+ +---------+
4316// | xapp | | submgr | | e2term |
4317// +-------+ +---------+ +---------+
4318// | | |
4319// | RESTSubReq | |
4320// |---------------->| |
4321// | | |
4322// | RESTSubResp | |
4323// |<----------------| |
4324// | | SubReq |
4325// | |------------->|
4326// | | |
4327// | | SubResp |
4328// | |<-------------|
4329// | | |
4330// | RESTNotif | |
4331// |<----------------| |
4332// | | |
4333// | RESTSubReq | |
4334// |---------------->| |
4335// | | |
4336// | RESTSubResp | |
4337// |<----------------| |
4338// | | SubReq |
4339// | |------------->|
4340// | | |
4341// | | SubResp |
4342// | |<-------------|
4343// | | |
4344// | RESTNotif | |
4345// |<----------------| |
4346// | | |
4347// | RESTSubDelReq | |
4348// |---------------->| |
4349// | | |
4350// | | SubDelReq |
4351// | |------------->|
4352// | | |
4353// | | SubDelResp |
4354// | |<-------------|
4355// | | |
4356// | RESTSubDelResp | |
4357// |<----------------| |
4358//
4359//-----------------------------------------------------------------------------
4360func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4361 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4362
4363 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004364 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004365 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004366 Counter{cSubReqToE2, 2},
4367 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004368 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004369 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004370 Counter{cSubDelReqToE2, 1},
4371 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004372 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004373 })
4374
4375 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004376
4377 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004378 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004379 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4380
4381 // Policy change
archaggeafbf95f2021-04-14 08:54:05 +03004382 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004383
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004384 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004385 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004386 params.SetTimeToWait("w200ms")
4387 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4388
4389 // Del
4390 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4391
4392 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4393 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4394
4395 // Wait that subs is cleaned
4396 waitSubsCleanup(t, e2SubsId, 10)
4397 mainCtrl.VerifyCounterValues(t)
4398}
4399
4400//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004401// TestRESTSubReqPolicyChangeNOk
4402//
4403// stub stub
4404// +-------+ +---------+ +---------+
4405// | xapp | | submgr | | e2term |
4406// +-------+ +---------+ +---------+
4407// | | |
4408// | RESTSubReq | |
4409// |---------------->| |
4410// | | |
4411// | RESTSubResp | |
4412// |<----------------| |
4413// | | SubReq |
4414// | |------------->|
4415// | | |
4416// | | SubResp |
4417// | |<-------------|
4418// | | |
4419// | RESTNotif | |
4420// |<----------------| |
4421// | | |
4422// | RESTSubReq | |
4423// |---------------->| |
4424// | | |
4425// | RESTSubUpdateFail |
4426// | | |
4427// | RESTSubDelReq | |
4428// |---------------->| |
4429// | | |
4430// | | SubDelReq |
4431// | |------------->|
4432// | | |
4433// | | SubDelResp |
4434// | |<-------------|
4435// | | |
4436// | RESTSubDelResp | |
4437// |<----------------| |
4438//
4439//-----------------------------------------------------------------------------
4440func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4441 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4442
4443 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4444 Counter{cRestSubReqFromXapp, 2},
4445 Counter{cRestSubRespToXapp, 1},
4446 Counter{cSubReqToE2, 1},
4447 Counter{cSubRespFromE2, 1},
4448 Counter{cRestSubNotifToXapp, 1},
4449 Counter{cRestSubFailToXapp, 1},
4450 Counter{cRestSubDelReqFromXapp, 1},
4451 Counter{cSubDelReqToE2, 1},
4452 Counter{cSubDelRespFromE2, 1},
4453 Counter{cRestSubDelRespToXapp, 1},
4454 })
4455
4456 const subReqCount int = 1
4457
4458 // Req
4459 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4460 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4461
4462 // Policy change
4463
4464 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4465
4466 restSubIdUpd := strings.ToUpper(restSubId)
4467 params.SetSubscriptionID(&restSubIdUpd)
4468 params.SetTimeToWait("w200ms")
4469
4470 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4471 assert.Equal(t, restSubId2, "")
4472
4473 // Del
4474 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4475
4476 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4477 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4478
4479 // Wait that subs is cleaned
4480 waitSubsCleanup(t, e2SubsId, 10)
4481 mainCtrl.VerifyCounterValues(t)
4482}
4483
4484//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004485// TestRESTSubReqAndSubDelOkTwoE2termParallel
4486//
4487// stub stub stub
4488// +-------+ +---------+ +---------+ +---------+
4489// | xapp | | submgr | | e2term1 | | e2term2 |
4490// +-------+ +---------+ +---------+ +---------+
4491// | | | |
4492// | | | |
4493// | | | |
4494// | RESTSubReq1 | | |
4495// |---------------->| | |
4496// | | | |
4497// | RESTSubResp1 | | |
4498// |<----------------| | |
4499// | | SubReq1 | |
4500// | |------------->| |
4501// | | | |
4502// | RESTSubReq2 | | |
4503// |---------------->| | |
4504// | | | |
4505// | RESTSubResp2 | | |
4506// |<----------------| | |
4507// | | SubReq2 | |
4508// | |---------------------------->|
4509// | | | |
4510// | | SubResp1 | |
4511// | |<-------------| |
4512// | RESTNotif1 | | |
4513// |<----------------| | |
4514// | | SubResp2 | |
4515// | |<----------------------------|
4516// | RESTNotif2 | | |
4517// |<----------------| | |
4518// | | | |
4519// | [SUBS 1 DELETE] | |
4520// | | | |
4521// | [SUBS 2 DELETE] | |
4522// | | | |
4523//
4524//-----------------------------------------------------------------------------
4525func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4526 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4527
4528 // Init counter check
4529 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004530 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004531 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004532 Counter{cSubReqToE2, 2},
4533 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004534 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004535 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004536 Counter{cSubDelReqToE2, 2},
4537 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004538 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004539 })
4540
4541 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004542
4543 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004544 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004545 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4546 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4547
4548 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004549 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004550 params.SetMeid("RAN_NAME_11")
4551 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4552 // would not work as notification would not be received
4553 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4554 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4555
4556 // Resp1
4557 xappConn1.ExpectRESTNotification(t, restSubId1)
4558 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4559 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4560 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
4561
4562 // Resp2
4563 xappConn2.ExpectRESTNotification(t, restSubId2)
4564 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4565 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4566 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
4567
4568 // Delete1
4569 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4570 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4571 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4572
4573 // Wait that subs is cleaned
4574 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4575
4576 // Delete2
4577 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4578 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4579 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4580
4581 // Wait that subs is cleaned
4582 waitSubsCleanup(t, e2SubsId2, 10)
4583
4584 mainCtrl.VerifyCounterValues(t)
4585}
4586
4587//-----------------------------------------------------------------------------
4588// TestRESTSubReqAsn1EncodeFail
4589//
4590// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4591// stub stub
4592// +-------+ +---------+ +---------+
4593// | xapp | | submgr | | e2term |
4594// +-------+ +---------+ +---------+
4595// | | |
4596// | RESTSubReq | |
4597// |---------------->| |
4598// | | |
4599// | RESTSubResp | |
4600// |<----------------| |
4601// | RESTSubDelReq | |
4602// |---------------->| |
4603// | RESTSubDelResp | |
4604// | unsuccess | |
4605// |<----------------| |
4606// | | |
4607//
4608//-----------------------------------------------------------------------------
4609func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4610 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4611
4612 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
4613
4614}
4615
4616//-----------------------------------------------------------------------------
4617// TestRESTSubReqInsertAndSubDelOk
4618//
4619// stub stub
4620// +-------+ +---------+ +---------+
4621// | xapp | | submgr | | e2term |
4622// +-------+ +---------+ +---------+
4623// | | |
4624// | RestSubReq | |
4625// |---------------->| |
4626// | | |
4627// | RESTSubResp | |
4628// |<----------------| |
4629// | | |
4630// | | SubReq |
4631// | |------------->|
4632// | | |
4633// | | SubResp |
4634// | |<-------------|
4635// | RESTNotif | |
4636// |<----------------| |
4637// | ... | ... |
4638// | | |
4639// | RESTSubDelReq | |
4640// |---------------->| |
4641// | | |
4642// | | SubDelReq |
4643// | |------------->|
4644// | | |
4645// | | SubDelResp |
4646// | |<-------------|
4647// | | |
4648// | RESTSubDelResp| |
4649// |<----------------| |
4650//
4651//-----------------------------------------------------------------------------
4652func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4653 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4654
4655 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004656 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004657 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004658 Counter{cSubReqToE2, 1},
4659 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004660 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004661 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004662 Counter{cSubDelReqToE2, 1},
4663 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004664 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004665 })
4666
4667 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004668
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004669 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004670 params.SetSubActionTypes("insert")
4671
4672 // Req
4673 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4674
4675 // Del
4676 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4677
4678 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4679 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4680
4681 // Wait that subs is cleaned
4682 waitSubsCleanup(t, e2SubsId, 10)
4683 mainCtrl.VerifyCounterValues(t)
4684}
4685
4686//-----------------------------------------------------------------------------
4687// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4688//
4689// stub stub
4690// +-------+ +---------+ +---------+
4691// | xapp | | submgr | | e2term |
4692// +-------+ +---------+ +---------+
4693// | | |
4694// | RESTSubReq | |
4695// |------------->| |
4696// | | |
4697// | | SubReq |
4698// | |------------->|
4699// | | |
4700// | | SubResp |
4701// | <----|
4702// | |
4703// | Submgr restart |
4704// | |
4705// | | |
4706// | | SubDelReq |
4707// | |------------->|
4708// | | |
4709// | | SubDelResp |
4710// | |<-------------|
4711// | | |
4712//
4713//-----------------------------------------------------------------------------
4714func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4715 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4716
4717 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004718 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004719 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004720 Counter{cSubReqToE2, 1},
4721 Counter{cSubDelReqFromXapp, 1},
4722 Counter{cSubDelReqToE2, 1},
4723 Counter{cSubDelRespFromE2, 1},
4724 })
4725
4726 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004727
4728 // Remove possible existing subscription
4729 mainCtrl.removeExistingSubscriptions(t)
4730
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004731 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004732
4733 //Req
4734 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
4735 restSubId := xappConn1.SendRESTSubsReq(t, params)
4736 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4737
4738 e2termConn1.RecvSubsReq(t)
4739
4740 mainCtrl.SetResetTestFlag(t, false)
4741
4742 mainCtrl.SimulateRestart(t)
4743 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4744
4745 //Del
4746 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4747 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4748
4749 xappConn1.TestMsgChanEmpty(t)
4750 xappConn2.TestMsgChanEmpty(t)
4751 e2termConn1.TestMsgChanEmpty(t)
4752 mainCtrl.wait_registry_empty(t, 10)
4753
4754 mainCtrl.VerifyCounterValues(t)
4755}
4756
4757//-----------------------------------------------------------------------------
4758// TestRESTSubReqAndSubDelOkWithRestartInMiddle
4759//
4760// stub stub
4761// +-------+ +---------+ +---------+
4762// | xapp | | submgr | | e2term |
4763// +-------+ +---------+ +---------+
4764// | | |
4765// | RESTSubReq | |
4766// |---------------->| |
4767// | | |
4768// | RESTSubResp | |
4769// |<----------------| |
4770// | | SubReq |
4771// | |------------->|
4772// | | |
4773// | | SubResp |
4774// | |<-------------|
4775// | | |
4776// | RESTNotif | |
4777// |<----------------| |
4778// | | |
4779// | |
4780// | Submgr restart |
4781// | | |
4782// | RESTSubDelReq | |
4783// |---------------->| |
4784// | | |
4785// | | SubDelReq |
4786// | |------------->|
4787// | | |
4788// | | SubDelResp |
4789// | |<-------------|
4790// | | |
4791// | RESTSubDelResp | |
4792// |<----------------| |
4793//
4794//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004795
archaggeafbf95f2021-04-14 08:54:05 +03004796func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4797 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4798
4799 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004800 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004801 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004802 Counter{cSubReqToE2, 1},
4803 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004804 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004805 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004806 Counter{cSubDelReqToE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004807 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004808 })
4809
4810 // Remove possible existing subscription
4811 mainCtrl.removeExistingSubscriptions(t)
4812
4813 var params *teststube2ap.RESTSubsReqParams = nil
4814
4815 // Create subscription
4816 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4817 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4818
4819 // Check subscription
4820 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4821
4822 // When SDL support for the REST Interface is added
4823 // the submgr restart statement below should be removed
4824 // from the comment.
4825
4826 // mainCtrl.SimulateRestart(t)
4827 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4828
4829 // Check subscription
4830 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4831
4832 // Delete subscription
4833 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4834
4835 //Wait that subs is cleaned
4836 waitSubsCleanup(t, e2SubsId, 10)
4837
4838 mainCtrl.VerifyCounterValues(t)
4839}
4840
4841//-----------------------------------------------------------------------------
4842// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4843//
4844// stub stub
4845// +-------+ +-------+ +---------+ +---------+
4846// | xapp2 | | xapp1 | | submgr | | e2term |
4847// +-------+ +-------+ +---------+ +---------+
4848// | | | |
4849// | | RESTSubReq1 | |
4850// | |---------------->| |
4851// | | | |
4852// | | RESTSubResp1 | |
4853// | |<----------------| |
4854// | | | |
4855// | | | SubReq1 |
4856// | | |------------->|
4857// | | | SubResp1 |
4858// | | |<-------------|
4859// | | RESTNotif1 | |
4860// | |<----------------| |
4861// | | | |
4862// | RESTSubReq2 | |
4863// |------------------------------>| |
4864// | | | |
4865// | RESTSubResp2 | |
4866// |<------------------------------| |
4867// | | | |
4868// | | RESTNotif2 | |
4869// |<------------------------------| |
4870// | | | |
4871// | | Submgr restart |
4872// | | | |
4873// | | RESTSubDelReq1 | |
4874// | |---------------->| |
4875// | | | |
4876// | | RESTSubDelResp1 | |
4877// | |<----------------| |
4878// | | | |
4879// | | Submgr restart |
4880// | | | |
4881// | RESTSubDelReq2 | |
4882// |------------------------------>| |
4883// | | | |
4884// | RESTSubDelResp2 | |
4885// |<------------------------------| |
4886// | | | |
4887// | | | SubDelReq2 |
4888// | | |------------->|
4889// | | | |
4890// | | | SubDelResp2 |
4891// | | |<-------------|
4892// | | | |
4893//
4894//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004895
archaggeafbf95f2021-04-14 08:54:05 +03004896func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4897 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4898
4899 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004900 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004901 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004902 Counter{cSubReqToE2, 1},
4903 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004904 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004905 Counter{cMergedSubscriptions, 1},
4906 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004907 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004908 Counter{cSubDelReqToE2, 1},
4909 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004910 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004911 })
4912
4913 // Remove possible existing subscription
4914 mainCtrl.removeExistingSubscriptions(t)
4915
4916 var params *teststube2ap.RESTSubsReqParams = nil
4917
4918 // Create subscription 1
4919 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4920 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4921
4922 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004923 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004924 params.SetMeid("RAN_NAME_1")
4925 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4926 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
4927 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4928 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4929 e2SubsId2 := <-xappConn2.RESTNotification
4930 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4931
4932 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4933
4934 // When SDL support for the REST Interface is added
4935 // the submgr restart statement below should be removed
4936 // from the comment.
4937
4938 // mainCtrl.SimulateRestart(t)
4939 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4940
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004941 // Delete subscription 1, and wait until it has removed the first endpoint
4942 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004943 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004944 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004945
4946 // When SDL support for the REST Interface is added
4947 // the submgr restart statement below should be removed
4948 // from the comment.
4949
4950 // mainCtrl.SimulateRestart(t)
4951 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004952 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4953
4954 // Delete subscription 2
4955 deleteXapp2Subscription(t, &restSubId2)
4956
4957 //Wait that subs is cleaned
4958 waitSubsCleanup(t, e2SubsId2, 10)
4959
4960 mainCtrl.VerifyCounterValues(t)
4961}
4962
4963//-----------------------------------------------------------------------------
4964// TestRESTReportSubReqAndSubDelOk
4965//
4966// stub stub
4967// +-------+ +---------+ +---------+
4968// | xapp | | submgr | | e2term |
4969// +-------+ +---------+ +---------+
4970// | | |
4971// | RestSubReq | |
4972// |---------------->| |
4973// | | |
4974// | RESTSubResp | |
4975// |<----------------| |
4976// | | |
4977// | | SubReq |
4978// | |------------->|
4979// | | |
4980// | | SubResp |
4981// | |<-------------|
4982// | RESTNotif | |
4983// |<----------------| |
4984// | | SubReq |
4985// | |------------->|
4986// | | |
4987// | | SubResp |
4988// | |<-------------|
4989// | RESTNotif | |
4990// |<----------------| |
4991// | ... | ... |
4992// | | |
4993// | | |
4994// | RESTSubDelReq | |
4995// |---------------->| |
4996// | | |
4997// | | SubDelReq |
4998// | |------------->|
4999// | | |
5000// | | SubDelResp |
5001// | |<-------------|
5002// | | |
5003// | RESTSubDelResp| |
5004// |<----------------| |
5005//
5006//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005007
archaggeafbf95f2021-04-14 08:54:05 +03005008func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5009 CaseBegin("TestRESTReportSubReqAndSubDelOk")
5010 subReqCount := 1
archaggeafbf95f2021-04-14 08:54:05 +03005011 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005012 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005013}
5014
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005015func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
5016 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005017
5018 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005019 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005020 restSubId := xappConn1.SendRESTSubsReq(t, params)
5021
5022 var e2SubsId []uint32
5023 for i := 0; i < subReqCount; i++ {
5024 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5025 xappConn1.ExpectRESTNotification(t, restSubId)
5026
5027 e2termConn1.SendSubsResp(t, crereq, cremsg)
5028 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5029 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5030 e2SubsId = append(e2SubsId, instanceId)
5031 resp, _ := xapp.Subscription.QuerySubscriptions()
5032 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5033 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5034 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5035
5036 }
5037
5038 // Del
5039 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5040
5041 for i := 0; i < subReqCount; i++ {
5042 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5043 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5044 }
5045
5046 // Wait that subs is cleaned
5047 for i := 0; i < subReqCount; i++ {
5048 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5049 }
5050
5051 xappConn1.TestMsgChanEmpty(t)
5052 e2termConn1.TestMsgChanEmpty(t)
5053 mainCtrl.wait_registry_empty(t, 10)
5054}
5055
5056/*
5057func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
5058 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5059
5060 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005061 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005062 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005063
5064 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005065 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005066 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005067}
5068*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005069func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
5070 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005071
5072 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005073 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005074 restSubId := xappConn1.SendRESTSubsReq(t, params)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005075 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005076 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
5077
5078 var e2SubsId []uint32
5079 for i := 0; i < subReqCount; i++ {
5080 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5081 xappConn1.ExpectRESTNotification(t, restSubId)
5082 e2termConn1.SendSubsResp(t, crereq, cremsg)
5083 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5084 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5085 e2SubsId = append(e2SubsId, instanceId)
5086 }
5087
5088 // Del
5089 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5090
5091 for i := 0; i < subReqCount; i++ {
5092 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5093 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5094 }
5095
5096 // Wait that subs is cleaned
5097 for i := 0; i < subReqCount; i++ {
5098 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5099 }
5100 xappConn1.TestMsgChanEmpty(t)
5101 e2termConn1.TestMsgChanEmpty(t)
5102 mainCtrl.wait_registry_empty(t, 10)
5103}
5104
archaggeafbf95f2021-04-14 08:54:05 +03005105func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5106
5107 subReqCount := 2
5108
5109 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005110 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005111 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005112 Counter{cSubReqToE2, 2},
5113 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005114 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005115 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005116 Counter{cSubDelReqToE2, 2},
5117 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005118 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005119 })
5120
5121 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005122 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005123 restSubId := xappConn1.SendRESTSubsReq(t, params)
5124 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5125
5126 assert.Equal(t, len(e2SubsIds), 2)
5127
5128 // Del
5129 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5130 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5131
5132 xappConn1.TestMsgChanEmpty(t)
5133 e2termConn1.TestMsgChanEmpty(t)
5134 mainCtrl.wait_registry_empty(t, 10)
5135
5136 mainCtrl.VerifyCounterValues(t)
5137}
archaggeafbf95f2021-04-14 08:54:05 +03005138func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5139
5140 subReqCount := 19
5141
5142 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005143 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005144 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005145 Counter{cSubReqToE2, 19},
5146 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005147 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005148 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005149 Counter{cSubDelReqToE2, 19},
5150 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005151 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005152 })
5153
5154 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005155 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005156 restSubId := xappConn1.SendRESTSubsReq(t, params)
5157 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5158
5159 assert.Equal(t, len(e2SubsIds), 19)
5160
5161 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5162 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5163
5164 xappConn1.TestMsgChanEmpty(t)
5165 e2termConn1.TestMsgChanEmpty(t)
5166 mainCtrl.wait_registry_empty(t, 10)
5167
5168 mainCtrl.VerifyCounterValues(t)
5169}
archaggeafbf95f2021-04-14 08:54:05 +03005170func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5171
5172 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005173
5174 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005175 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005176 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005177 Counter{cSubReqToE2, uint64(subReqCount)},
5178 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005179 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005180 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005181 Counter{cSubDelReqToE2, uint64(subReqCount)},
5182 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005183 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005184 })
5185
5186 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005187 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005188 restSubId := xappConn1.SendRESTSubsReq(t, params)
5189 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5190
5191 assert.Equal(t, len(e2SubsIds), subReqCount)
5192
5193 // Del
5194 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5195 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5196
5197 xappConn1.TestMsgChanEmpty(t)
5198 e2termConn1.TestMsgChanEmpty(t)
5199 mainCtrl.wait_registry_empty(t, 10)
5200
5201 mainCtrl.VerifyCounterValues(t)
5202}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005203
archaggeafbf95f2021-04-14 08:54:05 +03005204func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5205
5206 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005207
5208 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005209 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005210 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005211 Counter{cSubReqToE2, uint64(subReqCount)},
5212 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005213 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005214 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005215 Counter{cSubDelReqToE2, uint64(subReqCount)},
5216 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005217 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005218 })
5219
5220 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005221 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005222 restSubId := xappConn1.SendRESTSubsReq(t, params)
5223 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5224
5225 assert.Equal(t, len(e2SubsIds), subReqCount)
5226
5227 // Del
5228 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5229 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5230
5231 xappConn1.TestMsgChanEmpty(t)
5232 e2termConn1.TestMsgChanEmpty(t)
5233 mainCtrl.wait_registry_empty(t, 10)
5234
5235 mainCtrl.VerifyCounterValues(t)
5236}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005237
archaggeafbf95f2021-04-14 08:54:05 +03005238func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5239
5240 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005241
5242 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005243 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005244 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005245 Counter{cSubReqToE2, uint64(subReqCount)},
5246 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005247 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005248 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005249 Counter{cSubDelReqToE2, uint64(subReqCount)},
5250 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005251 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005252 })
5253
5254 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005255 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005256 restSubId := xappConn1.SendRESTSubsReq(t, params)
5257 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5258
5259 assert.Equal(t, len(e2SubsIds), subReqCount)
5260
5261 // Del
5262 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5263 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5264
5265 xappConn1.TestMsgChanEmpty(t)
5266 e2termConn1.TestMsgChanEmpty(t)
5267 mainCtrl.wait_registry_empty(t, 10)
5268
5269 mainCtrl.VerifyCounterValues(t)
5270}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005271
5272func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5273 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5274
5275 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005276 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005277 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005278 Counter{cSubReqToE2, 2},
5279 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005280 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005281 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005282 Counter{cSubDelReqToE2, 2},
5283 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005284 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005285 })
5286
5287 // Req1
5288 var params *teststube2ap.RESTSubsReqParams = nil
5289
5290 //Subs Create
5291 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5292 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5293
5294 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5295
5296 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005297 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005298 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005299 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005300 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5301
5302 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5303 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5304 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5305 xappConn2.ExpectRESTNotification(t, restSubId2)
5306 e2termConn1.SendSubsResp(t, crereq, cremsg)
5307 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5308
5309 deleteXapp1Subscription(t, &restSubId1)
5310 deleteXapp2Subscription(t, &restSubId2)
5311
5312 waitSubsCleanup(t, e2SubsId1, 10)
5313 waitSubsCleanup(t, e2SubsId2, 10)
5314
5315 mainCtrl.VerifyCounterValues(t)
5316
5317}
5318
5319func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5320 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5321
5322 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005323 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005324 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005325 Counter{cSubReqToE2, 2},
5326 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005327 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005328 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005329 Counter{cSubDelReqToE2, 2},
5330 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005331 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005332 })
5333
5334 // Req1
5335 var params *teststube2ap.RESTSubsReqParams = nil
5336
5337 //Subs Create
5338 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5339 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5340
5341 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5342
5343 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005344 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005345 params.SetMeid("RAN_NAME_1")
5346
5347 actionId := int64(1)
5348 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005349 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005350 subsequestActionType := "continue"
5351 timeToWait := "w10ms"
5352 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5353
5354 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5355 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5356 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5357 xappConn2.ExpectRESTNotification(t, restSubId2)
5358 e2termConn1.SendSubsResp(t, crereq, cremsg)
5359 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5360
5361 deleteXapp1Subscription(t, &restSubId1)
5362 deleteXapp2Subscription(t, &restSubId2)
5363
5364 waitSubsCleanup(t, e2SubsId1, 10)
5365 waitSubsCleanup(t, e2SubsId2, 10)
5366
5367 mainCtrl.VerifyCounterValues(t)
5368
5369}
5370
5371func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5372 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5373
5374 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005375 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005376 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005377 Counter{cSubReqToE2, 2},
5378 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005379 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005380 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005381 Counter{cSubDelReqToE2, 2},
5382 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005383 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005384 })
5385
5386 // Req1
5387 var params *teststube2ap.RESTSubsReqParams = nil
5388
5389 //Subs Create
5390 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5391 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5392
5393 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5394
5395 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005396 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005397 params.SetMeid("RAN_NAME_1")
5398 params.SetSubActionIDs(int64(2))
5399
5400 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5401 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5402 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5403 xappConn2.ExpectRESTNotification(t, restSubId2)
5404 e2termConn1.SendSubsResp(t, crereq, cremsg)
5405 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5406
5407 deleteXapp1Subscription(t, &restSubId1)
5408 deleteXapp2Subscription(t, &restSubId2)
5409
5410 waitSubsCleanup(t, e2SubsId1, 10)
5411 waitSubsCleanup(t, e2SubsId2, 10)
5412
5413 mainCtrl.VerifyCounterValues(t)
5414
5415}
5416
5417func TestRESTSubReqDiffActionType(t *testing.T) {
5418 CaseBegin("TestRESTSubReqDiffActionType")
5419
5420 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005421 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005422 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005423 Counter{cSubReqToE2, 2},
5424 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005425 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005426 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005427 Counter{cSubDelReqToE2, 2},
5428 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005429 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005430 })
5431
5432 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005433 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005434
5435 //Subs Create
5436 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5437 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5438
5439 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5440
5441 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005442 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005443 params.SetMeid("RAN_NAME_1")
5444
5445 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5446 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5447 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5448 xappConn2.ExpectRESTNotification(t, restSubId2)
5449 e2termConn1.SendSubsResp(t, crereq, cremsg)
5450 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5451
5452 deleteXapp1Subscription(t, &restSubId1)
5453 deleteXapp2Subscription(t, &restSubId2)
5454
5455 waitSubsCleanup(t, e2SubsId1, 10)
5456 waitSubsCleanup(t, e2SubsId2, 10)
5457
5458 mainCtrl.VerifyCounterValues(t)
5459
5460}
5461
5462func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5463 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5464
5465 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005466 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005467 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005468 Counter{cSubReqToE2, 2},
5469 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005470 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005471 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005472 Counter{cSubDelReqToE2, 2},
5473 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005474 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005475 })
5476
5477 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005478 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005479
5480 //Subs Create
5481 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5482 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5483
5484 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5485
5486 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005487 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005488 params.SetMeid("RAN_NAME_1")
5489
5490 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5491 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5492 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5493 xappConn2.ExpectRESTNotification(t, restSubId2)
5494 e2termConn1.SendSubsResp(t, crereq, cremsg)
5495 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5496
5497 deleteXapp1Subscription(t, &restSubId1)
5498 deleteXapp2Subscription(t, &restSubId2)
5499
5500 waitSubsCleanup(t, e2SubsId1, 10)
5501 waitSubsCleanup(t, e2SubsId2, 10)
5502
5503 mainCtrl.VerifyCounterValues(t)
5504
5505}
5506
5507func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5508 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5509
5510 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005511 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005512 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005513 Counter{cSubReqToE2, 2},
5514 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005515 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005516 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005517 Counter{cSubDelReqToE2, 2},
5518 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005519 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005520 })
5521
5522 // Req1
5523 var params *teststube2ap.RESTSubsReqParams = nil
5524
5525 //Subs Create
5526 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5527 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5528
5529 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5530
5531 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005532 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005533 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005534 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005535 params.SetSubActionDefinition(actionDefinition)
5536
5537 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5538 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5539 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5540 xappConn2.ExpectRESTNotification(t, restSubId2)
5541 e2termConn1.SendSubsResp(t, crereq, cremsg)
5542 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5543
5544 deleteXapp1Subscription(t, &restSubId1)
5545 deleteXapp2Subscription(t, &restSubId2)
5546
5547 waitSubsCleanup(t, e2SubsId1, 10)
5548 waitSubsCleanup(t, e2SubsId2, 10)
5549
5550 mainCtrl.VerifyCounterValues(t)
5551
5552}
5553
5554func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5555 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5556
5557 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005558 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005559 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005560 Counter{cSubReqToE2, 2},
5561 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005562 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005563 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005564 Counter{cSubDelReqToE2, 2},
5565 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005566 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005567 })
5568
5569 // Req1
5570 var params *teststube2ap.RESTSubsReqParams = nil
5571
5572 //Subs Create
5573 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5574 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5575
5576 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5577
5578 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005579 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005580 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005581 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005582 params.SetSubActionDefinition(actionDefinition)
5583
5584 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5585 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5586 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5587 xappConn2.ExpectRESTNotification(t, restSubId2)
5588 e2termConn1.SendSubsResp(t, crereq, cremsg)
5589 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5590
5591 deleteXapp1Subscription(t, &restSubId1)
5592 deleteXapp2Subscription(t, &restSubId2)
5593
5594 waitSubsCleanup(t, e2SubsId1, 10)
5595 waitSubsCleanup(t, e2SubsId2, 10)
5596
5597 mainCtrl.VerifyCounterValues(t)
5598
5599}
5600
5601func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5602 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5603
5604 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005605 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005606 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005607 Counter{cSubReqToE2, 2},
5608 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005609 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005610 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005611 Counter{cSubDelReqToE2, 2},
5612 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005613 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005614 })
5615
5616 // Req1
5617 var params *teststube2ap.RESTSubsReqParams = nil
5618
5619 //Subs Create
5620 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5621 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5622
5623 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5624
5625 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005626 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005627 params.SetMeid("RAN_NAME_1")
5628 params.SetTimeToWait("w200ms")
5629 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5630 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5631 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5632 xappConn2.ExpectRESTNotification(t, restSubId2)
5633 e2termConn1.SendSubsResp(t, crereq, cremsg)
5634 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5635
5636 deleteXapp1Subscription(t, &restSubId1)
5637 deleteXapp2Subscription(t, &restSubId2)
5638
5639 waitSubsCleanup(t, e2SubsId1, 10)
5640 waitSubsCleanup(t, e2SubsId2, 10)
5641
5642 mainCtrl.VerifyCounterValues(t)
5643
5644}
5645
Anssi Mannila51122392021-05-25 11:51:31 +03005646//-----------------------------------------------------------------------------
5647// TestRESTUnpackSubscriptionResponseDecodeFail
5648//
5649// stub stub
5650// +-------+ +---------+ +---------+
5651// | xapp | | submgr | | e2term |
5652// +-------+ +---------+ +---------+
5653// | | |
5654// | RestSubReq | |
5655// |---------------->| |
5656// | | |
5657// | RESTSubResp | |
5658// |<----------------| |
5659// | | |
5660// | | SubReq |
5661// | |------------->|
5662// | | |
5663// | | SubResp | ASN.1 decode fails
5664// | |<-------------|
5665// | | |
5666// | | SubReq |
5667// | |------------->|
5668// | | |
5669// | | SubFail | Duplicated action
5670// | |<-------------|
5671// | RESTNotif (fail)| |
5672// |<----------------| |
5673// | | SubDelReq |
5674// | |------------->|
5675// | | |
5676// | | SubDelResp |
5677// | |<-------------|
5678//
5679//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005680
Anssi Mannila51122392021-05-25 11:51:31 +03005681func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
5682 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5683 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005684
5685 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005686 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005687 restSubId := xappConn1.SendRESTSubsReq(t, params)
5688
5689 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5690 // Decode of this response fails which will result resending original request
5691 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5692
5693 _, cremsg = e2termConn1.RecvSubsReq(t)
5694
Markku Virtanen55d2a282021-06-04 14:46:56 +03005695 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005696
5697 // Subscription already created in E2 Node.
5698 fparams := &teststube2ap.E2StubSubsFailParams{}
5699 fparams.Set(crereq)
5700 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5701 e2termConn1.SendSubsFail(t, fparams, cremsg)
5702
5703 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5704 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5705
5706 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5707 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5708
5709 // Wait that subs is cleaned
5710 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5711
5712 xappConn1.TestMsgChanEmpty(t)
5713 e2termConn1.TestMsgChanEmpty(t)
5714 mainCtrl.wait_registry_empty(t, 10)
5715}
5716
5717//-----------------------------------------------------------------------------
5718// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5719//
5720// stub stub
5721// +-------+ +---------+ +---------+
5722// | xapp | | submgr | | e2term |
5723// +-------+ +---------+ +---------+
5724// | | |
5725// | RestSubReq | |
5726// |---------------->| |
5727// | | |
5728// | RESTSubResp | |
5729// |<----------------| |
5730// | | |
5731// | | SubReq |
5732// | |------------->|
5733// | | |
5734// | | SubResp | Unknown instanceId
5735// | |<-------------|
5736// | | |
5737// | | SubReq |
5738// | |------------->|
5739// | | |
5740// | | SubFail | Duplicated action
5741// | |<-------------|
5742// | RESTNotif (fail)| |
5743// |<----------------| |
5744// | | SubDelReq |
5745// | |------------->|
5746// | | |
5747// | | SubDelResp |
5748// | |<-------------|
5749//
5750//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005751
Anssi Mannila51122392021-05-25 11:51:31 +03005752func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
5753 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5754 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005755
5756 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005757 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005758 restSubId := xappConn1.SendRESTSubsReq(t, params)
5759
5760 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5761
5762 // Unknown instanceId in this response which will result resending original request
5763 orgInstanceId := crereq.RequestId.InstanceId
5764 crereq.RequestId.InstanceId = 0
5765 e2termConn1.SendSubsResp(t, crereq, cremsg)
5766
5767 _, cremsg = e2termConn1.RecvSubsReq(t)
5768
Markku Virtanen55d2a282021-06-04 14:46:56 +03005769 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005770
5771 // Subscription already created in E2 Node.
5772 fparams := &teststube2ap.E2StubSubsFailParams{}
5773 fparams.Set(crereq)
5774 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5775 e2termConn1.SendSubsFail(t, fparams, cremsg)
5776
5777 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5778 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5779
5780 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5781 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5782
5783 // Wait that subs is cleaned
5784 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
5785
5786 xappConn1.TestMsgChanEmpty(t)
5787 e2termConn1.TestMsgChanEmpty(t)
5788 mainCtrl.wait_registry_empty(t, 10)
5789}
5790
5791//-----------------------------------------------------------------------------
5792// TestRESTUnpackSubscriptionResponseNoTransaction
5793//
5794// stub stub
5795// +-------+ +---------+ +---------+
5796// | xapp | | submgr | | e2term |
5797// +-------+ +---------+ +---------+
5798// | | |
5799// | RestSubReq | |
5800// |---------------->| |
5801// | | |
5802// | RESTSubResp | |
5803// |<----------------| |
5804// | | |
5805// | | SubReq |
5806// | |------------->|
5807// | | |
5808// | | SubResp | No transaction for the response
5809// | |<-------------|
5810// | | |
5811// | | SubReq |
5812// | |------------->|
5813// | | |
5814// | | SubFail | Duplicated action
5815// | |<-------------|
5816// | RESTNotif (fail)| |
5817// |<----------------| |
5818// | | SubDelReq |
5819// | |------------->|
5820// | | |
5821// | | SubDelResp |
5822// | |<-------------|
5823// | | |
5824// | | SubDelReq |
5825// | |------------->|
5826// | | |
5827// | | SubDelResp |
5828// | |<-------------|
5829//
5830//-----------------------------------------------------------------------------
5831func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
5832 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5833 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005834
5835 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005836 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005837 restSubId := xappConn1.SendRESTSubsReq(t, params)
5838
5839 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5840
5841 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5842 // No transaction exist for this response which will result resending original request
5843 e2termConn1.SendSubsResp(t, crereq, cremsg)
5844
5845 _, cremsg = e2termConn1.RecvSubsReq(t)
5846
Markku Virtanen55d2a282021-06-04 14:46:56 +03005847 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005848
5849 // Subscription already created in E2 Node.
5850 fparams := &teststube2ap.E2StubSubsFailParams{}
5851 fparams.Set(crereq)
5852 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5853 e2termConn1.SendSubsFail(t, fparams, cremsg)
5854
5855 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5856 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5857
5858 // Resending happens because there no transaction
5859 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5860 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5861
5862 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5863 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5864
5865 // Wait that subs is cleaned
5866 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5867
5868 xappConn1.TestMsgChanEmpty(t)
5869 e2termConn1.TestMsgChanEmpty(t)
5870 mainCtrl.wait_registry_empty(t, 10)
5871
5872}
5873
5874//-----------------------------------------------------------------------------
5875// TestRESTUnpackSubscriptionFailureDecodeFail
5876//
5877// stub stub
5878// +-------+ +---------+ +---------+
5879// | xapp | | submgr | | e2term |
5880// +-------+ +---------+ +---------+
5881// | | |
5882// | RestSubReq | |
5883// |---------------->| |
5884// | | |
5885// | RESTSubResp | |
5886// |<----------------| |
5887// | | |
5888// | | SubReq |
5889// | |------------->|
5890// | | |
5891// | | SubFail | ASN.1 decode fails
5892// | |<-------------|
5893// | | |
5894// | | SubReq |
5895// | |------------->|
5896// | | |
5897// | | SubFail | Duplicated action
5898// | |<-------------|
5899// | RESTNotif (fail)| |
5900// |<----------------| |
5901// | | SubDelReq |
5902// | |------------->|
5903// | | |
5904// | | SubDelResp |
5905// | |<-------------|
5906//
5907//-----------------------------------------------------------------------------
5908func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
5909 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5910 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005911
5912 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005913 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005914 restSubId := xappConn1.SendRESTSubsReq(t, params)
5915
5916 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5917
5918 // Decode of this response fails which will result resending original request
5919 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5920
5921 _, cremsg = e2termConn1.RecvSubsReq(t)
5922
Markku Virtanen55d2a282021-06-04 14:46:56 +03005923 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005924
5925 // Subscription already created in E2 Node.
5926 fparams := &teststube2ap.E2StubSubsFailParams{}
5927 fparams.Set(crereq)
5928 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5929 e2termConn1.SendSubsFail(t, fparams, cremsg)
5930
5931 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5932 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5933
5934 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5935 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5936
5937 // Wait that subs is cleaned
5938 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5939
5940 xappConn1.TestMsgChanEmpty(t)
5941 e2termConn1.TestMsgChanEmpty(t)
5942 mainCtrl.wait_registry_empty(t, 10)
5943}
5944
5945//-----------------------------------------------------------------------------
5946// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5947//
5948// stub stub
5949// +-------+ +---------+ +---------+
5950// | xapp | | submgr | | e2term |
5951// +-------+ +---------+ +---------+
5952// | | |
5953// | RestSubReq | |
5954// |---------------->| |
5955// | | |
5956// | RESTSubResp | |
5957// |<----------------| |
5958// | | |
5959// | | SubReq |
5960// | |------------->|
5961// | | |
5962// | | SubFail | Unknown instanceId
5963// | |<-------------|
5964// | | |
5965// | | SubReq |
5966// | |------------->|
5967// | | |
5968// | | SubFail | Duplicated action
5969// | |<-------------|
5970// | RESTNotif (fail)| |
5971// |<----------------| |
5972// | | SubDelReq |
5973// | |------------->|
5974// | | |
5975// | | SubDelResp |
5976// | |<-------------|
5977//
5978//-----------------------------------------------------------------------------
5979func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
5980 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
5981 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005982
5983 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005984 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005985 restSubId := xappConn1.SendRESTSubsReq(t, params)
5986
5987 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5988
5989 // Unknown instanceId in this response which will result resending original request
5990 fparams := &teststube2ap.E2StubSubsFailParams{}
5991 fparams.Set(crereq)
5992 fparams.Fail.RequestId.InstanceId = 0
5993 e2termConn1.SendSubsFail(t, fparams, cremsg)
5994
5995 _, cremsg = e2termConn1.RecvSubsReq(t)
5996
Markku Virtanen55d2a282021-06-04 14:46:56 +03005997 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005998
5999 // Subscription already created in E2 Node.
6000 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6001 e2termConn1.SendSubsFail(t, fparams, cremsg)
6002
6003 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6004 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6005
6006 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
6007 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
6008
6009 // Wait that subs is cleaned
6010 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6011
6012 xappConn1.TestMsgChanEmpty(t)
6013 e2termConn1.TestMsgChanEmpty(t)
6014 mainCtrl.wait_registry_empty(t, 10)
6015}
6016
6017//-----------------------------------------------------------------------------
6018// TestRESTUnpackSubscriptionFailureNoTransaction
6019//
6020// stub stub
6021// +-------+ +---------+ +---------+
6022// | xapp | | submgr | | e2term |
6023// +-------+ +---------+ +---------+
6024// | | |
6025// | RestSubReq | |
6026// |---------------->| |
6027// | | |
6028// | RESTSubResp | |
6029// |<----------------| |
6030// | | |
6031// | | SubReq |
6032// | |------------->|
6033// | | |
6034// | | SubFail | No transaction for the response
6035// | |<-------------|
6036// | | |
6037// | | SubReq |
6038// | |------------->|
6039// | | |
6040// | | SubFail | Duplicated action
6041// | |<-------------|
6042// | RESTNotif (fail)| |
6043// |<----------------| |
6044// | | SubDelReq |
6045// | |------------->|
6046// | | |
6047// | | SubDelResp |
6048// | |<-------------|
6049//
6050//-----------------------------------------------------------------------------
6051func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
6052 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6053 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03006054
6055 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006056 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006057 restSubId := xappConn1.SendRESTSubsReq(t, params)
6058
6059 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6060
6061 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6062
6063 // No transaction exist for this response which will result resending original request
6064 fparams := &teststube2ap.E2StubSubsFailParams{}
6065 fparams.Set(crereq)
6066 e2termConn1.SendSubsFail(t, fparams, cremsg)
6067
6068 _, cremsg = e2termConn1.RecvSubsReq(t)
6069
Markku Virtanen55d2a282021-06-04 14:46:56 +03006070 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006071
6072 // Subscription already created in E2 Node.
6073 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6074 e2termConn1.SendSubsFail(t, fparams, cremsg)
6075
6076 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6077 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6078
6079 // Resending happens because there no transaction
6080 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6081 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6082
6083 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
6084 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
6085
6086 // Wait that subs is cleaned
6087 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6088
6089 xappConn1.TestMsgChanEmpty(t)
6090 e2termConn1.TestMsgChanEmpty(t)
6091 mainCtrl.wait_registry_empty(t, 10)
6092}
6093
6094//-----------------------------------------------------------------------------
6095// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6096//
6097// stub stub
6098// +-------+ +---------+ +---------+
6099// | xapp | | submgr | | e2term |
6100// +-------+ +---------+ +---------+
6101// | | |
6102// | [SUBS CREATE] |
6103// | | |
6104// | | |
6105// | RESTSubDelReq | |
6106// |---------------->| |
6107// | | |
6108// | RESTSubDelResp | |
6109// |<----------------| |
6110// | | |
6111// | | SubDelReq |
6112// | |------------->|
6113// | | |
6114// | | SubDelResp | ASN.1 decode fails
6115// | |<-------------|
6116// | | |
6117// | | SubDelReq |
6118// | |------------->|
6119// | | |
6120// | | SubDelFail | Subscription does exist any more
6121// | |<-------------|
6122// | | |
6123//
6124//-----------------------------------------------------------------------------
6125func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
6126 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
6127
6128 // Req
6129 var params *teststube2ap.RESTSubsReqParams = nil
6130 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6131
6132 // Del
6133 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6134
6135 // E2t: Receive 1st SubsDelReq
6136 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6137
6138 // Decode of this response fails which will result resending original request
6139 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6140
6141 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6142 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6143
6144 // Subscription does not exist in in E2 Node.
6145 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6146
6147 // Wait that subs is cleaned
6148 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6149
6150 xappConn1.TestMsgChanEmpty(t)
6151 e2termConn1.TestMsgChanEmpty(t)
6152 mainCtrl.wait_registry_empty(t, 10)
6153}
6154
6155//-----------------------------------------------------------------------------
6156// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6157//
6158// stub stub
6159// +-------+ +---------+ +---------+
6160// | xapp | | submgr | | e2term |
6161// +-------+ +---------+ +---------+
6162// | | |
6163// | [SUBS CREATE] |
6164// | | |
6165// | | |
6166// | RESTSubDelReq | |
6167// |---------------->| |
6168// | | |
6169// | RESTSubDelResp | |
6170// |<----------------| |
6171// | | |
6172// | | SubDelReq |
6173// | |------------->|
6174// | | |
6175// | | SubDelResp | Unknown instanceId
6176// | |<-------------|
6177// | | |
6178// | | SubDelReq |
6179// | |------------->|
6180// | | |
6181// | | SubDelFail | Subscription does exist any more
6182// | |<-------------|
6183//
6184//-----------------------------------------------------------------------------
6185func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
6186 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
6187
6188 // Req
6189 var params *teststube2ap.RESTSubsReqParams = nil
6190 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6191
6192 // Del
6193 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6194
6195 // E2t: Receive 1st SubsDelReq
6196 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6197
6198 // Unknown instanceId in this response which will result resending original request
6199 delreq.RequestId.InstanceId = 0
6200 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6201
6202 // E2t: Receive 2nd SubsDelReq
6203 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6204
6205 // Subscription does not exist in in E2 Node.
6206 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6207
6208 // Wait that subs is cleaned
6209 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6210
6211 xappConn1.TestMsgChanEmpty(t)
6212 e2termConn1.TestMsgChanEmpty(t)
6213 mainCtrl.wait_registry_empty(t, 10)
6214}
6215
6216//-----------------------------------------------------------------------------
6217// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6218//
6219// stub stub
6220// +-------+ +---------+ +---------+
6221// | xapp | | submgr | | e2term |
6222// +-------+ +---------+ +---------+
6223// | | |
6224// | [SUBS CREATE] |
6225// | | |
6226// | | |
6227// | RESTSubDelReq | |
6228// |---------------->| |
6229// | | |
6230// | RESTSubDelResp | |
6231// |<----------------| |
6232// | | |
6233// | | SubDelReq |
6234// | |------------->|
6235// | | |
6236// | | SubDelResp | No transaction for the response
6237// | |<-------------|
6238// | | |
6239// | | SubDelReq |
6240// | |------------->|
6241// | | |
6242// | | SubDelFail | Subscription does exist any more
6243// | |<-------------|
6244//
6245//-----------------------------------------------------------------------------
6246func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
6247 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
6248
6249 // Req
6250 var params *teststube2ap.RESTSubsReqParams = nil
6251 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6252
6253 // Del
6254 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6255
6256 // E2t: Receive 1st SubsDelReq
6257 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6258
6259 mainCtrl.MakeTransactionNil(t, e2SubsId)
6260
6261 // No transaction exist for this response which will result resending original request
6262 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6263
6264 // E2t: Receive 2nd SubsDelReq
6265 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6266
6267 // Subscription does not exist in in E2 Node.
6268 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6269
6270 // Wait that subs is cleaned
6271 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6272
6273 xappConn1.TestMsgChanEmpty(t)
6274 e2termConn1.TestMsgChanEmpty(t)
6275 mainCtrl.wait_registry_empty(t, 10)
6276}
6277
6278//-----------------------------------------------------------------------------
6279// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6280//
6281// stub stub
6282// +-------+ +---------+ +---------+
6283// | xapp | | submgr | | e2term |
6284// +-------+ +---------+ +---------+
6285// | | |
6286// | [SUBS CREATE] |
6287// | | |
6288// | | |
6289// | RESTSubDelReq | |
6290// |---------------->| |
6291// | | |
6292// | RESTSubDelResp | |
6293// |<----------------| |
6294// | | |
6295// | | SubDelReq |
6296// | |------------->|
6297// | | |
6298// | | SubDelFail | ASN.1 decode fails
6299// | |<-------------|
6300// | | |
6301// | | SubDelReq |
6302// | |------------->|
6303// | | |
6304// | | SubDelFail | Subscription does exist any more
6305// | |<-------------|
6306//
6307//-----------------------------------------------------------------------------
6308func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
6309 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
6310
6311 // Req
6312 var params *teststube2ap.RESTSubsReqParams = nil
6313 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6314
6315 // Del
6316 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6317
6318 // E2t: Receive 1st SubsDelReq
6319 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6320
6321 // Decode of this response fails which will result resending original request
6322 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6323
6324 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6325 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6326
6327 // Subscription does not exist in in E2 Node.
6328 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6329
6330 // Wait that subs is cleaned
6331 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6332
6333 xappConn1.TestMsgChanEmpty(t)
6334 e2termConn1.TestMsgChanEmpty(t)
6335 mainCtrl.wait_registry_empty(t, 10)
6336}
6337
6338//-----------------------------------------------------------------------------
6339// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6340//
6341// stub stub
6342// +-------+ +---------+ +---------+
6343// | xapp | | submgr | | e2term |
6344// +-------+ +---------+ +---------+
6345// | | |
6346// | [SUBS CREATE] |
6347// | | |
6348// | | |
6349// | RESTSubDelReq | |
6350// |---------------->| |
6351// | | |
6352// | RESTSubDelResp | |
6353// |<----------------| |
6354// | | |
6355// | | SubDelReq |
6356// | |------------->|
6357// | | |
6358// | | SubDelFail | Unknown instanceId
6359// | |<-------------|
6360// | | |
6361// | | SubDelReq |
6362// | |------------->|
6363// | | |
6364// | | SubDelFail | Subscription does exist any more
6365// | |<-------------|
6366//
6367//-----------------------------------------------------------------------------
6368func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
6369 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
6370
6371 // Req
6372 var params *teststube2ap.RESTSubsReqParams = nil
6373 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6374
6375 // Del
6376 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6377
6378 // E2t: Receive 1st SubsDelReq
6379 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6380
6381 // Unknown instanceId in this response which will result resending original request
6382 delreq.RequestId.InstanceId = 0
6383 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6384
6385 // E2t: Receive 2nd SubsDelReq
6386 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6387
6388 // Subscription does not exist in in E2 Node.
6389 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6390
6391 // Wait that subs is cleaned
6392 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6393
6394 xappConn1.TestMsgChanEmpty(t)
6395 e2termConn1.TestMsgChanEmpty(t)
6396 mainCtrl.wait_registry_empty(t, 10)
6397}
6398
6399//-----------------------------------------------------------------------------
6400// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6401//
6402// stub stub
6403// +-------+ +---------+ +---------+
6404// | xapp | | submgr | | e2term |
6405// +-------+ +---------+ +---------+
6406// | | |
6407// | [SUBS CREATE] |
6408// | | |
6409// | | |
6410// | RESTSubDelReq | |
6411// |---------------->| |
6412// | | |
6413// | RESTSubDelResp | |
6414// |<----------------| |
6415// | | |
6416// | | SubDelReq |
6417// | |------------->|
6418// | | |
6419// | | SubDelFail | No transaction for the response
6420// | |<-------------|
6421// | | |
6422// | | SubDelReq |
6423// | |------------->|
6424// | | |
6425// | | SubDelFail | Subscription does exist any more
6426// | |<-------------|
6427//
6428//-----------------------------------------------------------------------------
6429func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
6430 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
6431
6432 // Req
6433 var params *teststube2ap.RESTSubsReqParams = nil
6434 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6435
6436 // Del
6437 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6438
6439 // E2t: Receive 1st SubsDelReq
6440 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6441
6442 mainCtrl.MakeTransactionNil(t, e2SubsId)
6443
6444 // No transaction exist for this response which will result resending original request
6445 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6446
6447 // E2t: Receive 2nd SubsDelReq
6448 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6449
6450 // Subscription does not exist in in E2 Node.
6451 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6452
6453 // Wait that subs is cleaned
6454 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6455
6456 xappConn1.TestMsgChanEmpty(t)
6457 e2termConn1.TestMsgChanEmpty(t)
6458 mainCtrl.wait_registry_empty(t, 10)
6459}
6460
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006461//-----------------------------------------------------------------------------
6462// TestRESTSubReqFailAsn1PackSubReqError
6463//
6464// stub stub
6465// +-------+ +---------+ +---------+
6466// | xapp | | submgr | | e2term |
6467// +-------+ +---------+ +---------+
6468// | | |
6469// | RESTSubReq | |
6470// |---------------->| |
6471// | | |
6472// | RESTSubResp | |
6473// |<----------------| |
6474// | | |
6475// | ASN.1 encode fails |
6476// | | |
6477// | | SubDelReq |
6478// | |------------->|
6479// | | |
6480// | | SubDelFail |
6481// | |<-------------|
6482// | | |
6483// | RESTNotif | |
6484// | unsuccess | |
6485// |<----------------| |
6486// | | |
6487// | [SUBS DELETE] |
6488// | | |
6489//
6490//-----------------------------------------------------------------------------
6491func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6492
6493 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006494 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006495 Counter{cRestSubRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006496 Counter{cSubDelReqToE2, 1},
6497 Counter{cSubDelFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006498 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006499 })
6500
6501 subReqCount := 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006502
6503 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006504 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006505 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6506
6507 // Req
6508 restSubId := xappConn1.SendRESTSubsReq(t, params)
6509 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6510
6511 // E2t: Receive SubsDelReq
6512 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03006513 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006514
6515 // Subscription does not exist in in E2 Node.
6516 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6517
6518 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6519 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
6520
6521 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
6522 // Wait that subs is cleaned
6523 waitSubsCleanup(t, e2SubsId, 10)
6524 mainCtrl.VerifyCounterValues(t)
6525}
6526
archaggeafbf95f2021-04-14 08:54:05 +03006527////////////////////////////////////////////////////////////////////////////////////
6528// Services for UT cases
6529////////////////////////////////////////////////////////////////////////////////////
6530const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006531const host string = "localhost"
6532
6533func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
6534 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006535 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006536 }
6537 restSubId := fromXappConn.SendRESTSubsReq(t, params)
6538 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6539
6540 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
6541 fromXappConn.ExpectRESTNotification(t, restSubId)
6542 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
6543 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
6544 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6545
6546 return restSubId, e2SubsId
6547}
6548
6549func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
6550
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006551 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006552 if meid != "" {
6553 params.SetMeid(meid)
6554 }
6555 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
6556 restSubId := xappConn2.SendRESTSubsReq(t, params)
6557 xappConn2.ExpectRESTNotification(t, restSubId)
6558 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6559 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
6560 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6561
6562 return restSubId, e2SubsId
6563}
6564
6565func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006566 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006567 restSubId := xappConn1.SendRESTSubsReq(t, params)
6568 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
6569
6570 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6571 xappConn1.ExpectRESTNotification(t, restSubId)
6572 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6573 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6574 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6575
6576 return restSubId, e2SubsId
6577}
6578
6579func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006580 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006581 restSubId := xappConn1.SendRESTSubsReq(t, params)
6582
6583 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6584 fparams1 := &teststube2ap.E2StubSubsFailParams{}
6585 fparams1.Set(crereq1)
6586 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
6587
6588 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
6589 xappConn1.ExpectRESTNotification(t, restSubId)
6590 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
6591 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6592 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
6593
6594 return restSubId, e2SubsId
6595}
6596
6597func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
6598 fromXappConn.SendRESTSubsDelReq(t, restSubId)
6599 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6600 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6601}
6602
6603func deleteXapp1Subscription(t *testing.T, restSubId *string) {
6604 xappConn1.SendRESTSubsDelReq(t, restSubId)
6605 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6606 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6607}
6608
6609func deleteXapp2Subscription(t *testing.T, restSubId *string) {
6610 xappConn2.SendRESTSubsDelReq(t, restSubId)
6611 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6612 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6613}
6614
6615func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
6616 resp, _ := xapp.Subscription.QuerySubscriptions()
6617 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
6618 assert.Equal(t, resp[0].Meid, meid)
6619 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
6620}
6621
6622func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
6623 //Wait that subs is cleaned
6624 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
6625
6626 xappConn1.TestMsgChanEmpty(t)
6627 xappConn2.TestMsgChanEmpty(t)
6628 e2termConn1.TestMsgChanEmpty(t)
6629 mainCtrl.wait_registry_empty(t, timeout)
6630}
6631
6632func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
6633
6634 var e2SubsId []uint32
6635
6636 for i := 0; i < count; i++ {
6637 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
6638 crereq, cremsg := toE2termConn.RecvSubsReq(t)
6639 fromXappConn.ExpectRESTNotification(t, restSubId)
6640 toE2termConn.SendSubsResp(t, crereq, cremsg)
6641 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
6642 e2SubsId = append(e2SubsId, instanceId)
6643 xapp.Logger.Info("TEST: %v", e2SubsId)
6644 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
6645 <-time.After(100 * time.Millisecond)
6646 }
6647 return e2SubsId
6648}
6649
6650func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
6651
6652 for i := 0; i < len(e2SubsIds); i++ {
6653 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
6654 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6655 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6656 <-time.After(1 * time.Second)
6657 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
6658 <-time.After(100 * time.Millisecond)
6659 }
6660
6661 // Wait that subs is cleaned
6662 for i := 0; i < len(e2SubsIds); i++ {
6663 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
6664 }
6665
6666}