blob: bc1b6d3450f40d04a608c329da77ab1a2ad29011 [file] [log] [blame]
Juha Hyttinenfa015662020-01-24 10:05:18 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17==================================================================================
18*/
19
20package control
21
22import (
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +000023 "strings"
Anssi Mannila4abf1802021-01-28 13:06:46 +020024 "testing"
25 "time"
26
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020027 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000028 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020029 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020030 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
31 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020032)
33
Markku Virtanenac8bde42021-05-25 09:54:42 +000034func TestSuiteSetup(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +000035 // The effect of this call shall endure thgough the UT suite!
36 // If this causes any issues, the previout interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000037 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000038 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
39
40 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Markku Virtanenb642a192021-06-09 09:08:14 +000041
42 restDuplicateCtrl.Init()
43
Markku Virtanenac8bde42021-05-25 09:54:42 +000044}
45
46//-----------------------------------------------------------------------------
47// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
48//
49// stub stub stub
50// +-------+ +---------+ +---------+ +---------+
51// | xapp | | submgr | | e2term | | rtmgr |
52// +-------+ +---------+ +---------+ +---------+
53// | | | |
54// | RESTSubReq | | |
55// |---------------->| | |
56// | | RouteCreate | |
57// | |--------------------------->| // The order of these events may vary
58// | | | |
59// | RESTSubResp | | | // The order of these events may vary
60// |<----------------| | |
61// | | RouteResponse| |
62// | |<---------------------------| // The order of these events may vary
63// | | | |
64// | | SubReq | |
65// | |------------->| | // The order of these events may vary
66// | | | |
67// | | SubResp | |
68// | |<-------------| |
69// | RESTNotif1 | | |
70// |<----------------| | |
71// | | | |
72// | RESTSubDelReq | | |
73// |---------------->| | |
74// | | SubDelReq | |
75// | |------------->| |
76// | | | |
77// | RESTSubDelResp| | |
78// |<----------------| | |
79// | | | |
80// | | SubDelResp | |
81// | |<-------------| |
82// | | | |
83// | | | |
84//
85//-----------------------------------------------------------------------------
86func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +000087
88 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
89
90 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
91
92 waitSubsCleanup(t, e2SubsId, 10)
93}
94
Juha Hyttinenfa015662020-01-24 10:05:18 +020095//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +000096// TestRESTSubReqAndE1apDeleteReqPackingError
97//
98// stub stub stub
99// +-------+ +---------+ +---------+ +---------+
100// | xapp | | submgr | | e2term | | rtmgr |
101// +-------+ +---------+ +---------+ +---------+
102// | | | |
103// | RESTSubReq | | |
104// |---------------->| | |
105// | | RouteCreate | |
106// | |--------------------------->| // The order of these events may vary
107// | | | |
108// | RESTSubResp | | | // The order of these events may vary
109// |<----------------| | |
110// | | RouteResponse| |
111// | |<---------------------------| // The order of these events may vary
112// | | | |
113// | | SubReq | |
114// | |------------->| | // The order of these events may vary
115// | | | |
116// | | SubResp | |
117// | |<-------------| |
118// | RESTNotif1 | | |
119// |<----------------| | |
120// | | | |
121// | RESTSubDelReq | | |
122// |---------------->| | |
123// | | | |
124// | RESTSubDelResp| | |
125// |<----------------| | |
126// | | | |
127// | | | |
128//
129//-----------------------------------------------------------------------------
130func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
131
132 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
133
134 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
135 xappConn1.SendRESTSubsDelReq(t, &restSubId)
136 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
137
138 waitSubsCleanup(t, e2SubsId, 10)
139}
140
141//-----------------------------------------------------------------------------
142// TestRESTSubReqAndE1apDeleteRespUnpackingError
143//
144// stub stub stub
145// +-------+ +---------+ +---------+ +---------+
146// | xapp | | submgr | | e2term | | rtmgr |
147// +-------+ +---------+ +---------+ +---------+
148// | | | |
149// | RESTSubReq | | |
150// |---------------->| | |
151// | | RouteCreate | |
152// | |--------------------------->| // The order of these events may vary
153// | | | |
154// | RESTSubResp | | | // The order of these events may vary
155// |<----------------| | |
156// | | RouteResponse| |
157// | |<---------------------------| // The order of these events may vary
158// | | | |
159// | | SubReq | |
160// | |------------->| | // The order of these events may vary
161// | | | |
162// | | SubResp | |
163// | |<-------------| |
164// | RESTNotif1 | | |
165// |<----------------| | |
166// | | | |
167// | RESTSubDelReq | | |
168// |---------------->| | |
169// | | SubDelReq | |
170// | |------------->| |
171// | | | |
172// | RESTSubDelResp| | |
173// |<----------------| | | // The order of these events may vary
174// | | | |
175// | | SubDelResp | |
176// | |<-------------| | // 1.st NOK
177// | | | |
178// | | SubDelReq | |
179// | |------------->| |
180// | | | |
181// | | SubDelResp | |
182// | |<-------------| | // 2.nd NOK
183//
184//-----------------------------------------------------------------------------
185
186func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
187
188 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
189
190 xappConn1.SendRESTSubsDelReq(t, &restSubId)
191 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
192 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
193 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
194
195 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
196 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
197
198 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
199
200 waitSubsCleanup(t, e2SubsId, 10)
201}
202
203//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200204// TestSubReqAndRouteNok
205//
206// stub stub
207// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200208// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200209// +-------+ +---------+ +---------+
210// | | |
211// | SubReq | |
212// |------------->| |
213// | | |
214// | | RouteCreate |
215// | |------------->|
216// | | |
217// | | RouteCreate |
218// | | status:400 |
219// | |<-------------|
220// | | |
221// | [SUBS INT DELETE] |
222// | | |
223//
224//-----------------------------------------------------------------------------
225
226func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200227 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200228
Anssi Mannila4abf1802021-01-28 13:06:46 +0200229 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200230 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
231 Counter{cSubReqFromXapp, 1},
232 Counter{cRouteCreateFail, 1},
233 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200234
Juha Hyttinenfa015662020-01-24 10:05:18 +0200235 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300236 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200237 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200238 waiter.WaitResult(t)
239
240 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200241 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200242
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200243 xappConn1.TestMsgChanEmpty(t)
244 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200245 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200246 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200247
248 <-time.After(1 * time.Second)
249 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200250}
251
252//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200253// TestSubReqAndRouteUpdateNok
254
255// stub stub
256// +-------+ +-------+ +---------+ +---------+
257// | xapp2 | | xapp1 | | submgr | | rtmgr |
258// +-------+ +-------+ +---------+ +---------+
259// | | | |
260// | [SUBS CREATE] | |
261// | | | |
262// | | | |
263// | | | |
264// | SubReq (mergeable) | |
265// |--------------------------->| | |
266// | | | |
267// | | | RouteUpdate |
268// | | |------------->|
269// | | | |
270// | | | RouteUpdate |
271// | | | status:400 |
272// | | |<-------------|
273// | | | |
274// | [SUBS INT DELETE] | |
275// | | | |
276// | | | |
277// | [SUBS DELETE] | |
278// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300279
Anssi Mannila4abf1802021-01-28 13:06:46 +0200280func TestSubReqAndRouteUpdateNok(t *testing.T) {
281 CaseBegin("TestSubReqAndRouteUpdateNok")
282
283 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200284 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
285 Counter{cSubReqFromXapp, 2},
286 Counter{cSubReqToE2, 1},
287 Counter{cSubRespFromE2, 1},
288 Counter{cSubRespToXapp, 1},
289 Counter{cRouteCreateUpdateFail, 1},
290 Counter{cSubDelReqFromXapp, 1},
291 Counter{cSubDelReqToE2, 1},
292 Counter{cSubDelRespFromE2, 1},
293 Counter{cSubDelRespToXapp, 1},
294 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200295
296 cretrans := xappConn1.SendSubsReq(t, nil, nil)
297 crereq, cremsg := e2termConn1.RecvSubsReq(t)
298 e2termConn1.SendSubsResp(t, crereq, cremsg)
299 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
300
301 resp, _ := xapp.Subscription.QuerySubscriptions()
302 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
303 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300304 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200305
306 waiter := rtmgrHttp.AllocNextEvent(false)
307 newSubsId := mainCtrl.get_registry_next_subid(t)
308 xappConn2.SendSubsReq(t, nil, nil)
309 waiter.WaitResult(t)
310
311 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
312 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
313
314 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
315 xappConn1.RecvSubsDelResp(t, deltrans)
316
317 //Wait that subs is cleaned
318 mainCtrl.wait_subs_clean(t, newSubsId, 10)
319 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
320
321 xappConn1.TestMsgChanEmpty(t)
322 xappConn2.TestMsgChanEmpty(t)
323 e2termConn1.TestMsgChanEmpty(t)
324 mainCtrl.wait_registry_empty(t, 10)
325
326 mainCtrl.VerifyCounterValues(t)
327}
328
329//-----------------------------------------------------------------------------
330// TestSubDelReqAndRouteDeleteNok
331//
332// stub stub
333// +-------+ +---------+ +---------+ +---------+
334// | xapp | | submgr | | e2term | | rtmgr |
335// +-------+ +---------+ +---------+ +---------+
336// | | | |
337// | [SUBS CREATE] | |
338// | | | |
339// | | | |
340// | | | |
341// | SubDelReq | | |
342// |------------->| | |
343// | | SubDelReq | |
344// | |------------->| |
345// | | SubDelRsp | |
346// | |<-------------| |
347// | SubDelRsp | | |
348// |<-------------| | |
349// | | RouteDelete | |
350// | |---------------------------->|
351// | | | |
352// | | RouteDelete | |
353// | | status:400 | |
354// | |<----------------------------|
355// | | | |
356func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
357 CaseBegin("TestSubDelReqAndRouteDeleteNok")
358
359 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200360 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
361 Counter{cSubReqFromXapp, 1},
362 Counter{cSubReqToE2, 1},
363 Counter{cSubRespFromE2, 1},
364 Counter{cSubRespToXapp, 1},
365 Counter{cSubDelReqFromXapp, 1},
366 Counter{cRouteDeleteFail, 1},
367 Counter{cSubDelReqToE2, 1},
368 Counter{cSubDelRespFromE2, 1},
369 Counter{cSubDelRespToXapp, 1},
370 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200371
372 cretrans := xappConn1.SendSubsReq(t, nil, nil)
373 crereq, cremsg := e2termConn1.RecvSubsReq(t)
374 e2termConn1.SendSubsResp(t, crereq, cremsg)
375 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
376
377 resp, _ := xapp.Subscription.QuerySubscriptions()
378 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
379 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300380 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200381
382 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
383 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
384
385 waiter := rtmgrHttp.AllocNextEvent(false)
386 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
387 waiter.WaitResult(t)
388
389 xappConn1.RecvSubsDelResp(t, deltrans)
390
391 //Wait that subs is cleaned
392 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
393
394 xappConn1.TestMsgChanEmpty(t)
395 xappConn2.TestMsgChanEmpty(t)
396 e2termConn1.TestMsgChanEmpty(t)
397 mainCtrl.wait_registry_empty(t, 10)
398
399 mainCtrl.VerifyCounterValues(t)
400}
401
402//-----------------------------------------------------------------------------
403// TestSubMergeDelAndRouteUpdateNok
404// stub stub
405// +-------+ +-------+ +---------+ +---------+
406// | xapp2 | | xapp1 | | submgr | | e2term |
407// +-------+ +-------+ +---------+ +---------+
408// | | | |
409// | | | |
410// | | | |
411// | | SubReq1 | |
412// | |------------->| |
413// | | | |
414// | | | SubReq1 |
415// | | |------------->|
416// | | | SubResp1 |
417// | | |<-------------|
418// | | SubResp1 | |
419// | |<-------------| |
420// | | | |
421// | SubReq2 | |
422// |--------------------------->| |
423// | | | |
424// | SubResp2 | |
425// |<---------------------------| |
426// | | | |
427// | | SubDelReq 1 | |
428// | |------------->| |
429// | | | RouteUpdate |
430// | | |-----> rtmgr |
431// | | | |
432// | | | RouteUpdate |
433// | | | status:400 |
434// | | |<----- rtmgr |
435// | | | |
436// | | SubDelResp 1 | |
437// | |<-------------| |
438// | | | |
439// | SubDelReq 2 | |
440// |--------------------------->| |
441// | | | |
442// | | | SubDelReq 2 |
443// | | |------------->|
444// | | | |
445// | | | SubDelReq 2 |
446// | | |------------->|
447// | | | |
448// | SubDelResp 2 | |
449// |<---------------------------| |
450//
451//-----------------------------------------------------------------------------
452func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
453 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
454
455 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200456 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
457 Counter{cSubReqFromXapp, 2},
458 Counter{cSubReqToE2, 1},
459 Counter{cSubRespFromE2, 1},
460 Counter{cSubRespToXapp, 2},
461 Counter{cSubDelReqFromXapp, 2},
462 Counter{cRouteDeleteUpdateFail, 1},
463 Counter{cSubDelReqToE2, 1},
464 Counter{cSubDelRespFromE2, 1},
465 Counter{cSubDelRespToXapp, 2},
466 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200467
468 //Req1
469 rparams1 := &teststube2ap.E2StubSubsReqParams{}
470 rparams1.Init()
471 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
472 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
473 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
474 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
475
476 //Req2
477 rparams2 := &teststube2ap.E2StubSubsReqParams{}
478 rparams2.Init()
479 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
480 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
481
482 resp, _ := xapp.Subscription.QuerySubscriptions()
483 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
484 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300485 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200486
487 //Del1
488 waiter := rtmgrHttp.AllocNextEvent(false)
489 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
490 waiter.WaitResult(t)
491
492 xappConn1.RecvSubsDelResp(t, deltrans1)
493
494 //Del2
495 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
496 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
497 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
498 xappConn2.RecvSubsDelResp(t, deltrans2)
499 //Wait that subs is cleaned
500 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
501
502 xappConn1.TestMsgChanEmpty(t)
503 xappConn2.TestMsgChanEmpty(t)
504 e2termConn1.TestMsgChanEmpty(t)
505 mainCtrl.wait_registry_empty(t, 10)
506
507 mainCtrl.VerifyCounterValues(t)
508}
509
510//-----------------------------------------------------------------------------
511
512//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200513// TestSubReqAndSubDelOk
514//
515// stub stub
516// +-------+ +---------+ +---------+
517// | xapp | | submgr | | e2term |
518// +-------+ +---------+ +---------+
519// | | |
520// | SubReq | |
521// |------------->| |
522// | | |
523// | | SubReq |
524// | |------------->|
525// | | |
526// | | SubResp |
527// | |<-------------|
528// | | |
529// | SubResp | |
530// |<-------------| |
531// | | |
532// | | |
533// | SubDelReq | |
534// |------------->| |
535// | | |
536// | | SubDelReq |
537// | |------------->|
538// | | |
539// | | SubDelResp |
540// | |<-------------|
541// | | |
542// | SubDelResp | |
543// |<-------------| |
544//
545//-----------------------------------------------------------------------------
546func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200547 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200548
Anssi Mannila4abf1802021-01-28 13:06:46 +0200549 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200550 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
551 Counter{cSubReqFromXapp, 1},
552 Counter{cSubReqToE2, 1},
553 Counter{cSubRespFromE2, 1},
554 Counter{cSubRespToXapp, 1},
555 Counter{cSubDelReqFromXapp, 1},
556 Counter{cSubDelReqToE2, 1},
557 Counter{cSubDelRespFromE2, 1},
558 Counter{cSubDelRespToXapp, 1},
559 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200560
561 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200562 crereq, cremsg := e2termConn1.RecvSubsReq(t)
563 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200564 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200565
566 resp, _ := xapp.Subscription.QuerySubscriptions()
567 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
568 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300569 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200570
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200571 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200572 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200573
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200574 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200575 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200576
577 //Wait that subs is cleaned
578 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
579
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200580 xappConn1.TestMsgChanEmpty(t)
581 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200582 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200583 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200584
585 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200586}
587
588//-----------------------------------------------------------------------------
589// TestSubReqRetransmission
590//
591// stub stub
592// +-------+ +---------+ +---------+
593// | xapp | | submgr | | e2term |
594// +-------+ +---------+ +---------+
595// | | |
596// | SubReq | |
597// |------------->| |
598// | | |
599// | | SubReq |
600// | |------------->|
601// | | |
602// | SubReq | |
603// | (retrans) | |
604// |------------->| |
605// | | |
606// | | SubResp |
607// | |<-------------|
608// | | |
609// | SubResp | |
610// |<-------------| |
611// | | |
612// | [SUBS DELETE] |
613// | | |
614//
615//-----------------------------------------------------------------------------
616func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200617 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200618
619 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200620 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200621 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200622
623 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200624 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200625 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
626
Juha Hyttinen1683f912020-04-17 10:39:57 +0300627 // hack as there is no real way to see has message be handled.
628 // Previuos counter check just tells that is has been received by submgr
629 // --> artificial delay
630 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200631 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200632 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200633
634 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200635 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200636 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
637 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200638 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200639
640 //Wait that subs is cleaned
641 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
642
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200643 xappConn1.TestMsgChanEmpty(t)
644 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200645 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200646 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200647}
648
649//-----------------------------------------------------------------------------
650// TestSubDelReqRetransmission
651//
652// stub stub
653// +-------+ +---------+ +---------+
654// | xapp | | submgr | | e2term |
655// +-------+ +---------+ +---------+
656// | | |
657// | [SUBS CREATE] |
658// | | |
659// | | |
660// | SubDelReq | |
661// |------------->| |
662// | | |
663// | | SubDelReq |
664// | |------------->|
665// | | |
666// | SubDelReq | |
667// | (same sub) | |
668// | (same xid) | |
669// |------------->| |
670// | | |
671// | | SubDelResp |
672// | |<-------------|
673// | | |
674// | SubDelResp | |
675// |<-------------| |
676//
677//-----------------------------------------------------------------------------
678func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200679 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200680
681 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200682 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200683 crereq, cremsg := e2termConn1.RecvSubsReq(t)
684 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200685 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200686
687 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200688 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200689 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200690
691 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200692 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200693 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
694
Juha Hyttinen1683f912020-04-17 10:39:57 +0300695 // hack as there is no real way to see has message be handled.
696 // Previuos counter check just tells that is has been received by submgr
697 // --> artificial delay
698 <-time.After(1 * time.Second)
699
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200700 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200701 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200702
703 //Wait that subs is cleaned
704 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
705
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200706 xappConn1.TestMsgChanEmpty(t)
707 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200708 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200709 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200710}
711
712//-----------------------------------------------------------------------------
713// TestSubDelReqCollision
714//
715// stub stub
716// +-------+ +---------+ +---------+
717// | xapp | | submgr | | e2term |
718// +-------+ +---------+ +---------+
719// | | |
720// | [SUBS CREATE] |
721// | | |
722// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200723// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200724// |------------->| |
725// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200726// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200727// | |------------->|
728// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200729// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200730// | (same sub) | |
731// | (diff xid) | |
732// |------------->| |
733// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200734// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200735// | |<-------------|
736// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200737// | SubDelResp 1 | |
738// |<-------------| |
739// | | |
740// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200741// |<-------------| |
742//
743//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200744
Juha Hyttinenfa015662020-01-24 10:05:18 +0200745func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200746 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200747
748 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200749 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200750 crereq, cremsg := e2termConn1.RecvSubsReq(t)
751 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200752 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200753
754 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200755 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200756 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200757
Juha Hyttinen3944a222020-01-24 11:51:46 +0200758 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200759 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200760 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
761 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200762 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
763
Juha Hyttinen1683f912020-04-17 10:39:57 +0300764 // hack as there is no real way to see has message be handled.
765 // Previuos counter check just tells that is has been received by submgr
766 // --> artificial delay
767 <-time.After(1 * time.Second)
768
Juha Hyttinen3944a222020-01-24 11:51:46 +0200769 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200770 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200771
772 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200773 xappConn1.RecvSubsDelResp(t, nil)
774 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200775
776 //Wait that subs is cleaned
777 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
778
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200779 xappConn1.TestMsgChanEmpty(t)
780 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200781 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200782 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200783}
784
785//-----------------------------------------------------------------------------
786// TestSubReqAndSubDelOkTwoParallel
787//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200788// stub stub stub
789// +-------+ +-------+ +---------+ +---------+
790// | xapp | | xapp | | submgr | | e2term |
791// +-------+ +-------+ +---------+ +---------+
792// | | | |
793// | | | |
794// | | | |
795// | | SubReq1 | |
796// | |------------->| |
797// | | | |
798// | | | SubReq1 |
799// | | |------------->|
800// | | | |
801// | SubReq2 | |
802// |------------------------>| |
803// | | | |
804// | | | SubReq2 |
805// | | |------------->|
806// | | | |
807// | | | SubResp1 |
808// | | |<-------------|
809// | | SubResp1 | |
810// | |<-------------| |
811// | | | |
812// | | | SubResp2 |
813// | | |<-------------|
814// | SubResp2 | |
815// |<------------------------| |
816// | | | |
817// | | [SUBS 1 DELETE] |
818// | | | |
819// | | [SUBS 2 DELETE] |
820// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200821//
822//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +0300823
Juha Hyttinenfa015662020-01-24 10:05:18 +0200824func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200825 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200826
827 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200828 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200829 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200830 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200831 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200832
833 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200834 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200835 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300836
837 rparams2.Req.EventTriggerDefinition.Data.Length = 1
838 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
839 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
840
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200841 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200842 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200843
844 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200845 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200846 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200847
848 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200849 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200850 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200851
852 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200853 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200854 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
855 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200856 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200857 //Wait that subs is cleaned
858 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
859
860 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200861 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200862 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
863 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200864 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200865 //Wait that subs is cleaned
866 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
867
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200868 xappConn1.TestMsgChanEmpty(t)
869 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200870 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200871 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200872}
873
874//-----------------------------------------------------------------------------
875// TestSameSubsDiffRan
876// Same subscription to different RANs
877//
878// stub stub
879// +-------+ +---------+ +---------+
880// | xapp | | submgr | | e2term |
881// +-------+ +---------+ +---------+
882// | | |
883// | | |
884// | | |
885// | SubReq(r1) | |
886// |------------->| |
887// | | |
888// | | SubReq(r1) |
889// | |------------->|
890// | | |
891// | | SubResp(r1) |
892// | |<-------------|
893// | | |
894// | SubResp(r1) | |
895// |<-------------| |
896// | | |
897// | SubReq(r2) | |
898// |------------->| |
899// | | |
900// | | SubReq(r2) |
901// | |------------->|
902// | | |
903// | | SubResp(r2) |
904// | |<-------------|
905// | | |
906// | SubResp(r2) | |
907// |<-------------| |
908// | | |
909// | [SUBS r1 DELETE] |
910// | | |
911// | [SUBS r2 DELETE] |
912// | | |
913//
914//-----------------------------------------------------------------------------
915func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200916 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200917
918 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200919 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
920 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200921 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
922 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200923 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200924
925 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200926 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
927 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200928 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
929 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200930 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200931
932 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200933 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
934 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200935 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
936 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200937 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200938 //Wait that subs is cleaned
939 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
940
941 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200942 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
943 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200944 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
945 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200946 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200947 //Wait that subs is cleaned
948 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
949
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200950 xappConn1.TestMsgChanEmpty(t)
951 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200952 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200953 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200954}
955
956//-----------------------------------------------------------------------------
957// TestSubReqRetryInSubmgr
958//
959// stub stub
960// +-------+ +---------+ +---------+
961// | xapp | | submgr | | e2term |
962// +-------+ +---------+ +---------+
963// | | |
964// | SubReq | |
965// |------------->| |
966// | | |
967// | | SubReq |
968// | |------------->|
969// | | |
970// | | |
971// | | SubReq |
972// | |------------->|
973// | | |
974// | | SubResp |
975// | |<-------------|
976// | | |
977// | SubResp | |
978// |<-------------| |
979// | | |
980// | [SUBS DELETE] |
981// | | |
982//
983//-----------------------------------------------------------------------------
984
985func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200986 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200987
988 // Init counter check
989 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
990 Counter{cSubReqFromXapp, 1},
991 Counter{cSubReqToE2, 1},
992 Counter{cSubReReqToE2, 1},
993 Counter{cSubRespFromE2, 1},
994 Counter{cSubRespToXapp, 1},
995 Counter{cSubDelReqFromXapp, 1},
996 Counter{cSubDelReqToE2, 1},
997 Counter{cSubDelRespFromE2, 1},
998 Counter{cSubDelRespToXapp, 1},
999 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001000
1001 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001002 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001003
1004 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001005 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001006
1007 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001008 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1009 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001010
1011 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001012 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001013
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001014 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001015 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1016 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001017 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001018
1019 // Wait that subs is cleaned
1020 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1021
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001022 xappConn1.TestMsgChanEmpty(t)
1023 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001024 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001025 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001026
1027 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001028}
1029
1030//-----------------------------------------------------------------------------
1031// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1032//
1033// stub stub
1034// +-------+ +---------+ +---------+
1035// | xapp | | submgr | | e2term |
1036// +-------+ +---------+ +---------+
1037// | | |
1038// | SubReq | |
1039// |------------->| |
1040// | | |
1041// | | SubReq |
1042// | |------------->|
1043// | | |
1044// | | |
1045// | | SubReq |
1046// | |------------->|
1047// | | |
1048// | | SubDelReq |
1049// | |------------->|
1050// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001051// | | SubDelResp |
1052// | |<-------------|
1053// | | |
1054//
1055//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001056func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001057 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001058
1059 // Init counter check
1060 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1061 Counter{cSubReqFromXapp, 1},
1062 Counter{cSubReqToE2, 1},
1063 Counter{cSubReReqToE2, 1},
1064 Counter{cSubReqTimerExpiry, 2},
1065 Counter{cSubDelReqToE2, 1},
1066 Counter{cSubDelRespFromE2, 1},
1067 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001068
1069 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001070 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001071
1072 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001073 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001074
1075 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001076 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001077
1078 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001079 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1080 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001081
1082 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001083 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001084
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001085 xappConn1.TestMsgChanEmpty(t)
1086 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001087 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001088 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001089
1090 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001091}
1092
1093//-----------------------------------------------------------------------------
1094// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1095//
1096// stub stub
1097// +-------+ +---------+ +---------+
1098// | xapp | | submgr | | e2term |
1099// +-------+ +---------+ +---------+
1100// | | |
1101// | SubReq | |
1102// |------------->| |
1103// | | |
1104// | | SubReq |
1105// | |------------->|
1106// | | |
1107// | | |
1108// | | SubReq |
1109// | |------------->|
1110// | | |
1111// | | SubDelReq |
1112// | |------------->|
1113// | | |
1114// | | |
1115// | | SubDelReq |
1116// | |------------->|
1117// | | |
1118// | | |
1119//
1120//-----------------------------------------------------------------------------
1121
1122func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001123 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001124
1125 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1126 Counter{cSubReqFromXapp, 1},
1127 Counter{cSubReqToE2, 1},
1128 Counter{cSubReReqToE2, 1},
1129 Counter{cSubReqTimerExpiry, 2},
1130 Counter{cSubDelReqToE2, 1},
1131 Counter{cSubDelReReqToE2, 1},
1132 Counter{cSubDelReqTimerExpiry, 2},
1133 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001134
1135 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001136 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001137
1138 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001139 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001140
1141 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001142 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001143
1144 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001145 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001146
1147 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001148 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001149
1150 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001151 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001152
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001153 xappConn1.TestMsgChanEmpty(t)
1154 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001155 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001156 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001157
1158 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001159}
1160
1161//-----------------------------------------------------------------------------
1162// TestSubReqSubFailRespInSubmgr
1163//
1164// stub stub
1165// +-------+ +---------+ +---------+
1166// | xapp | | submgr | | e2term |
1167// +-------+ +---------+ +---------+
1168// | | |
1169// | SubReq | |
1170// |------------->| |
1171// | | |
1172// | | SubReq |
1173// | |------------->|
1174// | | |
1175// | | SubFail |
1176// | |<-------------|
1177// | | |
archaggeafbf95f2021-04-14 08:54:05 +03001178// | | SubDelReq |
1179// | |------------->|
1180// | | |
1181// | | SubDelResp |
1182// | |<-------------|
1183// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001184// | SubFail | |
1185// |<-------------| |
1186// | | |
1187//
1188//-----------------------------------------------------------------------------
1189
1190func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001191 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001192
1193 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1194 Counter{cSubReqFromXapp, 1},
1195 Counter{cSubReqToE2, 1},
1196 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001197 Counter{cSubFailToXapp, 1},
1198 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001199
1200 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001201 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001202
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001203 // E2t: Receive SubsReq and send SubsFail (first)
1204 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1205 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1206 fparams1.Set(crereq1)
1207 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1208
archaggeafbf95f2021-04-14 08:54:05 +03001209 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1210 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1211 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1212
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001213 // Xapp: Receive SubsFail
1214 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1215
1216 // Wait that subs is cleaned
1217 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1218
1219 xappConn1.TestMsgChanEmpty(t)
1220 xappConn2.TestMsgChanEmpty(t)
1221 e2termConn1.TestMsgChanEmpty(t)
1222 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001223
1224 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001225}
1226
1227//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001228// TestSubDelReqRetryInSubmgr
1229//
1230// stub stub
1231// +-------+ +---------+ +---------+
1232// | xapp | | submgr | | e2term |
1233// +-------+ +---------+ +---------+
1234// | | |
1235// | [SUBS CREATE] |
1236// | | |
1237// | | |
1238// | SubDelReq | |
1239// |------------->| |
1240// | | |
1241// | | SubDelReq |
1242// | |------------->|
1243// | | |
1244// | | SubDelReq |
1245// | |------------->|
1246// | | |
1247// | | SubDelResp |
1248// | |<-------------|
1249// | | |
1250// | SubDelResp | |
1251// |<-------------| |
1252//
1253//-----------------------------------------------------------------------------
1254
1255func TestSubDelReqRetryInSubmgr(t *testing.T) {
1256
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001257 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001258
1259 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001260 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001261 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1262 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001263 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001264
1265 // Subs Delete
1266 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001267 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001268
1269 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001270 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001271
1272 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001273 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1274 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001275
1276 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001277 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001278
1279 // Wait that subs is cleaned
1280 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1281
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001282 xappConn1.TestMsgChanEmpty(t)
1283 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001284 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001285 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001286}
1287
1288//-----------------------------------------------------------------------------
1289// TestSubDelReqTwoRetriesNoRespInSubmgr
1290//
1291// stub stub
1292// +-------+ +---------+ +---------+
1293// | xapp | | submgr | | e2term |
1294// +-------+ +---------+ +---------+
1295// | | |
1296// | [SUBS CREATE] |
1297// | | |
1298// | | |
1299// | SubDelReq | |
1300// |------------->| |
1301// | | |
1302// | | SubDelReq |
1303// | |------------->|
1304// | | |
1305// | | SubDelReq |
1306// | |------------->|
1307// | | |
1308// | | |
1309// | SubDelResp | |
1310// |<-------------| |
1311//
1312//-----------------------------------------------------------------------------
1313
1314func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1315
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001316 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001317
1318 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001319 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001320 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1321 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001322 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001323
1324 // Subs Delete
1325 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001326 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001327
1328 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001329 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001330
1331 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001332 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001333
1334 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001335 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001336
1337 // Wait that subs is cleaned
1338 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1339
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001340 xappConn1.TestMsgChanEmpty(t)
1341 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001342 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001343 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001344}
1345
1346//-----------------------------------------------------------------------------
1347// TestSubDelReqSubDelFailRespInSubmgr
1348//
1349// stub stub
1350// +-------+ +---------+ +---------+
1351// | xapp | | submgr | | e2term |
1352// +-------+ +---------+ +---------+
1353// | | |
1354// | [SUBS CREATE] |
1355// | | |
1356// | | |
1357// | SubDelReq | |
1358// |------------->| |
1359// | | |
1360// | | SubDelReq |
1361// | |------------->|
1362// | | |
1363// | | SubDelFail |
1364// | |<-------------|
1365// | | |
1366// | SubDelResp | |
1367// |<-------------| |
1368// | | |
1369//
1370//-----------------------------------------------------------------------------
1371
1372func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001373 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001374
1375 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1376 Counter{cSubReqFromXapp, 1},
1377 Counter{cSubReqToE2, 1},
1378 Counter{cSubRespFromE2, 1},
1379 Counter{cSubRespToXapp, 1},
1380 Counter{cSubDelReqFromXapp, 1},
1381 Counter{cSubDelReqToE2, 1},
1382 Counter{cSubDelFailFromE2, 1},
1383 Counter{cSubDelRespToXapp, 1},
1384 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001385
1386 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001387 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001388 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1389 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001390 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001391
1392 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001393 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001394
1395 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001396 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1397 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001398
1399 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001400 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001401
1402 // Wait that subs is cleaned
1403 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1404
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001405 xappConn1.TestMsgChanEmpty(t)
1406 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001407 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001408 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001409
1410 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001411}
1412
1413//-----------------------------------------------------------------------------
1414// TestSubReqAndSubDelOkSameAction
1415//
1416// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001417// +-------+ +-------+ +---------+ +---------+
1418// | xapp2 | | xapp1 | | submgr | | e2term |
1419// +-------+ +-------+ +---------+ +---------+
1420// | | | |
1421// | | | |
1422// | | | |
1423// | | SubReq1 | |
1424// | |------------->| |
1425// | | | |
1426// | | | SubReq1 |
1427// | | |------------->|
1428// | | | SubResp1 |
1429// | | |<-------------|
1430// | | SubResp1 | |
1431// | |<-------------| |
1432// | | | |
1433// | SubReq2 | |
1434// |--------------------------->| |
1435// | | | |
1436// | SubResp2 | |
1437// |<---------------------------| |
1438// | | | |
1439// | | SubDelReq 1 | |
1440// | |------------->| |
1441// | | | |
1442// | | SubDelResp 1 | |
1443// | |<-------------| |
1444// | | | |
1445// | SubDelReq 2 | |
1446// |--------------------------->| |
1447// | | | |
1448// | | | SubDelReq 2 |
1449// | | |------------->|
1450// | | | |
1451// | | | SubDelReq 2 |
1452// | | |------------->|
1453// | | | |
1454// | SubDelResp 2 | |
1455// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001456//
1457//-----------------------------------------------------------------------------
1458func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001459 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001460
Anssi Mannila4abf1802021-01-28 13:06:46 +02001461 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001462 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1463 Counter{cSubReqFromXapp, 2},
1464 Counter{cSubReqToE2, 1},
1465 Counter{cSubRespFromE2, 1},
1466 Counter{cSubRespToXapp, 2},
1467 Counter{cMergedSubscriptions, 1},
1468 Counter{cUnmergedSubscriptions, 1},
1469 Counter{cSubDelReqFromXapp, 2},
1470 Counter{cSubDelReqToE2, 1},
1471 Counter{cSubDelRespFromE2, 1},
1472 Counter{cSubDelRespToXapp, 2},
1473 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001474
Juha Hyttinen3944a222020-01-24 11:51:46 +02001475 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001476 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001477 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001478 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001479 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1480 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001481 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001482
1483 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001484 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001485 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001486 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001487 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1488 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001489 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001490
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001491 resp, _ := xapp.Subscription.QuerySubscriptions()
1492 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1493 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001494 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001495
Juha Hyttinen3944a222020-01-24 11:51:46 +02001496 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001497 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001498 //e2termConn1.RecvSubsDelReq(t)
1499 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001500 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001501 //Wait that subs is cleaned
1502 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1503
1504 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001505 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001506 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1507 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001508 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001509 //Wait that subs is cleaned
1510 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1511
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001512 xappConn1.TestMsgChanEmpty(t)
1513 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001514 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001515 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001516
1517 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001518}
1519
1520//-----------------------------------------------------------------------------
1521// TestSubReqAndSubDelOkSameActionParallel
1522//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001523// stub stub stub
1524// +-------+ +-------+ +---------+ +---------+
1525// | xapp2 | | xapp1 | | submgr | | e2term |
1526// +-------+ +-------+ +---------+ +---------+
1527// | | | |
1528// | | | |
1529// | | | |
1530// | | SubReq1 | |
1531// | |------------->| |
1532// | | | |
1533// | | | SubReq1 |
1534// | | |------------->|
1535// | SubReq2 | |
1536// |--------------------------->| |
1537// | | | SubResp1 |
1538// | | |<-------------|
1539// | | SubResp1 | |
1540// | |<-------------| |
1541// | | | |
1542// | SubResp2 | |
1543// |<---------------------------| |
1544// | | | |
1545// | | SubDelReq 1 | |
1546// | |------------->| |
1547// | | | |
1548// | | SubDelResp 1 | |
1549// | |<-------------| |
1550// | | | |
1551// | SubDelReq 2 | |
1552// |--------------------------->| |
1553// | | | |
1554// | | | SubDelReq 2 |
1555// | | |------------->|
1556// | | | |
1557// | | | SubDelReq 2 |
1558// | | |------------->|
1559// | | | |
1560// | SubDelResp 2 | |
1561// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001562//
1563//-----------------------------------------------------------------------------
1564func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001565 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001566
1567 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001568 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001569 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001570 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001571 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001572
1573 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001574 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001575 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001576 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001577
1578 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001579 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001580 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001581
1582 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001583 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001584
1585 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001586 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1587 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001588
1589 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001590 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001591 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1592 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001593 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001594
1595 //Wait that subs is cleaned
1596 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1597
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001598 xappConn1.TestMsgChanEmpty(t)
1599 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001600 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001601 mainCtrl.wait_registry_empty(t, 10)
1602}
1603
1604//-----------------------------------------------------------------------------
1605// TestSubReqAndSubDelNokSameActionParallel
1606//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001607// stub stub stub
1608// +-------+ +-------+ +---------+ +---------+
1609// | xapp2 | | xapp1 | | submgr | | e2term |
1610// +-------+ +-------+ +---------+ +---------+
1611// | | | |
1612// | | | |
1613// | | | |
1614// | | SubReq1 | |
1615// | |------------->| |
1616// | | | |
1617// | | | SubReq1 |
1618// | | |------------->|
1619// | SubReq2 | |
1620// |--------------------------->| |
1621// | | | SubFail1 |
1622// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001623// | | | |
archaggeafbf95f2021-04-14 08:54:05 +03001624// | | | SubDelReq |
1625// | | |------------->|
1626// | | | SubDelResp |
1627// | | |<-------------|
1628// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001629// | | SubFail1 | |
1630// | |<-------------| |
1631// | | | |
1632// | SubFail2 | |
1633// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001634//
1635//-----------------------------------------------------------------------------
1636func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001637 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001638
1639 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001640 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001641 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001642 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001643
1644 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001645 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001646
1647 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001648 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001649 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001650 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001651 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001652 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001653
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001654 // E2t: send SubsFail (first)
1655 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1656 fparams1.Set(crereq1)
1657 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1658
archaggeafbf95f2021-04-14 08:54:05 +03001659 // E2t: internal delete
1660 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1661 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1662
Juha Hyttinen3944a222020-01-24 11:51:46 +02001663 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001664 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001665 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001666 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001667
1668 //Wait that subs is cleaned
1669 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1670
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001671 xappConn1.TestMsgChanEmpty(t)
1672 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001673 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001674 mainCtrl.wait_registry_empty(t, 10)
1675}
1676
1677//-----------------------------------------------------------------------------
1678// TestSubReqAndSubDelNoAnswerSameActionParallel
1679//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001680// stub stub stub
1681// +-------+ +-------+ +---------+ +---------+
1682// | xapp2 | | xapp1 | | submgr | | e2term |
1683// +-------+ +-------+ +---------+ +---------+
1684// | | | |
1685// | | | |
1686// | | | |
1687// | | SubReq1 | |
1688// | |------------->| |
1689// | | | |
1690// | | | SubReq1 |
1691// | | |------------->|
1692// | | SubReq2 | |
1693// |--------------------------->| |
1694// | | | |
1695// | | | SubReq1 |
1696// | | |------------->|
1697// | | | |
1698// | | | |
1699// | | | SubDelReq |
1700// | | |------------->|
1701// | | | |
1702// | | | SubDelResp |
1703// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001704//
1705//-----------------------------------------------------------------------------
1706func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001707 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001708
1709 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001710 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001711 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001712 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001713
Juha Hyttinen1683f912020-04-17 10:39:57 +03001714 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001715
1716 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001717 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001718 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001719 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001720 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001721 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001722
1723 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001724 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001725
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001726 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1727 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001728
1729 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001730 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001731
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001732 xappConn1.TestMsgChanEmpty(t)
1733 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001734 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001735 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001736}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001737
1738//----------------------------- Policy cases ---------------------------------
1739//-----------------------------------------------------------------------------
1740// TestSubReqPolicyAndSubDelOk
1741//
1742// stub stub
1743// +-------+ +---------+ +---------+
1744// | xapp | | submgr | | e2term |
1745// +-------+ +---------+ +---------+
1746// | | |
1747// | SubReq | |
1748// |------------->| |
1749// | | |
1750// | | SubReq |
1751// | |------------->|
1752// | | |
1753// | | SubResp |
1754// | |<-------------|
1755// | | |
1756// | SubResp | |
1757// |<-------------| |
1758// | | |
1759// | | |
1760// | SubDelReq | |
1761// |------------->| |
1762// | | |
1763// | | SubDelReq |
1764// | |------------->|
1765// | | |
1766// | | SubDelResp |
1767// | |<-------------|
1768// | | |
1769// | SubDelResp | |
1770// |<-------------| |
1771//
1772//-----------------------------------------------------------------------------
1773func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1774 CaseBegin("TestSubReqAndSubDelOk")
1775
1776 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1777 rparams1.Init()
1778 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1779 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1780
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001781 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1782 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001783 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1784 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001785 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001786
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001787 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001788 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001789
1790 //Wait that subs is cleaned
1791 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1792
1793 xappConn1.TestMsgChanEmpty(t)
1794 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001795 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001796 mainCtrl.wait_registry_empty(t, 10)
1797}
1798
1799//-----------------------------------------------------------------------------
1800// TestSubReqPolicyChangeAndSubDelOk
1801//
1802// stub stub
1803// +-------+ +---------+ +---------+
1804// | xapp | | submgr | | e2term |
1805// +-------+ +---------+ +---------+
1806// | | |
1807// | SubReq | |
1808// |------------->| |
1809// | | |
1810// | | SubReq |
1811// | |------------->|
1812// | | |
1813// | | SubResp |
1814// | |<-------------|
1815// | | |
1816// | SubResp | |
1817// |<-------------| |
1818// | | |
1819// | SubReq | |
1820// |------------->| |
1821// | | |
1822// | | SubReq |
1823// | |------------->|
1824// | | |
1825// | | SubResp |
1826// | |<-------------|
1827// | | |
1828// | SubResp | |
1829// |<-------------| |
1830// | | |
1831// | SubDelReq | |
1832// |------------->| |
1833// | | |
1834// | | SubDelReq |
1835// | |------------->|
1836// | | |
1837// | | SubDelResp |
1838// | |<-------------|
1839// | | |
1840// | SubDelResp | |
1841// |<-------------| |
1842//
1843//-----------------------------------------------------------------------------
1844
1845func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1846 CaseBegin("TestSubReqAndSubDelOk")
1847
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001848 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1849 rparams1.Init()
1850 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1851 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001852
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001853 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1854 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001855 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1856
1857 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001858 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001859 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1860 xappConn1.SendSubsReq(t, rparams1, cretrans)
1861
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001862 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1863 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001864 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1865 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001866 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001867
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001868 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001869 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001870
1871 //Wait that subs is cleaned
1872 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1873
1874 xappConn1.TestMsgChanEmpty(t)
1875 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001876 e2termConn1.TestMsgChanEmpty(t)
1877 mainCtrl.wait_registry_empty(t, 10)
1878}
1879
1880//-----------------------------------------------------------------------------
1881// TestSubReqAndSubDelOkTwoE2termParallel
1882//
1883// stub stub stub
1884// +-------+ +---------+ +---------+ +---------+
1885// | xapp | | submgr | | e2term1 | | e2term2 |
1886// +-------+ +---------+ +---------+ +---------+
1887// | | | |
1888// | | | |
1889// | | | |
1890// | SubReq1 | | |
1891// |------------->| | |
1892// | | | |
1893// | | SubReq1 | |
1894// | |------------->| |
1895// | | | |
1896// | SubReq2 | | |
1897// |------------->| | |
1898// | | | |
1899// | | SubReq2 | |
1900// | |---------------------------->|
1901// | | | |
1902// | | SubResp1 | |
1903// | |<-------------| |
1904// | SubResp1 | | |
1905// |<-------------| | |
1906// | | SubResp2 | |
1907// | |<----------------------------|
1908// | SubResp2 | | |
1909// |<-------------| | |
1910// | | | |
1911// | [SUBS 1 DELETE] | |
1912// | | | |
1913// | [SUBS 2 DELETE] | |
1914// | | | |
1915//
1916//-----------------------------------------------------------------------------
1917func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1918 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1919
1920 //Req1
1921 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1922 xappConn1.SendSubsReq(t, nil, cretrans1)
1923 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1924
1925 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1926 xappConn1.SendSubsReq(t, nil, cretrans2)
1927 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1928
1929 //Resp1
1930 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1931 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1932
1933 //Resp2
1934 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1935 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1936
1937 //Del1
1938 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1939 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1940 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1941 xappConn1.RecvSubsDelResp(t, deltrans1)
1942 //Wait that subs is cleaned
1943 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1944
1945 //Del2
1946 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1947 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1948 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1949 xappConn1.RecvSubsDelResp(t, deltrans2)
1950 //Wait that subs is cleaned
1951 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1952
1953 xappConn1.TestMsgChanEmpty(t)
1954 xappConn2.TestMsgChanEmpty(t)
1955 e2termConn1.TestMsgChanEmpty(t)
1956 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001957 mainCtrl.wait_registry_empty(t, 10)
1958}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001959
1960//-----------------------------------------------------------------------------
1961// TestSubReqInsertAndSubDelOk
1962//
1963// stub stub
1964// +-------+ +---------+ +---------+
1965// | xapp | | submgr | | e2term |
1966// +-------+ +---------+ +---------+
1967// | | |
1968// | SubReq | |
1969// |------------->| |
1970// | | |
1971// | | SubReq |
1972// | |------------->|
1973// | | |
1974// | | SubResp |
1975// | |<-------------|
1976// | | |
1977// | SubResp | |
1978// |<-------------| |
1979// | | |
1980// | | |
1981// | SubDelReq | |
1982// |------------->| |
1983// | | |
1984// | | SubDelReq |
1985// | |------------->|
1986// | | |
1987// | | SubDelResp |
1988// | |<-------------|
1989// | | |
1990// | SubDelResp | |
1991// |<-------------| |
1992//
1993//-----------------------------------------------------------------------------
1994func TestSubReqInsertAndSubDelOk(t *testing.T) {
1995 CaseBegin("TestInsertSubReqAndSubDelOk")
1996
1997 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1998 rparams1.Init()
1999 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2000 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2001
2002 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2003 e2termConn1.SendSubsResp(t, crereq, cremsg)
2004 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2005 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2006 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2007
2008 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2009 xappConn1.RecvSubsDelResp(t, deltrans)
2010
2011 //Wait that subs is cleaned
2012 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2013
2014 xappConn1.TestMsgChanEmpty(t)
2015 xappConn2.TestMsgChanEmpty(t)
2016 e2termConn1.TestMsgChanEmpty(t)
2017 mainCtrl.wait_registry_empty(t, 10)
2018}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002019
2020//-----------------------------------------------------------------------------
2021// TestSubReqRetransmissionWithSameSubIdDiffXid
2022//
2023// This case simulates case where xApp restarts and starts sending same
2024// subscription requests which have already subscribed successfully
2025
2026// stub stub
2027// +-------+ +---------+ +---------+
2028// | xapp | | submgr | | e2term |
2029// +-------+ +---------+ +---------+
2030// | | |
2031// | SubReq | |
2032// |------------->| |
2033// | | |
2034// | | SubReq |
2035// | |------------->|
2036// | | |
2037// | | SubResp |
2038// | |<-------------|
2039// | | |
2040// | SubResp | |
2041// |<-------------| |
2042// | | |
2043// | xApp restart | |
2044// | | |
2045// | SubReq | |
2046// | (retrans with same xApp generated subid but diff xid)
2047// |------------->| |
2048// | | |
2049// | SubResp | |
2050// |<-------------| |
2051// | | |
2052// | [SUBS DELETE] |
2053// | | |
2054//
2055//-----------------------------------------------------------------------------
2056func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2057 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2058
2059 //Subs Create
2060 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2061 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2062 e2termConn1.SendSubsResp(t, crereq, cremsg)
2063 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2064
2065 // xApp restart here
2066 // --> artificial delay
2067 <-time.After(1 * time.Second)
2068
2069 //Subs Create
2070 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2071 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2072
2073 //Subs Delete
2074 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2075 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2076 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2077 xappConn1.RecvSubsDelResp(t, deltrans)
2078
2079 //Wait that subs is cleaned
2080 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2081
2082 xappConn1.TestMsgChanEmpty(t)
2083 xappConn2.TestMsgChanEmpty(t)
2084 e2termConn1.TestMsgChanEmpty(t)
2085 mainCtrl.wait_registry_empty(t, 10)
2086}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002087
2088//-----------------------------------------------------------------------------
2089// TestSubReqNokAndSubDelOkWithRestartInMiddle
2090//
2091// stub stub
2092// +-------+ +---------+ +---------+
2093// | xapp | | submgr | | e2term |
2094// +-------+ +---------+ +---------+
2095// | | |
2096// | SubReq | |
2097// |------------->| |
2098// | | |
2099// | | SubReq |
2100// | |------------->|
2101// | | |
2102// | | SubResp |
2103// | <----|
2104// | |
2105// | Submgr restart |
2106// | |
2107// | | |
2108// | | SubDelReq |
2109// | |------------->|
2110// | | |
2111// | | SubDelResp |
2112// | |<-------------|
2113// | | |
2114//
2115//-----------------------------------------------------------------------------
2116
2117func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2118 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2119
2120 // Remove possible existing subscrition
2121 mainCtrl.removeExistingSubscriptions(t)
2122
2123 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2124 xappConn1.SendSubsReq(t, nil, nil)
2125 e2termConn1.RecvSubsReq(t)
2126 mainCtrl.SetResetTestFlag(t, false)
2127
2128 resp, _ := xapp.Subscription.QuerySubscriptions()
2129 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002130 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002131 e2SubsId := uint32(resp[0].SubscriptionID)
2132 t.Logf("e2SubsId = %v", e2SubsId)
2133
archaggeafbf95f2021-04-14 08:54:05 +03002134 mainCtrl.SimulateRestart(t)
2135 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002136
2137 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2138 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2139
2140 // Wait that subs is cleaned
2141 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2142
2143 xappConn1.TestMsgChanEmpty(t)
2144 xappConn2.TestMsgChanEmpty(t)
2145 e2termConn1.TestMsgChanEmpty(t)
2146 mainCtrl.wait_registry_empty(t, 10)
2147}
2148
2149//-----------------------------------------------------------------------------
2150// TestSubReqAndSubDelOkWithRestartInMiddle
2151//
2152// stub stub
2153// +-------+ +---------+ +---------+
2154// | xapp | | submgr | | e2term |
2155// +-------+ +---------+ +---------+
2156// | | |
2157// | SubReq | |
2158// |------------->| |
2159// | | |
2160// | | SubReq |
2161// | |------------->|
2162// | | |
2163// | | SubResp |
2164// | |<-------------|
2165// | | |
2166// | SubResp | |
2167// |<-------------| |
2168// | | |
2169// | |
2170// | Submgr restart |
2171// | |
2172// | SubDelReq | |
2173// |------------->| |
2174// | | |
2175// | | SubDelReq |
2176// | |------------->|
2177// | | |
2178// | | SubDelResp |
2179// | |<-------------|
2180// | | |
2181// | SubDelResp | |
2182// |<-------------| |
2183//
2184//-----------------------------------------------------------------------------
2185
2186func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2187 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2188
2189 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2190 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2191 e2termConn1.SendSubsResp(t, crereq, cremsg)
2192 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2193
2194 // Check subscription
2195 resp, _ := xapp.Subscription.QuerySubscriptions()
2196 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2197 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002198 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002199
2200 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002201 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002202
2203 // Check that subscription is restored correctly after restart
2204 resp, _ = xapp.Subscription.QuerySubscriptions()
2205 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2206 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002207 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002208
2209 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2210 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2211 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2212 xappConn1.RecvSubsDelResp(t, deltrans)
2213
2214 //Wait that subs is cleaned
2215 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2216
2217 xappConn1.TestMsgChanEmpty(t)
2218 xappConn2.TestMsgChanEmpty(t)
2219 e2termConn1.TestMsgChanEmpty(t)
2220 mainCtrl.wait_registry_empty(t, 10)
2221}
2222
2223//-----------------------------------------------------------------------------
2224// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2225//
2226// stub stub
2227// +-------+ +-------+ +---------+ +---------+
2228// | xapp2 | | xapp1 | | submgr | | e2term |
2229// +-------+ +-------+ +---------+ +---------+
2230// | | | |
2231// | | | |
2232// | | | |
2233// | | SubReq1 | |
2234// | |------------->| |
2235// | | | |
2236// | | | SubReq1 |
2237// | | |------------->|
2238// | | | SubResp1 |
2239// | | |<-------------|
2240// | | SubResp1 | |
2241// | |<-------------| |
2242// | | | |
2243// | |
2244// | submgr restart |
2245// | |
2246// | | | |
2247// | | | |
2248// | SubReq2 | |
2249// |--------------------------->| |
2250// | | | |
2251// | SubResp2 | |
2252// |<---------------------------| |
2253// | | | |
2254// | | SubDelReq 1 | |
2255// | |------------->| |
2256// | | | |
2257// | | SubDelResp 1 | |
2258// | |<-------------| |
2259// | | | |
2260// | | | |
2261// | |
2262// | submgr restart |
2263// | |
2264// | | | |
2265// | SubDelReq 2 | |
2266// |--------------------------->| |
2267// | | | |
2268// | | | SubDelReq 2 |
2269// | | |------------->|
2270// | | | |
2271// | | | SubDelReq 2 |
2272// | | |------------->|
2273// | | | |
2274// | SubDelResp 2 | |
2275// |<---------------------------| |
2276//
2277//-----------------------------------------------------------------------------
2278
2279func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2280 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2281
2282 //Req1
2283 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2284 rparams1.Init()
2285 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2286 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2287 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2288 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2289
2290 //Req2
2291 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2292 rparams2.Init()
2293 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2294 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2295
2296 // Check subscription
2297 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2298 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2299 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002300 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002301
2302 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002303 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002304
2305 // Check that subscription is restored correctly after restart
2306 resp, _ = xapp.Subscription.QuerySubscriptions()
2307 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2308 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002309 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002310
2311 //Del1
2312 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2313 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2314 xappConn1.RecvSubsDelResp(t, deltrans1)
2315 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2316
2317 mainCtrl.SimulateRestart(t)
2318 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2319
2320 //Del2
2321 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2322 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2323
2324 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2325 xappConn2.RecvSubsDelResp(t, deltrans2)
2326
2327 //Wait that subs is cleaned
2328 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2329
2330 xappConn1.TestMsgChanEmpty(t)
2331 xappConn2.TestMsgChanEmpty(t)
2332 e2termConn1.TestMsgChanEmpty(t)
2333 mainCtrl.wait_registry_empty(t, 10)
2334}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002335
archaggeafbf95f2021-04-14 08:54:05 +03002336//*****************************************************************************
2337// REST interface test cases
2338//*****************************************************************************
2339
Anssi Mannila47518ae2021-04-16 09:27:07 +03002340//-----------------------------------------------------------------------------
2341// Test debug GET and POST requests
2342//
2343// curl
2344// +-------+ +---------+
2345// | user | | submgr |
2346// +-------+ +---------+
2347// | |
2348// | GET/POST Req |
2349// |------------->|
2350// | Resp |
2351// |<-------------|
2352// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002353func TestGetSubscriptions(t *testing.T) {
2354
2355 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2356}
2357
2358func TestGetSymptomData(t *testing.T) {
2359
2360 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2361}
2362
2363func TestPostdeleteSubId(t *testing.T) {
2364
2365 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2366}
2367
2368func TestPostEmptyDb(t *testing.T) {
2369
2370 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2371}
archaggeafbf95f2021-04-14 08:54:05 +03002372
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002373func TestGetRestSubscriptions(t *testing.T) {
2374
2375 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2376}
2377
archaggeafbf95f2021-04-14 08:54:05 +03002378//-----------------------------------------------------------------------------
2379// TestRESTSubReqAndRouteNok
2380//
2381// stub stub
2382// +-------+ +---------+ +---------+
2383// | xapp | | submgr | | rtmgr |
2384// +-------+ +---------+ +---------+
2385// | | |
2386// | RESTSubReq | |
2387// |---------------->| |
2388// | | |
2389// | RESTSubResp | |
2390// |<----------------| |
2391// | | RouteCreate |
2392// | |------------->|
2393// | | |
2394// | | RouteCreate |
2395// | | status:400 |
2396// | |(Bad request) |
2397// | |<-------------|
2398// | RESTNotif | |
2399// |<----------------| |
2400// | | |
2401// | [SUBS INT DELETE] |
2402// | | |
2403// | RESTSubDelReq | |
2404// |---------------->| |
2405// | RESTSubDelResp | |
2406// |<----------------| |
2407//
2408//-----------------------------------------------------------------------------
2409func TestRESTSubReqAndRouteNok(t *testing.T) {
2410 CaseBegin("TestRESTSubReqAndRouteNok")
2411
2412 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002413 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002414 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002415 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002416 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002417 Counter{cRestSubDelReqFromXapp, 1},
2418 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002419 })
2420
2421 const subReqCount int = 1
Markku Virtanenda34eec2021-05-20 08:22:04 +00002422 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2423 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002424 newSubsId := mainCtrl.get_registry_next_subid(t)
2425
2426 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002427 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002428 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002429 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002430 waiter.WaitResult(t)
2431
archaggeafbf95f2021-04-14 08:54:05 +03002432 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2433 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2434
2435 // Del
2436 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2437
2438 // Wait that subs is cleaned
2439 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2440 waitSubsCleanup(t, e2SubsId, 10)
2441 mainCtrl.VerifyCounterValues(t)
2442}
2443
2444func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2445 CaseBegin("TestSubReqAndRouteUpdateNok")
2446
2447 //Init counter check
2448 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002449 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002450 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002451 Counter{cSubReqToE2, 1},
2452 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002453 Counter{cRestSubNotifToXapp, 1},
2454 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002455 Counter{cRouteCreateUpdateFail, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002456 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002457 Counter{cSubDelReqToE2, 1},
2458 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002459 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002460 })
2461
2462 var params *teststube2ap.RESTSubsReqParams = nil
2463
2464 //Subs Create
2465 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2466
2467 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2468
2469 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2470 waiter := rtmgrHttp.AllocNextEvent(false)
2471 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002472 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002473 params.SetMeid("RAN_NAME_1")
2474 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2475 xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002476 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002477 waiter.WaitResult(t)
2478 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2479 xappConn2.WaitRESTNotification(t, restSubId2)
2480
2481 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2482
2483 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2484
2485 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2486 //Wait that subs is cleaned
2487 waitSubsCleanup(t, e2SubsId, 10)
2488
2489 mainCtrl.VerifyCounterValues(t)
2490}
2491
2492func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2493 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2494
2495 // Init counter check
2496 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002497 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002498 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002499 Counter{cSubReqToE2, 1},
2500 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002501 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002502 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002503 Counter{cRouteDeleteFail, 1},
2504 Counter{cSubDelReqToE2, 1},
2505 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002506 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002507 })
2508
2509 var params *teststube2ap.RESTSubsReqParams = nil
2510
2511 //Subs Create
2512 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2513
2514 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2515
2516 waiter := rtmgrHttp.AllocNextEvent(false)
2517 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2518 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2519 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2520 waiter.WaitResult(t)
2521
2522 waitSubsCleanup(t, e2SubsId, 10)
2523
2524 mainCtrl.VerifyCounterValues(t)
2525}
2526
2527func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2528 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2529
2530 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002531 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002532 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002533 Counter{cSubReqToE2, 1},
2534 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002535 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002536 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002537 Counter{cRouteDeleteUpdateFail, 1},
2538 Counter{cSubDelReqToE2, 1},
2539 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002540 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002541 })
2542
2543 var params *teststube2ap.RESTSubsReqParams = nil
2544
2545 //Subs Create
2546 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2547
2548 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2549 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2550
2551 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2552
2553 //Del1, this shall fail on rtmgr side
2554 waiter := rtmgrHttp.AllocNextEvent(false)
2555 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2556 waiter.WaitResult(t)
2557
2558 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2559
2560 //Del2
2561 deleteXapp2Subscription(t, &restSubId2)
2562
2563 waitSubsCleanup(t, e2SubsId2, 10)
2564
2565 mainCtrl.VerifyCounterValues(t)
2566}
2567
2568//-----------------------------------------------------------------------------
2569// TestRESTSubReqRetransmission
2570//
2571// stub stub
2572// +-------+ +---------+ +---------+
2573// | xapp | | submgr | | e2term |
2574// +-------+ +---------+ +---------+
2575// | | |
2576// | RESTSubReq1 | |
2577// |---------------->| |
2578// | | |
2579// | RESTSubResp | |
2580// |<----------------| |
2581// | | SubReq1 |
2582// | |------------->|
2583// | | |
2584// | RESTSubReq2 | |
2585// | (retrans) | |
2586// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002587// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002588// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002589// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002590// | | SubResp1 |
2591// | |<-------------|
2592// | RESTNotif1 | |
2593// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002594// | | |
2595// | [SUBS DELETE] |
2596// | | |
2597//
2598//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002599
archaggeafbf95f2021-04-14 08:54:05 +03002600func TestRESTSubReqRetransmission(t *testing.T) {
2601 CaseBegin("TestRESTSubReqRetransmission")
2602
2603 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002604 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002605 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002606 Counter{cSubReqToE2, 1},
2607 Counter{cSubRespFromE2, 1},
2608 Counter{cRestSubNotifToXapp, 1},
2609 Counter{cRestSubDelReqFromXapp, 1},
2610 Counter{cSubDelReqToE2, 1},
2611 Counter{cSubDelRespFromE2, 1},
2612 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002613 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002614 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002615 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2616 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2617
2618 // Subs Create
2619 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002620
2621 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2622 // gets into execution before the rtmgrg responds for the first one.
2623 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002624 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002625 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenb642a192021-06-09 09:08:14 +00002626 xappConn2.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002627
2628 waiter.WaitResult(t)
2629
Markku Virtanenb642a192021-06-09 09:08:14 +00002630 xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
archaggeafbf95f2021-04-14 08:54:05 +03002631
2632 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2633 // the order is not significant he6re.
2634 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2635 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002636
2637 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2638 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03002639
2640 // Del1
2641 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2642 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2643 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2644
Markku Virtanenb642a192021-06-09 09:08:14 +00002645 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002646
2647 mainCtrl.VerifyCounterValues(t)
2648}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002649
Markku Virtanen42723e22021-06-15 10:09:23 +03002650//-----------------------------------------------------------------------------
2651// stub stub stub
2652// +-------+ +---------+ +---------+ +---------+
2653// | xapp | | submgr | | e2term | | rtmgr |
2654// +-------+ +---------+ +---------+ +---------+
2655// | | | |
2656// | RESTSubReq | | |
2657// |---------------->| | |
2658// | RESTSubResp | | |
2659// |<----------------| | |
2660// | | RouteCreate | |
2661// | |--------------------------->|
2662// | | RouteResponse| |
2663// | |<---------------------------| // The order of these events may vary
2664// | | SubReq | |
2665// | |------------->| | // The order of these events may vary
2666// | | SubResp | |
2667// | |<-------------| |
2668// | RESTNotif1 | | |
2669// |<----------------| | |
2670// | RESTSubReq | | |
2671// | [RETRANS1] | | |
2672// |---------------->| | |
2673// | RESTNotif1 | | |
2674// |<----------------| | |
2675// | RESTSubReq | | |
2676// | [RETRANS2] | | |
2677// |---------------->| | |
2678// | RESTNotif1 | | |
2679// |<----------------| | |
2680// | RESTSubDelReq | | |
2681// |---------------->| | |
2682// | | SubDelReq | |
2683// | |------------->| |
2684// | RESTSubDelResp| | |
2685// |<----------------| | |
2686// | | SubDelResp | |
2687// | |<-------------| |
2688// | | | |
2689//
2690//-----------------------------------------------------------------------------
2691
2692func TestRESTSubReqRetransmissionV2(t *testing.T) {
2693 CaseBegin("TestRESTSubReqRetransmissionV2")
2694
2695 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2696 Counter{cRestSubReqFromXapp, 3},
2697 Counter{cRestSubRespToXapp, 3},
2698 Counter{cSubReqToE2, 1},
2699 Counter{cSubRespFromE2, 1},
2700 Counter{cRestSubNotifToXapp, 3},
2701 Counter{cRestSubDelReqFromXapp, 1},
2702 Counter{cSubDelReqToE2, 1},
2703 Counter{cSubDelRespFromE2, 1},
2704 Counter{cRestSubDelRespToXapp, 1},
2705 })
2706
2707 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2708
2709 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2710
2711 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2712
2713 //1.st resend
2714 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2715
2716 assert.Equal(t, restSubId_resend, restSubId)
2717
2718 <-time.After(100 * time.Millisecond)
2719
2720 //2.nd resend
2721 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2722
2723 assert.Equal(t, restSubId_resend2, restSubId)
2724
2725 <-time.After(100 * time.Millisecond)
2726
2727 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2728
2729 waitSubsCleanup(t, e2SubsId, 10)
2730
2731 //Wait that subs is cleaned
2732 mainCtrl.VerifyCounterValues(t)
2733}
2734
2735//-----------------------------------------------------------------------------
2736// stub stub stub
2737// +-------+ +---------+ +---------+ +---------+
2738// | xapp | | submgr | | e2term | | rtmgr |
2739// +-------+ +---------+ +---------+ +---------+
2740// | | | |
2741// | RESTSubReq | | |
2742// |---------------->| | |
2743// | RESTSubResp | | |
2744// |<----------------| | |
2745// | | RouteCreate | |
2746// | |--------------------------->|
2747// | | RouteResponse| |
2748// | |<---------------------------| // The order of these events may vary
2749// | | SubReq | |
2750// | |------------->| | // The order of these events may vary
2751// | | SubResp | |
2752// | |<-------------| |
2753// | RESTNotif1 | | |
2754// |<----------------| | |
2755// | RESTSubReq | | |
2756// | [RETRANS, with RESTsubsId] | |
2757// |---------------->| | |
2758// | RESTNotif1 | | |
2759// |<----------------| | |
2760// | RESTSubReq | | |
2761// | [RETRANS, without RESTsubsId] | |
2762// |---------------->| | |
2763// | RESTNotif1 | | |
2764// |<----------------| | |
2765// | RESTSubDelReq | | |
2766// |---------------->| | |
2767// | | SubDelReq | |
2768// | |------------->| |
2769// | RESTSubDelResp| | |
2770// |<----------------| | |
2771// | | SubDelResp | |
2772// | |<-------------| |
2773// | | | |
2774//
2775//-----------------------------------------------------------------------------
2776func TestRESTSubReqRetransmissionV3(t *testing.T) {
2777 CaseBegin("TestRESTSubReqRetransmissionV3")
2778
2779 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2780 Counter{cRestSubReqFromXapp, 3},
2781 Counter{cRestSubRespToXapp, 3},
2782 Counter{cSubReqToE2, 1},
2783 Counter{cSubRespFromE2, 1},
2784 Counter{cRestSubNotifToXapp, 3},
2785 Counter{cRestSubDelReqFromXapp, 1},
2786 Counter{cSubDelReqToE2, 1},
2787 Counter{cSubDelRespFromE2, 1},
2788 Counter{cRestSubDelRespToXapp, 1},
2789 })
2790
2791 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2792
2793 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2794
2795 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2796
2797 <-time.After(100 * time.Millisecond)
2798
2799 //1.st resend with subscription ID
2800 params.SetSubscriptionID(&restSubId)
2801 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2802
2803 assert.Equal(t, restSubId_resend, restSubId)
2804
2805 <-time.After(100 * time.Millisecond)
2806
2807 //2.nd resend without subscription ID (faking app restart)
2808 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
2809 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2810
2811 assert.Equal(t, restSubId_resend2, restSubId)
2812
2813 <-time.After(100 * time.Millisecond)
2814
2815 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2816
2817 waitSubsCleanup(t, e2SubsId, 10)
2818
2819 //Wait that subs is cleaned
2820 mainCtrl.VerifyCounterValues(t)
2821}
2822
2823//-----------------------------------------------------------------------------
2824// stub stub stub
2825// +-------+ +---------+ +---------+ +---------+
2826// | xapp | | submgr | | e2term | | rtmgr |
2827// +-------+ +---------+ +---------+ +---------+
2828// | | | |
2829// | RESTSubReq | | |
2830// |---------------->| | |
2831// | RESTSubResp | | |
2832// |<----------------| | |
2833// | | RouteCreate | |
2834// | |--------------------------->|
2835// | | RouteResponse| |
2836// | |<---------------------------|
2837// | | SubReq | |
2838// | |------------->| |
2839// | | SubResp | |
2840// | |<-------------| |
2841// | RESTNotif1 | | |
2842// |<----------------| | |
2843// | RESTSubReq | | |
2844// | [with RestSUbsId + one additional e2 subDetail]
2845// |---------------->| | |
2846// | RESTNotif1 | | |
2847// | [for initial e2 subDetail] | |
2848// |<----------------| | |
2849// | | RouteCreate | |
2850// | |--------------------------->|
2851// | | RouteResponse| |
2852// | |<---------------------------|
2853// | | SubReq | |
2854// | |------------->| |
2855// | | SubResp | |
2856// | |<-------------| |
2857// | RESTNotif1 | | |
2858// |<----------------| | |
2859// | RESTSubReq | | |
2860// | [with RESTsubsId initial request] |
2861// |---------------->| | |
2862// | RESTNotif1 | | |
2863// |<----------------| | |
2864// | RESTSubDelReq | | |
2865// |---------------->| | |
2866// | RESTSubDelResp| | |
2867// |<----------------| | |
2868// | | SubDelReq | |
2869// | |------------->| |
2870// | | SubDelResp | |
2871// | |<-------------| |
2872// | | SubDelReq | |
2873// | |------------->| |
2874// | | SubDelResp | |
2875// | |<-------------| |
2876// | | | |
2877//
2878//-----------------------------------------------------------------------------
2879
2880func TestRESTSubReqRetransmissionV4(t *testing.T) {
2881 CaseBegin("TestRESTSubReqRetransmissionV4")
2882
2883 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2884 Counter{cRestSubReqFromXapp, 3},
2885 Counter{cRestSubRespToXapp, 3},
2886 Counter{cSubReqToE2, 2},
2887 Counter{cSubRespFromE2, 2},
2888 Counter{cRestSubNotifToXapp, 4},
2889 Counter{cRestSubDelReqFromXapp, 1},
2890 Counter{cSubDelReqToE2, 2},
2891 Counter{cSubDelRespFromE2, 2},
2892 Counter{cRestSubDelRespToXapp, 1},
2893 })
2894
2895 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2896
2897 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2898
2899 <-time.After(100 * time.Millisecond)
2900
2901 // Send modified requst, this time with e2 subscriptions.
2902 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
2903 params2.SetSubscriptionID(&restSubId)
2904
2905 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00002906 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03002907 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
2908 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00002909 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
2910 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03002911
2912 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2913
Markku Virtanen2b512b62021-07-30 12:04:00 +00002914 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03002915 xappConn1.ExpectRESTNotification(t, restSubId_resend)
2916 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2917 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
2918 assert.NotEqual(t, e2SubsId2, 0)
2919
2920 <-time.After(100 * time.Millisecond)
2921
2922 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
2923 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
2924 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00002925 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03002926 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
2927 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2928 assert.Equal(t, restSubId_resend, restSubId_resend2)
2929
Markku Virtanen2b512b62021-07-30 12:04:00 +00002930 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
2931 assert.Equal(t, e2SubsId, e2SubsId1)
2932
Markku Virtanen42723e22021-06-15 10:09:23 +03002933 // Delete both e2 subscriptions
2934 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2935 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
2936 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
2937
2938 waitSubsCleanup(t, e2SubsId, 10)
2939
2940 //Wait that subs is cleaned
2941 mainCtrl.VerifyCounterValues(t)
2942}
2943
2944//-----------------------------------------------------------------------------
2945// stub stub stub
2946// +-------+ +---------+ +---------+ +---------+
2947// | xapp | | submgr | | e2term | | rtmgr |
2948// +-------+ +---------+ +---------+ +---------+
2949// | | | |
2950// | RESTSubReq | | |
2951// |---------------->| | |
2952// | RESTSubResp | | |
2953// |<----------------| | |
2954// | | RouteCreate | |
2955// | |--------------------------->|
2956// | | RouteResponse| |
2957// | |<---------------------------|
2958// | | SubReq | |
2959// | |------------->| |
2960// | | SubResp | |
2961// | |<-------------| |
2962// | RESTNotif1 | | |
2963// |<----------------| | |
2964// | RESTSubReq | | |
2965// | [with RestSUbsId + one additional e2 subDetail]
2966// |---------------->| | |
2967// | RESTNotif1 | | |
2968// | [for initial e2 subDetail] | |
2969// |<----------------| | |
2970// | | RouteCreate | |
2971// | |--------------------------->|
2972// | | RouteResponse| |
2973// | |<---------------------------|
2974// | | SubReq | |
2975// | |------------->| |
2976// | | SubResp | |
2977// | |<-------------| |
2978// | RESTNotif1 | | |
2979// |<----------------| | |
2980// | RESTSubReq | | |
2981// | [without RESTsubsId initial request] |
2982// |---------------->| | |
2983// | RESTNotif1 | | |
2984// |<----------------| | |
2985// | RESTSubDelReq | | |
2986// |---------------->| | |
2987// | RESTSubDelResp| | |
2988// |<----------------| | |
2989// | | SubDelReq | |
2990// | |------------->| |
2991// | | SubDelResp | |
2992// | |<-------------| |
2993// | | SubDelReq | |
2994// | |------------->| |
2995// | | SubDelResp | |
2996// | |<-------------| |
2997// | | | |
2998//
2999//-----------------------------------------------------------------------------
3000
3001func TestRESTSubReqRetransmissionV5(t *testing.T) {
3002 CaseBegin("TestRESTSubReqRetransmissionV5")
3003
3004 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3005 Counter{cRestSubReqFromXapp, 3},
3006 Counter{cRestSubRespToXapp, 3},
3007 Counter{cSubReqToE2, 2},
3008 Counter{cSubRespFromE2, 2},
3009 Counter{cRestSubNotifToXapp, 4},
3010 Counter{cRestSubDelReqFromXapp, 1},
3011 Counter{cSubDelReqToE2, 2},
3012 Counter{cSubDelRespFromE2, 2},
3013 Counter{cRestSubDelRespToXapp, 1},
3014 })
3015
3016 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3017
3018 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3019
3020 <-time.After(100 * time.Millisecond)
3021
3022 // Send modified requst, this time with e2 subscriptions.
3023 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3024 params2.SetSubscriptionID(&restSubId)
3025
3026 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003027 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003028 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3029 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3030
Markku Virtanen2b512b62021-07-30 12:04:00 +00003031 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3032 assert.Equal(t, e2SubsId, e2SubsId1)
3033 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3034 xappConn1.DecrementRequestCount()
3035
Markku Virtanen42723e22021-06-15 10:09:23 +03003036 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3037
3038 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3039 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3040 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3041 assert.NotEqual(t, e2SubsId2, 0)
3042
3043 <-time.After(100 * time.Millisecond)
3044
3045 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3046 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003047 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003048 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3049 // md5sum shall find the original request
3050 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3051 assert.Equal(t, restSubId_resend, restSubId_resend2)
3052
Markku Virtanen2b512b62021-07-30 12:04:00 +00003053 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3054 assert.Equal(t, e2SubsId, e2SubsId1)
3055
Markku Virtanen42723e22021-06-15 10:09:23 +03003056 // Delete both e2 subscriptions
3057 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3058 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3059 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3060
3061 waitSubsCleanup(t, e2SubsId, 10)
3062
3063 //Wait that subs is cleaned
3064 mainCtrl.VerifyCounterValues(t)
3065}
3066
3067//-----------------------------------------------------------------------------
3068// stub stub stub
3069// +-------+ +---------+ +---------+ +---------+
3070// | xapp | | submgr | | e2term | | rtmgr |
3071// +-------+ +---------+ +---------+ +---------+
3072// | | | |
3073// | RESTSubReq | | |
3074// |---------------->| | |
3075// | RESTSubResp | | |
3076// |<----------------| | |
3077// | | RouteCreate | |
3078// | |--------------------------->|
3079// | | RouteResponse| |
3080// | |<---------------------------|
3081// | | SubReq | |
3082// | |------------->| |
3083// | | SubResp | |
3084// | |<-------------| |
3085// | RESTNotif1 | | |
3086// |<----------------| | |
3087// | RESTSubReq | | |
3088// | [with RestSUbsId + one additional e2 subDetail]
3089// |---------------->| | |
3090// | RESTNotif1 | | |
3091// | [for initial e2 subDetail] | |
3092// |<----------------| | |
3093// | | RouteCreate | |
3094// | |--------------------------->|
3095// | | RouteResponse| |
3096// | |<---------------------------|
3097// | | SubReq | |
3098// | |------------->| |
3099// | | SubResp | |
3100// | |<-------------| |
3101// | RESTNotif1 | | |
3102// |<----------------| | |
3103// | RESTSubDelReq | | |
3104// |---------------->| | |
3105// | RESTSubDelResp| | |
3106// |<----------------| | |
3107// | | SubDelReq | |
3108// | |------------->| |
3109// | | SubDelResp | |
3110// | |<-------------| |
3111// | | SubDelReq | |
3112// | |------------->| |
3113// | | SubDelResp | |
3114// | |<-------------| |
3115// | RESTSubReq | | |
3116// | [with RESTsubsId initial request] |
3117// |---------------->| | |
3118// | RESTSubResp | | |
3119// |<----------------| | |
3120// | | RouteCreate | |
3121// | |--------------------------->|
3122// | | RouteResponse| |
3123// | |<---------------------------|
3124// | | SubReq | |
3125// | |------------->| |
3126// | | SubResp | |
3127// | |<-------------| |
3128// | RESTNotif1 | | |
3129// |<----------------| | |
3130// | | | |
3131//
3132//-----------------------------------------------------------------------------
3133func TestRESTSubReqRetransmissionV6(t *testing.T) {
3134 CaseBegin("TestRESTSubReqRetransmissionV6")
3135
3136 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3137 Counter{cRestSubReqFromXapp, 3},
3138 Counter{cRestSubRespToXapp, 3},
3139 Counter{cSubReqToE2, 3},
3140 Counter{cSubRespFromE2, 3},
3141 Counter{cRestSubNotifToXapp, 4},
3142 Counter{cRestSubDelReqFromXapp, 2},
3143 Counter{cSubDelReqToE2, 3},
3144 Counter{cSubDelRespFromE2, 3},
3145 Counter{cRestSubDelRespToXapp, 2},
3146 })
3147
3148 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3149
3150 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3151
3152 <-time.After(100 * time.Millisecond)
3153
3154 // Send modified requst, this time with e2 subscriptions.
3155 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3156 params2.SetSubscriptionID(&restSubId)
3157
3158 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003159 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003160 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3161 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3162
Markku Virtanen2b512b62021-07-30 12:04:00 +00003163 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3164 assert.Equal(t, e2SubsId, e2SubsId1)
3165
Markku Virtanen42723e22021-06-15 10:09:23 +03003166 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3167
3168 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3169 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3170 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3171 assert.NotEqual(t, e2SubsId2, 0)
3172
3173 <-time.After(100 * time.Millisecond)
3174
3175 // Delete both e2 subscriptions
3176 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3177 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3178 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3179
3180 waitSubsCleanup(t, e2SubsId, 10)
3181
3182 // Resend the original request, we shall find it's previous md5sum/restsubs
3183 // but the restsubscription has been already removed. This shall trigger a
3184 // fresh create.
3185 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3186
3187 <-time.After(100 * time.Millisecond)
3188
3189 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3190
3191 waitSubsCleanup(t, e2SubsId, 10)
3192
3193 //Wait that subs is cleaned
3194 mainCtrl.VerifyCounterValues(t)
3195}
3196
archaggeafbf95f2021-04-14 08:54:05 +03003197func TestRESTSubDelReqRetransmission(t *testing.T) {
3198 CaseBegin("TestRESTSubDelReqRetransmission")
3199
3200 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003201 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003202 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003203 Counter{cSubReqToE2, 1},
3204 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003205 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003206 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003207 Counter{cSubDelReqToE2, 1},
3208 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003209 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003210 })
3211
3212 var params *teststube2ap.RESTSubsReqParams = nil
3213
3214 //Subs Create
3215 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3216
3217 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3218
3219 //Subs Delete
3220 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3221 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3222
3223 seqBef := mainCtrl.get_msgcounter(t)
3224 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3225 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3226
3227 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3228
3229 waitSubsCleanup(t, e2SubsId, 10)
3230
3231 mainCtrl.VerifyCounterValues(t)
3232}
3233
3234//-----------------------------------------------------------------------------
3235// TestRESTSubReqDelReq
3236//
3237// stub stub
3238// +-------+ +---------+ +---------+
3239// | xapp | | submgr | | e2term |
3240// +-------+ +---------+ +---------+
3241// | | |
3242// | RESTSubReq | |
3243// |---------------->| |
3244// | | |
3245// | RESTSubResp | |
3246// |<----------------| |
3247// | | SubReq |
3248// | |------------->|
3249// | RESTSubDelReq | |
3250// |---------------->| |
3251// | RESTSubDelResp | |
3252// | unsuccess | |
3253// |<----------------| |
3254// | | SubResp |
3255// | |<-------------|
3256// | RESTNotif1 | |
3257// |<----------------| |
3258// | | |
3259// | [SUBS DELETE] |
3260// | | |
3261//
3262//-----------------------------------------------------------------------------
3263func TestRESTSubReqDelReq(t *testing.T) {
3264 CaseBegin("TestRESTSubReqDelReq")
3265
3266 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003267 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003268 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003269 Counter{cSubReqToE2, 1},
3270 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003271 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003272 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003273 Counter{cSubDelReqToE2, 1},
3274 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003275 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003276 })
3277
3278 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003279
3280 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003281 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003282 restSubId := xappConn1.SendRESTSubsReq(t, params)
3283
3284 // Del. This will fail as processing of the subscription
3285 // is still ongoing in submgr. Deletion is not allowed before
3286 // subscription creation has been completed.
3287 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3288 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3289 xappConn1.ExpectRESTNotification(t, restSubId)
3290 e2termConn1.SendSubsResp(t, crereq, cremsg)
3291 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3292
3293 // Retry del
3294 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3295
3296 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3297 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3298
3299 // Wait that subs is cleaned
3300 waitSubsCleanup(t, e2SubsId, 10)
3301 mainCtrl.VerifyCounterValues(t)
3302
3303}
3304
3305func TestRESTSubDelReqCollision(t *testing.T) {
3306 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3307}
3308
3309func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3310 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3311
3312 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003313 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003314 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003315 Counter{cSubReqToE2, 2},
3316 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003317 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003318 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003319 Counter{cSubDelReqToE2, 2},
3320 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003321 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003322 })
3323
3324 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003325 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003326 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3327 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
3328
3329 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003330 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003331 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3332 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
3333
3334 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3335 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3336
3337 //XappConn1 receives both of the responses
3338 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3339
3340 //Resp1
3341 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3342 //Resp2
3343 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3344
3345 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3346 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3347 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3348 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3349
3350 //Del1
3351 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3352 //Del2
3353 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3354
3355 //Wait that subs is cleaned
3356 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3357 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3358
3359 mainCtrl.VerifyCounterValues(t)
3360
3361}
3362
3363func TestRESTSameSubsDiffRan(t *testing.T) {
3364 CaseBegin("TestRESTSameSubsDiffRan")
3365
3366 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003367 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003368 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003369 Counter{cSubReqToE2, 2},
3370 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003371 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003372 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003373 Counter{cSubDelReqToE2, 2},
3374 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003375 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003376 })
3377
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003378 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003379 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3380 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
3381
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003382 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003383 params.SetMeid("RAN_NAME_2")
3384 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
3385 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
3386
3387 //Del1
3388 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3389 //Del2
3390 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3391
3392 //Wait that subs is cleaned
3393 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3394 waitSubsCleanup(t, e2SubsId2, 10)
3395
3396 mainCtrl.VerifyCounterValues(t)
3397
3398}
3399
3400func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3401 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3402
3403 // Init counter check
3404 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003405 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003406 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003407 Counter{cSubReqToE2, 1},
3408 Counter{cSubReReqToE2, 1},
3409 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003410 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003411 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003412 Counter{cSubDelReqToE2, 1},
3413 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003414 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003415 })
3416
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003417 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003418 restSubId := xappConn1.SendRESTSubsReq(t, params)
3419
3420 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3421
3422 // Catch the first message and ignore it
3423 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3424 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
3425
3426 // The second request is being handled normally
3427 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3428 xappConn1.ExpectRESTNotification(t, restSubId)
3429 e2termConn1.SendSubsResp(t, crereq, cremsg)
3430 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3431
3432 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3433
3434 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3435
3436 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3437 //Wait that subs is cleaned
3438 waitSubsCleanup(t, e2SubsId, 10)
3439
3440 mainCtrl.VerifyCounterValues(t)
3441
3442}
3443
3444//-----------------------------------------------------------------------------
3445// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3446//
3447// stub stub
3448// +-------+ +---------+ +---------+
3449// | xapp | | submgr | | e2term |
3450// +-------+ +---------+ +---------+
3451// | | |
3452// | RESTSubReq | |
3453// |---------------->| |
3454// | | |
3455// | RESTSubResp | |
3456// |<----------------| |
3457// | | SubReq |
3458// | |------------->|
3459// | | |
3460// | | |
3461// | | SubReq |
3462// | |------------->|
3463// | | |
3464// | | SubDelReq |
3465// | |------------->|
3466// | | |
3467// | | |
3468// | | SubDelReq |
3469// | |------------->|
3470// | | |
3471// | | |
3472// | | SubDelResp |
3473// | |<-------------|
3474// | RESTNotif | |
3475// | unsuccess | |
3476// |<----------------| |
3477// | | |
3478// | [SUBS DELETE] |
3479// | | |
3480//
3481//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003482
archaggeafbf95f2021-04-14 08:54:05 +03003483func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3484 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3485
3486 // Init counter check
3487 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003488 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003489 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003490 Counter{cSubReqToE2, 1},
3491 Counter{cSubReReqToE2, 1},
3492 Counter{cSubReqTimerExpiry, 2},
3493 Counter{cSubDelReqToE2, 1},
3494 Counter{cSubDelRespFromE2, 1},
3495 })
3496
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003497 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003498 restSubId := xappConn1.SendRESTSubsReq(t, params)
3499 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3500
3501 e2termConn1.RecvSubsReq(t)
3502 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3503
3504 e2termConn1.RecvSubsReq(t)
3505 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3506
3507 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003508 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003509 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003510 xappConn1.WaitRESTNotification(t, restSubId)
3511
3512 // Wait that subs is cleaned
3513 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
3514
3515 mainCtrl.VerifyCounterValues(t)
3516}
3517
3518func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3519 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3520
3521 // Init counter check
3522 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003523 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003524 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003525 Counter{cSubReqToE2, 1},
3526 Counter{cSubReReqToE2, 1},
3527 Counter{cSubReqTimerExpiry, 2},
3528 Counter{cSubDelReqToE2, 1},
3529 Counter{cSubDelReqTimerExpiry, 2},
3530 })
3531
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003532 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003533 restSubId := xappConn1.SendRESTSubsReq(t, params)
3534 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3535
3536 e2termConn1.RecvSubsReq(t)
3537 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3538
3539 e2termConn1.RecvSubsReq(t)
3540 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3541
3542 e2termConn1.RecvSubsDelReq(t)
3543 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3544
Markku Virtanen55d2a282021-06-04 14:46:56 +03003545 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003546 e2termConn1.RecvSubsDelReq(t)
3547 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3548
3549 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3550
3551 waitSubsCleanup(t, e2SubsId, 10)
3552
3553 mainCtrl.VerifyCounterValues(t)
3554
3555}
3556
3557//-----------------------------------------------------------------------------
3558// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3559//
3560// stub stub
3561// +-------+ +---------+ +---------+
3562// | xapp | | submgr | | e2term |
3563// +-------+ +---------+ +---------+
3564// | | |
3565// | RESTSubReq | |
3566// |---------------->| |
3567// | | |
3568// | RESTSubResp | |
3569// |<----------------| |
3570// | | SubReq |
3571// | |------------->|
3572// | | |
3573// | | |
3574// | | SubReq |
3575// | |------------->|
3576// | | |
3577// | | SubDelReq |
3578// | |------------->|
3579// | | |
3580// | | |
3581// | | SubDelReq |
3582// | |------------->|
3583// | | |
3584// | | |
3585// | | SubDelResp |
3586// | |<-------------|
3587// | RESTNotif | |
3588// | unsuccess | |
3589// |<----------------| |
3590// | | |
3591// | [SUBS DELETE] |
3592// | | |
3593//
3594//-----------------------------------------------------------------------------
3595func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3596 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3597
3598 // Init counter check
3599 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003600 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003601 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003602 Counter{cSubReqToE2, 1},
3603 Counter{cSubReReqToE2, 1},
3604 Counter{cSubReqTimerExpiry, 2},
3605 Counter{cSubDelReqToE2, 1},
3606 Counter{cSubDelReReqToE2, 1},
3607 Counter{cSubDelReqTimerExpiry, 2},
3608 })
3609
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003610 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003611 restSubId := xappConn1.SendRESTSubsReq(t, params)
3612 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3613
3614 e2termConn1.RecvSubsReq(t)
3615 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3616
3617 e2termConn1.RecvSubsReq(t)
3618 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3619
3620 e2termConn1.RecvSubsDelReq(t)
3621 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3622
Markku Virtanen55d2a282021-06-04 14:46:56 +03003623 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003624 e2termConn1.RecvSubsDelReq(t)
3625 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3626
3627 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3628
3629 waitSubsCleanup(t, e2SubsId, 10)
3630
3631 mainCtrl.VerifyCounterValues(t)
3632}
3633
3634//-----------------------------------------------------------------------------
3635// TestRESTSubReqSubFailRespInSubmgr
3636//
3637// stub stub
3638// +-------+ +---------+ +---------+
3639// | xapp | | submgr | | e2term |
3640// +-------+ +---------+ +---------+
3641// | | |
3642// | RESTSubReq | |
3643// |---------------->| |
3644// | | |
3645// | RESTSubResp | |
3646// |<----------------| |
3647// | | SubReq |
3648// | |------------->|
3649// | | |
3650// | | SubFail |
3651// | |<-------------|
3652// | | |
3653// | | SubDelReq |
3654// | |------------->|
3655// | | |
3656// | | SubDelResp |
3657// | |<-------------|
3658// | | |
3659// | RESTNotif | |
3660// | unsuccess | |
3661// |<----------------| |
3662// | | |
3663// | [SUBS DELETE] |
3664// | | |
3665//
3666//-----------------------------------------------------------------------------
3667func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3668 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3669
3670 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003671 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003672 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003673 Counter{cSubReqToE2, 1},
3674 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003675 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003676 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003677 })
3678
3679 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003680
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003681 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003682 restSubId := xappConn1.SendRESTSubsReq(t, params)
3683
3684 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3685 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3686 fparams1.Set(crereq1)
3687 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3688
3689 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003690 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003691 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3692 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3693 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
3694
3695 // REST subscription sill there to be deleted
3696 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3697
3698 // Wait that subs is cleaned
3699 waitSubsCleanup(t, e2SubsId, 10)
3700
3701 mainCtrl.VerifyCounterValues(t)
3702
3703}
3704
3705//-----------------------------------------------------------------------------
3706// TestRESTSubDelReqRetryInSubmgr
3707//
3708// stub stub
3709// +-------+ +---------+ +---------+
3710// | xapp | | submgr | | e2term |
3711// +-------+ +---------+ +---------+
3712// | | |
3713// | [SUBS CREATE] |
3714// | | |
3715// | | |
3716// | RESTSubDelReq | |
3717// |---------------->| |
3718// | | |
3719// | RESTSubDelResp | |
3720// |<----------------| |
3721// | | SubDelReq |
3722// | |------------->|
3723// | | |
3724// | | SubDelReq |
3725// | |------------->|
3726// | | |
3727// | | SubDelResp |
3728// | |<-------------|
3729// | | |
3730//
3731//-----------------------------------------------------------------------------
3732func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3733 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3734
3735 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003736 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003737 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003738 Counter{cSubReqToE2, 1},
3739 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003740 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003741 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003742 Counter{cSubDelReqToE2, 1},
3743 Counter{cSubDelReReqToE2, 1},
3744 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003745 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003746 })
3747 // Req
3748 var params *teststube2ap.RESTSubsReqParams = nil
3749 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3750
3751 // Del
3752 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3753
3754 // E2t: Receive 1st SubsDelReq
3755 e2termConn1.RecvSubsDelReq(t)
3756
3757 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3758 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3759 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3760
3761 //Wait that subs is cleaned
3762 waitSubsCleanup(t, e2SubsId, 10)
3763
3764 mainCtrl.VerifyCounterValues(t)
3765}
3766
3767//-----------------------------------------------------------------------------
3768// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3769//
3770// stub stub
3771// +-------+ +---------+ +---------+
3772// | xapp | | submgr | | e2term |
3773// +-------+ +---------+ +---------+
3774// | | |
3775// | [SUBS CREATE] |
3776// | | |
3777// | | |
3778// | RESTSubDelReq | |
3779// |---------------->| |
3780// | | |
3781// | RESTSubDelResp | |
3782// |<----------------| |
3783// | | SubDelReq |
3784// | |------------->|
3785// | | |
3786// | | SubDelReq |
3787// | |------------->|
3788// | | |
3789// | | |
3790//
3791//-----------------------------------------------------------------------------
3792func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3793 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3794
3795 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003796 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003797 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003798 Counter{cSubReqToE2, 1},
3799 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003800 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003801 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003802 Counter{cSubDelReqToE2, 1},
3803 Counter{cSubDelReReqToE2, 1},
3804 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003805 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003806 })
3807
3808 // Req
3809 var params *teststube2ap.RESTSubsReqParams = nil
3810 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3811
3812 // Del
3813 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3814
3815 // E2t: Receive 1st SubsDelReq
3816 e2termConn1.RecvSubsDelReq(t)
3817
3818 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3819 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3820 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3821
3822 //Wait that subs is cleaned
3823 waitSubsCleanup(t, e2SubsId, 10)
3824
3825 mainCtrl.VerifyCounterValues(t)
3826}
3827
3828//-----------------------------------------------------------------------------
3829// TestRESTSubDelReqSubDelFailRespInSubmgr
3830//
3831// stub stub
3832// +-------+ +---------+ +---------+
3833// | xapp | | submgr | | e2term |
3834// +-------+ +---------+ +---------+
3835// | | |
3836// | [SUBS CREATE] |
3837// | | |
3838// | | |
3839// | RESTSubDelReq | |
3840// |---------------->| |
3841// | | |
3842// | RESTSubDelResp | |
3843// |<----------------| |
3844// | | SubDelReq |
3845// | |------------->|
3846// | | |
3847// | | SubDelFail |
3848// | |<-------------|
3849// | | |
3850//
3851//-----------------------------------------------------------------------------
3852func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3853 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3854
3855 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003856 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003857 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003858 Counter{cSubReqToE2, 1},
3859 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003860 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003861 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003862 Counter{cSubDelReqToE2, 1},
3863 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003864 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003865 })
3866
3867 // Req
3868 var params *teststube2ap.RESTSubsReqParams = nil
3869 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3870
3871 // Del
3872 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3873
3874 // E2t: Send receive SubsDelReq and send SubsDelFail
3875 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3876 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3877
3878 //Wait that subs is cleaned
3879 waitSubsCleanup(t, e2SubsId, 10)
3880
3881 mainCtrl.VerifyCounterValues(t)
3882}
3883
3884//-----------------------------------------------------------------------------
3885// TestRESTSubReqAndSubDelOkSameAction
3886//
3887// stub stub
3888// +-------+ +-------+ +---------+ +---------+
3889// | xapp2 | | xapp1 | | submgr | | e2term |
3890// +-------+ +-------+ +---------+ +---------+
3891// | | | |
3892// | | RESTSubReq1 | |
3893// | |---------------->| |
3894// | | | |
3895// | | RESTSubResp1 | |
3896// | |<----------------| |
3897// | | | |
3898// | | | SubReq1 |
3899// | | |------------->|
3900// | | | SubResp1 |
3901// | | |<-------------|
3902// | | RESTNotif1 | |
3903// | |<----------------| |
3904// | | | |
3905// | RESTSubReq2 | |
3906// |------------------------------>| |
3907// | | | |
3908// | RESTSubResp2 | |
3909// |<------------------------------| |
3910// | | | |
3911// | | RESTNotif2 | |
3912// |<------------------------------| |
3913// | | | |
3914// | | RESTSubDelReq1 | |
3915// | |---------------->| |
3916// | | | |
3917// | | RESTSubDelResp1 | |
3918// | |<----------------| |
3919// | | | |
3920// | RESTSubDelReq2 | |
3921// |------------------------------>| |
3922// | | | |
3923// | RESTSubDelResp2 | |
3924// |<------------------------------| |
3925// | | | |
3926// | | | SubDelReq2 |
3927// | | |------------->|
3928// | | | |
3929// | | | SubDelResp2 |
3930// | | |<-------------|
3931// | | | |
3932//
3933//-----------------------------------------------------------------------------
3934func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3935 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3936
3937 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003938 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003939 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003940 Counter{cSubReqToE2, 1},
3941 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003942 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003943 Counter{cMergedSubscriptions, 1},
3944 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003945 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003946 Counter{cSubDelReqToE2, 1},
3947 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003948 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003949 })
3950
3951 // Req1
3952 var params *teststube2ap.RESTSubsReqParams = nil
3953
3954 //Subs Create
3955 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3956 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3957
3958 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003959 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003960 params.SetMeid("RAN_NAME_1")
3961
3962 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003963 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003964 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003965 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003966 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003967 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003968 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03003969 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3970
3971 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3972
3973 // Del1
3974 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3975
3976 // Del2
3977 deleteXapp2Subscription(t, &restSubId2)
3978
3979 //Wait that subs is cleaned
3980 waitSubsCleanup(t, e2SubsId2, 10)
3981
3982 mainCtrl.VerifyCounterValues(t)
3983}
3984
3985//-----------------------------------------------------------------------------
3986// TestSubReqAndSubDelOkSameActionParallel
3987//
3988// stub stub stub
3989// +-------+ +-------+ +---------+ +---------+
3990// | xapp2 | | xapp1 | | submgr | | e2term |
3991// +-------+ +-------+ +---------+ +---------+
3992// | | | |
3993// | | | |
3994// | | | |
3995// | | SubReq1 | |
3996// | |------------->| |
3997// | | | |
3998// | | | SubReq1 |
3999// | | |------------->|
4000// | SubReq2 | |
4001// |--------------------------->| |
4002// | | | SubResp1 |
4003// | | |<-------------|
4004// | | SubResp1 | |
4005// | |<-------------| |
4006// | | | SubReq2 |
4007// | | |------------->|
4008// | | | |
4009// | | | SubResp2 |
4010// | | |<-------------|
4011// | SubResp2 | |
4012// |<---------------------------| |
4013// | | | |
4014// | | SubDelReq 1 | |
4015// | |------------->| |
4016// | | | |
4017// | | SubDelResp 1 | |
4018// | |<-------------| |
4019// | | | |
4020// | SubDelReq 2 | |
4021// |--------------------------->| |
4022// | | | |
4023// | | | SubDelReq 2 |
4024// | | |------------->|
4025// | | | |
4026// | | | SubDelReq 2 |
4027// | | |------------->|
4028// | | | |
4029// | SubDelResp 2 | |
4030// |<---------------------------| |
4031//
4032func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4033 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4034
4035 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004036 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004037 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004038 Counter{cSubReqToE2, 2},
4039 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004040 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004041 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004042 Counter{cSubDelReqToE2, 2},
4043 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004044 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004045 })
4046
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004047 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004048 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4049 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4050
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004051 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004052 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4053
4054 xappConn1.ExpectRESTNotification(t, restSubId1)
4055 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4056 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4057
4058 xappConn2.ExpectRESTNotification(t, restSubId2)
4059 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4060 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4061 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4062
4063 // Del1
4064 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4065 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4066 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4067 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4068
4069 // Del2
4070 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4071 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4072 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4073
4074 waitSubsCleanup(t, e2SubsId2, 10)
4075
4076 mainCtrl.VerifyCounterValues(t)
4077}
4078
4079//-----------------------------------------------------------------------------
4080// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4081//
4082// stub stub stub
4083// +-------+ +-------+ +---------+ +---------+
4084// | xapp2 | | xapp1 | | submgr | | e2term |
4085// +-------+ +-------+ +---------+ +---------+
4086// | | | |
4087// | | | |
4088// | | | |
4089// | | RESTSubReq1 | |
4090// | |---------------->| |
4091// | | | |
4092// | | RESTSubResp1 | |
4093// | |<----------------| |
4094// | | | SubReq1 |
4095// | | |------------->|
4096// | RESTSubReq2 | |
4097// |------------------------------>| |
4098// | | | |
4099// | RESTSubDelResp2 | |
4100// |<------------------------------| |
4101// | | | SubReq1 |
4102// | | |------------->|
4103// | | | |
4104// | | | |
4105// | | | SubDelReq |
4106// | | |------------->|
4107// | | | |
4108// | | | SubDelResp |
4109// | | |<-------------|
4110// | | RESTNotif1 | |
4111// | | unsuccess | |
4112// | |<----------------| |
4113// | RESTNotif2 | |
4114// | | unsuccess | |
4115// |<------------------------------| |
4116// | | | |
4117// | | RESTSubDelReq1 | |
4118// | |---------------->| |
4119// | | | |
4120// | | RESTSubDelResp1 | |
4121// | |<----------------| |
4122// | | | |
4123// | RESTSubDelReq2 | |
4124// |------------------------------>| |
4125// | | | |
4126// | RESTSubDelResp2 | |
4127// |<------------------------------| |
4128//
4129//-----------------------------------------------------------------------------
4130func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4131 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4132
4133 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004134 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004135 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004136 Counter{cSubReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004137 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004138 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004139 Counter{cSubDelReqToE2, 1},
4140 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004141 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004142 })
4143
4144 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004145
4146 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004147 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004148 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4149 crereq1, _ := e2termConn1.RecvSubsReq(t)
4150
4151 // Req2
4152 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004153 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004154 params2.SetMeid("RAN_NAME_1")
4155 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4156 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4157
4158 //Req1 (retransmitted)
4159 e2termConn1.RecvSubsReq(t)
4160
4161 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004162
4163 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004164 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4165
Markku Virtanenda34eec2021-05-20 08:22:04 +00004166 e2SubsIdA := <-xappConn1.ListedRESTNotifications
4167 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
4168 e2SubsIdB := <-xappConn1.ListedRESTNotifications
4169 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004170
4171 // Del1
4172 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4173
4174 // Del2
4175 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4176
Markku Virtanenda34eec2021-05-20 08:22:04 +00004177 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4178
archaggeafbf95f2021-04-14 08:54:05 +03004179 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004180 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004181
4182 mainCtrl.VerifyCounterValues(t)
4183}
4184
4185//-----------------------------------------------------------------------------
4186// TestRESTSubReqAndSubDelNokSameActionParallel
4187//
4188// stub stub stub
4189// +-------+ +-------+ +---------+ +---------+
4190// | xapp2 | | xapp1 | | submgr | | e2term |
4191// +-------+ +-------+ +---------+ +---------+
4192// | | | |
4193// | | | |
4194// | | | |
4195// | | RESTSubReq1 | |
4196// | |---------------->| |
4197// | | | |
4198// | | RESTSubResp1 | |
4199// | |<----------------| |
4200// | | | SubReq1 |
4201// | | |------------->|
4202// | RESTSubReq2 | |
4203// |------------------------------>| |
4204// | | | |
4205// | RESTSubDelResp2 | |
4206// |<------------------------------| |
4207// | | | SubFail1 |
4208// | | |<-------------|
4209// | | | |
4210// | | RESTNotif1 | |
4211// | | unsuccess | |
4212// | |<----------------| |
4213// | RESTNotif2 | |
4214// | | unsuccess | |
4215// |<------------------------------| |
4216// | | | SubDelReq |
4217// | | |------------->|
4218// | | | SubDelResp |
4219// | | |<-------------|
4220// | | | |
4221// | | RESTSubDelReq1 | |
4222// | |---------------->| |
4223// | | | |
4224// | | RESTSubDelResp1 | |
4225// | |<----------------| |
4226// | | | |
4227// | RESTSubDelReq2 | |
4228// |------------------------------>| |
4229// | | | |
4230// | RESTSubDelResp2 | |
4231// |<------------------------------| |
4232//
4233//-----------------------------------------------------------------------------
4234func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4235 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4236
4237 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004238 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004239 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004240 Counter{cSubReqToE2, 1},
4241 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004242 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004243 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004244 Counter{cSubDelReqToE2, 1},
4245 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004246 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004247 })
4248
4249 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004250
4251 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004252 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004253 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4254 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4255
4256 // Req2
4257 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004258 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004259 params2.SetMeid("RAN_NAME_1")
4260 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4261 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4262
4263 // E2t: send SubsFail (first)
4264 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4265 fparams1.Set(crereq1)
4266 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4267
4268 // E2t: internal delete
4269 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4270 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4271 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4272
4273 e2SubsIdA := <-xappConn1.ListedRESTNotifications
4274 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
4275 e2SubsIdB := <-xappConn1.ListedRESTNotifications
4276 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
4277
4278 // Del1
4279 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4280
4281 // Del2
4282 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4283
4284 //Wait that subs is cleaned
4285 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4286 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4287
4288 mainCtrl.VerifyCounterValues(t)
4289}
4290
4291func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4292 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4293
4294 // Init counter check
4295 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004296 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004297 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004298 Counter{cSubReqToE2, 1},
4299 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004300 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004301 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004302 Counter{cSubDelReqToE2, 1},
4303 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004304 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004305 })
4306
4307 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004308
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004309 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004310 restSubId := xappConn1.SendRESTSubsReq(t, params)
4311 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
4312
4313 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4314 xappConn1.ExpectRESTNotification(t, restSubId)
4315 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4316 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4317 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
4318
4319 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4320 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4321 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4322
4323 // Wait that subs is cleaned
4324 waitSubsCleanup(t, e2SubsId, 10)
4325 mainCtrl.VerifyCounterValues(t)
4326}
4327
4328//-----------------------------------------------------------------------------
4329// TestRESTSubReqPolicyChangeAndSubDelOk
4330//
4331// stub stub
4332// +-------+ +---------+ +---------+
4333// | xapp | | submgr | | e2term |
4334// +-------+ +---------+ +---------+
4335// | | |
4336// | RESTSubReq | |
4337// |---------------->| |
4338// | | |
4339// | RESTSubResp | |
4340// |<----------------| |
4341// | | SubReq |
4342// | |------------->|
4343// | | |
4344// | | SubResp |
4345// | |<-------------|
4346// | | |
4347// | RESTNotif | |
4348// |<----------------| |
4349// | | |
4350// | RESTSubReq | |
4351// |---------------->| |
4352// | | |
4353// | RESTSubResp | |
4354// |<----------------| |
4355// | | SubReq |
4356// | |------------->|
4357// | | |
4358// | | SubResp |
4359// | |<-------------|
4360// | | |
4361// | RESTNotif | |
4362// |<----------------| |
4363// | | |
4364// | RESTSubDelReq | |
4365// |---------------->| |
4366// | | |
4367// | | SubDelReq |
4368// | |------------->|
4369// | | |
4370// | | SubDelResp |
4371// | |<-------------|
4372// | | |
4373// | RESTSubDelResp | |
4374// |<----------------| |
4375//
4376//-----------------------------------------------------------------------------
4377func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4378 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4379
4380 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004381 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004382 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004383 Counter{cSubReqToE2, 2},
4384 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004385 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004386 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004387 Counter{cSubDelReqToE2, 1},
4388 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004389 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004390 })
4391
4392 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004393
4394 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004395 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004396 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4397
4398 // Policy change
archaggeafbf95f2021-04-14 08:54:05 +03004399 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004400
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004401 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004402 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004403 params.SetTimeToWait("w200ms")
4404 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4405
4406 // Del
4407 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4408
4409 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4410 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4411
4412 // Wait that subs is cleaned
4413 waitSubsCleanup(t, e2SubsId, 10)
4414 mainCtrl.VerifyCounterValues(t)
4415}
4416
4417//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004418// TestRESTSubReqPolicyChangeNOk
4419//
4420// stub stub
4421// +-------+ +---------+ +---------+
4422// | xapp | | submgr | | e2term |
4423// +-------+ +---------+ +---------+
4424// | | |
4425// | RESTSubReq | |
4426// |---------------->| |
4427// | | |
4428// | RESTSubResp | |
4429// |<----------------| |
4430// | | SubReq |
4431// | |------------->|
4432// | | |
4433// | | SubResp |
4434// | |<-------------|
4435// | | |
4436// | RESTNotif | |
4437// |<----------------| |
4438// | | |
4439// | RESTSubReq | |
4440// |---------------->| |
4441// | | |
4442// | RESTSubUpdateFail |
4443// | | |
4444// | RESTSubDelReq | |
4445// |---------------->| |
4446// | | |
4447// | | SubDelReq |
4448// | |------------->|
4449// | | |
4450// | | SubDelResp |
4451// | |<-------------|
4452// | | |
4453// | RESTSubDelResp | |
4454// |<----------------| |
4455//
4456//-----------------------------------------------------------------------------
4457func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4458 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4459
4460 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4461 Counter{cRestSubReqFromXapp, 2},
4462 Counter{cRestSubRespToXapp, 1},
4463 Counter{cSubReqToE2, 1},
4464 Counter{cSubRespFromE2, 1},
4465 Counter{cRestSubNotifToXapp, 1},
4466 Counter{cRestSubFailToXapp, 1},
4467 Counter{cRestSubDelReqFromXapp, 1},
4468 Counter{cSubDelReqToE2, 1},
4469 Counter{cSubDelRespFromE2, 1},
4470 Counter{cRestSubDelRespToXapp, 1},
4471 })
4472
4473 const subReqCount int = 1
4474
4475 // Req
4476 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4477 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4478
4479 // Policy change
4480
4481 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4482
4483 restSubIdUpd := strings.ToUpper(restSubId)
4484 params.SetSubscriptionID(&restSubIdUpd)
4485 params.SetTimeToWait("w200ms")
4486
4487 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4488 assert.Equal(t, restSubId2, "")
4489
4490 // Del
4491 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4492
4493 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4494 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4495
4496 // Wait that subs is cleaned
4497 waitSubsCleanup(t, e2SubsId, 10)
4498 mainCtrl.VerifyCounterValues(t)
4499}
4500
4501//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004502// TestRESTSubReqAndSubDelOkTwoE2termParallel
4503//
4504// stub stub stub
4505// +-------+ +---------+ +---------+ +---------+
4506// | xapp | | submgr | | e2term1 | | e2term2 |
4507// +-------+ +---------+ +---------+ +---------+
4508// | | | |
4509// | | | |
4510// | | | |
4511// | RESTSubReq1 | | |
4512// |---------------->| | |
4513// | | | |
4514// | RESTSubResp1 | | |
4515// |<----------------| | |
4516// | | SubReq1 | |
4517// | |------------->| |
4518// | | | |
4519// | RESTSubReq2 | | |
4520// |---------------->| | |
4521// | | | |
4522// | RESTSubResp2 | | |
4523// |<----------------| | |
4524// | | SubReq2 | |
4525// | |---------------------------->|
4526// | | | |
4527// | | SubResp1 | |
4528// | |<-------------| |
4529// | RESTNotif1 | | |
4530// |<----------------| | |
4531// | | SubResp2 | |
4532// | |<----------------------------|
4533// | RESTNotif2 | | |
4534// |<----------------| | |
4535// | | | |
4536// | [SUBS 1 DELETE] | |
4537// | | | |
4538// | [SUBS 2 DELETE] | |
4539// | | | |
4540//
4541//-----------------------------------------------------------------------------
4542func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4543 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4544
4545 // Init counter check
4546 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004547 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004548 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004549 Counter{cSubReqToE2, 2},
4550 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004551 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004552 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004553 Counter{cSubDelReqToE2, 2},
4554 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004555 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004556 })
4557
4558 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004559
4560 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004561 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004562 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4563 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4564
4565 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004566 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004567 params.SetMeid("RAN_NAME_11")
4568 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4569 // would not work as notification would not be received
4570 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4571 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4572
4573 // Resp1
4574 xappConn1.ExpectRESTNotification(t, restSubId1)
4575 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4576 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4577 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
4578
4579 // Resp2
4580 xappConn2.ExpectRESTNotification(t, restSubId2)
4581 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4582 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4583 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
4584
4585 // Delete1
4586 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4587 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4588 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4589
4590 // Wait that subs is cleaned
4591 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4592
4593 // Delete2
4594 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4595 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4596 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4597
4598 // Wait that subs is cleaned
4599 waitSubsCleanup(t, e2SubsId2, 10)
4600
4601 mainCtrl.VerifyCounterValues(t)
4602}
4603
4604//-----------------------------------------------------------------------------
4605// TestRESTSubReqAsn1EncodeFail
4606//
4607// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4608// stub stub
4609// +-------+ +---------+ +---------+
4610// | xapp | | submgr | | e2term |
4611// +-------+ +---------+ +---------+
4612// | | |
4613// | RESTSubReq | |
4614// |---------------->| |
4615// | | |
4616// | RESTSubResp | |
4617// |<----------------| |
4618// | RESTSubDelReq | |
4619// |---------------->| |
4620// | RESTSubDelResp | |
4621// | unsuccess | |
4622// |<----------------| |
4623// | | |
4624//
4625//-----------------------------------------------------------------------------
4626func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4627 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4628
4629 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
4630
4631}
4632
4633//-----------------------------------------------------------------------------
4634// TestRESTSubReqInsertAndSubDelOk
4635//
4636// stub stub
4637// +-------+ +---------+ +---------+
4638// | xapp | | submgr | | e2term |
4639// +-------+ +---------+ +---------+
4640// | | |
4641// | RestSubReq | |
4642// |---------------->| |
4643// | | |
4644// | RESTSubResp | |
4645// |<----------------| |
4646// | | |
4647// | | SubReq |
4648// | |------------->|
4649// | | |
4650// | | SubResp |
4651// | |<-------------|
4652// | RESTNotif | |
4653// |<----------------| |
4654// | ... | ... |
4655// | | |
4656// | RESTSubDelReq | |
4657// |---------------->| |
4658// | | |
4659// | | SubDelReq |
4660// | |------------->|
4661// | | |
4662// | | SubDelResp |
4663// | |<-------------|
4664// | | |
4665// | RESTSubDelResp| |
4666// |<----------------| |
4667//
4668//-----------------------------------------------------------------------------
4669func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4670 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4671
4672 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004673 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004674 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004675 Counter{cSubReqToE2, 1},
4676 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004677 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004678 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004679 Counter{cSubDelReqToE2, 1},
4680 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004681 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004682 })
4683
4684 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004685
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004686 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004687 params.SetSubActionTypes("insert")
4688
4689 // Req
4690 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4691
4692 // Del
4693 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4694
4695 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4696 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4697
4698 // Wait that subs is cleaned
4699 waitSubsCleanup(t, e2SubsId, 10)
4700 mainCtrl.VerifyCounterValues(t)
4701}
4702
4703//-----------------------------------------------------------------------------
4704// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4705//
4706// stub stub
4707// +-------+ +---------+ +---------+
4708// | xapp | | submgr | | e2term |
4709// +-------+ +---------+ +---------+
4710// | | |
4711// | RESTSubReq | |
4712// |------------->| |
4713// | | |
4714// | | SubReq |
4715// | |------------->|
4716// | | |
4717// | | SubResp |
4718// | <----|
4719// | |
4720// | Submgr restart |
4721// | |
4722// | | |
4723// | | SubDelReq |
4724// | |------------->|
4725// | | |
4726// | | SubDelResp |
4727// | |<-------------|
4728// | | |
4729//
4730//-----------------------------------------------------------------------------
4731func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4732 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4733
4734 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004735 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004736 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004737 Counter{cSubReqToE2, 1},
4738 Counter{cSubDelReqFromXapp, 1},
4739 Counter{cSubDelReqToE2, 1},
4740 Counter{cSubDelRespFromE2, 1},
4741 })
4742
4743 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004744
4745 // Remove possible existing subscription
4746 mainCtrl.removeExistingSubscriptions(t)
4747
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004748 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004749
4750 //Req
4751 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
4752 restSubId := xappConn1.SendRESTSubsReq(t, params)
4753 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4754
4755 e2termConn1.RecvSubsReq(t)
4756
4757 mainCtrl.SetResetTestFlag(t, false)
4758
4759 mainCtrl.SimulateRestart(t)
4760 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4761
4762 //Del
4763 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4764 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4765
4766 xappConn1.TestMsgChanEmpty(t)
4767 xappConn2.TestMsgChanEmpty(t)
4768 e2termConn1.TestMsgChanEmpty(t)
4769 mainCtrl.wait_registry_empty(t, 10)
4770
4771 mainCtrl.VerifyCounterValues(t)
4772}
4773
4774//-----------------------------------------------------------------------------
4775// TestRESTSubReqAndSubDelOkWithRestartInMiddle
4776//
4777// stub stub
4778// +-------+ +---------+ +---------+
4779// | xapp | | submgr | | e2term |
4780// +-------+ +---------+ +---------+
4781// | | |
4782// | RESTSubReq | |
4783// |---------------->| |
4784// | | |
4785// | RESTSubResp | |
4786// |<----------------| |
4787// | | SubReq |
4788// | |------------->|
4789// | | |
4790// | | SubResp |
4791// | |<-------------|
4792// | | |
4793// | RESTNotif | |
4794// |<----------------| |
4795// | | |
4796// | |
4797// | Submgr restart |
4798// | | |
4799// | RESTSubDelReq | |
4800// |---------------->| |
4801// | | |
4802// | | SubDelReq |
4803// | |------------->|
4804// | | |
4805// | | SubDelResp |
4806// | |<-------------|
4807// | | |
4808// | RESTSubDelResp | |
4809// |<----------------| |
4810//
4811//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004812
archaggeafbf95f2021-04-14 08:54:05 +03004813func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4814 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4815
4816 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004817 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004818 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004819 Counter{cSubReqToE2, 1},
4820 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004821 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004822 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004823 Counter{cSubDelReqToE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004824 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004825 })
4826
4827 // Remove possible existing subscription
4828 mainCtrl.removeExistingSubscriptions(t)
4829
4830 var params *teststube2ap.RESTSubsReqParams = nil
4831
4832 // Create subscription
4833 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4834 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4835
4836 // Check subscription
4837 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4838
4839 // When SDL support for the REST Interface is added
4840 // the submgr restart statement below should be removed
4841 // from the comment.
4842
4843 // mainCtrl.SimulateRestart(t)
4844 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4845
4846 // Check subscription
4847 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4848
4849 // Delete subscription
4850 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4851
4852 //Wait that subs is cleaned
4853 waitSubsCleanup(t, e2SubsId, 10)
4854
4855 mainCtrl.VerifyCounterValues(t)
4856}
4857
4858//-----------------------------------------------------------------------------
4859// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4860//
4861// stub stub
4862// +-------+ +-------+ +---------+ +---------+
4863// | xapp2 | | xapp1 | | submgr | | e2term |
4864// +-------+ +-------+ +---------+ +---------+
4865// | | | |
4866// | | RESTSubReq1 | |
4867// | |---------------->| |
4868// | | | |
4869// | | RESTSubResp1 | |
4870// | |<----------------| |
4871// | | | |
4872// | | | SubReq1 |
4873// | | |------------->|
4874// | | | SubResp1 |
4875// | | |<-------------|
4876// | | RESTNotif1 | |
4877// | |<----------------| |
4878// | | | |
4879// | RESTSubReq2 | |
4880// |------------------------------>| |
4881// | | | |
4882// | RESTSubResp2 | |
4883// |<------------------------------| |
4884// | | | |
4885// | | RESTNotif2 | |
4886// |<------------------------------| |
4887// | | | |
4888// | | Submgr restart |
4889// | | | |
4890// | | RESTSubDelReq1 | |
4891// | |---------------->| |
4892// | | | |
4893// | | RESTSubDelResp1 | |
4894// | |<----------------| |
4895// | | | |
4896// | | Submgr restart |
4897// | | | |
4898// | RESTSubDelReq2 | |
4899// |------------------------------>| |
4900// | | | |
4901// | RESTSubDelResp2 | |
4902// |<------------------------------| |
4903// | | | |
4904// | | | SubDelReq2 |
4905// | | |------------->|
4906// | | | |
4907// | | | SubDelResp2 |
4908// | | |<-------------|
4909// | | | |
4910//
4911//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004912
archaggeafbf95f2021-04-14 08:54:05 +03004913func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4914 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4915
4916 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004917 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004918 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004919 Counter{cSubReqToE2, 1},
4920 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004921 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004922 Counter{cMergedSubscriptions, 1},
4923 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004924 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004925 Counter{cSubDelReqToE2, 1},
4926 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004927 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004928 })
4929
4930 // Remove possible existing subscription
4931 mainCtrl.removeExistingSubscriptions(t)
4932
4933 var params *teststube2ap.RESTSubsReqParams = nil
4934
4935 // Create subscription 1
4936 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4937 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4938
4939 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004940 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004941 params.SetMeid("RAN_NAME_1")
4942 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004943 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03004944 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4945 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004946 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03004947 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4948
4949 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4950
4951 // When SDL support for the REST Interface is added
4952 // the submgr restart statement below should be removed
4953 // from the comment.
4954
4955 // mainCtrl.SimulateRestart(t)
4956 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4957
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004958 // Delete subscription 1, and wait until it has removed the first endpoint
4959 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004960 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004961 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004962
4963 // When SDL support for the REST Interface is added
4964 // the submgr restart statement below should be removed
4965 // from the comment.
4966
4967 // mainCtrl.SimulateRestart(t)
4968 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004969 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4970
4971 // Delete subscription 2
4972 deleteXapp2Subscription(t, &restSubId2)
4973
4974 //Wait that subs is cleaned
4975 waitSubsCleanup(t, e2SubsId2, 10)
4976
4977 mainCtrl.VerifyCounterValues(t)
4978}
4979
4980//-----------------------------------------------------------------------------
4981// TestRESTReportSubReqAndSubDelOk
4982//
4983// stub stub
4984// +-------+ +---------+ +---------+
4985// | xapp | | submgr | | e2term |
4986// +-------+ +---------+ +---------+
4987// | | |
4988// | RestSubReq | |
4989// |---------------->| |
4990// | | |
4991// | RESTSubResp | |
4992// |<----------------| |
4993// | | |
4994// | | SubReq |
4995// | |------------->|
4996// | | |
4997// | | SubResp |
4998// | |<-------------|
4999// | RESTNotif | |
5000// |<----------------| |
5001// | | SubReq |
5002// | |------------->|
5003// | | |
5004// | | SubResp |
5005// | |<-------------|
5006// | RESTNotif | |
5007// |<----------------| |
5008// | ... | ... |
5009// | | |
5010// | | |
5011// | RESTSubDelReq | |
5012// |---------------->| |
5013// | | |
5014// | | SubDelReq |
5015// | |------------->|
5016// | | |
5017// | | SubDelResp |
5018// | |<-------------|
5019// | | |
5020// | RESTSubDelResp| |
5021// |<----------------| |
5022//
5023//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005024
archaggeafbf95f2021-04-14 08:54:05 +03005025func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5026 CaseBegin("TestRESTReportSubReqAndSubDelOk")
5027 subReqCount := 1
archaggeafbf95f2021-04-14 08:54:05 +03005028 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005029 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005030}
5031
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005032func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
5033 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005034
5035 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005036 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005037 restSubId := xappConn1.SendRESTSubsReq(t, params)
5038
5039 var e2SubsId []uint32
5040 for i := 0; i < subReqCount; i++ {
5041 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5042 xappConn1.ExpectRESTNotification(t, restSubId)
5043
5044 e2termConn1.SendSubsResp(t, crereq, cremsg)
5045 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5046 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5047 e2SubsId = append(e2SubsId, instanceId)
5048 resp, _ := xapp.Subscription.QuerySubscriptions()
5049 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5050 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5051 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5052
5053 }
5054
5055 // Del
5056 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5057
5058 for i := 0; i < subReqCount; i++ {
5059 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5060 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5061 }
5062
5063 // Wait that subs is cleaned
5064 for i := 0; i < subReqCount; i++ {
5065 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5066 }
5067
5068 xappConn1.TestMsgChanEmpty(t)
5069 e2termConn1.TestMsgChanEmpty(t)
5070 mainCtrl.wait_registry_empty(t, 10)
5071}
5072
5073/*
5074func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
5075 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5076
5077 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005078 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005079 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005080
5081 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005082 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005083 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005084}
5085*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005086func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
5087 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005088
5089 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005090 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005091 restSubId := xappConn1.SendRESTSubsReq(t, params)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005092 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005093 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
5094
5095 var e2SubsId []uint32
5096 for i := 0; i < subReqCount; i++ {
5097 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5098 xappConn1.ExpectRESTNotification(t, restSubId)
5099 e2termConn1.SendSubsResp(t, crereq, cremsg)
5100 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5101 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5102 e2SubsId = append(e2SubsId, instanceId)
5103 }
5104
5105 // Del
5106 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5107
5108 for i := 0; i < subReqCount; i++ {
5109 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5110 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5111 }
5112
5113 // Wait that subs is cleaned
5114 for i := 0; i < subReqCount; i++ {
5115 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5116 }
5117 xappConn1.TestMsgChanEmpty(t)
5118 e2termConn1.TestMsgChanEmpty(t)
5119 mainCtrl.wait_registry_empty(t, 10)
5120}
5121
archaggeafbf95f2021-04-14 08:54:05 +03005122func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5123
5124 subReqCount := 2
5125
5126 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005127 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005128 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005129 Counter{cSubReqToE2, 2},
5130 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005131 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005132 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005133 Counter{cSubDelReqToE2, 2},
5134 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005135 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005136 })
5137
5138 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005139 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005140 restSubId := xappConn1.SendRESTSubsReq(t, params)
5141 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5142
5143 assert.Equal(t, len(e2SubsIds), 2)
5144
5145 // Del
5146 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5147 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5148
5149 xappConn1.TestMsgChanEmpty(t)
5150 e2termConn1.TestMsgChanEmpty(t)
5151 mainCtrl.wait_registry_empty(t, 10)
5152
5153 mainCtrl.VerifyCounterValues(t)
5154}
archaggeafbf95f2021-04-14 08:54:05 +03005155func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5156
5157 subReqCount := 19
5158
5159 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005160 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005161 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005162 Counter{cSubReqToE2, 19},
5163 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005164 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005165 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005166 Counter{cSubDelReqToE2, 19},
5167 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005168 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005169 })
5170
5171 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005172 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005173 restSubId := xappConn1.SendRESTSubsReq(t, params)
5174 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5175
5176 assert.Equal(t, len(e2SubsIds), 19)
5177
5178 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5179 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5180
5181 xappConn1.TestMsgChanEmpty(t)
5182 e2termConn1.TestMsgChanEmpty(t)
5183 mainCtrl.wait_registry_empty(t, 10)
5184
5185 mainCtrl.VerifyCounterValues(t)
5186}
archaggeafbf95f2021-04-14 08:54:05 +03005187func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5188
5189 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005190
5191 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005192 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005193 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005194 Counter{cSubReqToE2, uint64(subReqCount)},
5195 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005196 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005197 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005198 Counter{cSubDelReqToE2, uint64(subReqCount)},
5199 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005200 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005201 })
5202
5203 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005204 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005205 restSubId := xappConn1.SendRESTSubsReq(t, params)
5206 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5207
5208 assert.Equal(t, len(e2SubsIds), subReqCount)
5209
5210 // Del
5211 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5212 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5213
5214 xappConn1.TestMsgChanEmpty(t)
5215 e2termConn1.TestMsgChanEmpty(t)
5216 mainCtrl.wait_registry_empty(t, 10)
5217
5218 mainCtrl.VerifyCounterValues(t)
5219}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005220
archaggeafbf95f2021-04-14 08:54:05 +03005221func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5222
5223 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005224
5225 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005226 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005227 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005228 Counter{cSubReqToE2, uint64(subReqCount)},
5229 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005230 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005231 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005232 Counter{cSubDelReqToE2, uint64(subReqCount)},
5233 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005234 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005235 })
5236
5237 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005238 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005239 restSubId := xappConn1.SendRESTSubsReq(t, params)
5240 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5241
5242 assert.Equal(t, len(e2SubsIds), subReqCount)
5243
5244 // Del
5245 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5246 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5247
5248 xappConn1.TestMsgChanEmpty(t)
5249 e2termConn1.TestMsgChanEmpty(t)
5250 mainCtrl.wait_registry_empty(t, 10)
5251
5252 mainCtrl.VerifyCounterValues(t)
5253}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005254
archaggeafbf95f2021-04-14 08:54:05 +03005255func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5256
5257 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005258
5259 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005260 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005261 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005262 Counter{cSubReqToE2, uint64(subReqCount)},
5263 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005264 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005265 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005266 Counter{cSubDelReqToE2, uint64(subReqCount)},
5267 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005268 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005269 })
5270
5271 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005272 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005273 restSubId := xappConn1.SendRESTSubsReq(t, params)
5274 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5275
5276 assert.Equal(t, len(e2SubsIds), subReqCount)
5277
5278 // Del
5279 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5280 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5281
5282 xappConn1.TestMsgChanEmpty(t)
5283 e2termConn1.TestMsgChanEmpty(t)
5284 mainCtrl.wait_registry_empty(t, 10)
5285
5286 mainCtrl.VerifyCounterValues(t)
5287}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005288
5289func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5290 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5291
5292 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005293 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005294 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005295 Counter{cSubReqToE2, 2},
5296 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005297 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005298 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005299 Counter{cSubDelReqToE2, 2},
5300 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005301 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005302 })
5303
5304 // Req1
5305 var params *teststube2ap.RESTSubsReqParams = nil
5306
5307 //Subs Create
5308 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5309 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5310
5311 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5312
5313 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005314 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005315 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005316 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005317 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5318
5319 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5320 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5321 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5322 xappConn2.ExpectRESTNotification(t, restSubId2)
5323 e2termConn1.SendSubsResp(t, crereq, cremsg)
5324 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5325
5326 deleteXapp1Subscription(t, &restSubId1)
5327 deleteXapp2Subscription(t, &restSubId2)
5328
5329 waitSubsCleanup(t, e2SubsId1, 10)
5330 waitSubsCleanup(t, e2SubsId2, 10)
5331
5332 mainCtrl.VerifyCounterValues(t)
5333
5334}
5335
5336func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5337 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5338
5339 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005340 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005341 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005342 Counter{cSubReqToE2, 2},
5343 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005344 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005345 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005346 Counter{cSubDelReqToE2, 2},
5347 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005348 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005349 })
5350
5351 // Req1
5352 var params *teststube2ap.RESTSubsReqParams = nil
5353
5354 //Subs Create
5355 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5356 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5357
5358 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5359
5360 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005361 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005362 params.SetMeid("RAN_NAME_1")
5363
5364 actionId := int64(1)
5365 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005366 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005367 subsequestActionType := "continue"
5368 timeToWait := "w10ms"
5369 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5370
5371 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5372 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5373 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5374 xappConn2.ExpectRESTNotification(t, restSubId2)
5375 e2termConn1.SendSubsResp(t, crereq, cremsg)
5376 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5377
5378 deleteXapp1Subscription(t, &restSubId1)
5379 deleteXapp2Subscription(t, &restSubId2)
5380
5381 waitSubsCleanup(t, e2SubsId1, 10)
5382 waitSubsCleanup(t, e2SubsId2, 10)
5383
5384 mainCtrl.VerifyCounterValues(t)
5385
5386}
5387
5388func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5389 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5390
5391 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005392 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005393 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005394 Counter{cSubReqToE2, 2},
5395 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005396 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005397 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005398 Counter{cSubDelReqToE2, 2},
5399 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005400 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005401 })
5402
5403 // Req1
5404 var params *teststube2ap.RESTSubsReqParams = nil
5405
5406 //Subs Create
5407 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5408 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5409
5410 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5411
5412 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005413 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005414 params.SetMeid("RAN_NAME_1")
5415 params.SetSubActionIDs(int64(2))
5416
5417 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5418 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5419 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5420 xappConn2.ExpectRESTNotification(t, restSubId2)
5421 e2termConn1.SendSubsResp(t, crereq, cremsg)
5422 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5423
5424 deleteXapp1Subscription(t, &restSubId1)
5425 deleteXapp2Subscription(t, &restSubId2)
5426
5427 waitSubsCleanup(t, e2SubsId1, 10)
5428 waitSubsCleanup(t, e2SubsId2, 10)
5429
5430 mainCtrl.VerifyCounterValues(t)
5431
5432}
5433
5434func TestRESTSubReqDiffActionType(t *testing.T) {
5435 CaseBegin("TestRESTSubReqDiffActionType")
5436
5437 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005438 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005439 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005440 Counter{cSubReqToE2, 2},
5441 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005442 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005443 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005444 Counter{cSubDelReqToE2, 2},
5445 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005446 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005447 })
5448
5449 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005450 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005451
5452 //Subs Create
5453 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5454 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5455
5456 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5457
5458 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005459 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005460 params.SetMeid("RAN_NAME_1")
5461
5462 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5463 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5464 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5465 xappConn2.ExpectRESTNotification(t, restSubId2)
5466 e2termConn1.SendSubsResp(t, crereq, cremsg)
5467 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5468
5469 deleteXapp1Subscription(t, &restSubId1)
5470 deleteXapp2Subscription(t, &restSubId2)
5471
5472 waitSubsCleanup(t, e2SubsId1, 10)
5473 waitSubsCleanup(t, e2SubsId2, 10)
5474
5475 mainCtrl.VerifyCounterValues(t)
5476
5477}
5478
5479func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5480 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5481
5482 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005483 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005484 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005485 Counter{cSubReqToE2, 2},
5486 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005487 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005488 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005489 Counter{cSubDelReqToE2, 2},
5490 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005491 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005492 })
5493
5494 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005495 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005496
5497 //Subs Create
5498 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5499 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5500
5501 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5502
5503 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005504 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005505 params.SetMeid("RAN_NAME_1")
5506
5507 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5508 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5509 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5510 xappConn2.ExpectRESTNotification(t, restSubId2)
5511 e2termConn1.SendSubsResp(t, crereq, cremsg)
5512 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5513
5514 deleteXapp1Subscription(t, &restSubId1)
5515 deleteXapp2Subscription(t, &restSubId2)
5516
5517 waitSubsCleanup(t, e2SubsId1, 10)
5518 waitSubsCleanup(t, e2SubsId2, 10)
5519
5520 mainCtrl.VerifyCounterValues(t)
5521
5522}
5523
5524func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5525 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5526
5527 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005528 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005529 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005530 Counter{cSubReqToE2, 2},
5531 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005532 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005533 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005534 Counter{cSubDelReqToE2, 2},
5535 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005536 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005537 })
5538
5539 // Req1
5540 var params *teststube2ap.RESTSubsReqParams = nil
5541
5542 //Subs Create
5543 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5544 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5545
5546 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5547
5548 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005549 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005550 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005551 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005552 params.SetSubActionDefinition(actionDefinition)
5553
5554 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5555 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5556 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5557 xappConn2.ExpectRESTNotification(t, restSubId2)
5558 e2termConn1.SendSubsResp(t, crereq, cremsg)
5559 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5560
5561 deleteXapp1Subscription(t, &restSubId1)
5562 deleteXapp2Subscription(t, &restSubId2)
5563
5564 waitSubsCleanup(t, e2SubsId1, 10)
5565 waitSubsCleanup(t, e2SubsId2, 10)
5566
5567 mainCtrl.VerifyCounterValues(t)
5568
5569}
5570
5571func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5572 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5573
5574 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005575 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005576 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005577 Counter{cSubReqToE2, 2},
5578 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005579 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005580 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005581 Counter{cSubDelReqToE2, 2},
5582 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005583 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005584 })
5585
5586 // Req1
5587 var params *teststube2ap.RESTSubsReqParams = nil
5588
5589 //Subs Create
5590 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5591 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5592
5593 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5594
5595 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005596 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005597 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005598 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005599 params.SetSubActionDefinition(actionDefinition)
5600
5601 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5602 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5603 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5604 xappConn2.ExpectRESTNotification(t, restSubId2)
5605 e2termConn1.SendSubsResp(t, crereq, cremsg)
5606 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5607
5608 deleteXapp1Subscription(t, &restSubId1)
5609 deleteXapp2Subscription(t, &restSubId2)
5610
5611 waitSubsCleanup(t, e2SubsId1, 10)
5612 waitSubsCleanup(t, e2SubsId2, 10)
5613
5614 mainCtrl.VerifyCounterValues(t)
5615
5616}
5617
5618func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5619 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5620
5621 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005622 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005623 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005624 Counter{cSubReqToE2, 2},
5625 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005626 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005627 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005628 Counter{cSubDelReqToE2, 2},
5629 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005630 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005631 })
5632
5633 // Req1
5634 var params *teststube2ap.RESTSubsReqParams = nil
5635
5636 //Subs Create
5637 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5638 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5639
5640 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5641
5642 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005643 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005644 params.SetMeid("RAN_NAME_1")
5645 params.SetTimeToWait("w200ms")
5646 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5647 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5648 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5649 xappConn2.ExpectRESTNotification(t, restSubId2)
5650 e2termConn1.SendSubsResp(t, crereq, cremsg)
5651 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5652
5653 deleteXapp1Subscription(t, &restSubId1)
5654 deleteXapp2Subscription(t, &restSubId2)
5655
5656 waitSubsCleanup(t, e2SubsId1, 10)
5657 waitSubsCleanup(t, e2SubsId2, 10)
5658
5659 mainCtrl.VerifyCounterValues(t)
5660
5661}
5662
Anssi Mannila51122392021-05-25 11:51:31 +03005663//-----------------------------------------------------------------------------
5664// TestRESTUnpackSubscriptionResponseDecodeFail
5665//
5666// stub stub
5667// +-------+ +---------+ +---------+
5668// | xapp | | submgr | | e2term |
5669// +-------+ +---------+ +---------+
5670// | | |
5671// | RestSubReq | |
5672// |---------------->| |
5673// | | |
5674// | RESTSubResp | |
5675// |<----------------| |
5676// | | |
5677// | | SubReq |
5678// | |------------->|
5679// | | |
5680// | | SubResp | ASN.1 decode fails
5681// | |<-------------|
5682// | | |
5683// | | SubReq |
5684// | |------------->|
5685// | | |
5686// | | SubFail | Duplicated action
5687// | |<-------------|
5688// | RESTNotif (fail)| |
5689// |<----------------| |
5690// | | SubDelReq |
5691// | |------------->|
5692// | | |
5693// | | SubDelResp |
5694// | |<-------------|
5695//
5696//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005697
Anssi Mannila51122392021-05-25 11:51:31 +03005698func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
5699 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5700 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005701
5702 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005703 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005704 restSubId := xappConn1.SendRESTSubsReq(t, params)
5705
5706 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5707 // Decode of this response fails which will result resending original request
5708 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5709
5710 _, cremsg = e2termConn1.RecvSubsReq(t)
5711
Markku Virtanen55d2a282021-06-04 14:46:56 +03005712 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005713
5714 // Subscription already created in E2 Node.
5715 fparams := &teststube2ap.E2StubSubsFailParams{}
5716 fparams.Set(crereq)
5717 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5718 e2termConn1.SendSubsFail(t, fparams, cremsg)
5719
5720 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5721 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5722
5723 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5724 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5725
5726 // Wait that subs is cleaned
5727 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5728
5729 xappConn1.TestMsgChanEmpty(t)
5730 e2termConn1.TestMsgChanEmpty(t)
5731 mainCtrl.wait_registry_empty(t, 10)
5732}
5733
5734//-----------------------------------------------------------------------------
5735// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5736//
5737// stub stub
5738// +-------+ +---------+ +---------+
5739// | xapp | | submgr | | e2term |
5740// +-------+ +---------+ +---------+
5741// | | |
5742// | RestSubReq | |
5743// |---------------->| |
5744// | | |
5745// | RESTSubResp | |
5746// |<----------------| |
5747// | | |
5748// | | SubReq |
5749// | |------------->|
5750// | | |
5751// | | SubResp | Unknown instanceId
5752// | |<-------------|
5753// | | |
5754// | | SubReq |
5755// | |------------->|
5756// | | |
5757// | | SubFail | Duplicated action
5758// | |<-------------|
5759// | RESTNotif (fail)| |
5760// |<----------------| |
5761// | | SubDelReq |
5762// | |------------->|
5763// | | |
5764// | | SubDelResp |
5765// | |<-------------|
5766//
5767//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005768
Anssi Mannila51122392021-05-25 11:51:31 +03005769func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
5770 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5771 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005772
5773 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005774 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005775 restSubId := xappConn1.SendRESTSubsReq(t, params)
5776
5777 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5778
5779 // Unknown instanceId in this response which will result resending original request
5780 orgInstanceId := crereq.RequestId.InstanceId
5781 crereq.RequestId.InstanceId = 0
5782 e2termConn1.SendSubsResp(t, crereq, cremsg)
5783
5784 _, cremsg = e2termConn1.RecvSubsReq(t)
5785
Markku Virtanen55d2a282021-06-04 14:46:56 +03005786 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005787
5788 // Subscription already created in E2 Node.
5789 fparams := &teststube2ap.E2StubSubsFailParams{}
5790 fparams.Set(crereq)
5791 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5792 e2termConn1.SendSubsFail(t, fparams, cremsg)
5793
5794 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5795 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5796
5797 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5798 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5799
5800 // Wait that subs is cleaned
5801 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
5802
5803 xappConn1.TestMsgChanEmpty(t)
5804 e2termConn1.TestMsgChanEmpty(t)
5805 mainCtrl.wait_registry_empty(t, 10)
5806}
5807
5808//-----------------------------------------------------------------------------
5809// TestRESTUnpackSubscriptionResponseNoTransaction
5810//
5811// stub stub
5812// +-------+ +---------+ +---------+
5813// | xapp | | submgr | | e2term |
5814// +-------+ +---------+ +---------+
5815// | | |
5816// | RestSubReq | |
5817// |---------------->| |
5818// | | |
5819// | RESTSubResp | |
5820// |<----------------| |
5821// | | |
5822// | | SubReq |
5823// | |------------->|
5824// | | |
5825// | | SubResp | No transaction for the response
5826// | |<-------------|
5827// | | |
5828// | | SubReq |
5829// | |------------->|
5830// | | |
5831// | | SubFail | Duplicated action
5832// | |<-------------|
5833// | RESTNotif (fail)| |
5834// |<----------------| |
5835// | | SubDelReq |
5836// | |------------->|
5837// | | |
5838// | | SubDelResp |
5839// | |<-------------|
5840// | | |
5841// | | SubDelReq |
5842// | |------------->|
5843// | | |
5844// | | SubDelResp |
5845// | |<-------------|
5846//
5847//-----------------------------------------------------------------------------
5848func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
5849 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5850 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005851
5852 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005853 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005854 restSubId := xappConn1.SendRESTSubsReq(t, params)
5855
5856 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5857
5858 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5859 // No transaction exist for this response which will result resending original request
5860 e2termConn1.SendSubsResp(t, crereq, cremsg)
5861
5862 _, cremsg = e2termConn1.RecvSubsReq(t)
5863
Markku Virtanen55d2a282021-06-04 14:46:56 +03005864 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005865
5866 // Subscription already created in E2 Node.
5867 fparams := &teststube2ap.E2StubSubsFailParams{}
5868 fparams.Set(crereq)
5869 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5870 e2termConn1.SendSubsFail(t, fparams, cremsg)
5871
5872 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5873 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5874
5875 // Resending happens because there no transaction
5876 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5877 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5878
5879 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5880 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5881
5882 // Wait that subs is cleaned
5883 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5884
5885 xappConn1.TestMsgChanEmpty(t)
5886 e2termConn1.TestMsgChanEmpty(t)
5887 mainCtrl.wait_registry_empty(t, 10)
5888
5889}
5890
5891//-----------------------------------------------------------------------------
5892// TestRESTUnpackSubscriptionFailureDecodeFail
5893//
5894// stub stub
5895// +-------+ +---------+ +---------+
5896// | xapp | | submgr | | e2term |
5897// +-------+ +---------+ +---------+
5898// | | |
5899// | RestSubReq | |
5900// |---------------->| |
5901// | | |
5902// | RESTSubResp | |
5903// |<----------------| |
5904// | | |
5905// | | SubReq |
5906// | |------------->|
5907// | | |
5908// | | SubFail | ASN.1 decode fails
5909// | |<-------------|
5910// | | |
5911// | | SubReq |
5912// | |------------->|
5913// | | |
5914// | | SubFail | Duplicated action
5915// | |<-------------|
5916// | RESTNotif (fail)| |
5917// |<----------------| |
5918// | | SubDelReq |
5919// | |------------->|
5920// | | |
5921// | | SubDelResp |
5922// | |<-------------|
5923//
5924//-----------------------------------------------------------------------------
5925func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
5926 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5927 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005928
5929 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005930 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005931 restSubId := xappConn1.SendRESTSubsReq(t, params)
5932
5933 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5934
5935 // Decode of this response fails which will result resending original request
5936 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5937
5938 _, cremsg = e2termConn1.RecvSubsReq(t)
5939
Markku Virtanen55d2a282021-06-04 14:46:56 +03005940 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005941
5942 // Subscription already created in E2 Node.
5943 fparams := &teststube2ap.E2StubSubsFailParams{}
5944 fparams.Set(crereq)
5945 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5946 e2termConn1.SendSubsFail(t, fparams, cremsg)
5947
5948 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5949 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5950
5951 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5952 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5953
5954 // Wait that subs is cleaned
5955 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5956
5957 xappConn1.TestMsgChanEmpty(t)
5958 e2termConn1.TestMsgChanEmpty(t)
5959 mainCtrl.wait_registry_empty(t, 10)
5960}
5961
5962//-----------------------------------------------------------------------------
5963// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5964//
5965// stub stub
5966// +-------+ +---------+ +---------+
5967// | xapp | | submgr | | e2term |
5968// +-------+ +---------+ +---------+
5969// | | |
5970// | RestSubReq | |
5971// |---------------->| |
5972// | | |
5973// | RESTSubResp | |
5974// |<----------------| |
5975// | | |
5976// | | SubReq |
5977// | |------------->|
5978// | | |
5979// | | SubFail | Unknown instanceId
5980// | |<-------------|
5981// | | |
5982// | | SubReq |
5983// | |------------->|
5984// | | |
5985// | | SubFail | Duplicated action
5986// | |<-------------|
5987// | RESTNotif (fail)| |
5988// |<----------------| |
5989// | | SubDelReq |
5990// | |------------->|
5991// | | |
5992// | | SubDelResp |
5993// | |<-------------|
5994//
5995//-----------------------------------------------------------------------------
5996func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
5997 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
5998 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005999
6000 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006001 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006002 restSubId := xappConn1.SendRESTSubsReq(t, params)
6003
6004 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6005
6006 // Unknown instanceId in this response which will result resending original request
6007 fparams := &teststube2ap.E2StubSubsFailParams{}
6008 fparams.Set(crereq)
6009 fparams.Fail.RequestId.InstanceId = 0
6010 e2termConn1.SendSubsFail(t, fparams, cremsg)
6011
6012 _, cremsg = e2termConn1.RecvSubsReq(t)
6013
Markku Virtanen55d2a282021-06-04 14:46:56 +03006014 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006015
6016 // Subscription already created in E2 Node.
6017 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6018 e2termConn1.SendSubsFail(t, fparams, cremsg)
6019
6020 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6021 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6022
6023 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
6024 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
6025
6026 // Wait that subs is cleaned
6027 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6028
6029 xappConn1.TestMsgChanEmpty(t)
6030 e2termConn1.TestMsgChanEmpty(t)
6031 mainCtrl.wait_registry_empty(t, 10)
6032}
6033
6034//-----------------------------------------------------------------------------
6035// TestRESTUnpackSubscriptionFailureNoTransaction
6036//
6037// stub stub
6038// +-------+ +---------+ +---------+
6039// | xapp | | submgr | | e2term |
6040// +-------+ +---------+ +---------+
6041// | | |
6042// | RestSubReq | |
6043// |---------------->| |
6044// | | |
6045// | RESTSubResp | |
6046// |<----------------| |
6047// | | |
6048// | | SubReq |
6049// | |------------->|
6050// | | |
6051// | | SubFail | No transaction for the response
6052// | |<-------------|
6053// | | |
6054// | | SubReq |
6055// | |------------->|
6056// | | |
6057// | | SubFail | Duplicated action
6058// | |<-------------|
6059// | RESTNotif (fail)| |
6060// |<----------------| |
6061// | | SubDelReq |
6062// | |------------->|
6063// | | |
6064// | | SubDelResp |
6065// | |<-------------|
6066//
6067//-----------------------------------------------------------------------------
6068func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
6069 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6070 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03006071
6072 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006073 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006074 restSubId := xappConn1.SendRESTSubsReq(t, params)
6075
6076 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6077
6078 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6079
6080 // No transaction exist for this response which will result resending original request
6081 fparams := &teststube2ap.E2StubSubsFailParams{}
6082 fparams.Set(crereq)
6083 e2termConn1.SendSubsFail(t, fparams, cremsg)
6084
6085 _, cremsg = e2termConn1.RecvSubsReq(t)
6086
Markku Virtanen55d2a282021-06-04 14:46:56 +03006087 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006088
6089 // Subscription already created in E2 Node.
6090 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6091 e2termConn1.SendSubsFail(t, fparams, cremsg)
6092
6093 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6094 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6095
6096 // Resending happens because there no transaction
6097 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6098 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6099
6100 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
6101 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
6102
6103 // Wait that subs is cleaned
6104 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6105
6106 xappConn1.TestMsgChanEmpty(t)
6107 e2termConn1.TestMsgChanEmpty(t)
6108 mainCtrl.wait_registry_empty(t, 10)
6109}
6110
6111//-----------------------------------------------------------------------------
6112// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6113//
6114// stub stub
6115// +-------+ +---------+ +---------+
6116// | xapp | | submgr | | e2term |
6117// +-------+ +---------+ +---------+
6118// | | |
6119// | [SUBS CREATE] |
6120// | | |
6121// | | |
6122// | RESTSubDelReq | |
6123// |---------------->| |
6124// | | |
6125// | RESTSubDelResp | |
6126// |<----------------| |
6127// | | |
6128// | | SubDelReq |
6129// | |------------->|
6130// | | |
6131// | | SubDelResp | ASN.1 decode fails
6132// | |<-------------|
6133// | | |
6134// | | SubDelReq |
6135// | |------------->|
6136// | | |
6137// | | SubDelFail | Subscription does exist any more
6138// | |<-------------|
6139// | | |
6140//
6141//-----------------------------------------------------------------------------
6142func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
6143 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
6144
6145 // Req
6146 var params *teststube2ap.RESTSubsReqParams = nil
6147 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6148
6149 // Del
6150 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6151
6152 // E2t: Receive 1st SubsDelReq
6153 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6154
6155 // Decode of this response fails which will result resending original request
6156 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6157
6158 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6159 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6160
6161 // Subscription does not exist in in E2 Node.
6162 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6163
6164 // Wait that subs is cleaned
6165 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6166
6167 xappConn1.TestMsgChanEmpty(t)
6168 e2termConn1.TestMsgChanEmpty(t)
6169 mainCtrl.wait_registry_empty(t, 10)
6170}
6171
6172//-----------------------------------------------------------------------------
6173// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6174//
6175// stub stub
6176// +-------+ +---------+ +---------+
6177// | xapp | | submgr | | e2term |
6178// +-------+ +---------+ +---------+
6179// | | |
6180// | [SUBS CREATE] |
6181// | | |
6182// | | |
6183// | RESTSubDelReq | |
6184// |---------------->| |
6185// | | |
6186// | RESTSubDelResp | |
6187// |<----------------| |
6188// | | |
6189// | | SubDelReq |
6190// | |------------->|
6191// | | |
6192// | | SubDelResp | Unknown instanceId
6193// | |<-------------|
6194// | | |
6195// | | SubDelReq |
6196// | |------------->|
6197// | | |
6198// | | SubDelFail | Subscription does exist any more
6199// | |<-------------|
6200//
6201//-----------------------------------------------------------------------------
6202func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
6203 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
6204
6205 // Req
6206 var params *teststube2ap.RESTSubsReqParams = nil
6207 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6208
6209 // Del
6210 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6211
6212 // E2t: Receive 1st SubsDelReq
6213 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6214
6215 // Unknown instanceId in this response which will result resending original request
6216 delreq.RequestId.InstanceId = 0
6217 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6218
6219 // E2t: Receive 2nd SubsDelReq
6220 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6221
6222 // Subscription does not exist in in E2 Node.
6223 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6224
6225 // Wait that subs is cleaned
6226 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6227
6228 xappConn1.TestMsgChanEmpty(t)
6229 e2termConn1.TestMsgChanEmpty(t)
6230 mainCtrl.wait_registry_empty(t, 10)
6231}
6232
6233//-----------------------------------------------------------------------------
6234// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6235//
6236// stub stub
6237// +-------+ +---------+ +---------+
6238// | xapp | | submgr | | e2term |
6239// +-------+ +---------+ +---------+
6240// | | |
6241// | [SUBS CREATE] |
6242// | | |
6243// | | |
6244// | RESTSubDelReq | |
6245// |---------------->| |
6246// | | |
6247// | RESTSubDelResp | |
6248// |<----------------| |
6249// | | |
6250// | | SubDelReq |
6251// | |------------->|
6252// | | |
6253// | | SubDelResp | No transaction for the response
6254// | |<-------------|
6255// | | |
6256// | | SubDelReq |
6257// | |------------->|
6258// | | |
6259// | | SubDelFail | Subscription does exist any more
6260// | |<-------------|
6261//
6262//-----------------------------------------------------------------------------
6263func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
6264 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
6265
6266 // Req
6267 var params *teststube2ap.RESTSubsReqParams = nil
6268 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6269
6270 // Del
6271 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6272
6273 // E2t: Receive 1st SubsDelReq
6274 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6275
6276 mainCtrl.MakeTransactionNil(t, e2SubsId)
6277
6278 // No transaction exist for this response which will result resending original request
6279 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6280
6281 // E2t: Receive 2nd SubsDelReq
6282 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6283
6284 // Subscription does not exist in in E2 Node.
6285 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6286
6287 // Wait that subs is cleaned
6288 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6289
6290 xappConn1.TestMsgChanEmpty(t)
6291 e2termConn1.TestMsgChanEmpty(t)
6292 mainCtrl.wait_registry_empty(t, 10)
6293}
6294
6295//-----------------------------------------------------------------------------
6296// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6297//
6298// stub stub
6299// +-------+ +---------+ +---------+
6300// | xapp | | submgr | | e2term |
6301// +-------+ +---------+ +---------+
6302// | | |
6303// | [SUBS CREATE] |
6304// | | |
6305// | | |
6306// | RESTSubDelReq | |
6307// |---------------->| |
6308// | | |
6309// | RESTSubDelResp | |
6310// |<----------------| |
6311// | | |
6312// | | SubDelReq |
6313// | |------------->|
6314// | | |
6315// | | SubDelFail | ASN.1 decode fails
6316// | |<-------------|
6317// | | |
6318// | | SubDelReq |
6319// | |------------->|
6320// | | |
6321// | | SubDelFail | Subscription does exist any more
6322// | |<-------------|
6323//
6324//-----------------------------------------------------------------------------
6325func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
6326 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
6327
6328 // Req
6329 var params *teststube2ap.RESTSubsReqParams = nil
6330 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6331
6332 // Del
6333 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6334
6335 // E2t: Receive 1st SubsDelReq
6336 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6337
6338 // Decode of this response fails which will result resending original request
6339 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6340
6341 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6342 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6343
6344 // Subscription does not exist in in E2 Node.
6345 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6346
6347 // Wait that subs is cleaned
6348 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6349
6350 xappConn1.TestMsgChanEmpty(t)
6351 e2termConn1.TestMsgChanEmpty(t)
6352 mainCtrl.wait_registry_empty(t, 10)
6353}
6354
6355//-----------------------------------------------------------------------------
6356// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6357//
6358// stub stub
6359// +-------+ +---------+ +---------+
6360// | xapp | | submgr | | e2term |
6361// +-------+ +---------+ +---------+
6362// | | |
6363// | [SUBS CREATE] |
6364// | | |
6365// | | |
6366// | RESTSubDelReq | |
6367// |---------------->| |
6368// | | |
6369// | RESTSubDelResp | |
6370// |<----------------| |
6371// | | |
6372// | | SubDelReq |
6373// | |------------->|
6374// | | |
6375// | | SubDelFail | Unknown instanceId
6376// | |<-------------|
6377// | | |
6378// | | SubDelReq |
6379// | |------------->|
6380// | | |
6381// | | SubDelFail | Subscription does exist any more
6382// | |<-------------|
6383//
6384//-----------------------------------------------------------------------------
6385func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
6386 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
6387
6388 // Req
6389 var params *teststube2ap.RESTSubsReqParams = nil
6390 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6391
6392 // Del
6393 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6394
6395 // E2t: Receive 1st SubsDelReq
6396 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6397
6398 // Unknown instanceId in this response which will result resending original request
6399 delreq.RequestId.InstanceId = 0
6400 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6401
6402 // E2t: Receive 2nd SubsDelReq
6403 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6404
6405 // Subscription does not exist in in E2 Node.
6406 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6407
6408 // Wait that subs is cleaned
6409 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6410
6411 xappConn1.TestMsgChanEmpty(t)
6412 e2termConn1.TestMsgChanEmpty(t)
6413 mainCtrl.wait_registry_empty(t, 10)
6414}
6415
6416//-----------------------------------------------------------------------------
6417// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6418//
6419// stub stub
6420// +-------+ +---------+ +---------+
6421// | xapp | | submgr | | e2term |
6422// +-------+ +---------+ +---------+
6423// | | |
6424// | [SUBS CREATE] |
6425// | | |
6426// | | |
6427// | RESTSubDelReq | |
6428// |---------------->| |
6429// | | |
6430// | RESTSubDelResp | |
6431// |<----------------| |
6432// | | |
6433// | | SubDelReq |
6434// | |------------->|
6435// | | |
6436// | | SubDelFail | No transaction for the response
6437// | |<-------------|
6438// | | |
6439// | | SubDelReq |
6440// | |------------->|
6441// | | |
6442// | | SubDelFail | Subscription does exist any more
6443// | |<-------------|
6444//
6445//-----------------------------------------------------------------------------
6446func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
6447 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
6448
6449 // Req
6450 var params *teststube2ap.RESTSubsReqParams = nil
6451 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6452
6453 // Del
6454 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6455
6456 // E2t: Receive 1st SubsDelReq
6457 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6458
6459 mainCtrl.MakeTransactionNil(t, e2SubsId)
6460
6461 // No transaction exist for this response which will result resending original request
6462 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6463
6464 // E2t: Receive 2nd SubsDelReq
6465 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6466
6467 // Subscription does not exist in in E2 Node.
6468 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6469
6470 // Wait that subs is cleaned
6471 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6472
6473 xappConn1.TestMsgChanEmpty(t)
6474 e2termConn1.TestMsgChanEmpty(t)
6475 mainCtrl.wait_registry_empty(t, 10)
6476}
6477
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006478//-----------------------------------------------------------------------------
6479// TestRESTSubReqFailAsn1PackSubReqError
6480//
6481// stub stub
6482// +-------+ +---------+ +---------+
6483// | xapp | | submgr | | e2term |
6484// +-------+ +---------+ +---------+
6485// | | |
6486// | RESTSubReq | |
6487// |---------------->| |
6488// | | |
6489// | RESTSubResp | |
6490// |<----------------| |
6491// | | |
6492// | ASN.1 encode fails |
6493// | | |
6494// | | SubDelReq |
6495// | |------------->|
6496// | | |
6497// | | SubDelFail |
6498// | |<-------------|
6499// | | |
6500// | RESTNotif | |
6501// | unsuccess | |
6502// |<----------------| |
6503// | | |
6504// | [SUBS DELETE] |
6505// | | |
6506//
6507//-----------------------------------------------------------------------------
6508func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6509
6510 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006511 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006512 Counter{cRestSubRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006513 Counter{cSubDelReqToE2, 1},
6514 Counter{cSubDelFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006515 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006516 })
6517
6518 subReqCount := 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006519
6520 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006521 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006522 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6523
6524 // Req
6525 restSubId := xappConn1.SendRESTSubsReq(t, params)
6526 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6527
6528 // E2t: Receive SubsDelReq
6529 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03006530 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006531
6532 // Subscription does not exist in in E2 Node.
6533 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6534
6535 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6536 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
6537
6538 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
6539 // Wait that subs is cleaned
6540 waitSubsCleanup(t, e2SubsId, 10)
6541 mainCtrl.VerifyCounterValues(t)
6542}
6543
archaggeafbf95f2021-04-14 08:54:05 +03006544////////////////////////////////////////////////////////////////////////////////////
6545// Services for UT cases
6546////////////////////////////////////////////////////////////////////////////////////
6547const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006548const host string = "localhost"
6549
6550func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
6551 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006552 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006553 }
6554 restSubId := fromXappConn.SendRESTSubsReq(t, params)
6555 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6556
6557 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
6558 fromXappConn.ExpectRESTNotification(t, restSubId)
6559 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
6560 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
6561 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6562
6563 return restSubId, e2SubsId
6564}
6565
6566func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
6567
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006568 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006569 if meid != "" {
6570 params.SetMeid(meid)
6571 }
6572 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
6573 restSubId := xappConn2.SendRESTSubsReq(t, params)
6574 xappConn2.ExpectRESTNotification(t, restSubId)
6575 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6576 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
6577 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6578
6579 return restSubId, e2SubsId
6580}
6581
6582func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006583 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006584 restSubId := xappConn1.SendRESTSubsReq(t, params)
6585 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
6586
6587 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6588 xappConn1.ExpectRESTNotification(t, restSubId)
6589 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6590 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6591 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6592
6593 return restSubId, e2SubsId
6594}
6595
6596func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006597 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006598 restSubId := xappConn1.SendRESTSubsReq(t, params)
6599
6600 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6601 fparams1 := &teststube2ap.E2StubSubsFailParams{}
6602 fparams1.Set(crereq1)
6603 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
6604
6605 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
6606 xappConn1.ExpectRESTNotification(t, restSubId)
6607 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
6608 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6609 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
6610
6611 return restSubId, e2SubsId
6612}
6613
6614func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
6615 fromXappConn.SendRESTSubsDelReq(t, restSubId)
6616 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6617 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6618}
6619
6620func deleteXapp1Subscription(t *testing.T, restSubId *string) {
6621 xappConn1.SendRESTSubsDelReq(t, restSubId)
6622 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6623 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6624}
6625
6626func deleteXapp2Subscription(t *testing.T, restSubId *string) {
6627 xappConn2.SendRESTSubsDelReq(t, restSubId)
6628 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6629 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6630}
6631
6632func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
6633 resp, _ := xapp.Subscription.QuerySubscriptions()
6634 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
6635 assert.Equal(t, resp[0].Meid, meid)
6636 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
6637}
6638
6639func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
6640 //Wait that subs is cleaned
6641 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
6642
6643 xappConn1.TestMsgChanEmpty(t)
6644 xappConn2.TestMsgChanEmpty(t)
6645 e2termConn1.TestMsgChanEmpty(t)
6646 mainCtrl.wait_registry_empty(t, timeout)
6647}
6648
6649func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
6650
6651 var e2SubsId []uint32
6652
6653 for i := 0; i < count; i++ {
6654 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
6655 crereq, cremsg := toE2termConn.RecvSubsReq(t)
6656 fromXappConn.ExpectRESTNotification(t, restSubId)
6657 toE2termConn.SendSubsResp(t, crereq, cremsg)
6658 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
6659 e2SubsId = append(e2SubsId, instanceId)
6660 xapp.Logger.Info("TEST: %v", e2SubsId)
6661 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
6662 <-time.After(100 * time.Millisecond)
6663 }
6664 return e2SubsId
6665}
6666
6667func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
6668
6669 for i := 0; i < len(e2SubsIds); i++ {
6670 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
6671 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6672 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6673 <-time.After(1 * time.Second)
6674 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
6675 <-time.After(100 * time.Millisecond)
6676 }
6677
6678 // Wait that subs is cleaned
6679 for i := 0; i < len(e2SubsIds); i++ {
6680 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
6681 }
6682
6683}