blob: 69e7c1f92f75766e26673015aabdcff52b034763 [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
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002137 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002138 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2139 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2140
2141 // Wait that subs is cleaned
2142 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2143
2144 xappConn1.TestMsgChanEmpty(t)
2145 xappConn2.TestMsgChanEmpty(t)
2146 e2termConn1.TestMsgChanEmpty(t)
2147 mainCtrl.wait_registry_empty(t, 10)
2148}
2149
2150//-----------------------------------------------------------------------------
2151// TestSubReqAndSubDelOkWithRestartInMiddle
2152//
2153// stub stub
2154// +-------+ +---------+ +---------+
2155// | xapp | | submgr | | e2term |
2156// +-------+ +---------+ +---------+
2157// | | |
2158// | SubReq | |
2159// |------------->| |
2160// | | |
2161// | | SubReq |
2162// | |------------->|
2163// | | |
2164// | | SubResp |
2165// | |<-------------|
2166// | | |
2167// | SubResp | |
2168// |<-------------| |
2169// | | |
2170// | |
2171// | Submgr restart |
2172// | |
2173// | SubDelReq | |
2174// |------------->| |
2175// | | |
2176// | | SubDelReq |
2177// | |------------->|
2178// | | |
2179// | | SubDelResp |
2180// | |<-------------|
2181// | | |
2182// | SubDelResp | |
2183// |<-------------| |
2184//
2185//-----------------------------------------------------------------------------
2186
2187func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2188 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2189
2190 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2191 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2192 e2termConn1.SendSubsResp(t, crereq, cremsg)
2193 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2194
2195 // Check subscription
2196 resp, _ := xapp.Subscription.QuerySubscriptions()
2197 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2198 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002199 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002200
2201 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002202 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002203
2204 // Check that subscription is restored correctly after restart
2205 resp, _ = xapp.Subscription.QuerySubscriptions()
2206 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2207 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002208 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002209
2210 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2211 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2212 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2213 xappConn1.RecvSubsDelResp(t, deltrans)
2214
2215 //Wait that subs is cleaned
2216 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2217
2218 xappConn1.TestMsgChanEmpty(t)
2219 xappConn2.TestMsgChanEmpty(t)
2220 e2termConn1.TestMsgChanEmpty(t)
2221 mainCtrl.wait_registry_empty(t, 10)
2222}
2223
2224//-----------------------------------------------------------------------------
2225// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2226//
2227// stub stub
2228// +-------+ +-------+ +---------+ +---------+
2229// | xapp2 | | xapp1 | | submgr | | e2term |
2230// +-------+ +-------+ +---------+ +---------+
2231// | | | |
2232// | | | |
2233// | | | |
2234// | | SubReq1 | |
2235// | |------------->| |
2236// | | | |
2237// | | | SubReq1 |
2238// | | |------------->|
2239// | | | SubResp1 |
2240// | | |<-------------|
2241// | | SubResp1 | |
2242// | |<-------------| |
2243// | | | |
2244// | |
2245// | submgr restart |
2246// | |
2247// | | | |
2248// | | | |
2249// | SubReq2 | |
2250// |--------------------------->| |
2251// | | | |
2252// | SubResp2 | |
2253// |<---------------------------| |
2254// | | | |
2255// | | SubDelReq 1 | |
2256// | |------------->| |
2257// | | | |
2258// | | SubDelResp 1 | |
2259// | |<-------------| |
2260// | | | |
2261// | | | |
2262// | |
2263// | submgr restart |
2264// | |
2265// | | | |
2266// | SubDelReq 2 | |
2267// |--------------------------->| |
2268// | | | |
2269// | | | SubDelReq 2 |
2270// | | |------------->|
2271// | | | |
2272// | | | SubDelReq 2 |
2273// | | |------------->|
2274// | | | |
2275// | SubDelResp 2 | |
2276// |<---------------------------| |
2277//
2278//-----------------------------------------------------------------------------
2279
2280func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2281 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2282
2283 //Req1
2284 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2285 rparams1.Init()
2286 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2287 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2288 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2289 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2290
2291 //Req2
2292 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2293 rparams2.Init()
2294 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2295 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2296
2297 // Check subscription
2298 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2299 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2300 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002301 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002302
2303 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002304 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002305
2306 // Check that subscription is restored correctly after restart
2307 resp, _ = xapp.Subscription.QuerySubscriptions()
2308 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2309 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002310 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002311
2312 //Del1
2313 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2314 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2315 xappConn1.RecvSubsDelResp(t, deltrans1)
2316 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2317
2318 mainCtrl.SimulateRestart(t)
2319 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2320
2321 //Del2
2322 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2323 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2324
2325 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2326 xappConn2.RecvSubsDelResp(t, deltrans2)
2327
2328 //Wait that subs is cleaned
2329 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2330
2331 xappConn1.TestMsgChanEmpty(t)
2332 xappConn2.TestMsgChanEmpty(t)
2333 e2termConn1.TestMsgChanEmpty(t)
2334 mainCtrl.wait_registry_empty(t, 10)
2335}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002336
archaggeafbf95f2021-04-14 08:54:05 +03002337//*****************************************************************************
2338// REST interface test cases
2339//*****************************************************************************
2340
Anssi Mannila47518ae2021-04-16 09:27:07 +03002341//-----------------------------------------------------------------------------
2342// Test debug GET and POST requests
2343//
2344// curl
2345// +-------+ +---------+
2346// | user | | submgr |
2347// +-------+ +---------+
2348// | |
2349// | GET/POST Req |
2350// |------------->|
2351// | Resp |
2352// |<-------------|
2353// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002354func TestGetSubscriptions(t *testing.T) {
2355
2356 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2357}
2358
2359func TestGetSymptomData(t *testing.T) {
2360
2361 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2362}
2363
2364func TestPostdeleteSubId(t *testing.T) {
2365
2366 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2367}
2368
2369func TestPostEmptyDb(t *testing.T) {
2370
2371 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2372}
archaggeafbf95f2021-04-14 08:54:05 +03002373
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002374func TestGetRestSubscriptions(t *testing.T) {
2375
2376 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2377}
2378
archaggeafbf95f2021-04-14 08:54:05 +03002379//-----------------------------------------------------------------------------
2380// TestRESTSubReqAndRouteNok
2381//
2382// stub stub
2383// +-------+ +---------+ +---------+
2384// | xapp | | submgr | | rtmgr |
2385// +-------+ +---------+ +---------+
2386// | | |
2387// | RESTSubReq | |
2388// |---------------->| |
2389// | | |
2390// | RESTSubResp | |
2391// |<----------------| |
2392// | | RouteCreate |
2393// | |------------->|
2394// | | |
2395// | | RouteCreate |
2396// | | status:400 |
2397// | |(Bad request) |
2398// | |<-------------|
2399// | RESTNotif | |
2400// |<----------------| |
2401// | | |
2402// | [SUBS INT DELETE] |
2403// | | |
2404// | RESTSubDelReq | |
2405// |---------------->| |
2406// | RESTSubDelResp | |
2407// |<----------------| |
2408//
2409//-----------------------------------------------------------------------------
2410func TestRESTSubReqAndRouteNok(t *testing.T) {
2411 CaseBegin("TestRESTSubReqAndRouteNok")
2412
2413 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002414 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002415 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002416 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002417 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002418 Counter{cRestSubDelReqFromXapp, 1},
2419 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002420 })
2421
2422 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002423
Markku Virtanenda34eec2021-05-20 08:22:04 +00002424 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2425 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002426 newSubsId := mainCtrl.get_registry_next_subid(t)
2427
2428 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002429 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002430 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002431 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002432 waiter.WaitResult(t)
2433
archaggeafbf95f2021-04-14 08:54:05 +03002434 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002435 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002436
2437 // Del
2438 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2439
2440 // Wait that subs is cleaned
2441 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2442 waitSubsCleanup(t, e2SubsId, 10)
2443 mainCtrl.VerifyCounterValues(t)
2444}
2445
2446func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2447 CaseBegin("TestSubReqAndRouteUpdateNok")
2448
2449 //Init counter check
2450 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002451 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002452 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002453 Counter{cSubReqToE2, 1},
2454 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002455 Counter{cRestSubNotifToXapp, 1},
2456 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002457 Counter{cRouteCreateUpdateFail, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002458 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002459 Counter{cSubDelReqToE2, 1},
2460 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002461 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002462 })
2463
2464 var params *teststube2ap.RESTSubsReqParams = nil
2465
2466 //Subs Create
2467 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2468
2469 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2470
2471 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2472 waiter := rtmgrHttp.AllocNextEvent(false)
2473 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002474 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002475 params.SetMeid("RAN_NAME_1")
2476 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002477 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002478 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002479 waiter.WaitResult(t)
2480 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2481 xappConn2.WaitRESTNotification(t, restSubId2)
2482
2483 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2484
2485 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2486
2487 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2488 //Wait that subs is cleaned
2489 waitSubsCleanup(t, e2SubsId, 10)
2490
2491 mainCtrl.VerifyCounterValues(t)
2492}
2493
2494func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2495 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2496
2497 // Init counter check
2498 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002499 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002500 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002501 Counter{cSubReqToE2, 1},
2502 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002503 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002504 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002505 Counter{cRouteDeleteFail, 1},
2506 Counter{cSubDelReqToE2, 1},
2507 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002508 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002509 })
2510
2511 var params *teststube2ap.RESTSubsReqParams = nil
2512
2513 //Subs Create
2514 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2515
2516 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2517
2518 waiter := rtmgrHttp.AllocNextEvent(false)
2519 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2520 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2521 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2522 waiter.WaitResult(t)
2523
2524 waitSubsCleanup(t, e2SubsId, 10)
2525
2526 mainCtrl.VerifyCounterValues(t)
2527}
2528
2529func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2530 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2531
2532 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002533 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002534 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002535 Counter{cSubReqToE2, 1},
2536 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002537 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002538 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002539 Counter{cRouteDeleteUpdateFail, 1},
2540 Counter{cSubDelReqToE2, 1},
2541 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002542 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002543 })
2544
2545 var params *teststube2ap.RESTSubsReqParams = nil
2546
2547 //Subs Create
2548 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2549
2550 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2551 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2552
2553 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2554
2555 //Del1, this shall fail on rtmgr side
2556 waiter := rtmgrHttp.AllocNextEvent(false)
2557 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2558 waiter.WaitResult(t)
2559
2560 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2561
2562 //Del2
2563 deleteXapp2Subscription(t, &restSubId2)
2564
2565 waitSubsCleanup(t, e2SubsId2, 10)
2566
2567 mainCtrl.VerifyCounterValues(t)
2568}
2569
2570//-----------------------------------------------------------------------------
2571// TestRESTSubReqRetransmission
2572//
2573// stub stub
2574// +-------+ +---------+ +---------+
2575// | xapp | | submgr | | e2term |
2576// +-------+ +---------+ +---------+
2577// | | |
2578// | RESTSubReq1 | |
2579// |---------------->| |
2580// | | |
2581// | RESTSubResp | |
2582// |<----------------| |
2583// | | SubReq1 |
2584// | |------------->|
2585// | | |
2586// | RESTSubReq2 | |
2587// | (retrans) | |
2588// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002589// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002590// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002591// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002592// | | SubResp1 |
2593// | |<-------------|
2594// | RESTNotif1 | |
2595// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002596// | | |
2597// | [SUBS DELETE] |
2598// | | |
2599//
2600//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002601
archaggeafbf95f2021-04-14 08:54:05 +03002602func TestRESTSubReqRetransmission(t *testing.T) {
2603 CaseBegin("TestRESTSubReqRetransmission")
2604
2605 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002606 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002607 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002608 Counter{cSubReqToE2, 1},
2609 Counter{cSubRespFromE2, 1},
2610 Counter{cRestSubNotifToXapp, 1},
2611 Counter{cRestSubDelReqFromXapp, 1},
2612 Counter{cSubDelReqToE2, 1},
2613 Counter{cSubDelRespFromE2, 1},
2614 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002615 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002616 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002617 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2618 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2619
2620 // Subs Create
2621 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002622
2623 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2624 // gets into execution before the rtmgrg responds for the first one.
2625 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002626 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002627 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenb642a192021-06-09 09:08:14 +00002628 xappConn2.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002629
2630 waiter.WaitResult(t)
2631
Markku Virtanenb642a192021-06-09 09:08:14 +00002632 xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
archaggeafbf95f2021-04-14 08:54:05 +03002633
2634 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2635 // the order is not significant he6re.
2636 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2637 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002638
2639 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002640 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03002641
2642 // Del1
2643 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2644 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2645 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2646
Markku Virtanenb642a192021-06-09 09:08:14 +00002647 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002648
2649 mainCtrl.VerifyCounterValues(t)
2650}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002651
Markku Virtanen42723e22021-06-15 10:09:23 +03002652//-----------------------------------------------------------------------------
2653// stub stub stub
2654// +-------+ +---------+ +---------+ +---------+
2655// | xapp | | submgr | | e2term | | rtmgr |
2656// +-------+ +---------+ +---------+ +---------+
2657// | | | |
2658// | RESTSubReq | | |
2659// |---------------->| | |
2660// | RESTSubResp | | |
2661// |<----------------| | |
2662// | | RouteCreate | |
2663// | |--------------------------->|
2664// | | RouteResponse| |
2665// | |<---------------------------| // The order of these events may vary
2666// | | SubReq | |
2667// | |------------->| | // The order of these events may vary
2668// | | SubResp | |
2669// | |<-------------| |
2670// | RESTNotif1 | | |
2671// |<----------------| | |
2672// | RESTSubReq | | |
2673// | [RETRANS1] | | |
2674// |---------------->| | |
2675// | RESTNotif1 | | |
2676// |<----------------| | |
2677// | RESTSubReq | | |
2678// | [RETRANS2] | | |
2679// |---------------->| | |
2680// | RESTNotif1 | | |
2681// |<----------------| | |
2682// | RESTSubDelReq | | |
2683// |---------------->| | |
2684// | | SubDelReq | |
2685// | |------------->| |
2686// | RESTSubDelResp| | |
2687// |<----------------| | |
2688// | | SubDelResp | |
2689// | |<-------------| |
2690// | | | |
2691//
2692//-----------------------------------------------------------------------------
2693
2694func TestRESTSubReqRetransmissionV2(t *testing.T) {
2695 CaseBegin("TestRESTSubReqRetransmissionV2")
2696
2697 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2698 Counter{cRestSubReqFromXapp, 3},
2699 Counter{cRestSubRespToXapp, 3},
2700 Counter{cSubReqToE2, 1},
2701 Counter{cSubRespFromE2, 1},
2702 Counter{cRestSubNotifToXapp, 3},
2703 Counter{cRestSubDelReqFromXapp, 1},
2704 Counter{cSubDelReqToE2, 1},
2705 Counter{cSubDelRespFromE2, 1},
2706 Counter{cRestSubDelRespToXapp, 1},
2707 })
2708
2709 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2710
2711 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2712
2713 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2714
2715 //1.st resend
2716 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2717
2718 assert.Equal(t, restSubId_resend, restSubId)
2719
2720 <-time.After(100 * time.Millisecond)
2721
2722 //2.nd resend
2723 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2724
2725 assert.Equal(t, restSubId_resend2, restSubId)
2726
2727 <-time.After(100 * time.Millisecond)
2728
2729 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2730
2731 waitSubsCleanup(t, e2SubsId, 10)
2732
2733 //Wait that subs is cleaned
2734 mainCtrl.VerifyCounterValues(t)
2735}
2736
2737//-----------------------------------------------------------------------------
2738// stub stub stub
2739// +-------+ +---------+ +---------+ +---------+
2740// | xapp | | submgr | | e2term | | rtmgr |
2741// +-------+ +---------+ +---------+ +---------+
2742// | | | |
2743// | RESTSubReq | | |
2744// |---------------->| | |
2745// | RESTSubResp | | |
2746// |<----------------| | |
2747// | | RouteCreate | |
2748// | |--------------------------->|
2749// | | RouteResponse| |
2750// | |<---------------------------| // The order of these events may vary
2751// | | SubReq | |
2752// | |------------->| | // The order of these events may vary
2753// | | SubResp | |
2754// | |<-------------| |
2755// | RESTNotif1 | | |
2756// |<----------------| | |
2757// | RESTSubReq | | |
2758// | [RETRANS, with RESTsubsId] | |
2759// |---------------->| | |
2760// | RESTNotif1 | | |
2761// |<----------------| | |
2762// | RESTSubReq | | |
2763// | [RETRANS, without RESTsubsId] | |
2764// |---------------->| | |
2765// | RESTNotif1 | | |
2766// |<----------------| | |
2767// | RESTSubDelReq | | |
2768// |---------------->| | |
2769// | | SubDelReq | |
2770// | |------------->| |
2771// | RESTSubDelResp| | |
2772// |<----------------| | |
2773// | | SubDelResp | |
2774// | |<-------------| |
2775// | | | |
2776//
2777//-----------------------------------------------------------------------------
2778func TestRESTSubReqRetransmissionV3(t *testing.T) {
2779 CaseBegin("TestRESTSubReqRetransmissionV3")
2780
2781 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2782 Counter{cRestSubReqFromXapp, 3},
2783 Counter{cRestSubRespToXapp, 3},
2784 Counter{cSubReqToE2, 1},
2785 Counter{cSubRespFromE2, 1},
2786 Counter{cRestSubNotifToXapp, 3},
2787 Counter{cRestSubDelReqFromXapp, 1},
2788 Counter{cSubDelReqToE2, 1},
2789 Counter{cSubDelRespFromE2, 1},
2790 Counter{cRestSubDelRespToXapp, 1},
2791 })
2792
2793 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2794
2795 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2796
2797 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2798
2799 <-time.After(100 * time.Millisecond)
2800
2801 //1.st resend with subscription ID
2802 params.SetSubscriptionID(&restSubId)
2803 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2804
2805 assert.Equal(t, restSubId_resend, restSubId)
2806
2807 <-time.After(100 * time.Millisecond)
2808
2809 //2.nd resend without subscription ID (faking app restart)
2810 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
2811 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2812
2813 assert.Equal(t, restSubId_resend2, restSubId)
2814
2815 <-time.After(100 * time.Millisecond)
2816
2817 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2818
2819 waitSubsCleanup(t, e2SubsId, 10)
2820
2821 //Wait that subs is cleaned
2822 mainCtrl.VerifyCounterValues(t)
2823}
2824
2825//-----------------------------------------------------------------------------
2826// stub stub stub
2827// +-------+ +---------+ +---------+ +---------+
2828// | xapp | | submgr | | e2term | | rtmgr |
2829// +-------+ +---------+ +---------+ +---------+
2830// | | | |
2831// | RESTSubReq | | |
2832// |---------------->| | |
2833// | RESTSubResp | | |
2834// |<----------------| | |
2835// | | RouteCreate | |
2836// | |--------------------------->|
2837// | | RouteResponse| |
2838// | |<---------------------------|
2839// | | SubReq | |
2840// | |------------->| |
2841// | | SubResp | |
2842// | |<-------------| |
2843// | RESTNotif1 | | |
2844// |<----------------| | |
2845// | RESTSubReq | | |
2846// | [with RestSUbsId + one additional e2 subDetail]
2847// |---------------->| | |
2848// | RESTNotif1 | | |
2849// | [for initial e2 subDetail] | |
2850// |<----------------| | |
2851// | | RouteCreate | |
2852// | |--------------------------->|
2853// | | RouteResponse| |
2854// | |<---------------------------|
2855// | | SubReq | |
2856// | |------------->| |
2857// | | SubResp | |
2858// | |<-------------| |
2859// | RESTNotif1 | | |
2860// |<----------------| | |
2861// | RESTSubReq | | |
2862// | [with RESTsubsId initial request] |
2863// |---------------->| | |
2864// | RESTNotif1 | | |
2865// |<----------------| | |
2866// | RESTSubDelReq | | |
2867// |---------------->| | |
2868// | RESTSubDelResp| | |
2869// |<----------------| | |
2870// | | SubDelReq | |
2871// | |------------->| |
2872// | | SubDelResp | |
2873// | |<-------------| |
2874// | | SubDelReq | |
2875// | |------------->| |
2876// | | SubDelResp | |
2877// | |<-------------| |
2878// | | | |
2879//
2880//-----------------------------------------------------------------------------
2881
2882func TestRESTSubReqRetransmissionV4(t *testing.T) {
2883 CaseBegin("TestRESTSubReqRetransmissionV4")
2884
2885 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2886 Counter{cRestSubReqFromXapp, 3},
2887 Counter{cRestSubRespToXapp, 3},
2888 Counter{cSubReqToE2, 2},
2889 Counter{cSubRespFromE2, 2},
2890 Counter{cRestSubNotifToXapp, 4},
2891 Counter{cRestSubDelReqFromXapp, 1},
2892 Counter{cSubDelReqToE2, 2},
2893 Counter{cSubDelRespFromE2, 2},
2894 Counter{cRestSubDelRespToXapp, 1},
2895 })
2896
2897 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2898
2899 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2900
2901 <-time.After(100 * time.Millisecond)
2902
2903 // Send modified requst, this time with e2 subscriptions.
2904 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
2905 params2.SetSubscriptionID(&restSubId)
2906
2907 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00002908 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03002909 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
2910 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00002911 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
2912 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03002913
2914 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2915
Markku Virtanen2b512b62021-07-30 12:04:00 +00002916 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03002917 xappConn1.ExpectRESTNotification(t, restSubId_resend)
2918 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2919 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
2920 assert.NotEqual(t, e2SubsId2, 0)
2921
2922 <-time.After(100 * time.Millisecond)
2923
2924 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
2925 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
2926 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00002927 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03002928 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
2929 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2930 assert.Equal(t, restSubId_resend, restSubId_resend2)
2931
Markku Virtanen2b512b62021-07-30 12:04:00 +00002932 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
2933 assert.Equal(t, e2SubsId, e2SubsId1)
2934
Markku Virtanen42723e22021-06-15 10:09:23 +03002935 // Delete both e2 subscriptions
2936 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2937 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
2938 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
2939
2940 waitSubsCleanup(t, e2SubsId, 10)
2941
2942 //Wait that subs is cleaned
2943 mainCtrl.VerifyCounterValues(t)
2944}
2945
2946//-----------------------------------------------------------------------------
2947// stub stub stub
2948// +-------+ +---------+ +---------+ +---------+
2949// | xapp | | submgr | | e2term | | rtmgr |
2950// +-------+ +---------+ +---------+ +---------+
2951// | | | |
2952// | RESTSubReq | | |
2953// |---------------->| | |
2954// | RESTSubResp | | |
2955// |<----------------| | |
2956// | | RouteCreate | |
2957// | |--------------------------->|
2958// | | RouteResponse| |
2959// | |<---------------------------|
2960// | | SubReq | |
2961// | |------------->| |
2962// | | SubResp | |
2963// | |<-------------| |
2964// | RESTNotif1 | | |
2965// |<----------------| | |
2966// | RESTSubReq | | |
2967// | [with RestSUbsId + one additional e2 subDetail]
2968// |---------------->| | |
2969// | RESTNotif1 | | |
2970// | [for initial e2 subDetail] | |
2971// |<----------------| | |
2972// | | RouteCreate | |
2973// | |--------------------------->|
2974// | | RouteResponse| |
2975// | |<---------------------------|
2976// | | SubReq | |
2977// | |------------->| |
2978// | | SubResp | |
2979// | |<-------------| |
2980// | RESTNotif1 | | |
2981// |<----------------| | |
2982// | RESTSubReq | | |
2983// | [without RESTsubsId initial request] |
2984// |---------------->| | |
2985// | RESTNotif1 | | |
2986// |<----------------| | |
2987// | RESTSubDelReq | | |
2988// |---------------->| | |
2989// | RESTSubDelResp| | |
2990// |<----------------| | |
2991// | | SubDelReq | |
2992// | |------------->| |
2993// | | SubDelResp | |
2994// | |<-------------| |
2995// | | SubDelReq | |
2996// | |------------->| |
2997// | | SubDelResp | |
2998// | |<-------------| |
2999// | | | |
3000//
3001//-----------------------------------------------------------------------------
3002
3003func TestRESTSubReqRetransmissionV5(t *testing.T) {
3004 CaseBegin("TestRESTSubReqRetransmissionV5")
3005
3006 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3007 Counter{cRestSubReqFromXapp, 3},
3008 Counter{cRestSubRespToXapp, 3},
3009 Counter{cSubReqToE2, 2},
3010 Counter{cSubRespFromE2, 2},
3011 Counter{cRestSubNotifToXapp, 4},
3012 Counter{cRestSubDelReqFromXapp, 1},
3013 Counter{cSubDelReqToE2, 2},
3014 Counter{cSubDelRespFromE2, 2},
3015 Counter{cRestSubDelRespToXapp, 1},
3016 })
3017
3018 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3019
3020 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3021
3022 <-time.After(100 * time.Millisecond)
3023
3024 // Send modified requst, this time with e2 subscriptions.
3025 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3026 params2.SetSubscriptionID(&restSubId)
3027
3028 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003029 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003030 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3031 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3032
Markku Virtanen2b512b62021-07-30 12:04:00 +00003033 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3034 assert.Equal(t, e2SubsId, e2SubsId1)
3035 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3036 xappConn1.DecrementRequestCount()
3037
Markku Virtanen42723e22021-06-15 10:09:23 +03003038 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3039
3040 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3041 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3042 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3043 assert.NotEqual(t, e2SubsId2, 0)
3044
3045 <-time.After(100 * time.Millisecond)
3046
3047 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3048 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003049 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003050 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3051 // md5sum shall find the original request
3052 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3053 assert.Equal(t, restSubId_resend, restSubId_resend2)
3054
Markku Virtanen2b512b62021-07-30 12:04:00 +00003055 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3056 assert.Equal(t, e2SubsId, e2SubsId1)
3057
Markku Virtanen42723e22021-06-15 10:09:23 +03003058 // Delete both e2 subscriptions
3059 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3060 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3061 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3062
3063 waitSubsCleanup(t, e2SubsId, 10)
3064
3065 //Wait that subs is cleaned
3066 mainCtrl.VerifyCounterValues(t)
3067}
3068
3069//-----------------------------------------------------------------------------
3070// stub stub stub
3071// +-------+ +---------+ +---------+ +---------+
3072// | xapp | | submgr | | e2term | | rtmgr |
3073// +-------+ +---------+ +---------+ +---------+
3074// | | | |
3075// | RESTSubReq | | |
3076// |---------------->| | |
3077// | RESTSubResp | | |
3078// |<----------------| | |
3079// | | RouteCreate | |
3080// | |--------------------------->|
3081// | | RouteResponse| |
3082// | |<---------------------------|
3083// | | SubReq | |
3084// | |------------->| |
3085// | | SubResp | |
3086// | |<-------------| |
3087// | RESTNotif1 | | |
3088// |<----------------| | |
3089// | RESTSubReq | | |
3090// | [with RestSUbsId + one additional e2 subDetail]
3091// |---------------->| | |
3092// | RESTNotif1 | | |
3093// | [for initial e2 subDetail] | |
3094// |<----------------| | |
3095// | | RouteCreate | |
3096// | |--------------------------->|
3097// | | RouteResponse| |
3098// | |<---------------------------|
3099// | | SubReq | |
3100// | |------------->| |
3101// | | SubResp | |
3102// | |<-------------| |
3103// | RESTNotif1 | | |
3104// |<----------------| | |
3105// | RESTSubDelReq | | |
3106// |---------------->| | |
3107// | RESTSubDelResp| | |
3108// |<----------------| | |
3109// | | SubDelReq | |
3110// | |------------->| |
3111// | | SubDelResp | |
3112// | |<-------------| |
3113// | | SubDelReq | |
3114// | |------------->| |
3115// | | SubDelResp | |
3116// | |<-------------| |
3117// | RESTSubReq | | |
3118// | [with RESTsubsId initial request] |
3119// |---------------->| | |
3120// | RESTSubResp | | |
3121// |<----------------| | |
3122// | | RouteCreate | |
3123// | |--------------------------->|
3124// | | RouteResponse| |
3125// | |<---------------------------|
3126// | | SubReq | |
3127// | |------------->| |
3128// | | SubResp | |
3129// | |<-------------| |
3130// | RESTNotif1 | | |
3131// |<----------------| | |
3132// | | | |
3133//
3134//-----------------------------------------------------------------------------
3135func TestRESTSubReqRetransmissionV6(t *testing.T) {
3136 CaseBegin("TestRESTSubReqRetransmissionV6")
3137
3138 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3139 Counter{cRestSubReqFromXapp, 3},
3140 Counter{cRestSubRespToXapp, 3},
3141 Counter{cSubReqToE2, 3},
3142 Counter{cSubRespFromE2, 3},
3143 Counter{cRestSubNotifToXapp, 4},
3144 Counter{cRestSubDelReqFromXapp, 2},
3145 Counter{cSubDelReqToE2, 3},
3146 Counter{cSubDelRespFromE2, 3},
3147 Counter{cRestSubDelRespToXapp, 2},
3148 })
3149
3150 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3151
3152 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3153
3154 <-time.After(100 * time.Millisecond)
3155
3156 // Send modified requst, this time with e2 subscriptions.
3157 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3158 params2.SetSubscriptionID(&restSubId)
3159
3160 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003161 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003162 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3163 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3164
Markku Virtanen2b512b62021-07-30 12:04:00 +00003165 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3166 assert.Equal(t, e2SubsId, e2SubsId1)
3167
Markku Virtanen42723e22021-06-15 10:09:23 +03003168 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3169
3170 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3171 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3172 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3173 assert.NotEqual(t, e2SubsId2, 0)
3174
3175 <-time.After(100 * time.Millisecond)
3176
3177 // Delete both e2 subscriptions
3178 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3179 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3180 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3181
3182 waitSubsCleanup(t, e2SubsId, 10)
3183
3184 // Resend the original request, we shall find it's previous md5sum/restsubs
3185 // but the restsubscription has been already removed. This shall trigger a
3186 // fresh create.
3187 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3188
3189 <-time.After(100 * time.Millisecond)
3190
3191 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3192
3193 waitSubsCleanup(t, e2SubsId, 10)
3194
3195 //Wait that subs is cleaned
3196 mainCtrl.VerifyCounterValues(t)
3197}
3198
archaggeafbf95f2021-04-14 08:54:05 +03003199func TestRESTSubDelReqRetransmission(t *testing.T) {
3200 CaseBegin("TestRESTSubDelReqRetransmission")
3201
3202 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003203 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003204 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003205 Counter{cSubReqToE2, 1},
3206 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003207 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003208 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003209 Counter{cSubDelReqToE2, 1},
3210 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003211 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003212 })
3213
3214 var params *teststube2ap.RESTSubsReqParams = nil
3215
3216 //Subs Create
3217 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3218
3219 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3220
3221 //Subs Delete
3222 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3223 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3224
3225 seqBef := mainCtrl.get_msgcounter(t)
3226 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3227 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3228
3229 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3230
3231 waitSubsCleanup(t, e2SubsId, 10)
3232
3233 mainCtrl.VerifyCounterValues(t)
3234}
3235
3236//-----------------------------------------------------------------------------
3237// TestRESTSubReqDelReq
3238//
3239// stub stub
3240// +-------+ +---------+ +---------+
3241// | xapp | | submgr | | e2term |
3242// +-------+ +---------+ +---------+
3243// | | |
3244// | RESTSubReq | |
3245// |---------------->| |
3246// | | |
3247// | RESTSubResp | |
3248// |<----------------| |
3249// | | SubReq |
3250// | |------------->|
3251// | RESTSubDelReq | |
3252// |---------------->| |
3253// | RESTSubDelResp | |
3254// | unsuccess | |
3255// |<----------------| |
3256// | | SubResp |
3257// | |<-------------|
3258// | RESTNotif1 | |
3259// |<----------------| |
3260// | | |
3261// | [SUBS DELETE] |
3262// | | |
3263//
3264//-----------------------------------------------------------------------------
3265func TestRESTSubReqDelReq(t *testing.T) {
3266 CaseBegin("TestRESTSubReqDelReq")
3267
3268 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003269 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003270 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003271 Counter{cSubReqToE2, 1},
3272 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003273 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003274 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003275 Counter{cSubDelReqToE2, 1},
3276 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003277 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003278 })
3279
3280 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003281
3282 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003283 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003284 restSubId := xappConn1.SendRESTSubsReq(t, params)
3285
3286 // Del. This will fail as processing of the subscription
3287 // is still ongoing in submgr. Deletion is not allowed before
3288 // subscription creation has been completed.
3289 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3290 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3291 xappConn1.ExpectRESTNotification(t, restSubId)
3292 e2termConn1.SendSubsResp(t, crereq, cremsg)
3293 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3294
3295 // Retry del
3296 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3297
3298 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3299 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3300
3301 // Wait that subs is cleaned
3302 waitSubsCleanup(t, e2SubsId, 10)
3303 mainCtrl.VerifyCounterValues(t)
3304
3305}
3306
3307func TestRESTSubDelReqCollision(t *testing.T) {
3308 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3309}
3310
3311func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3312 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3313
3314 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003315 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003316 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003317 Counter{cSubReqToE2, 2},
3318 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003319 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003320 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003321 Counter{cSubDelReqToE2, 2},
3322 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003323 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003324 })
3325
3326 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003327 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003328 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003329 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003330
3331 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003332 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003333 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003334 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003335
3336 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3337 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3338
3339 //XappConn1 receives both of the responses
3340 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3341
3342 //Resp1
3343 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3344 //Resp2
3345 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3346
3347 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003348 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003349 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003350 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003351
3352 //Del1
3353 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3354 //Del2
3355 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3356
3357 //Wait that subs is cleaned
3358 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3359 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3360
3361 mainCtrl.VerifyCounterValues(t)
3362
3363}
3364
3365func TestRESTSameSubsDiffRan(t *testing.T) {
3366 CaseBegin("TestRESTSameSubsDiffRan")
3367
3368 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003369 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003370 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003371 Counter{cSubReqToE2, 2},
3372 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003373 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003374 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003375 Counter{cSubDelReqToE2, 2},
3376 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003377 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003378 })
3379
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003380 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003381 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003382 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003383
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003384 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003385 params.SetMeid("RAN_NAME_2")
3386 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003387 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003388
3389 //Del1
3390 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3391 //Del2
3392 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3393
3394 //Wait that subs is cleaned
3395 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3396 waitSubsCleanup(t, e2SubsId2, 10)
3397
3398 mainCtrl.VerifyCounterValues(t)
3399
3400}
3401
3402func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3403 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3404
3405 // Init counter check
3406 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003407 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003408 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003409 Counter{cSubReqToE2, 1},
3410 Counter{cSubReReqToE2, 1},
3411 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003412 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003413 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003414 Counter{cSubDelReqToE2, 1},
3415 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003416 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003417 })
3418
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003419 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003420 restSubId := xappConn1.SendRESTSubsReq(t, params)
3421
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003422 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003423
3424 // Catch the first message and ignore it
3425 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003426 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003427
3428 // The second request is being handled normally
3429 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3430 xappConn1.ExpectRESTNotification(t, restSubId)
3431 e2termConn1.SendSubsResp(t, crereq, cremsg)
3432 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3433
3434 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3435
3436 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3437
3438 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3439 //Wait that subs is cleaned
3440 waitSubsCleanup(t, e2SubsId, 10)
3441
3442 mainCtrl.VerifyCounterValues(t)
3443
3444}
3445
3446//-----------------------------------------------------------------------------
3447// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3448//
3449// stub stub
3450// +-------+ +---------+ +---------+
3451// | xapp | | submgr | | e2term |
3452// +-------+ +---------+ +---------+
3453// | | |
3454// | RESTSubReq | |
3455// |---------------->| |
3456// | | |
3457// | RESTSubResp | |
3458// |<----------------| |
3459// | | SubReq |
3460// | |------------->|
3461// | | |
3462// | | |
3463// | | SubReq |
3464// | |------------->|
3465// | | |
3466// | | SubDelReq |
3467// | |------------->|
3468// | | |
3469// | | |
3470// | | SubDelReq |
3471// | |------------->|
3472// | | |
3473// | | |
3474// | | SubDelResp |
3475// | |<-------------|
3476// | RESTNotif | |
3477// | unsuccess | |
3478// |<----------------| |
3479// | | |
3480// | [SUBS DELETE] |
3481// | | |
3482//
3483//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003484
archaggeafbf95f2021-04-14 08:54:05 +03003485func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3486 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3487
3488 // Init counter check
3489 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003490 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003491 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003492 Counter{cSubReqToE2, 1},
3493 Counter{cSubReReqToE2, 1},
3494 Counter{cSubReqTimerExpiry, 2},
3495 Counter{cSubDelReqToE2, 1},
3496 Counter{cSubDelRespFromE2, 1},
3497 })
3498
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003499 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003500 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003501 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003502
3503 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003504 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003505
3506 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003507 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003508
3509 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003510 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003511 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003512 xappConn1.WaitRESTNotification(t, restSubId)
3513
3514 // Wait that subs is cleaned
3515 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
3516
3517 mainCtrl.VerifyCounterValues(t)
3518}
3519
3520func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3521 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3522
3523 // Init counter check
3524 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003525 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003526 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003527 Counter{cSubReqToE2, 1},
3528 Counter{cSubReReqToE2, 1},
3529 Counter{cSubReqTimerExpiry, 2},
3530 Counter{cSubDelReqToE2, 1},
3531 Counter{cSubDelReqTimerExpiry, 2},
3532 })
3533
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003534 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003535 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003536 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003537
3538 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003539 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003540
3541 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003542 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003543
3544 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003545 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003546
Markku Virtanen55d2a282021-06-04 14:46:56 +03003547 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003548 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003549 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003550
3551 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3552
3553 waitSubsCleanup(t, e2SubsId, 10)
3554
3555 mainCtrl.VerifyCounterValues(t)
3556
3557}
3558
3559//-----------------------------------------------------------------------------
3560// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3561//
3562// stub stub
3563// +-------+ +---------+ +---------+
3564// | xapp | | submgr | | e2term |
3565// +-------+ +---------+ +---------+
3566// | | |
3567// | RESTSubReq | |
3568// |---------------->| |
3569// | | |
3570// | RESTSubResp | |
3571// |<----------------| |
3572// | | SubReq |
3573// | |------------->|
3574// | | |
3575// | | |
3576// | | SubReq |
3577// | |------------->|
3578// | | |
3579// | | SubDelReq |
3580// | |------------->|
3581// | | |
3582// | | |
3583// | | SubDelReq |
3584// | |------------->|
3585// | | |
3586// | | |
3587// | | SubDelResp |
3588// | |<-------------|
3589// | RESTNotif | |
3590// | unsuccess | |
3591// |<----------------| |
3592// | | |
3593// | [SUBS DELETE] |
3594// | | |
3595//
3596//-----------------------------------------------------------------------------
3597func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3598 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3599
3600 // Init counter check
3601 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003602 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003603 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003604 Counter{cSubReqToE2, 1},
3605 Counter{cSubReReqToE2, 1},
3606 Counter{cSubReqTimerExpiry, 2},
3607 Counter{cSubDelReqToE2, 1},
3608 Counter{cSubDelReReqToE2, 1},
3609 Counter{cSubDelReqTimerExpiry, 2},
3610 })
3611
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003612 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003613 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003614 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003615
3616 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003617 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003618
3619 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003620 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003621
3622 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003623 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003624
Markku Virtanen55d2a282021-06-04 14:46:56 +03003625 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003626 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003627 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003628
3629 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3630
3631 waitSubsCleanup(t, e2SubsId, 10)
3632
3633 mainCtrl.VerifyCounterValues(t)
3634}
3635
3636//-----------------------------------------------------------------------------
3637// TestRESTSubReqSubFailRespInSubmgr
3638//
3639// stub stub
3640// +-------+ +---------+ +---------+
3641// | xapp | | submgr | | e2term |
3642// +-------+ +---------+ +---------+
3643// | | |
3644// | RESTSubReq | |
3645// |---------------->| |
3646// | | |
3647// | RESTSubResp | |
3648// |<----------------| |
3649// | | SubReq |
3650// | |------------->|
3651// | | |
3652// | | SubFail |
3653// | |<-------------|
3654// | | |
3655// | | SubDelReq |
3656// | |------------->|
3657// | | |
3658// | | SubDelResp |
3659// | |<-------------|
3660// | | |
3661// | RESTNotif | |
3662// | unsuccess | |
3663// |<----------------| |
3664// | | |
3665// | [SUBS DELETE] |
3666// | | |
3667//
3668//-----------------------------------------------------------------------------
3669func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3670 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3671
3672 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003673 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003674 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003675 Counter{cSubReqToE2, 1},
3676 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003677 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003678 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003679 })
3680
3681 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003682 const e2Timeout int64 = 2
3683 const e2RetryCount int64 = 1
3684 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03003685
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003686 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003687 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03003688 restSubId := xappConn1.SendRESTSubsReq(t, params)
3689
3690 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3691 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3692 fparams1.Set(crereq1)
3693 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3694
3695 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003696 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003697 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3698 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003699 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003700
3701 // REST subscription sill there to be deleted
3702 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3703
3704 // Wait that subs is cleaned
3705 waitSubsCleanup(t, e2SubsId, 10)
3706
3707 mainCtrl.VerifyCounterValues(t)
3708
3709}
3710
3711//-----------------------------------------------------------------------------
3712// TestRESTSubDelReqRetryInSubmgr
3713//
3714// stub stub
3715// +-------+ +---------+ +---------+
3716// | xapp | | submgr | | e2term |
3717// +-------+ +---------+ +---------+
3718// | | |
3719// | [SUBS CREATE] |
3720// | | |
3721// | | |
3722// | RESTSubDelReq | |
3723// |---------------->| |
3724// | | |
3725// | RESTSubDelResp | |
3726// |<----------------| |
3727// | | SubDelReq |
3728// | |------------->|
3729// | | |
3730// | | SubDelReq |
3731// | |------------->|
3732// | | |
3733// | | SubDelResp |
3734// | |<-------------|
3735// | | |
3736//
3737//-----------------------------------------------------------------------------
3738func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3739 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3740
3741 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003742 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003743 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003744 Counter{cSubReqToE2, 1},
3745 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003746 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003747 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003748 Counter{cSubDelReqToE2, 1},
3749 Counter{cSubDelReReqToE2, 1},
3750 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003751 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003752 })
3753 // Req
3754 var params *teststube2ap.RESTSubsReqParams = nil
3755 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3756
3757 // Del
3758 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3759
3760 // E2t: Receive 1st SubsDelReq
3761 e2termConn1.RecvSubsDelReq(t)
3762
3763 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3764 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3765 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3766
3767 //Wait that subs is cleaned
3768 waitSubsCleanup(t, e2SubsId, 10)
3769
3770 mainCtrl.VerifyCounterValues(t)
3771}
3772
3773//-----------------------------------------------------------------------------
3774// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3775//
3776// stub stub
3777// +-------+ +---------+ +---------+
3778// | xapp | | submgr | | e2term |
3779// +-------+ +---------+ +---------+
3780// | | |
3781// | [SUBS CREATE] |
3782// | | |
3783// | | |
3784// | RESTSubDelReq | |
3785// |---------------->| |
3786// | | |
3787// | RESTSubDelResp | |
3788// |<----------------| |
3789// | | SubDelReq |
3790// | |------------->|
3791// | | |
3792// | | SubDelReq |
3793// | |------------->|
3794// | | |
3795// | | |
3796//
3797//-----------------------------------------------------------------------------
3798func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3799 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3800
3801 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003802 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003803 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003804 Counter{cSubReqToE2, 1},
3805 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003806 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003807 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003808 Counter{cSubDelReqToE2, 1},
3809 Counter{cSubDelReReqToE2, 1},
3810 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003811 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003812 })
3813
3814 // Req
3815 var params *teststube2ap.RESTSubsReqParams = nil
3816 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3817
3818 // Del
3819 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3820
3821 // E2t: Receive 1st SubsDelReq
3822 e2termConn1.RecvSubsDelReq(t)
3823
3824 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3825 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3826 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3827
3828 //Wait that subs is cleaned
3829 waitSubsCleanup(t, e2SubsId, 10)
3830
3831 mainCtrl.VerifyCounterValues(t)
3832}
3833
3834//-----------------------------------------------------------------------------
3835// TestRESTSubDelReqSubDelFailRespInSubmgr
3836//
3837// stub stub
3838// +-------+ +---------+ +---------+
3839// | xapp | | submgr | | e2term |
3840// +-------+ +---------+ +---------+
3841// | | |
3842// | [SUBS CREATE] |
3843// | | |
3844// | | |
3845// | RESTSubDelReq | |
3846// |---------------->| |
3847// | | |
3848// | RESTSubDelResp | |
3849// |<----------------| |
3850// | | SubDelReq |
3851// | |------------->|
3852// | | |
3853// | | SubDelFail |
3854// | |<-------------|
3855// | | |
3856//
3857//-----------------------------------------------------------------------------
3858func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3859 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3860
3861 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003862 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003863 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003864 Counter{cSubReqToE2, 1},
3865 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003866 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003867 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003868 Counter{cSubDelReqToE2, 1},
3869 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003870 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003871 })
3872
3873 // Req
3874 var params *teststube2ap.RESTSubsReqParams = nil
3875 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3876
3877 // Del
3878 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3879
3880 // E2t: Send receive SubsDelReq and send SubsDelFail
3881 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3882 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3883
3884 //Wait that subs is cleaned
3885 waitSubsCleanup(t, e2SubsId, 10)
3886
3887 mainCtrl.VerifyCounterValues(t)
3888}
3889
3890//-----------------------------------------------------------------------------
3891// TestRESTSubReqAndSubDelOkSameAction
3892//
3893// stub stub
3894// +-------+ +-------+ +---------+ +---------+
3895// | xapp2 | | xapp1 | | submgr | | e2term |
3896// +-------+ +-------+ +---------+ +---------+
3897// | | | |
3898// | | RESTSubReq1 | |
3899// | |---------------->| |
3900// | | | |
3901// | | RESTSubResp1 | |
3902// | |<----------------| |
3903// | | | |
3904// | | | SubReq1 |
3905// | | |------------->|
3906// | | | SubResp1 |
3907// | | |<-------------|
3908// | | RESTNotif1 | |
3909// | |<----------------| |
3910// | | | |
3911// | RESTSubReq2 | |
3912// |------------------------------>| |
3913// | | | |
3914// | RESTSubResp2 | |
3915// |<------------------------------| |
3916// | | | |
3917// | | RESTNotif2 | |
3918// |<------------------------------| |
3919// | | | |
3920// | | RESTSubDelReq1 | |
3921// | |---------------->| |
3922// | | | |
3923// | | RESTSubDelResp1 | |
3924// | |<----------------| |
3925// | | | |
3926// | RESTSubDelReq2 | |
3927// |------------------------------>| |
3928// | | | |
3929// | RESTSubDelResp2 | |
3930// |<------------------------------| |
3931// | | | |
3932// | | | SubDelReq2 |
3933// | | |------------->|
3934// | | | |
3935// | | | SubDelResp2 |
3936// | | |<-------------|
3937// | | | |
3938//
3939//-----------------------------------------------------------------------------
3940func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3941 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3942
3943 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003944 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003945 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003946 Counter{cSubReqToE2, 1},
3947 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003948 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003949 Counter{cMergedSubscriptions, 1},
3950 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003951 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003952 Counter{cSubDelReqToE2, 1},
3953 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003954 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003955 })
3956
3957 // Req1
3958 var params *teststube2ap.RESTSubsReqParams = nil
3959
3960 //Subs Create
3961 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3962 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3963
3964 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003965 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003966 params.SetMeid("RAN_NAME_1")
3967
3968 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003969 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003970 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003971 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003972 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003973 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003974 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003975 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03003976
3977 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3978
3979 // Del1
3980 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3981
3982 // Del2
3983 deleteXapp2Subscription(t, &restSubId2)
3984
3985 //Wait that subs is cleaned
3986 waitSubsCleanup(t, e2SubsId2, 10)
3987
3988 mainCtrl.VerifyCounterValues(t)
3989}
3990
3991//-----------------------------------------------------------------------------
3992// TestSubReqAndSubDelOkSameActionParallel
3993//
3994// stub stub stub
3995// +-------+ +-------+ +---------+ +---------+
3996// | xapp2 | | xapp1 | | submgr | | e2term |
3997// +-------+ +-------+ +---------+ +---------+
3998// | | | |
3999// | | | |
4000// | | | |
4001// | | SubReq1 | |
4002// | |------------->| |
4003// | | | |
4004// | | | SubReq1 |
4005// | | |------------->|
4006// | SubReq2 | |
4007// |--------------------------->| |
4008// | | | SubResp1 |
4009// | | |<-------------|
4010// | | SubResp1 | |
4011// | |<-------------| |
4012// | | | SubReq2 |
4013// | | |------------->|
4014// | | | |
4015// | | | SubResp2 |
4016// | | |<-------------|
4017// | SubResp2 | |
4018// |<---------------------------| |
4019// | | | |
4020// | | SubDelReq 1 | |
4021// | |------------->| |
4022// | | | |
4023// | | SubDelResp 1 | |
4024// | |<-------------| |
4025// | | | |
4026// | SubDelReq 2 | |
4027// |--------------------------->| |
4028// | | | |
4029// | | | SubDelReq 2 |
4030// | | |------------->|
4031// | | | |
4032// | | | SubDelReq 2 |
4033// | | |------------->|
4034// | | | |
4035// | SubDelResp 2 | |
4036// |<---------------------------| |
4037//
4038func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4039 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4040
4041 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004042 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004043 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004044 Counter{cSubReqToE2, 2},
4045 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004046 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004047 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004048 Counter{cSubDelReqToE2, 2},
4049 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004050 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004051 })
4052
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004053 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004054 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4055 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4056
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004057 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004058 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4059
4060 xappConn1.ExpectRESTNotification(t, restSubId1)
4061 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4062 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4063
4064 xappConn2.ExpectRESTNotification(t, restSubId2)
4065 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4066 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4067 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4068
4069 // Del1
4070 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4071 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4072 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4073 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4074
4075 // Del2
4076 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4077 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4078 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4079
4080 waitSubsCleanup(t, e2SubsId2, 10)
4081
4082 mainCtrl.VerifyCounterValues(t)
4083}
4084
4085//-----------------------------------------------------------------------------
4086// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4087//
4088// stub stub stub
4089// +-------+ +-------+ +---------+ +---------+
4090// | xapp2 | | xapp1 | | submgr | | e2term |
4091// +-------+ +-------+ +---------+ +---------+
4092// | | | |
4093// | | | |
4094// | | | |
4095// | | RESTSubReq1 | |
4096// | |---------------->| |
4097// | | | |
4098// | | RESTSubResp1 | |
4099// | |<----------------| |
4100// | | | SubReq1 |
4101// | | |------------->|
4102// | RESTSubReq2 | |
4103// |------------------------------>| |
4104// | | | |
4105// | RESTSubDelResp2 | |
4106// |<------------------------------| |
4107// | | | SubReq1 |
4108// | | |------------->|
4109// | | | |
4110// | | | |
4111// | | | SubDelReq |
4112// | | |------------->|
4113// | | | |
4114// | | | SubDelResp |
4115// | | |<-------------|
4116// | | RESTNotif1 | |
4117// | | unsuccess | |
4118// | |<----------------| |
4119// | RESTNotif2 | |
4120// | | unsuccess | |
4121// |<------------------------------| |
4122// | | | |
4123// | | RESTSubDelReq1 | |
4124// | |---------------->| |
4125// | | | |
4126// | | RESTSubDelResp1 | |
4127// | |<----------------| |
4128// | | | |
4129// | RESTSubDelReq2 | |
4130// |------------------------------>| |
4131// | | | |
4132// | RESTSubDelResp2 | |
4133// |<------------------------------| |
4134//
4135//-----------------------------------------------------------------------------
4136func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4137 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4138
4139 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004140 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004141 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004142 Counter{cSubReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004143 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004144 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004145 Counter{cSubDelReqToE2, 1},
4146 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004147 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004148 })
4149
4150 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004151
4152 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004153 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004154 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4155 crereq1, _ := e2termConn1.RecvSubsReq(t)
4156
4157 // Req2
4158 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004159 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004160 params2.SetMeid("RAN_NAME_1")
4161 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4162 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4163
4164 //Req1 (retransmitted)
4165 e2termConn1.RecvSubsReq(t)
4166
4167 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004168
4169 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004170 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4171
Markku Virtanenda34eec2021-05-20 08:22:04 +00004172 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004173 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004174 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004175 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004176
4177 // Del1
4178 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4179
4180 // Del2
4181 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4182
Markku Virtanenda34eec2021-05-20 08:22:04 +00004183 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4184
archaggeafbf95f2021-04-14 08:54:05 +03004185 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004186 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004187
4188 mainCtrl.VerifyCounterValues(t)
4189}
4190
4191//-----------------------------------------------------------------------------
4192// TestRESTSubReqAndSubDelNokSameActionParallel
4193//
4194// stub stub stub
4195// +-------+ +-------+ +---------+ +---------+
4196// | xapp2 | | xapp1 | | submgr | | e2term |
4197// +-------+ +-------+ +---------+ +---------+
4198// | | | |
4199// | | | |
4200// | | | |
4201// | | RESTSubReq1 | |
4202// | |---------------->| |
4203// | | | |
4204// | | RESTSubResp1 | |
4205// | |<----------------| |
4206// | | | SubReq1 |
4207// | | |------------->|
4208// | RESTSubReq2 | |
4209// |------------------------------>| |
4210// | | | |
4211// | RESTSubDelResp2 | |
4212// |<------------------------------| |
4213// | | | SubFail1 |
4214// | | |<-------------|
4215// | | | |
4216// | | RESTNotif1 | |
4217// | | unsuccess | |
4218// | |<----------------| |
4219// | RESTNotif2 | |
4220// | | unsuccess | |
4221// |<------------------------------| |
4222// | | | SubDelReq |
4223// | | |------------->|
4224// | | | SubDelResp |
4225// | | |<-------------|
4226// | | | |
4227// | | RESTSubDelReq1 | |
4228// | |---------------->| |
4229// | | | |
4230// | | RESTSubDelResp1 | |
4231// | |<----------------| |
4232// | | | |
4233// | RESTSubDelReq2 | |
4234// |------------------------------>| |
4235// | | | |
4236// | RESTSubDelResp2 | |
4237// |<------------------------------| |
4238//
4239//-----------------------------------------------------------------------------
4240func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4241 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4242
4243 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004244 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004245 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004246 Counter{cSubReqToE2, 1},
4247 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004248 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004249 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004250 Counter{cSubDelReqToE2, 1},
4251 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004252 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004253 })
4254
4255 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004256
4257 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004258 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004259 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4260 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4261
4262 // Req2
4263 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004264 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004265 params2.SetMeid("RAN_NAME_1")
4266 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4267 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4268
4269 // E2t: send SubsFail (first)
4270 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4271 fparams1.Set(crereq1)
4272 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4273
4274 // E2t: internal delete
4275 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4276 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4277 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4278
4279 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004280 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004281 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004282 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004283
4284 // Del1
4285 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4286
4287 // Del2
4288 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4289
4290 //Wait that subs is cleaned
4291 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4292 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4293
4294 mainCtrl.VerifyCounterValues(t)
4295}
4296
4297func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4298 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4299
4300 // Init counter check
4301 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004302 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004303 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004304 Counter{cSubReqToE2, 1},
4305 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004306 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004307 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004308 Counter{cSubDelReqToE2, 1},
4309 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004310 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004311 })
4312
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004313 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004314 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004315 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004316
4317 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4318 xappConn1.ExpectRESTNotification(t, restSubId)
4319 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4320 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004321 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004322
4323 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4324 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4325 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4326
4327 // Wait that subs is cleaned
4328 waitSubsCleanup(t, e2SubsId, 10)
4329 mainCtrl.VerifyCounterValues(t)
4330}
4331
4332//-----------------------------------------------------------------------------
4333// TestRESTSubReqPolicyChangeAndSubDelOk
4334//
4335// stub stub
4336// +-------+ +---------+ +---------+
4337// | xapp | | submgr | | e2term |
4338// +-------+ +---------+ +---------+
4339// | | |
4340// | RESTSubReq | |
4341// |---------------->| |
4342// | | |
4343// | RESTSubResp | |
4344// |<----------------| |
4345// | | SubReq |
4346// | |------------->|
4347// | | |
4348// | | SubResp |
4349// | |<-------------|
4350// | | |
4351// | RESTNotif | |
4352// |<----------------| |
4353// | | |
4354// | RESTSubReq | |
4355// |---------------->| |
4356// | | |
4357// | RESTSubResp | |
4358// |<----------------| |
4359// | | SubReq |
4360// | |------------->|
4361// | | |
4362// | | SubResp |
4363// | |<-------------|
4364// | | |
4365// | RESTNotif | |
4366// |<----------------| |
4367// | | |
4368// | RESTSubDelReq | |
4369// |---------------->| |
4370// | | |
4371// | | SubDelReq |
4372// | |------------->|
4373// | | |
4374// | | SubDelResp |
4375// | |<-------------|
4376// | | |
4377// | RESTSubDelResp | |
4378// |<----------------| |
4379//
4380//-----------------------------------------------------------------------------
4381func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4382 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4383
4384 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004385 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004386 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004387 Counter{cSubReqToE2, 2},
4388 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004389 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004390 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004391 Counter{cSubDelReqToE2, 1},
4392 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004393 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004394 })
4395
4396 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004397 const e2Timeout int64 = 1
4398 const e2RetryCount int64 = 0
4399 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004400
4401 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004402 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004403 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004404 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4405
4406 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004407 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004408
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004409 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004410 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004411 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004412 params.SetTimeToWait("w200ms")
4413 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4414
4415 // Del
4416 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4417
4418 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4419 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4420
4421 // Wait that subs is cleaned
4422 waitSubsCleanup(t, e2SubsId, 10)
4423 mainCtrl.VerifyCounterValues(t)
4424}
4425
4426//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004427// TestRESTSubReqPolicyChangeNOk
4428//
4429// stub stub
4430// +-------+ +---------+ +---------+
4431// | xapp | | submgr | | e2term |
4432// +-------+ +---------+ +---------+
4433// | | |
4434// | RESTSubReq | |
4435// |---------------->| |
4436// | | |
4437// | RESTSubResp | |
4438// |<----------------| |
4439// | | SubReq |
4440// | |------------->|
4441// | | |
4442// | | SubResp |
4443// | |<-------------|
4444// | | |
4445// | RESTNotif | |
4446// |<----------------| |
4447// | | |
4448// | RESTSubReq | |
4449// |---------------->| |
4450// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004451// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004452// | | |
4453// | RESTSubDelReq | |
4454// |---------------->| |
4455// | | |
4456// | | SubDelReq |
4457// | |------------->|
4458// | | |
4459// | | SubDelResp |
4460// | |<-------------|
4461// | | |
4462// | RESTSubDelResp | |
4463// |<----------------| |
4464//
4465//-----------------------------------------------------------------------------
4466func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4467 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4468
4469 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4470 Counter{cRestSubReqFromXapp, 2},
4471 Counter{cRestSubRespToXapp, 1},
4472 Counter{cSubReqToE2, 1},
4473 Counter{cSubRespFromE2, 1},
4474 Counter{cRestSubNotifToXapp, 1},
4475 Counter{cRestSubFailToXapp, 1},
4476 Counter{cRestSubDelReqFromXapp, 1},
4477 Counter{cSubDelReqToE2, 1},
4478 Counter{cSubDelRespFromE2, 1},
4479 Counter{cRestSubDelRespToXapp, 1},
4480 })
4481
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004482 // Req
4483 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4484 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4485
4486 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004487 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4488
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004489 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004490 params.SetSubscriptionID(&restSubIdUpd)
4491 params.SetTimeToWait("w200ms")
4492
4493 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4494 assert.Equal(t, restSubId2, "")
4495
4496 // Del
4497 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4498
4499 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4500 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4501
4502 // Wait that subs is cleaned
4503 waitSubsCleanup(t, e2SubsId, 10)
4504 mainCtrl.VerifyCounterValues(t)
4505}
4506
4507//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004508// TestRESTSubReqAndSubDelOkTwoE2termParallel
4509//
4510// stub stub stub
4511// +-------+ +---------+ +---------+ +---------+
4512// | xapp | | submgr | | e2term1 | | e2term2 |
4513// +-------+ +---------+ +---------+ +---------+
4514// | | | |
4515// | | | |
4516// | | | |
4517// | RESTSubReq1 | | |
4518// |---------------->| | |
4519// | | | |
4520// | RESTSubResp1 | | |
4521// |<----------------| | |
4522// | | SubReq1 | |
4523// | |------------->| |
4524// | | | |
4525// | RESTSubReq2 | | |
4526// |---------------->| | |
4527// | | | |
4528// | RESTSubResp2 | | |
4529// |<----------------| | |
4530// | | SubReq2 | |
4531// | |---------------------------->|
4532// | | | |
4533// | | SubResp1 | |
4534// | |<-------------| |
4535// | RESTNotif1 | | |
4536// |<----------------| | |
4537// | | SubResp2 | |
4538// | |<----------------------------|
4539// | RESTNotif2 | | |
4540// |<----------------| | |
4541// | | | |
4542// | [SUBS 1 DELETE] | |
4543// | | | |
4544// | [SUBS 2 DELETE] | |
4545// | | | |
4546//
4547//-----------------------------------------------------------------------------
4548func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4549 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4550
4551 // Init counter check
4552 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004553 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004554 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004555 Counter{cSubReqToE2, 2},
4556 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004557 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004558 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004559 Counter{cSubDelReqToE2, 2},
4560 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004561 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004562 })
4563
4564 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004565
4566 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004567 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004568 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4569 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4570
4571 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004572 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004573 params.SetMeid("RAN_NAME_11")
4574 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4575 // would not work as notification would not be received
4576 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4577 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4578
4579 // Resp1
4580 xappConn1.ExpectRESTNotification(t, restSubId1)
4581 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4582 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004583 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004584
4585 // Resp2
4586 xappConn2.ExpectRESTNotification(t, restSubId2)
4587 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4588 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004589 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004590
4591 // Delete1
4592 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4593 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4594 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4595
4596 // Wait that subs is cleaned
4597 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4598
4599 // Delete2
4600 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4601 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4602 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4603
4604 // Wait that subs is cleaned
4605 waitSubsCleanup(t, e2SubsId2, 10)
4606
4607 mainCtrl.VerifyCounterValues(t)
4608}
4609
4610//-----------------------------------------------------------------------------
4611// TestRESTSubReqAsn1EncodeFail
4612//
4613// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4614// stub stub
4615// +-------+ +---------+ +---------+
4616// | xapp | | submgr | | e2term |
4617// +-------+ +---------+ +---------+
4618// | | |
4619// | RESTSubReq | |
4620// |---------------->| |
4621// | | |
4622// | RESTSubResp | |
4623// |<----------------| |
4624// | RESTSubDelReq | |
4625// |---------------->| |
4626// | RESTSubDelResp | |
4627// | unsuccess | |
4628// |<----------------| |
4629// | | |
4630//
4631//-----------------------------------------------------------------------------
4632func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4633 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4634
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004635 xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
archaggeafbf95f2021-04-14 08:54:05 +03004636
4637}
4638
4639//-----------------------------------------------------------------------------
4640// TestRESTSubReqInsertAndSubDelOk
4641//
4642// stub stub
4643// +-------+ +---------+ +---------+
4644// | xapp | | submgr | | e2term |
4645// +-------+ +---------+ +---------+
4646// | | |
4647// | RestSubReq | |
4648// |---------------->| |
4649// | | |
4650// | RESTSubResp | |
4651// |<----------------| |
4652// | | |
4653// | | SubReq |
4654// | |------------->|
4655// | | |
4656// | | SubResp |
4657// | |<-------------|
4658// | RESTNotif | |
4659// |<----------------| |
4660// | ... | ... |
4661// | | |
4662// | RESTSubDelReq | |
4663// |---------------->| |
4664// | | |
4665// | | SubDelReq |
4666// | |------------->|
4667// | | |
4668// | | SubDelResp |
4669// | |<-------------|
4670// | | |
4671// | RESTSubDelResp| |
4672// |<----------------| |
4673//
4674//-----------------------------------------------------------------------------
4675func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4676 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4677
4678 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004679 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004680 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004681 Counter{cSubReqToE2, 1},
4682 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004683 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004684 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004685 Counter{cSubDelReqToE2, 1},
4686 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004687 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004688 })
4689
4690 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004691
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004692 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004693 params.SetSubActionTypes("insert")
4694
4695 // Req
4696 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4697
4698 // Del
4699 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4700
4701 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4702 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4703
4704 // Wait that subs is cleaned
4705 waitSubsCleanup(t, e2SubsId, 10)
4706 mainCtrl.VerifyCounterValues(t)
4707}
4708
4709//-----------------------------------------------------------------------------
4710// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4711//
4712// stub stub
4713// +-------+ +---------+ +---------+
4714// | xapp | | submgr | | e2term |
4715// +-------+ +---------+ +---------+
4716// | | |
4717// | RESTSubReq | |
4718// |------------->| |
4719// | | |
4720// | | SubReq |
4721// | |------------->|
4722// | | |
4723// | | SubResp |
4724// | <----|
4725// | |
4726// | Submgr restart |
4727// | |
4728// | | |
4729// | | SubDelReq |
4730// | |------------->|
4731// | | |
4732// | | SubDelResp |
4733// | |<-------------|
4734// | | |
4735//
4736//-----------------------------------------------------------------------------
4737func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4738 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4739
4740 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004741 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004742 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004743 Counter{cSubReqToE2, 1},
4744 Counter{cSubDelReqFromXapp, 1},
4745 Counter{cSubDelReqToE2, 1},
4746 Counter{cSubDelRespFromE2, 1},
4747 })
4748
4749 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004750
4751 // Remove possible existing subscription
4752 mainCtrl.removeExistingSubscriptions(t)
4753
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004754 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004755
4756 //Req
4757 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
4758 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004759 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004760
4761 e2termConn1.RecvSubsReq(t)
4762
4763 mainCtrl.SetResetTestFlag(t, false)
4764
4765 mainCtrl.SimulateRestart(t)
4766 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4767
4768 //Del
4769 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4770 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4771
4772 xappConn1.TestMsgChanEmpty(t)
4773 xappConn2.TestMsgChanEmpty(t)
4774 e2termConn1.TestMsgChanEmpty(t)
4775 mainCtrl.wait_registry_empty(t, 10)
4776
4777 mainCtrl.VerifyCounterValues(t)
4778}
4779
4780//-----------------------------------------------------------------------------
4781// TestRESTSubReqAndSubDelOkWithRestartInMiddle
4782//
4783// stub stub
4784// +-------+ +---------+ +---------+
4785// | xapp | | submgr | | e2term |
4786// +-------+ +---------+ +---------+
4787// | | |
4788// | RESTSubReq | |
4789// |---------------->| |
4790// | | |
4791// | RESTSubResp | |
4792// |<----------------| |
4793// | | SubReq |
4794// | |------------->|
4795// | | |
4796// | | SubResp |
4797// | |<-------------|
4798// | | |
4799// | RESTNotif | |
4800// |<----------------| |
4801// | | |
4802// | |
4803// | Submgr restart |
4804// | | |
4805// | RESTSubDelReq | |
4806// |---------------->| |
4807// | | |
4808// | | SubDelReq |
4809// | |------------->|
4810// | | |
4811// | | SubDelResp |
4812// | |<-------------|
4813// | | |
4814// | RESTSubDelResp | |
4815// |<----------------| |
4816//
4817//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004818
archaggeafbf95f2021-04-14 08:54:05 +03004819func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4820 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4821
4822 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004823 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004824 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004825 Counter{cSubReqToE2, 1},
4826 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004827 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004828 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004829 Counter{cSubDelReqToE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004830 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004831 })
4832
4833 // Remove possible existing subscription
4834 mainCtrl.removeExistingSubscriptions(t)
4835
4836 var params *teststube2ap.RESTSubsReqParams = nil
4837
4838 // Create subscription
4839 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004840 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004841
4842 // Check subscription
4843 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4844
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004845 mainCtrl.SimulateRestart(t)
4846 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004847
4848 // Check subscription
4849 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4850
4851 // Delete subscription
4852 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4853
4854 //Wait that subs is cleaned
4855 waitSubsCleanup(t, e2SubsId, 10)
4856
4857 mainCtrl.VerifyCounterValues(t)
4858}
4859
4860//-----------------------------------------------------------------------------
4861// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4862//
4863// stub stub
4864// +-------+ +-------+ +---------+ +---------+
4865// | xapp2 | | xapp1 | | submgr | | e2term |
4866// +-------+ +-------+ +---------+ +---------+
4867// | | | |
4868// | | RESTSubReq1 | |
4869// | |---------------->| |
4870// | | | |
4871// | | RESTSubResp1 | |
4872// | |<----------------| |
4873// | | | |
4874// | | | SubReq1 |
4875// | | |------------->|
4876// | | | SubResp1 |
4877// | | |<-------------|
4878// | | RESTNotif1 | |
4879// | |<----------------| |
4880// | | | |
4881// | RESTSubReq2 | |
4882// |------------------------------>| |
4883// | | | |
4884// | RESTSubResp2 | |
4885// |<------------------------------| |
4886// | | | |
4887// | | RESTNotif2 | |
4888// |<------------------------------| |
4889// | | | |
4890// | | Submgr restart |
4891// | | | |
4892// | | RESTSubDelReq1 | |
4893// | |---------------->| |
4894// | | | |
4895// | | RESTSubDelResp1 | |
4896// | |<----------------| |
4897// | | | |
4898// | | Submgr restart |
4899// | | | |
4900// | RESTSubDelReq2 | |
4901// |------------------------------>| |
4902// | | | |
4903// | RESTSubDelResp2 | |
4904// |<------------------------------| |
4905// | | | |
4906// | | | SubDelReq2 |
4907// | | |------------->|
4908// | | | |
4909// | | | SubDelResp2 |
4910// | | |<-------------|
4911// | | | |
4912//
4913//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004914
archaggeafbf95f2021-04-14 08:54:05 +03004915func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4916 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4917
4918 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004919 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004920 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004921 Counter{cSubReqToE2, 1},
4922 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004923 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004924 Counter{cMergedSubscriptions, 1},
4925 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004926 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004927 Counter{cSubDelReqToE2, 1},
4928 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004929 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004930 })
4931
4932 // Remove possible existing subscription
4933 mainCtrl.removeExistingSubscriptions(t)
4934
4935 var params *teststube2ap.RESTSubsReqParams = nil
4936
4937 // Create subscription 1
4938 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004939 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004940
4941 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004942 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004943 params.SetMeid("RAN_NAME_1")
4944 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004945 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03004946 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004947 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004948 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004949 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004950
4951 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4952
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004953 mainCtrl.SimulateRestart(t)
4954 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004955
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004956 // Delete subscription 1, and wait until it has removed the first endpoint
4957 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004958 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004959 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004960
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004961 mainCtrl.SimulateRestart(t)
4962 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004963 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4964
4965 // Delete subscription 2
4966 deleteXapp2Subscription(t, &restSubId2)
4967
4968 //Wait that subs is cleaned
4969 waitSubsCleanup(t, e2SubsId2, 10)
4970
4971 mainCtrl.VerifyCounterValues(t)
4972}
4973
4974//-----------------------------------------------------------------------------
4975// TestRESTReportSubReqAndSubDelOk
4976//
4977// stub stub
4978// +-------+ +---------+ +---------+
4979// | xapp | | submgr | | e2term |
4980// +-------+ +---------+ +---------+
4981// | | |
4982// | RestSubReq | |
4983// |---------------->| |
4984// | | |
4985// | RESTSubResp | |
4986// |<----------------| |
4987// | | |
4988// | | SubReq |
4989// | |------------->|
4990// | | |
4991// | | SubResp |
4992// | |<-------------|
4993// | RESTNotif | |
4994// |<----------------| |
4995// | | SubReq |
4996// | |------------->|
4997// | | |
4998// | | SubResp |
4999// | |<-------------|
5000// | RESTNotif | |
5001// |<----------------| |
5002// | ... | ... |
5003// | | |
5004// | | |
5005// | RESTSubDelReq | |
5006// |---------------->| |
5007// | | |
5008// | | SubDelReq |
5009// | |------------->|
5010// | | |
5011// | | SubDelResp |
5012// | |<-------------|
5013// | | |
5014// | RESTSubDelResp| |
5015// |<----------------| |
5016//
5017//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005018
archaggeafbf95f2021-04-14 08:54:05 +03005019func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5020 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005021 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005022 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005023 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005024}
5025
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005026func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005027 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005028
5029 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005030 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005031 restSubId := xappConn1.SendRESTSubsReq(t, params)
5032
5033 var e2SubsId []uint32
5034 for i := 0; i < subReqCount; i++ {
5035 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5036 xappConn1.ExpectRESTNotification(t, restSubId)
5037
5038 e2termConn1.SendSubsResp(t, crereq, cremsg)
5039 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005040 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005041 e2SubsId = append(e2SubsId, instanceId)
5042 resp, _ := xapp.Subscription.QuerySubscriptions()
5043 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5044 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5045 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5046
5047 }
5048
5049 // Del
5050 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5051
5052 for i := 0; i < subReqCount; i++ {
5053 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5054 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5055 }
5056
5057 // Wait that subs is cleaned
5058 for i := 0; i < subReqCount; i++ {
5059 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5060 }
5061
5062 xappConn1.TestMsgChanEmpty(t)
5063 e2termConn1.TestMsgChanEmpty(t)
5064 mainCtrl.wait_registry_empty(t, 10)
5065}
5066
5067/*
5068func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
5069 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5070
5071 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005072 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005073 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005074
5075 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005076 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005077 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005078}
5079*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005080func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005081 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005082
5083 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005084 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005085 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005086
5087 var e2SubsId []uint32
5088 for i := 0; i < subReqCount; i++ {
5089 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5090 xappConn1.ExpectRESTNotification(t, restSubId)
5091 e2termConn1.SendSubsResp(t, crereq, cremsg)
5092 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005093 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005094 e2SubsId = append(e2SubsId, instanceId)
5095 }
5096
5097 // Del
5098 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5099
5100 for i := 0; i < subReqCount; i++ {
5101 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5102 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5103 }
5104
5105 // Wait that subs is cleaned
5106 for i := 0; i < subReqCount; i++ {
5107 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5108 }
5109 xappConn1.TestMsgChanEmpty(t)
5110 e2termConn1.TestMsgChanEmpty(t)
5111 mainCtrl.wait_registry_empty(t, 10)
5112}
5113
archaggeafbf95f2021-04-14 08:54:05 +03005114func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5115
archaggeafbf95f2021-04-14 08:54:05 +03005116 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005117 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005118 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005119 Counter{cSubReqToE2, 2},
5120 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005121 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005122 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005123 Counter{cSubDelReqToE2, 2},
5124 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005125 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005126 })
5127
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005128 const subReqCount int = 2
5129
archaggeafbf95f2021-04-14 08:54:05 +03005130 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005131 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005132 restSubId := xappConn1.SendRESTSubsReq(t, params)
5133 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5134
5135 assert.Equal(t, len(e2SubsIds), 2)
5136
5137 // Del
5138 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5139 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5140
5141 xappConn1.TestMsgChanEmpty(t)
5142 e2termConn1.TestMsgChanEmpty(t)
5143 mainCtrl.wait_registry_empty(t, 10)
5144
5145 mainCtrl.VerifyCounterValues(t)
5146}
archaggeafbf95f2021-04-14 08:54:05 +03005147func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5148
archaggeafbf95f2021-04-14 08:54:05 +03005149 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005150 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005151 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005152 Counter{cSubReqToE2, 19},
5153 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005154 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005155 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005156 Counter{cSubDelReqToE2, 19},
5157 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005158 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005159 })
5160
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005161 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005162 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005163 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005164 restSubId := xappConn1.SendRESTSubsReq(t, params)
5165 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5166
5167 assert.Equal(t, len(e2SubsIds), 19)
5168
5169 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5170 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5171
5172 xappConn1.TestMsgChanEmpty(t)
5173 e2termConn1.TestMsgChanEmpty(t)
5174 mainCtrl.wait_registry_empty(t, 10)
5175
5176 mainCtrl.VerifyCounterValues(t)
5177}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005178
archaggeafbf95f2021-04-14 08:54:05 +03005179func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5180
5181 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005182
5183 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005184 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005185 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005186 Counter{cSubReqToE2, uint64(subReqCount)},
5187 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005188 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005189 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005190 Counter{cSubDelReqToE2, uint64(subReqCount)},
5191 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005192 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005193 })
5194
5195 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005196 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005197 restSubId := xappConn1.SendRESTSubsReq(t, params)
5198 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5199
5200 assert.Equal(t, len(e2SubsIds), subReqCount)
5201
5202 // Del
5203 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5204 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5205
5206 xappConn1.TestMsgChanEmpty(t)
5207 e2termConn1.TestMsgChanEmpty(t)
5208 mainCtrl.wait_registry_empty(t, 10)
5209
5210 mainCtrl.VerifyCounterValues(t)
5211}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005212
archaggeafbf95f2021-04-14 08:54:05 +03005213func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5214
5215 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005216
5217 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005218 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005219 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005220 Counter{cSubReqToE2, uint64(subReqCount)},
5221 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005222 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005223 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005224 Counter{cSubDelReqToE2, uint64(subReqCount)},
5225 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005226 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005227 })
5228
5229 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005230 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005231 restSubId := xappConn1.SendRESTSubsReq(t, params)
5232 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5233
5234 assert.Equal(t, len(e2SubsIds), subReqCount)
5235
5236 // Del
5237 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5238 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5239
5240 xappConn1.TestMsgChanEmpty(t)
5241 e2termConn1.TestMsgChanEmpty(t)
5242 mainCtrl.wait_registry_empty(t, 10)
5243
5244 mainCtrl.VerifyCounterValues(t)
5245}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005246
archaggeafbf95f2021-04-14 08:54:05 +03005247func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5248
5249 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005250
5251 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005252 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005253 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005254 Counter{cSubReqToE2, uint64(subReqCount)},
5255 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005256 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005257 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005258 Counter{cSubDelReqToE2, uint64(subReqCount)},
5259 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005260 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005261 })
5262
5263 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005264 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005265 restSubId := xappConn1.SendRESTSubsReq(t, params)
5266 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5267
5268 assert.Equal(t, len(e2SubsIds), subReqCount)
5269
5270 // Del
5271 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5272 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5273
5274 xappConn1.TestMsgChanEmpty(t)
5275 e2termConn1.TestMsgChanEmpty(t)
5276 mainCtrl.wait_registry_empty(t, 10)
5277
5278 mainCtrl.VerifyCounterValues(t)
5279}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005280
5281func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5282 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5283
5284 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005285 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005286 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005287 Counter{cSubReqToE2, 2},
5288 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005289 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005290 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005291 Counter{cSubDelReqToE2, 2},
5292 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005293 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005294 })
5295
5296 // Req1
5297 var params *teststube2ap.RESTSubsReqParams = nil
5298
5299 //Subs Create
5300 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005301 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005302
5303 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5304
5305 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005306 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005307 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005308 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005309 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5310
5311 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005312 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005313 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5314 xappConn2.ExpectRESTNotification(t, restSubId2)
5315 e2termConn1.SendSubsResp(t, crereq, cremsg)
5316 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5317
5318 deleteXapp1Subscription(t, &restSubId1)
5319 deleteXapp2Subscription(t, &restSubId2)
5320
5321 waitSubsCleanup(t, e2SubsId1, 10)
5322 waitSubsCleanup(t, e2SubsId2, 10)
5323
5324 mainCtrl.VerifyCounterValues(t)
5325
5326}
5327
5328func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5329 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5330
5331 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005332 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005333 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005334 Counter{cSubReqToE2, 2},
5335 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005336 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005337 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005338 Counter{cSubDelReqToE2, 2},
5339 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005340 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005341 })
5342
5343 // Req1
5344 var params *teststube2ap.RESTSubsReqParams = nil
5345
5346 //Subs Create
5347 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005348 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005349
5350 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5351
5352 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005353 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005354 params.SetMeid("RAN_NAME_1")
5355
5356 actionId := int64(1)
5357 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005358 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005359 subsequestActionType := "continue"
5360 timeToWait := "w10ms"
5361 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5362
5363 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005364 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005365 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5366 xappConn2.ExpectRESTNotification(t, restSubId2)
5367 e2termConn1.SendSubsResp(t, crereq, cremsg)
5368 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5369
5370 deleteXapp1Subscription(t, &restSubId1)
5371 deleteXapp2Subscription(t, &restSubId2)
5372
5373 waitSubsCleanup(t, e2SubsId1, 10)
5374 waitSubsCleanup(t, e2SubsId2, 10)
5375
5376 mainCtrl.VerifyCounterValues(t)
5377
5378}
5379
5380func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5381 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5382
5383 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005384 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005385 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005386 Counter{cSubReqToE2, 2},
5387 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005388 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005389 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005390 Counter{cSubDelReqToE2, 2},
5391 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005392 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005393 })
5394
5395 // Req1
5396 var params *teststube2ap.RESTSubsReqParams = nil
5397
5398 //Subs Create
5399 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005400 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005401
5402 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5403
5404 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005405 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005406 params.SetMeid("RAN_NAME_1")
5407 params.SetSubActionIDs(int64(2))
5408
5409 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005410 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005411 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5412 xappConn2.ExpectRESTNotification(t, restSubId2)
5413 e2termConn1.SendSubsResp(t, crereq, cremsg)
5414 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5415
5416 deleteXapp1Subscription(t, &restSubId1)
5417 deleteXapp2Subscription(t, &restSubId2)
5418
5419 waitSubsCleanup(t, e2SubsId1, 10)
5420 waitSubsCleanup(t, e2SubsId2, 10)
5421
5422 mainCtrl.VerifyCounterValues(t)
5423
5424}
5425
5426func TestRESTSubReqDiffActionType(t *testing.T) {
5427 CaseBegin("TestRESTSubReqDiffActionType")
5428
5429 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005430 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005431 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005432 Counter{cSubReqToE2, 2},
5433 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005434 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005435 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005436 Counter{cSubDelReqToE2, 2},
5437 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005438 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005439 })
5440
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005441 const e2Timeout int64 = 2
5442 const e2RetryCount int64 = 2
5443 const routingNeeded bool = true
5444
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005445 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005446 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005447 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005448
5449 //Subs Create
5450 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005451 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005452
5453 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5454
5455 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005456 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005457 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005458 params.SetMeid("RAN_NAME_1")
5459
5460 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005461 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005462 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5463 xappConn2.ExpectRESTNotification(t, restSubId2)
5464 e2termConn1.SendSubsResp(t, crereq, cremsg)
5465 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5466
5467 deleteXapp1Subscription(t, &restSubId1)
5468 deleteXapp2Subscription(t, &restSubId2)
5469
5470 waitSubsCleanup(t, e2SubsId1, 10)
5471 waitSubsCleanup(t, e2SubsId2, 10)
5472
5473 mainCtrl.VerifyCounterValues(t)
5474
5475}
5476
5477func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5478 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5479
5480 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005481 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005482 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005483 Counter{cSubReqToE2, 2},
5484 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005485 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005486 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005487 Counter{cSubDelReqToE2, 2},
5488 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005489 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005490 })
5491
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005492 const e2Timeout int64 = 2
5493 const e2RetryCount int64 = 2
5494 const routingNeeded bool = true
5495
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005496 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005497 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005498 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005499
5500 //Subs Create
5501 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005502 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005503
5504 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5505
5506 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005507 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005508 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005509 params.SetMeid("RAN_NAME_1")
5510
5511 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005512 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005513 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5514 xappConn2.ExpectRESTNotification(t, restSubId2)
5515 e2termConn1.SendSubsResp(t, crereq, cremsg)
5516 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5517
5518 deleteXapp1Subscription(t, &restSubId1)
5519 deleteXapp2Subscription(t, &restSubId2)
5520
5521 waitSubsCleanup(t, e2SubsId1, 10)
5522 waitSubsCleanup(t, e2SubsId2, 10)
5523
5524 mainCtrl.VerifyCounterValues(t)
5525
5526}
5527
5528func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5529 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5530
5531 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005532 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005533 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005534 Counter{cSubReqToE2, 2},
5535 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005536 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005537 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005538 Counter{cSubDelReqToE2, 2},
5539 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005540 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005541 })
5542
5543 // Req1
5544 var params *teststube2ap.RESTSubsReqParams = nil
5545
5546 //Subs Create
5547 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005548 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005549
5550 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5551
5552 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005553 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005554 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005555 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005556 params.SetSubActionDefinition(actionDefinition)
5557
5558 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005559 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005560 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5561 xappConn2.ExpectRESTNotification(t, restSubId2)
5562 e2termConn1.SendSubsResp(t, crereq, cremsg)
5563 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5564
5565 deleteXapp1Subscription(t, &restSubId1)
5566 deleteXapp2Subscription(t, &restSubId2)
5567
5568 waitSubsCleanup(t, e2SubsId1, 10)
5569 waitSubsCleanup(t, e2SubsId2, 10)
5570
5571 mainCtrl.VerifyCounterValues(t)
5572
5573}
5574
5575func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5576 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5577
5578 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005579 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005580 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005581 Counter{cSubReqToE2, 2},
5582 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005583 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005584 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005585 Counter{cSubDelReqToE2, 2},
5586 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005587 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005588 })
5589
5590 // Req1
5591 var params *teststube2ap.RESTSubsReqParams = nil
5592
5593 //Subs Create
5594 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005595 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005596
5597 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5598
5599 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005600 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005601 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005602 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005603 params.SetSubActionDefinition(actionDefinition)
5604
5605 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005606 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005607 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5608 xappConn2.ExpectRESTNotification(t, restSubId2)
5609 e2termConn1.SendSubsResp(t, crereq, cremsg)
5610 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5611
5612 deleteXapp1Subscription(t, &restSubId1)
5613 deleteXapp2Subscription(t, &restSubId2)
5614
5615 waitSubsCleanup(t, e2SubsId1, 10)
5616 waitSubsCleanup(t, e2SubsId2, 10)
5617
5618 mainCtrl.VerifyCounterValues(t)
5619
5620}
5621
5622func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5623 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5624
5625 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005626 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005627 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005628 Counter{cSubReqToE2, 2},
5629 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005630 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005631 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005632 Counter{cSubDelReqToE2, 2},
5633 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005634 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005635 })
5636
5637 // Req1
5638 var params *teststube2ap.RESTSubsReqParams = nil
5639
5640 //Subs Create
5641 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005642 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005643
5644 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5645
5646 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005647 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005648 params.SetMeid("RAN_NAME_1")
5649 params.SetTimeToWait("w200ms")
5650 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005651 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005652 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5653 xappConn2.ExpectRESTNotification(t, restSubId2)
5654 e2termConn1.SendSubsResp(t, crereq, cremsg)
5655 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5656
5657 deleteXapp1Subscription(t, &restSubId1)
5658 deleteXapp2Subscription(t, &restSubId2)
5659
5660 waitSubsCleanup(t, e2SubsId1, 10)
5661 waitSubsCleanup(t, e2SubsId2, 10)
5662
5663 mainCtrl.VerifyCounterValues(t)
5664
5665}
5666
Anssi Mannila51122392021-05-25 11:51:31 +03005667//-----------------------------------------------------------------------------
5668// TestRESTUnpackSubscriptionResponseDecodeFail
5669//
5670// stub stub
5671// +-------+ +---------+ +---------+
5672// | xapp | | submgr | | e2term |
5673// +-------+ +---------+ +---------+
5674// | | |
5675// | RestSubReq | |
5676// |---------------->| |
5677// | | |
5678// | RESTSubResp | |
5679// |<----------------| |
5680// | | |
5681// | | SubReq |
5682// | |------------->|
5683// | | |
5684// | | SubResp | ASN.1 decode fails
5685// | |<-------------|
5686// | | |
5687// | | SubReq |
5688// | |------------->|
5689// | | |
5690// | | SubFail | Duplicated action
5691// | |<-------------|
5692// | RESTNotif (fail)| |
5693// |<----------------| |
5694// | | SubDelReq |
5695// | |------------->|
5696// | | |
5697// | | SubDelResp |
5698// | |<-------------|
5699//
5700//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005701
Anssi Mannila51122392021-05-25 11:51:31 +03005702func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005703 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5704 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03005705
5706 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005707 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005708 restSubId := xappConn1.SendRESTSubsReq(t, params)
5709
5710 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5711 // Decode of this response fails which will result resending original request
5712 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5713
5714 _, cremsg = e2termConn1.RecvSubsReq(t)
5715
Markku Virtanen55d2a282021-06-04 14:46:56 +03005716 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005717
5718 // Subscription already created in E2 Node.
5719 fparams := &teststube2ap.E2StubSubsFailParams{}
5720 fparams.Set(crereq)
5721 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5722 e2termConn1.SendSubsFail(t, fparams, cremsg)
5723
5724 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5725 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5726
5727 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005728 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03005729
5730 // Wait that subs is cleaned
5731 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5732
5733 xappConn1.TestMsgChanEmpty(t)
5734 e2termConn1.TestMsgChanEmpty(t)
5735 mainCtrl.wait_registry_empty(t, 10)
5736}
5737
5738//-----------------------------------------------------------------------------
5739// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5740//
5741// stub stub
5742// +-------+ +---------+ +---------+
5743// | xapp | | submgr | | e2term |
5744// +-------+ +---------+ +---------+
5745// | | |
5746// | RestSubReq | |
5747// |---------------->| |
5748// | | |
5749// | RESTSubResp | |
5750// |<----------------| |
5751// | | |
5752// | | SubReq |
5753// | |------------->|
5754// | | |
5755// | | SubResp | Unknown instanceId
5756// | |<-------------|
5757// | | |
5758// | | SubReq |
5759// | |------------->|
5760// | | |
5761// | | SubFail | Duplicated action
5762// | |<-------------|
5763// | RESTNotif (fail)| |
5764// |<----------------| |
5765// | | SubDelReq |
5766// | |------------->|
5767// | | |
5768// | | SubDelResp |
5769// | |<-------------|
5770//
5771//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005772
Anssi Mannila51122392021-05-25 11:51:31 +03005773func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005774 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5775 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03005776
5777 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005778 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005779 restSubId := xappConn1.SendRESTSubsReq(t, params)
5780
5781 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5782
5783 // Unknown instanceId in this response which will result resending original request
5784 orgInstanceId := crereq.RequestId.InstanceId
5785 crereq.RequestId.InstanceId = 0
5786 e2termConn1.SendSubsResp(t, crereq, cremsg)
5787
5788 _, cremsg = e2termConn1.RecvSubsReq(t)
5789
Markku Virtanen55d2a282021-06-04 14:46:56 +03005790 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005791
5792 // Subscription already created in E2 Node.
5793 fparams := &teststube2ap.E2StubSubsFailParams{}
5794 fparams.Set(crereq)
5795 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5796 e2termConn1.SendSubsFail(t, fparams, cremsg)
5797
5798 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5799 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5800
5801 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005802 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03005803
5804 // Wait that subs is cleaned
5805 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
5806
5807 xappConn1.TestMsgChanEmpty(t)
5808 e2termConn1.TestMsgChanEmpty(t)
5809 mainCtrl.wait_registry_empty(t, 10)
5810}
5811
5812//-----------------------------------------------------------------------------
5813// TestRESTUnpackSubscriptionResponseNoTransaction
5814//
5815// stub stub
5816// +-------+ +---------+ +---------+
5817// | xapp | | submgr | | e2term |
5818// +-------+ +---------+ +---------+
5819// | | |
5820// | RestSubReq | |
5821// |---------------->| |
5822// | | |
5823// | RESTSubResp | |
5824// |<----------------| |
5825// | | |
5826// | | SubReq |
5827// | |------------->|
5828// | | |
5829// | | SubResp | No transaction for the response
5830// | |<-------------|
5831// | | |
5832// | | SubReq |
5833// | |------------->|
5834// | | |
5835// | | SubFail | Duplicated action
5836// | |<-------------|
5837// | RESTNotif (fail)| |
5838// |<----------------| |
5839// | | SubDelReq |
5840// | |------------->|
5841// | | |
5842// | | SubDelResp |
5843// | |<-------------|
5844// | | |
5845// | | SubDelReq |
5846// | |------------->|
5847// | | |
5848// | | SubDelResp |
5849// | |<-------------|
5850//
5851//-----------------------------------------------------------------------------
5852func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005853 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5854 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03005855
5856 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005857 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005858 restSubId := xappConn1.SendRESTSubsReq(t, params)
5859
5860 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5861
5862 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5863 // No transaction exist for this response which will result resending original request
5864 e2termConn1.SendSubsResp(t, crereq, cremsg)
5865
5866 _, cremsg = e2termConn1.RecvSubsReq(t)
5867
Markku Virtanen55d2a282021-06-04 14:46:56 +03005868 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005869
5870 // Subscription already created in E2 Node.
5871 fparams := &teststube2ap.E2StubSubsFailParams{}
5872 fparams.Set(crereq)
5873 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5874 e2termConn1.SendSubsFail(t, fparams, cremsg)
5875
5876 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5877 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5878
5879 // Resending happens because there no transaction
5880 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5881 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5882
5883 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005884 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03005885
5886 // Wait that subs is cleaned
5887 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5888
5889 xappConn1.TestMsgChanEmpty(t)
5890 e2termConn1.TestMsgChanEmpty(t)
5891 mainCtrl.wait_registry_empty(t, 10)
5892
5893}
5894
5895//-----------------------------------------------------------------------------
5896// TestRESTUnpackSubscriptionFailureDecodeFail
5897//
5898// stub stub
5899// +-------+ +---------+ +---------+
5900// | xapp | | submgr | | e2term |
5901// +-------+ +---------+ +---------+
5902// | | |
5903// | RestSubReq | |
5904// |---------------->| |
5905// | | |
5906// | RESTSubResp | |
5907// |<----------------| |
5908// | | |
5909// | | SubReq |
5910// | |------------->|
5911// | | |
5912// | | SubFail | ASN.1 decode fails
5913// | |<-------------|
5914// | | |
5915// | | SubReq |
5916// | |------------->|
5917// | | |
5918// | | SubFail | Duplicated action
5919// | |<-------------|
5920// | RESTNotif (fail)| |
5921// |<----------------| |
5922// | | SubDelReq |
5923// | |------------->|
5924// | | |
5925// | | SubDelResp |
5926// | |<-------------|
5927//
5928//-----------------------------------------------------------------------------
5929func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005930 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5931 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03005932
5933 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005934 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005935 restSubId := xappConn1.SendRESTSubsReq(t, params)
5936
5937 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5938
5939 // Decode of this response fails which will result resending original request
5940 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5941
5942 _, cremsg = e2termConn1.RecvSubsReq(t)
5943
Markku Virtanen55d2a282021-06-04 14:46:56 +03005944 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005945
5946 // Subscription already created in E2 Node.
5947 fparams := &teststube2ap.E2StubSubsFailParams{}
5948 fparams.Set(crereq)
5949 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5950 e2termConn1.SendSubsFail(t, fparams, cremsg)
5951
5952 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5953 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5954
5955 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005956 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03005957
5958 // Wait that subs is cleaned
5959 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5960
5961 xappConn1.TestMsgChanEmpty(t)
5962 e2termConn1.TestMsgChanEmpty(t)
5963 mainCtrl.wait_registry_empty(t, 10)
5964}
5965
5966//-----------------------------------------------------------------------------
5967// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5968//
5969// stub stub
5970// +-------+ +---------+ +---------+
5971// | xapp | | submgr | | e2term |
5972// +-------+ +---------+ +---------+
5973// | | |
5974// | RestSubReq | |
5975// |---------------->| |
5976// | | |
5977// | RESTSubResp | |
5978// |<----------------| |
5979// | | |
5980// | | SubReq |
5981// | |------------->|
5982// | | |
5983// | | SubFail | Unknown instanceId
5984// | |<-------------|
5985// | | |
5986// | | SubReq |
5987// | |------------->|
5988// | | |
5989// | | SubFail | Duplicated action
5990// | |<-------------|
5991// | RESTNotif (fail)| |
5992// |<----------------| |
5993// | | SubDelReq |
5994// | |------------->|
5995// | | |
5996// | | SubDelResp |
5997// | |<-------------|
5998//
5999//-----------------------------------------------------------------------------
6000func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006001 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6002 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006003
6004 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006005 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006006 restSubId := xappConn1.SendRESTSubsReq(t, params)
6007
6008 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6009
6010 // Unknown instanceId in this response which will result resending original request
6011 fparams := &teststube2ap.E2StubSubsFailParams{}
6012 fparams.Set(crereq)
6013 fparams.Fail.RequestId.InstanceId = 0
6014 e2termConn1.SendSubsFail(t, fparams, cremsg)
6015
6016 _, cremsg = e2termConn1.RecvSubsReq(t)
6017
Markku Virtanen55d2a282021-06-04 14:46:56 +03006018 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006019
6020 // Subscription already created in E2 Node.
6021 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6022 e2termConn1.SendSubsFail(t, fparams, cremsg)
6023
6024 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6025 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6026
6027 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006028 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006029
6030 // Wait that subs is cleaned
6031 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6032
6033 xappConn1.TestMsgChanEmpty(t)
6034 e2termConn1.TestMsgChanEmpty(t)
6035 mainCtrl.wait_registry_empty(t, 10)
6036}
6037
6038//-----------------------------------------------------------------------------
6039// TestRESTUnpackSubscriptionFailureNoTransaction
6040//
6041// stub stub
6042// +-------+ +---------+ +---------+
6043// | xapp | | submgr | | e2term |
6044// +-------+ +---------+ +---------+
6045// | | |
6046// | RestSubReq | |
6047// |---------------->| |
6048// | | |
6049// | RESTSubResp | |
6050// |<----------------| |
6051// | | |
6052// | | SubReq |
6053// | |------------->|
6054// | | |
6055// | | SubFail | No transaction for the response
6056// | |<-------------|
6057// | | |
6058// | | SubReq |
6059// | |------------->|
6060// | | |
6061// | | SubFail | Duplicated action
6062// | |<-------------|
6063// | RESTNotif (fail)| |
6064// |<----------------| |
6065// | | SubDelReq |
6066// | |------------->|
6067// | | |
6068// | | SubDelResp |
6069// | |<-------------|
6070//
6071//-----------------------------------------------------------------------------
6072func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006073 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6074 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006075
6076 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006077 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006078 restSubId := xappConn1.SendRESTSubsReq(t, params)
6079
6080 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6081
6082 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6083
6084 // No transaction exist for this response which will result resending original request
6085 fparams := &teststube2ap.E2StubSubsFailParams{}
6086 fparams.Set(crereq)
6087 e2termConn1.SendSubsFail(t, fparams, cremsg)
6088
6089 _, cremsg = e2termConn1.RecvSubsReq(t)
6090
Markku Virtanen55d2a282021-06-04 14:46:56 +03006091 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006092
6093 // Subscription already created in E2 Node.
6094 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6095 e2termConn1.SendSubsFail(t, fparams, cremsg)
6096
6097 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6098 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6099
6100 // Resending happens because there no transaction
6101 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6102 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6103
6104 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006105 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006106
6107 // Wait that subs is cleaned
6108 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6109
6110 xappConn1.TestMsgChanEmpty(t)
6111 e2termConn1.TestMsgChanEmpty(t)
6112 mainCtrl.wait_registry_empty(t, 10)
6113}
6114
6115//-----------------------------------------------------------------------------
6116// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6117//
6118// stub stub
6119// +-------+ +---------+ +---------+
6120// | xapp | | submgr | | e2term |
6121// +-------+ +---------+ +---------+
6122// | | |
6123// | [SUBS CREATE] |
6124// | | |
6125// | | |
6126// | RESTSubDelReq | |
6127// |---------------->| |
6128// | | |
6129// | RESTSubDelResp | |
6130// |<----------------| |
6131// | | |
6132// | | SubDelReq |
6133// | |------------->|
6134// | | |
6135// | | SubDelResp | ASN.1 decode fails
6136// | |<-------------|
6137// | | |
6138// | | SubDelReq |
6139// | |------------->|
6140// | | |
6141// | | SubDelFail | Subscription does exist any more
6142// | |<-------------|
6143// | | |
6144//
6145//-----------------------------------------------------------------------------
6146func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006147 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006148
6149 // Req
6150 var params *teststube2ap.RESTSubsReqParams = nil
6151 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6152
6153 // Del
6154 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6155
6156 // E2t: Receive 1st SubsDelReq
6157 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6158
6159 // Decode of this response fails which will result resending original request
6160 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6161
6162 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6163 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6164
6165 // Subscription does not exist in in E2 Node.
6166 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6167
6168 // Wait that subs is cleaned
6169 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6170
6171 xappConn1.TestMsgChanEmpty(t)
6172 e2termConn1.TestMsgChanEmpty(t)
6173 mainCtrl.wait_registry_empty(t, 10)
6174}
6175
6176//-----------------------------------------------------------------------------
6177// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6178//
6179// stub stub
6180// +-------+ +---------+ +---------+
6181// | xapp | | submgr | | e2term |
6182// +-------+ +---------+ +---------+
6183// | | |
6184// | [SUBS CREATE] |
6185// | | |
6186// | | |
6187// | RESTSubDelReq | |
6188// |---------------->| |
6189// | | |
6190// | RESTSubDelResp | |
6191// |<----------------| |
6192// | | |
6193// | | SubDelReq |
6194// | |------------->|
6195// | | |
6196// | | SubDelResp | Unknown instanceId
6197// | |<-------------|
6198// | | |
6199// | | SubDelReq |
6200// | |------------->|
6201// | | |
6202// | | SubDelFail | Subscription does exist any more
6203// | |<-------------|
6204//
6205//-----------------------------------------------------------------------------
6206func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006207 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006208
6209 // Req
6210 var params *teststube2ap.RESTSubsReqParams = nil
6211 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6212
6213 // Del
6214 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6215
6216 // E2t: Receive 1st SubsDelReq
6217 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6218
6219 // Unknown instanceId in this response which will result resending original request
6220 delreq.RequestId.InstanceId = 0
6221 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6222
6223 // E2t: Receive 2nd SubsDelReq
6224 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6225
6226 // Subscription does not exist in in E2 Node.
6227 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6228
6229 // Wait that subs is cleaned
6230 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6231
6232 xappConn1.TestMsgChanEmpty(t)
6233 e2termConn1.TestMsgChanEmpty(t)
6234 mainCtrl.wait_registry_empty(t, 10)
6235}
6236
6237//-----------------------------------------------------------------------------
6238// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6239//
6240// stub stub
6241// +-------+ +---------+ +---------+
6242// | xapp | | submgr | | e2term |
6243// +-------+ +---------+ +---------+
6244// | | |
6245// | [SUBS CREATE] |
6246// | | |
6247// | | |
6248// | RESTSubDelReq | |
6249// |---------------->| |
6250// | | |
6251// | RESTSubDelResp | |
6252// |<----------------| |
6253// | | |
6254// | | SubDelReq |
6255// | |------------->|
6256// | | |
6257// | | SubDelResp | No transaction for the response
6258// | |<-------------|
6259// | | |
6260// | | SubDelReq |
6261// | |------------->|
6262// | | |
6263// | | SubDelFail | Subscription does exist any more
6264// | |<-------------|
6265//
6266//-----------------------------------------------------------------------------
6267func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006268 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006269
6270 // Req
6271 var params *teststube2ap.RESTSubsReqParams = nil
6272 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6273
6274 // Del
6275 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6276
6277 // E2t: Receive 1st SubsDelReq
6278 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6279
6280 mainCtrl.MakeTransactionNil(t, e2SubsId)
6281
6282 // No transaction exist for this response which will result resending original request
6283 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6284
6285 // E2t: Receive 2nd SubsDelReq
6286 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6287
6288 // Subscription does not exist in in E2 Node.
6289 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6290
6291 // Wait that subs is cleaned
6292 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6293
6294 xappConn1.TestMsgChanEmpty(t)
6295 e2termConn1.TestMsgChanEmpty(t)
6296 mainCtrl.wait_registry_empty(t, 10)
6297}
6298
6299//-----------------------------------------------------------------------------
6300// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6301//
6302// stub stub
6303// +-------+ +---------+ +---------+
6304// | xapp | | submgr | | e2term |
6305// +-------+ +---------+ +---------+
6306// | | |
6307// | [SUBS CREATE] |
6308// | | |
6309// | | |
6310// | RESTSubDelReq | |
6311// |---------------->| |
6312// | | |
6313// | RESTSubDelResp | |
6314// |<----------------| |
6315// | | |
6316// | | SubDelReq |
6317// | |------------->|
6318// | | |
6319// | | SubDelFail | ASN.1 decode fails
6320// | |<-------------|
6321// | | |
6322// | | SubDelReq |
6323// | |------------->|
6324// | | |
6325// | | SubDelFail | Subscription does exist any more
6326// | |<-------------|
6327//
6328//-----------------------------------------------------------------------------
6329func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006330 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006331
6332 // Req
6333 var params *teststube2ap.RESTSubsReqParams = nil
6334 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6335
6336 // Del
6337 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6338
6339 // E2t: Receive 1st SubsDelReq
6340 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6341
6342 // Decode of this response fails which will result resending original request
6343 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6344
6345 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6346 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6347
6348 // Subscription does not exist in in E2 Node.
6349 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6350
6351 // Wait that subs is cleaned
6352 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6353
6354 xappConn1.TestMsgChanEmpty(t)
6355 e2termConn1.TestMsgChanEmpty(t)
6356 mainCtrl.wait_registry_empty(t, 10)
6357}
6358
6359//-----------------------------------------------------------------------------
6360// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6361//
6362// stub stub
6363// +-------+ +---------+ +---------+
6364// | xapp | | submgr | | e2term |
6365// +-------+ +---------+ +---------+
6366// | | |
6367// | [SUBS CREATE] |
6368// | | |
6369// | | |
6370// | RESTSubDelReq | |
6371// |---------------->| |
6372// | | |
6373// | RESTSubDelResp | |
6374// |<----------------| |
6375// | | |
6376// | | SubDelReq |
6377// | |------------->|
6378// | | |
6379// | | SubDelFail | Unknown instanceId
6380// | |<-------------|
6381// | | |
6382// | | SubDelReq |
6383// | |------------->|
6384// | | |
6385// | | SubDelFail | Subscription does exist any more
6386// | |<-------------|
6387//
6388//-----------------------------------------------------------------------------
6389func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006390 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006391
6392 // Req
6393 var params *teststube2ap.RESTSubsReqParams = nil
6394 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6395
6396 // Del
6397 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6398
6399 // E2t: Receive 1st SubsDelReq
6400 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6401
6402 // Unknown instanceId in this response which will result resending original request
6403 delreq.RequestId.InstanceId = 0
6404 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6405
6406 // E2t: Receive 2nd SubsDelReq
6407 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6408
6409 // Subscription does not exist in in E2 Node.
6410 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6411
6412 // Wait that subs is cleaned
6413 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6414
6415 xappConn1.TestMsgChanEmpty(t)
6416 e2termConn1.TestMsgChanEmpty(t)
6417 mainCtrl.wait_registry_empty(t, 10)
6418}
6419
6420//-----------------------------------------------------------------------------
6421// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6422//
6423// stub stub
6424// +-------+ +---------+ +---------+
6425// | xapp | | submgr | | e2term |
6426// +-------+ +---------+ +---------+
6427// | | |
6428// | [SUBS CREATE] |
6429// | | |
6430// | | |
6431// | RESTSubDelReq | |
6432// |---------------->| |
6433// | | |
6434// | RESTSubDelResp | |
6435// |<----------------| |
6436// | | |
6437// | | SubDelReq |
6438// | |------------->|
6439// | | |
6440// | | SubDelFail | No transaction for the response
6441// | |<-------------|
6442// | | |
6443// | | SubDelReq |
6444// | |------------->|
6445// | | |
6446// | | SubDelFail | Subscription does exist any more
6447// | |<-------------|
6448//
6449//-----------------------------------------------------------------------------
6450func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006451 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006452
6453 // Req
6454 var params *teststube2ap.RESTSubsReqParams = nil
6455 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6456
6457 // Del
6458 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6459
6460 // E2t: Receive 1st SubsDelReq
6461 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6462
6463 mainCtrl.MakeTransactionNil(t, e2SubsId)
6464
6465 // No transaction exist for this response which will result resending original request
6466 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6467
6468 // E2t: Receive 2nd SubsDelReq
6469 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6470
6471 // Subscription does not exist in in E2 Node.
6472 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6473
6474 // Wait that subs is cleaned
6475 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6476
6477 xappConn1.TestMsgChanEmpty(t)
6478 e2termConn1.TestMsgChanEmpty(t)
6479 mainCtrl.wait_registry_empty(t, 10)
6480}
6481
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006482//-----------------------------------------------------------------------------
6483// TestRESTSubReqFailAsn1PackSubReqError
6484//
6485// stub stub
6486// +-------+ +---------+ +---------+
6487// | xapp | | submgr | | e2term |
6488// +-------+ +---------+ +---------+
6489// | | |
6490// | RESTSubReq | |
6491// |---------------->| |
6492// | | |
6493// | RESTSubResp | |
6494// |<----------------| |
6495// | | |
6496// | ASN.1 encode fails |
6497// | | |
6498// | | SubDelReq |
6499// | |------------->|
6500// | | |
6501// | | SubDelFail |
6502// | |<-------------|
6503// | | |
6504// | RESTNotif | |
6505// | unsuccess | |
6506// |<----------------| |
6507// | | |
6508// | [SUBS DELETE] |
6509// | | |
6510//
6511//-----------------------------------------------------------------------------
6512func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6513
6514 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006515 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006516 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006517 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006518 })
6519
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006520 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006521
6522 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006523 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006524 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6525
6526 // Req
6527 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006528 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006529
6530 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03006531 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006532
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006533 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006534 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006535
6536 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
6537 // Wait that subs is cleaned
6538 waitSubsCleanup(t, e2SubsId, 10)
6539 mainCtrl.VerifyCounterValues(t)
6540}
6541
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006542func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
6543 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
6544
6545 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6546 Counter{cRestSubReqFromXapp, 2},
6547 Counter{cRestSubRespToXapp, 2},
6548 Counter{cSubReqToE2, 2},
6549 Counter{cSubRespFromE2, 1},
6550 Counter{cRestSubNotifToXapp, 1},
6551 Counter{cRestSubFailNotifToXapp, 1},
6552 Counter{cRestSubDelReqFromXapp, 1},
6553 Counter{cSubDelReqToE2, 1},
6554 Counter{cSubDelRespFromE2, 1},
6555 Counter{cRestSubDelRespToXapp, 1},
6556 })
6557
6558 const e2Timeout int64 = 1
6559 const e2RetryCount int64 = 0
6560 const routingNeeded bool = false
6561
6562 // Req1
6563 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6564 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6565
6566 // Subs Create
6567 restSubId := xappConn1.SendRESTSubsReq(t, params)
6568 xapp.Logger.Debug("Send REST subscribe 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.Debug("REST notification received e2SubsId=%v", e2SubsId)
6575
6576 // Policy change
6577 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6578 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6579 params.SetSubscriptionID(&restSubId)
6580 params.SetTimeToWait("w200ms")
6581 restSubId = xappConn1.SendRESTSubsReq(t, params)
6582 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6583
6584 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6585 xappConn1.ExpectRESTNotification(t, restSubId)
6586 // SubsResp is missing
6587 e2SubsId = xappConn1.WaitRESTNotification(t, restSubId)
6588 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
6589
6590 // Del
6591 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6592 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6593 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6594
6595 waitSubsCleanup(t, e2SubsId, 10)
6596
6597 mainCtrl.VerifyCounterValues(t)
6598}
6599
6600//-----------------------------------------------------------------------------
6601// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
6602//
6603// stub stub
6604// +-------+ +---------+ +---------+
6605// | xapp | | submgr | | e2term |
6606// +-------+ +---------+ +---------+
6607// | | |
6608// | RESTSubReq | |
6609// |---------------->| |
6610// | | |
6611// | RESTSubResp | |
6612// |<----------------| |
6613// | | SubReq |
6614// | |------------->|
6615// | | |
6616// | | SubResp |
6617// | |<-------------|
6618// | | |
6619// | RESTNotif | |
6620// |<----------------| |
6621// | | |
6622// | RESTSubReq | |
6623// |---------------->| |
6624// | | |
6625// | RESTSubResp | |
6626// |<----------------| |
6627// | | SubReq |
6628// | |------------->|
6629// | |
6630// | Submgr restart |
6631// | | |
6632// | RESTSubDelReq | |
6633// |---------------->| |
6634// | | |
6635// | | SubDelReq |
6636// | |------------->|
6637// | | |
6638// | | SubDelResp |
6639// | |<-------------|
6640// | | |
6641// | RESTSubDelResp | |
6642// |<----------------| |
6643//
6644//-----------------------------------------------------------------------------
6645
6646func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
6647 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
6648
6649 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6650 Counter{cRestSubReqFromXapp, 2},
6651 Counter{cRestSubRespToXapp, 2},
6652 Counter{cSubReqToE2, 2},
6653 Counter{cSubRespFromE2, 1},
6654 Counter{cRestSubNotifToXapp, 1},
6655 Counter{cRestSubNotifToXapp, 1},
6656 Counter{cRestSubDelReqFromXapp, 1},
6657 Counter{cSubDelReqToE2, 1},
6658 Counter{cRestSubDelRespToXapp, 1},
6659 })
6660
6661 // Remove possible existing subscription
6662 mainCtrl.removeExistingSubscriptions(t)
6663
6664 const e2Timeout int64 = 1
6665 const e2RetryCount int64 = 0
6666 const routingNeeded bool = false
6667
6668 // Req1
6669 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6670 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6671 // Create subscription
6672 restSubId := xappConn1.SendRESTSubsReq(t, params)
6673 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6674
6675 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6676 xappConn1.ExpectRESTNotification(t, restSubId)
6677 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6678 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6679 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6680
6681 // Check subscription
6682 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6683
6684 // Policy change
6685 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6686 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6687 params.SetSubscriptionID(&restSubId)
6688 params.SetTimeToWait("w200ms")
6689 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
6690 restSubId = xappConn1.SendRESTSubsReq(t, params)
6691 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6692
6693 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6694 mainCtrl.SetResetTestFlag(t, false)
6695
6696 // SubsResp is missing due to submgr restart
6697
6698 mainCtrl.SimulateRestart(t)
6699 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
6700
6701 // Check subscription
6702 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6703
6704 xapp.Logger.Debug("Here 1")
6705 //<-time.After(3 * time.Second)
6706 xapp.Logger.Debug("Here 2")
6707
6708 // Delete subscription
6709 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6710 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6711 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6712
6713 //Wait that subs is cleaned
6714 waitSubsCleanup(t, e2SubsId, 10)
6715
6716 mainCtrl.VerifyCounterValues(t)
6717}
6718
archaggeafbf95f2021-04-14 08:54:05 +03006719////////////////////////////////////////////////////////////////////////////////////
6720// Services for UT cases
6721////////////////////////////////////////////////////////////////////////////////////
6722const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006723const host string = "localhost"
6724
6725func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
6726 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006727 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006728 }
6729 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006730 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006731
6732 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
6733 fromXappConn.ExpectRESTNotification(t, restSubId)
6734 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
6735 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006736 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006737
6738 return restSubId, e2SubsId
6739}
6740
6741func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
6742
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006743 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006744 if meid != "" {
6745 params.SetMeid(meid)
6746 }
6747 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
6748 restSubId := xappConn2.SendRESTSubsReq(t, params)
6749 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006750 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006751 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006752 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006753
6754 return restSubId, e2SubsId
6755}
6756
6757func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006758
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006759 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006760 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006761 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006762
6763 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6764 xappConn1.ExpectRESTNotification(t, restSubId)
6765 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6766 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006767 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006768
6769 return restSubId, e2SubsId
6770}
6771
6772func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006773 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006774 restSubId := xappConn1.SendRESTSubsReq(t, params)
6775
6776 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6777 fparams1 := &teststube2ap.E2StubSubsFailParams{}
6778 fparams1.Set(crereq1)
6779 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
6780
6781 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
6782 xappConn1.ExpectRESTNotification(t, restSubId)
6783 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
6784 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006785 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006786
6787 return restSubId, e2SubsId
6788}
6789
6790func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
6791 fromXappConn.SendRESTSubsDelReq(t, restSubId)
6792 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6793 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6794}
6795
6796func deleteXapp1Subscription(t *testing.T, restSubId *string) {
6797 xappConn1.SendRESTSubsDelReq(t, restSubId)
6798 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6799 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6800}
6801
6802func deleteXapp2Subscription(t *testing.T, restSubId *string) {
6803 xappConn2.SendRESTSubsDelReq(t, restSubId)
6804 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6805 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6806}
6807
6808func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
6809 resp, _ := xapp.Subscription.QuerySubscriptions()
6810 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
6811 assert.Equal(t, resp[0].Meid, meid)
6812 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
6813}
6814
6815func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
6816 //Wait that subs is cleaned
6817 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
6818
6819 xappConn1.TestMsgChanEmpty(t)
6820 xappConn2.TestMsgChanEmpty(t)
6821 e2termConn1.TestMsgChanEmpty(t)
6822 mainCtrl.wait_registry_empty(t, timeout)
6823}
6824
6825func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
6826
6827 var e2SubsId []uint32
6828
6829 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006830 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03006831 crereq, cremsg := toE2termConn.RecvSubsReq(t)
6832 fromXappConn.ExpectRESTNotification(t, restSubId)
6833 toE2termConn.SendSubsResp(t, crereq, cremsg)
6834 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
6835 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006836 xapp.Logger.Debug("TEST: %v", e2SubsId)
6837 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03006838 <-time.After(100 * time.Millisecond)
6839 }
6840 return e2SubsId
6841}
6842
6843func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
6844
6845 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006846 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03006847 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6848 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6849 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006850 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03006851 <-time.After(100 * time.Millisecond)
6852 }
6853
6854 // Wait that subs is cleaned
6855 for i := 0; i < len(e2SubsIds); i++ {
6856 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
6857 }
6858
6859}