blob: 69a953325c3269974ebed4fc2678e87199ff805a [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
2373//-----------------------------------------------------------------------------
2374// TestRESTSubReqAndRouteNok
2375//
2376// stub stub
2377// +-------+ +---------+ +---------+
2378// | xapp | | submgr | | rtmgr |
2379// +-------+ +---------+ +---------+
2380// | | |
2381// | RESTSubReq | |
2382// |---------------->| |
2383// | | |
2384// | RESTSubResp | |
2385// |<----------------| |
2386// | | RouteCreate |
2387// | |------------->|
2388// | | |
2389// | | RouteCreate |
2390// | | status:400 |
2391// | |(Bad request) |
2392// | |<-------------|
2393// | RESTNotif | |
2394// |<----------------| |
2395// | | |
2396// | [SUBS INT DELETE] |
2397// | | |
2398// | RESTSubDelReq | |
2399// |---------------->| |
2400// | RESTSubDelResp | |
2401// |<----------------| |
2402//
2403//-----------------------------------------------------------------------------
2404func TestRESTSubReqAndRouteNok(t *testing.T) {
2405 CaseBegin("TestRESTSubReqAndRouteNok")
2406
2407 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002408 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002409 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002410 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002411 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002412 Counter{cRestSubDelReqFromXapp, 1},
2413 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002414 })
2415
2416 const subReqCount int = 1
Markku Virtanenda34eec2021-05-20 08:22:04 +00002417 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2418 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002419 newSubsId := mainCtrl.get_registry_next_subid(t)
2420
2421 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002422 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002423 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002424 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002425 waiter.WaitResult(t)
2426
archaggeafbf95f2021-04-14 08:54:05 +03002427 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2428 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2429
2430 // Del
2431 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2432
2433 // Wait that subs is cleaned
2434 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2435 waitSubsCleanup(t, e2SubsId, 10)
2436 mainCtrl.VerifyCounterValues(t)
2437}
2438
2439func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2440 CaseBegin("TestSubReqAndRouteUpdateNok")
2441
2442 //Init counter check
2443 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002444 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002445 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002446 Counter{cSubReqToE2, 1},
2447 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002448 Counter{cRestSubNotifToXapp, 1},
2449 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002450 Counter{cRouteCreateUpdateFail, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002451 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002452 Counter{cSubDelReqToE2, 1},
2453 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002454 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002455 })
2456
2457 var params *teststube2ap.RESTSubsReqParams = nil
2458
2459 //Subs Create
2460 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2461
2462 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2463
2464 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2465 waiter := rtmgrHttp.AllocNextEvent(false)
2466 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002467 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002468 params.SetMeid("RAN_NAME_1")
2469 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2470 xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002471 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002472 waiter.WaitResult(t)
2473 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2474 xappConn2.WaitRESTNotification(t, restSubId2)
2475
2476 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2477
2478 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2479
2480 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2481 //Wait that subs is cleaned
2482 waitSubsCleanup(t, e2SubsId, 10)
2483
2484 mainCtrl.VerifyCounterValues(t)
2485}
2486
2487func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2488 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2489
2490 // Init counter check
2491 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002492 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002493 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002494 Counter{cSubReqToE2, 1},
2495 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002496 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002497 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002498 Counter{cRouteDeleteFail, 1},
2499 Counter{cSubDelReqToE2, 1},
2500 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002501 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002502 })
2503
2504 var params *teststube2ap.RESTSubsReqParams = nil
2505
2506 //Subs Create
2507 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2508
2509 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2510
2511 waiter := rtmgrHttp.AllocNextEvent(false)
2512 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2513 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2514 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2515 waiter.WaitResult(t)
2516
2517 waitSubsCleanup(t, e2SubsId, 10)
2518
2519 mainCtrl.VerifyCounterValues(t)
2520}
2521
2522func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2523 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2524
2525 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002526 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002527 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002528 Counter{cSubReqToE2, 1},
2529 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002530 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002531 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002532 Counter{cRouteDeleteUpdateFail, 1},
2533 Counter{cSubDelReqToE2, 1},
2534 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002535 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002536 })
2537
2538 var params *teststube2ap.RESTSubsReqParams = nil
2539
2540 //Subs Create
2541 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2542
2543 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2544 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2545
2546 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2547
2548 //Del1, this shall fail on rtmgr side
2549 waiter := rtmgrHttp.AllocNextEvent(false)
2550 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2551 waiter.WaitResult(t)
2552
2553 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2554
2555 //Del2
2556 deleteXapp2Subscription(t, &restSubId2)
2557
2558 waitSubsCleanup(t, e2SubsId2, 10)
2559
2560 mainCtrl.VerifyCounterValues(t)
2561}
2562
2563//-----------------------------------------------------------------------------
2564// TestRESTSubReqRetransmission
2565//
2566// stub stub
2567// +-------+ +---------+ +---------+
2568// | xapp | | submgr | | e2term |
2569// +-------+ +---------+ +---------+
2570// | | |
2571// | RESTSubReq1 | |
2572// |---------------->| |
2573// | | |
2574// | RESTSubResp | |
2575// |<----------------| |
2576// | | SubReq1 |
2577// | |------------->|
2578// | | |
2579// | RESTSubReq2 | |
2580// | (retrans) | |
2581// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002582// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002583// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002584// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002585// | | SubResp1 |
2586// | |<-------------|
2587// | RESTNotif1 | |
2588// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002589// | | |
2590// | [SUBS DELETE] |
2591// | | |
2592//
2593//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002594
archaggeafbf95f2021-04-14 08:54:05 +03002595func TestRESTSubReqRetransmission(t *testing.T) {
2596 CaseBegin("TestRESTSubReqRetransmission")
2597
2598 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002599 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002600 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002601 Counter{cSubReqToE2, 1},
2602 Counter{cSubRespFromE2, 1},
2603 Counter{cRestSubNotifToXapp, 1},
2604 Counter{cRestSubDelReqFromXapp, 1},
2605 Counter{cSubDelReqToE2, 1},
2606 Counter{cSubDelRespFromE2, 1},
2607 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002608 })
2609 // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests
2610 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2611 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2612
2613 // Subs Create
2614 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002615
2616 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2617 // gets into execution before the rtmgrg responds for the first one.
2618 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002619 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002620 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenb642a192021-06-09 09:08:14 +00002621 xappConn2.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002622
2623 waiter.WaitResult(t)
2624
Markku Virtanenb642a192021-06-09 09:08:14 +00002625 xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
archaggeafbf95f2021-04-14 08:54:05 +03002626
2627 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2628 // the order is not significant he6re.
2629 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2630 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002631
2632 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2633 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03002634
2635 // Del1
2636 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2637 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2638 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2639
Markku Virtanenb642a192021-06-09 09:08:14 +00002640 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002641
2642 mainCtrl.VerifyCounterValues(t)
2643}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002644
archaggeafbf95f2021-04-14 08:54:05 +03002645func TestRESTSubDelReqRetransmission(t *testing.T) {
2646 CaseBegin("TestRESTSubDelReqRetransmission")
2647
2648 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002649 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002650 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002651 Counter{cSubReqToE2, 1},
2652 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002653 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002654 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002655 Counter{cSubDelReqToE2, 1},
2656 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002657 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002658 })
2659
2660 var params *teststube2ap.RESTSubsReqParams = nil
2661
2662 //Subs Create
2663 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2664
2665 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2666
2667 //Subs Delete
2668 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2669 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2670
2671 seqBef := mainCtrl.get_msgcounter(t)
2672 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2673 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
2674
2675 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2676
2677 waitSubsCleanup(t, e2SubsId, 10)
2678
2679 mainCtrl.VerifyCounterValues(t)
2680}
2681
2682//-----------------------------------------------------------------------------
2683// TestRESTSubReqDelReq
2684//
2685// stub stub
2686// +-------+ +---------+ +---------+
2687// | xapp | | submgr | | e2term |
2688// +-------+ +---------+ +---------+
2689// | | |
2690// | RESTSubReq | |
2691// |---------------->| |
2692// | | |
2693// | RESTSubResp | |
2694// |<----------------| |
2695// | | SubReq |
2696// | |------------->|
2697// | RESTSubDelReq | |
2698// |---------------->| |
2699// | RESTSubDelResp | |
2700// | unsuccess | |
2701// |<----------------| |
2702// | | SubResp |
2703// | |<-------------|
2704// | RESTNotif1 | |
2705// |<----------------| |
2706// | | |
2707// | [SUBS DELETE] |
2708// | | |
2709//
2710//-----------------------------------------------------------------------------
2711func TestRESTSubReqDelReq(t *testing.T) {
2712 CaseBegin("TestRESTSubReqDelReq")
2713
2714 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002715 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002716 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002717 Counter{cSubReqToE2, 1},
2718 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002719 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002720 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002721 Counter{cSubDelReqToE2, 1},
2722 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002723 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002724 })
2725
2726 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002727
2728 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002729 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002730 restSubId := xappConn1.SendRESTSubsReq(t, params)
2731
2732 // Del. This will fail as processing of the subscription
2733 // is still ongoing in submgr. Deletion is not allowed before
2734 // subscription creation has been completed.
2735 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2736 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2737 xappConn1.ExpectRESTNotification(t, restSubId)
2738 e2termConn1.SendSubsResp(t, crereq, cremsg)
2739 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2740
2741 // Retry del
2742 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2743
2744 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2745 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2746
2747 // Wait that subs is cleaned
2748 waitSubsCleanup(t, e2SubsId, 10)
2749 mainCtrl.VerifyCounterValues(t)
2750
2751}
2752
2753func TestRESTSubDelReqCollision(t *testing.T) {
2754 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
2755}
2756
2757func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
2758 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
2759
2760 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002761 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002762 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002763 Counter{cSubReqToE2, 2},
2764 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002765 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002766 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002767 Counter{cSubDelReqToE2, 2},
2768 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002769 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002770 })
2771
2772 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002773 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002774 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2775 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2776
2777 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002778 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002779 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2780 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2781
2782 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2783 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2784
2785 //XappConn1 receives both of the responses
2786 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2787
2788 //Resp1
2789 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2790 //Resp2
2791 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2792
2793 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2794 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2795 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2796 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2797
2798 //Del1
2799 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2800 //Del2
2801 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
2802
2803 //Wait that subs is cleaned
2804 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
2805 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2806
2807 mainCtrl.VerifyCounterValues(t)
2808
2809}
2810
2811func TestRESTSameSubsDiffRan(t *testing.T) {
2812 CaseBegin("TestRESTSameSubsDiffRan")
2813
2814 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002815 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002816 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002817 Counter{cSubReqToE2, 2},
2818 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002819 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002820 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002821 Counter{cSubDelReqToE2, 2},
2822 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002823 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002824 })
2825
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002826 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002827 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
2828 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2829
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002830 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002831 params.SetMeid("RAN_NAME_2")
2832 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
2833 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2834
2835 //Del1
2836 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2837 //Del2
2838 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
2839
2840 //Wait that subs is cleaned
2841 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2842 waitSubsCleanup(t, e2SubsId2, 10)
2843
2844 mainCtrl.VerifyCounterValues(t)
2845
2846}
2847
2848func TestRESTSubReqRetryInSubmgr(t *testing.T) {
2849 CaseBegin("TestRESTSubReqRetryInSubmgr start")
2850
2851 // Init counter check
2852 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002853 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002854 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002855 Counter{cSubReqToE2, 1},
2856 Counter{cSubReReqToE2, 1},
2857 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002858 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002859 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002860 Counter{cSubDelReqToE2, 1},
2861 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002862 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002863 })
2864
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002865 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002866 restSubId := xappConn1.SendRESTSubsReq(t, params)
2867
2868 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2869
2870 // Catch the first message and ignore it
2871 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2872 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
2873
2874 // The second request is being handled normally
2875 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2876 xappConn1.ExpectRESTNotification(t, restSubId)
2877 e2termConn1.SendSubsResp(t, crereq, cremsg)
2878 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2879
2880 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2881
2882 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2883
2884 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2885 //Wait that subs is cleaned
2886 waitSubsCleanup(t, e2SubsId, 10)
2887
2888 mainCtrl.VerifyCounterValues(t)
2889
2890}
2891
2892//-----------------------------------------------------------------------------
2893// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2894//
2895// stub stub
2896// +-------+ +---------+ +---------+
2897// | xapp | | submgr | | e2term |
2898// +-------+ +---------+ +---------+
2899// | | |
2900// | RESTSubReq | |
2901// |---------------->| |
2902// | | |
2903// | RESTSubResp | |
2904// |<----------------| |
2905// | | SubReq |
2906// | |------------->|
2907// | | |
2908// | | |
2909// | | SubReq |
2910// | |------------->|
2911// | | |
2912// | | SubDelReq |
2913// | |------------->|
2914// | | |
2915// | | |
2916// | | SubDelReq |
2917// | |------------->|
2918// | | |
2919// | | |
2920// | | SubDelResp |
2921// | |<-------------|
2922// | RESTNotif | |
2923// | unsuccess | |
2924// |<----------------| |
2925// | | |
2926// | [SUBS DELETE] |
2927// | | |
2928//
2929//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03002930
archaggeafbf95f2021-04-14 08:54:05 +03002931func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
2932 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
2933
2934 // Init counter check
2935 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002936 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002937 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002938 Counter{cSubReqToE2, 1},
2939 Counter{cSubReReqToE2, 1},
2940 Counter{cSubReqTimerExpiry, 2},
2941 Counter{cSubDelReqToE2, 1},
2942 Counter{cSubDelRespFromE2, 1},
2943 })
2944
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002945 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002946 restSubId := xappConn1.SendRESTSubsReq(t, params)
2947 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2948
2949 e2termConn1.RecvSubsReq(t)
2950 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2951
2952 e2termConn1.RecvSubsReq(t)
2953 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2954
2955 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002956 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002957 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03002958 xappConn1.WaitRESTNotification(t, restSubId)
2959
2960 // Wait that subs is cleaned
2961 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
2962
2963 mainCtrl.VerifyCounterValues(t)
2964}
2965
2966func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
2967 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
2968
2969 // Init counter check
2970 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002971 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002972 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002973 Counter{cSubReqToE2, 1},
2974 Counter{cSubReReqToE2, 1},
2975 Counter{cSubReqTimerExpiry, 2},
2976 Counter{cSubDelReqToE2, 1},
2977 Counter{cSubDelReqTimerExpiry, 2},
2978 })
2979
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002980 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002981 restSubId := xappConn1.SendRESTSubsReq(t, params)
2982 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2983
2984 e2termConn1.RecvSubsReq(t)
2985 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2986
2987 e2termConn1.RecvSubsReq(t)
2988 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2989
2990 e2termConn1.RecvSubsDelReq(t)
2991 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
2992
Markku Virtanen55d2a282021-06-04 14:46:56 +03002993 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002994 e2termConn1.RecvSubsDelReq(t)
2995 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
2996
2997 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2998
2999 waitSubsCleanup(t, e2SubsId, 10)
3000
3001 mainCtrl.VerifyCounterValues(t)
3002
3003}
3004
3005//-----------------------------------------------------------------------------
3006// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3007//
3008// stub stub
3009// +-------+ +---------+ +---------+
3010// | xapp | | submgr | | e2term |
3011// +-------+ +---------+ +---------+
3012// | | |
3013// | RESTSubReq | |
3014// |---------------->| |
3015// | | |
3016// | RESTSubResp | |
3017// |<----------------| |
3018// | | SubReq |
3019// | |------------->|
3020// | | |
3021// | | |
3022// | | SubReq |
3023// | |------------->|
3024// | | |
3025// | | SubDelReq |
3026// | |------------->|
3027// | | |
3028// | | |
3029// | | SubDelReq |
3030// | |------------->|
3031// | | |
3032// | | |
3033// | | SubDelResp |
3034// | |<-------------|
3035// | RESTNotif | |
3036// | unsuccess | |
3037// |<----------------| |
3038// | | |
3039// | [SUBS DELETE] |
3040// | | |
3041//
3042//-----------------------------------------------------------------------------
3043func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3044 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3045
3046 // Init counter check
3047 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003048 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003049 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003050 Counter{cSubReqToE2, 1},
3051 Counter{cSubReReqToE2, 1},
3052 Counter{cSubReqTimerExpiry, 2},
3053 Counter{cSubDelReqToE2, 1},
3054 Counter{cSubDelReReqToE2, 1},
3055 Counter{cSubDelReqTimerExpiry, 2},
3056 })
3057
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003058 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003059 restSubId := xappConn1.SendRESTSubsReq(t, params)
3060 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3061
3062 e2termConn1.RecvSubsReq(t)
3063 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3064
3065 e2termConn1.RecvSubsReq(t)
3066 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3067
3068 e2termConn1.RecvSubsDelReq(t)
3069 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3070
Markku Virtanen55d2a282021-06-04 14:46:56 +03003071 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003072 e2termConn1.RecvSubsDelReq(t)
3073 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3074
3075 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3076
3077 waitSubsCleanup(t, e2SubsId, 10)
3078
3079 mainCtrl.VerifyCounterValues(t)
3080}
3081
3082//-----------------------------------------------------------------------------
3083// TestRESTSubReqSubFailRespInSubmgr
3084//
3085// stub stub
3086// +-------+ +---------+ +---------+
3087// | xapp | | submgr | | e2term |
3088// +-------+ +---------+ +---------+
3089// | | |
3090// | RESTSubReq | |
3091// |---------------->| |
3092// | | |
3093// | RESTSubResp | |
3094// |<----------------| |
3095// | | SubReq |
3096// | |------------->|
3097// | | |
3098// | | SubFail |
3099// | |<-------------|
3100// | | |
3101// | | SubDelReq |
3102// | |------------->|
3103// | | |
3104// | | SubDelResp |
3105// | |<-------------|
3106// | | |
3107// | RESTNotif | |
3108// | unsuccess | |
3109// |<----------------| |
3110// | | |
3111// | [SUBS DELETE] |
3112// | | |
3113//
3114//-----------------------------------------------------------------------------
3115func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3116 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3117
3118 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003119 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003120 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003121 Counter{cSubReqToE2, 1},
3122 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003123 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003124 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003125 })
3126
3127 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003128
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003129 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003130 restSubId := xappConn1.SendRESTSubsReq(t, params)
3131
3132 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3133 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3134 fparams1.Set(crereq1)
3135 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3136
3137 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003138 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003139 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3140 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3141 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
3142
3143 // REST subscription sill there to be deleted
3144 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3145
3146 // Wait that subs is cleaned
3147 waitSubsCleanup(t, e2SubsId, 10)
3148
3149 mainCtrl.VerifyCounterValues(t)
3150
3151}
3152
3153//-----------------------------------------------------------------------------
3154// TestRESTSubDelReqRetryInSubmgr
3155//
3156// stub stub
3157// +-------+ +---------+ +---------+
3158// | xapp | | submgr | | e2term |
3159// +-------+ +---------+ +---------+
3160// | | |
3161// | [SUBS CREATE] |
3162// | | |
3163// | | |
3164// | RESTSubDelReq | |
3165// |---------------->| |
3166// | | |
3167// | RESTSubDelResp | |
3168// |<----------------| |
3169// | | SubDelReq |
3170// | |------------->|
3171// | | |
3172// | | SubDelReq |
3173// | |------------->|
3174// | | |
3175// | | SubDelResp |
3176// | |<-------------|
3177// | | |
3178//
3179//-----------------------------------------------------------------------------
3180func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3181 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3182
3183 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003184 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003185 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003186 Counter{cSubReqToE2, 1},
3187 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003188 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003189 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003190 Counter{cSubDelReqToE2, 1},
3191 Counter{cSubDelReReqToE2, 1},
3192 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003193 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003194 })
3195 // Req
3196 var params *teststube2ap.RESTSubsReqParams = nil
3197 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3198
3199 // Del
3200 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3201
3202 // E2t: Receive 1st SubsDelReq
3203 e2termConn1.RecvSubsDelReq(t)
3204
3205 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3206 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3207 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3208
3209 //Wait that subs is cleaned
3210 waitSubsCleanup(t, e2SubsId, 10)
3211
3212 mainCtrl.VerifyCounterValues(t)
3213}
3214
3215//-----------------------------------------------------------------------------
3216// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3217//
3218// stub stub
3219// +-------+ +---------+ +---------+
3220// | xapp | | submgr | | e2term |
3221// +-------+ +---------+ +---------+
3222// | | |
3223// | [SUBS CREATE] |
3224// | | |
3225// | | |
3226// | RESTSubDelReq | |
3227// |---------------->| |
3228// | | |
3229// | RESTSubDelResp | |
3230// |<----------------| |
3231// | | SubDelReq |
3232// | |------------->|
3233// | | |
3234// | | SubDelReq |
3235// | |------------->|
3236// | | |
3237// | | |
3238//
3239//-----------------------------------------------------------------------------
3240func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3241 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3242
3243 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003244 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003245 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003246 Counter{cSubReqToE2, 1},
3247 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003248 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003249 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003250 Counter{cSubDelReqToE2, 1},
3251 Counter{cSubDelReReqToE2, 1},
3252 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003253 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003254 })
3255
3256 // Req
3257 var params *teststube2ap.RESTSubsReqParams = nil
3258 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3259
3260 // Del
3261 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3262
3263 // E2t: Receive 1st SubsDelReq
3264 e2termConn1.RecvSubsDelReq(t)
3265
3266 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3267 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3268 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3269
3270 //Wait that subs is cleaned
3271 waitSubsCleanup(t, e2SubsId, 10)
3272
3273 mainCtrl.VerifyCounterValues(t)
3274}
3275
3276//-----------------------------------------------------------------------------
3277// TestRESTSubDelReqSubDelFailRespInSubmgr
3278//
3279// stub stub
3280// +-------+ +---------+ +---------+
3281// | xapp | | submgr | | e2term |
3282// +-------+ +---------+ +---------+
3283// | | |
3284// | [SUBS CREATE] |
3285// | | |
3286// | | |
3287// | RESTSubDelReq | |
3288// |---------------->| |
3289// | | |
3290// | RESTSubDelResp | |
3291// |<----------------| |
3292// | | SubDelReq |
3293// | |------------->|
3294// | | |
3295// | | SubDelFail |
3296// | |<-------------|
3297// | | |
3298//
3299//-----------------------------------------------------------------------------
3300func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3301 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3302
3303 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003304 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003305 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003306 Counter{cSubReqToE2, 1},
3307 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003308 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003309 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003310 Counter{cSubDelReqToE2, 1},
3311 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003312 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003313 })
3314
3315 // Req
3316 var params *teststube2ap.RESTSubsReqParams = nil
3317 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3318
3319 // Del
3320 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3321
3322 // E2t: Send receive SubsDelReq and send SubsDelFail
3323 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3324 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3325
3326 //Wait that subs is cleaned
3327 waitSubsCleanup(t, e2SubsId, 10)
3328
3329 mainCtrl.VerifyCounterValues(t)
3330}
3331
3332//-----------------------------------------------------------------------------
3333// TestRESTSubReqAndSubDelOkSameAction
3334//
3335// stub stub
3336// +-------+ +-------+ +---------+ +---------+
3337// | xapp2 | | xapp1 | | submgr | | e2term |
3338// +-------+ +-------+ +---------+ +---------+
3339// | | | |
3340// | | RESTSubReq1 | |
3341// | |---------------->| |
3342// | | | |
3343// | | RESTSubResp1 | |
3344// | |<----------------| |
3345// | | | |
3346// | | | SubReq1 |
3347// | | |------------->|
3348// | | | SubResp1 |
3349// | | |<-------------|
3350// | | RESTNotif1 | |
3351// | |<----------------| |
3352// | | | |
3353// | RESTSubReq2 | |
3354// |------------------------------>| |
3355// | | | |
3356// | RESTSubResp2 | |
3357// |<------------------------------| |
3358// | | | |
3359// | | RESTNotif2 | |
3360// |<------------------------------| |
3361// | | | |
3362// | | RESTSubDelReq1 | |
3363// | |---------------->| |
3364// | | | |
3365// | | RESTSubDelResp1 | |
3366// | |<----------------| |
3367// | | | |
3368// | RESTSubDelReq2 | |
3369// |------------------------------>| |
3370// | | | |
3371// | RESTSubDelResp2 | |
3372// |<------------------------------| |
3373// | | | |
3374// | | | SubDelReq2 |
3375// | | |------------->|
3376// | | | |
3377// | | | SubDelResp2 |
3378// | | |<-------------|
3379// | | | |
3380//
3381//-----------------------------------------------------------------------------
3382func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3383 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3384
3385 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003386 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003387 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003388 Counter{cSubReqToE2, 1},
3389 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003390 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003391 Counter{cMergedSubscriptions, 1},
3392 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003393 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003394 Counter{cSubDelReqToE2, 1},
3395 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003396 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003397 })
3398
3399 // Req1
3400 var params *teststube2ap.RESTSubsReqParams = nil
3401
3402 //Subs Create
3403 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3404 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3405
3406 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003407 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003408 params.SetMeid("RAN_NAME_1")
3409
3410 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
3411 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003412 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003413 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003414 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003415 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
3416 e2SubsId2 := <-xappConn2.RESTNotification
3417 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3418
3419 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3420
3421 // Del1
3422 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3423
3424 // Del2
3425 deleteXapp2Subscription(t, &restSubId2)
3426
3427 //Wait that subs is cleaned
3428 waitSubsCleanup(t, e2SubsId2, 10)
3429
3430 mainCtrl.VerifyCounterValues(t)
3431}
3432
3433//-----------------------------------------------------------------------------
3434// TestSubReqAndSubDelOkSameActionParallel
3435//
3436// stub stub stub
3437// +-------+ +-------+ +---------+ +---------+
3438// | xapp2 | | xapp1 | | submgr | | e2term |
3439// +-------+ +-------+ +---------+ +---------+
3440// | | | |
3441// | | | |
3442// | | | |
3443// | | SubReq1 | |
3444// | |------------->| |
3445// | | | |
3446// | | | SubReq1 |
3447// | | |------------->|
3448// | SubReq2 | |
3449// |--------------------------->| |
3450// | | | SubResp1 |
3451// | | |<-------------|
3452// | | SubResp1 | |
3453// | |<-------------| |
3454// | | | SubReq2 |
3455// | | |------------->|
3456// | | | |
3457// | | | SubResp2 |
3458// | | |<-------------|
3459// | SubResp2 | |
3460// |<---------------------------| |
3461// | | | |
3462// | | SubDelReq 1 | |
3463// | |------------->| |
3464// | | | |
3465// | | SubDelResp 1 | |
3466// | |<-------------| |
3467// | | | |
3468// | SubDelReq 2 | |
3469// |--------------------------->| |
3470// | | | |
3471// | | | SubDelReq 2 |
3472// | | |------------->|
3473// | | | |
3474// | | | SubDelReq 2 |
3475// | | |------------->|
3476// | | | |
3477// | SubDelResp 2 | |
3478// |<---------------------------| |
3479//
3480func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
3481 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
3482
3483 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003484 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003485 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003486 Counter{cSubReqToE2, 2},
3487 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003488 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003489 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003490 Counter{cSubDelReqToE2, 2},
3491 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003492 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003493 })
3494
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003495 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003496 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3497 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3498
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003499 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003500 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3501
3502 xappConn1.ExpectRESTNotification(t, restSubId1)
3503 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3504 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3505
3506 xappConn2.ExpectRESTNotification(t, restSubId2)
3507 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3508 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3509 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3510
3511 // Del1
3512 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3513 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3514 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3515 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3516
3517 // Del2
3518 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3519 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
3520 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
3521
3522 waitSubsCleanup(t, e2SubsId2, 10)
3523
3524 mainCtrl.VerifyCounterValues(t)
3525}
3526
3527//-----------------------------------------------------------------------------
3528// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
3529//
3530// stub stub stub
3531// +-------+ +-------+ +---------+ +---------+
3532// | xapp2 | | xapp1 | | submgr | | e2term |
3533// +-------+ +-------+ +---------+ +---------+
3534// | | | |
3535// | | | |
3536// | | | |
3537// | | RESTSubReq1 | |
3538// | |---------------->| |
3539// | | | |
3540// | | RESTSubResp1 | |
3541// | |<----------------| |
3542// | | | SubReq1 |
3543// | | |------------->|
3544// | RESTSubReq2 | |
3545// |------------------------------>| |
3546// | | | |
3547// | RESTSubDelResp2 | |
3548// |<------------------------------| |
3549// | | | SubReq1 |
3550// | | |------------->|
3551// | | | |
3552// | | | |
3553// | | | SubDelReq |
3554// | | |------------->|
3555// | | | |
3556// | | | SubDelResp |
3557// | | |<-------------|
3558// | | RESTNotif1 | |
3559// | | unsuccess | |
3560// | |<----------------| |
3561// | RESTNotif2 | |
3562// | | unsuccess | |
3563// |<------------------------------| |
3564// | | | |
3565// | | RESTSubDelReq1 | |
3566// | |---------------->| |
3567// | | | |
3568// | | RESTSubDelResp1 | |
3569// | |<----------------| |
3570// | | | |
3571// | RESTSubDelReq2 | |
3572// |------------------------------>| |
3573// | | | |
3574// | RESTSubDelResp2 | |
3575// |<------------------------------| |
3576//
3577//-----------------------------------------------------------------------------
3578func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
3579 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
3580
3581 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003582 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003583 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003584 Counter{cSubReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003585 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003586 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003587 Counter{cSubDelReqToE2, 1},
3588 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003589 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003590 })
3591
3592 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003593
3594 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003595 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003596 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
3597 crereq1, _ := e2termConn1.RecvSubsReq(t)
3598
3599 // Req2
3600 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003601 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003602 params2.SetMeid("RAN_NAME_1")
3603 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3604 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3605
3606 //Req1 (retransmitted)
3607 e2termConn1.RecvSubsReq(t)
3608
3609 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00003610
3611 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03003612 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3613
Markku Virtanenda34eec2021-05-20 08:22:04 +00003614 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3615 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3616 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3617 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003618
3619 // Del1
3620 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3621
3622 // Del2
3623 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3624
Markku Virtanenda34eec2021-05-20 08:22:04 +00003625 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
3626
archaggeafbf95f2021-04-14 08:54:05 +03003627 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00003628 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003629
3630 mainCtrl.VerifyCounterValues(t)
3631}
3632
3633//-----------------------------------------------------------------------------
3634// TestRESTSubReqAndSubDelNokSameActionParallel
3635//
3636// stub stub stub
3637// +-------+ +-------+ +---------+ +---------+
3638// | xapp2 | | xapp1 | | submgr | | e2term |
3639// +-------+ +-------+ +---------+ +---------+
3640// | | | |
3641// | | | |
3642// | | | |
3643// | | RESTSubReq1 | |
3644// | |---------------->| |
3645// | | | |
3646// | | RESTSubResp1 | |
3647// | |<----------------| |
3648// | | | SubReq1 |
3649// | | |------------->|
3650// | RESTSubReq2 | |
3651// |------------------------------>| |
3652// | | | |
3653// | RESTSubDelResp2 | |
3654// |<------------------------------| |
3655// | | | SubFail1 |
3656// | | |<-------------|
3657// | | | |
3658// | | RESTNotif1 | |
3659// | | unsuccess | |
3660// | |<----------------| |
3661// | RESTNotif2 | |
3662// | | unsuccess | |
3663// |<------------------------------| |
3664// | | | SubDelReq |
3665// | | |------------->|
3666// | | | SubDelResp |
3667// | | |<-------------|
3668// | | | |
3669// | | RESTSubDelReq1 | |
3670// | |---------------->| |
3671// | | | |
3672// | | RESTSubDelResp1 | |
3673// | |<----------------| |
3674// | | | |
3675// | RESTSubDelReq2 | |
3676// |------------------------------>| |
3677// | | | |
3678// | RESTSubDelResp2 | |
3679// |<------------------------------| |
3680//
3681//-----------------------------------------------------------------------------
3682func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
3683 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
3684
3685 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003686 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003687 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003688 Counter{cSubReqToE2, 1},
3689 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003690 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003691 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003692 Counter{cSubDelReqToE2, 1},
3693 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003694 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003695 })
3696
3697 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003698
3699 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003700 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003701 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3702 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3703
3704 // Req2
3705 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003706 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003707 params2.SetMeid("RAN_NAME_1")
3708 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3709 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3710
3711 // E2t: send SubsFail (first)
3712 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3713 fparams1.Set(crereq1)
3714 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3715
3716 // E2t: internal delete
3717 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3718 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3719 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3720
3721 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3722 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3723 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3724 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3725
3726 // Del1
3727 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3728
3729 // Del2
3730 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3731
3732 //Wait that subs is cleaned
3733 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
3734 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3735
3736 mainCtrl.VerifyCounterValues(t)
3737}
3738
3739func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
3740 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3741
3742 // Init counter check
3743 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003744 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003745 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003746 Counter{cSubReqToE2, 1},
3747 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003748 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003749 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003750 Counter{cSubDelReqToE2, 1},
3751 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003752 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003753 })
3754
3755 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003756
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003757 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003758 restSubId := xappConn1.SendRESTSubsReq(t, params)
3759 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3760
3761 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3762 xappConn1.ExpectRESTNotification(t, restSubId)
3763 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3764 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3765 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
3766
3767 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3768 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3769 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3770
3771 // Wait that subs is cleaned
3772 waitSubsCleanup(t, e2SubsId, 10)
3773 mainCtrl.VerifyCounterValues(t)
3774}
3775
3776//-----------------------------------------------------------------------------
3777// TestRESTSubReqPolicyChangeAndSubDelOk
3778//
3779// stub stub
3780// +-------+ +---------+ +---------+
3781// | xapp | | submgr | | e2term |
3782// +-------+ +---------+ +---------+
3783// | | |
3784// | RESTSubReq | |
3785// |---------------->| |
3786// | | |
3787// | RESTSubResp | |
3788// |<----------------| |
3789// | | SubReq |
3790// | |------------->|
3791// | | |
3792// | | SubResp |
3793// | |<-------------|
3794// | | |
3795// | RESTNotif | |
3796// |<----------------| |
3797// | | |
3798// | RESTSubReq | |
3799// |---------------->| |
3800// | | |
3801// | RESTSubResp | |
3802// |<----------------| |
3803// | | SubReq |
3804// | |------------->|
3805// | | |
3806// | | SubResp |
3807// | |<-------------|
3808// | | |
3809// | RESTNotif | |
3810// |<----------------| |
3811// | | |
3812// | RESTSubDelReq | |
3813// |---------------->| |
3814// | | |
3815// | | SubDelReq |
3816// | |------------->|
3817// | | |
3818// | | SubDelResp |
3819// | |<-------------|
3820// | | |
3821// | RESTSubDelResp | |
3822// |<----------------| |
3823//
3824//-----------------------------------------------------------------------------
3825func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
3826 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3827
3828 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003829 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003830 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003831 Counter{cSubReqToE2, 2},
3832 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003833 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003834 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003835 Counter{cSubDelReqToE2, 1},
3836 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003837 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003838 })
3839
3840 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003841
3842 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003843 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003844 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3845
3846 // Policy change
archaggeafbf95f2021-04-14 08:54:05 +03003847 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00003848
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003849 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00003850 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003851 params.SetTimeToWait("w200ms")
3852 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3853
3854 // Del
3855 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3856
3857 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3858 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3859
3860 // Wait that subs is cleaned
3861 waitSubsCleanup(t, e2SubsId, 10)
3862 mainCtrl.VerifyCounterValues(t)
3863}
3864
3865//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00003866// TestRESTSubReqPolicyChangeNOk
3867//
3868// stub stub
3869// +-------+ +---------+ +---------+
3870// | xapp | | submgr | | e2term |
3871// +-------+ +---------+ +---------+
3872// | | |
3873// | RESTSubReq | |
3874// |---------------->| |
3875// | | |
3876// | RESTSubResp | |
3877// |<----------------| |
3878// | | SubReq |
3879// | |------------->|
3880// | | |
3881// | | SubResp |
3882// | |<-------------|
3883// | | |
3884// | RESTNotif | |
3885// |<----------------| |
3886// | | |
3887// | RESTSubReq | |
3888// |---------------->| |
3889// | | |
3890// | RESTSubUpdateFail |
3891// | | |
3892// | RESTSubDelReq | |
3893// |---------------->| |
3894// | | |
3895// | | SubDelReq |
3896// | |------------->|
3897// | | |
3898// | | SubDelResp |
3899// | |<-------------|
3900// | | |
3901// | RESTSubDelResp | |
3902// |<----------------| |
3903//
3904//-----------------------------------------------------------------------------
3905func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
3906 CaseBegin("TestRESTSubReqPolicyChangeNOk")
3907
3908 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3909 Counter{cRestSubReqFromXapp, 2},
3910 Counter{cRestSubRespToXapp, 1},
3911 Counter{cSubReqToE2, 1},
3912 Counter{cSubRespFromE2, 1},
3913 Counter{cRestSubNotifToXapp, 1},
3914 Counter{cRestSubFailToXapp, 1},
3915 Counter{cRestSubDelReqFromXapp, 1},
3916 Counter{cSubDelReqToE2, 1},
3917 Counter{cSubDelRespFromE2, 1},
3918 Counter{cRestSubDelRespToXapp, 1},
3919 })
3920
3921 const subReqCount int = 1
3922
3923 // Req
3924 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
3925 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3926
3927 // Policy change
3928
3929 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
3930
3931 restSubIdUpd := strings.ToUpper(restSubId)
3932 params.SetSubscriptionID(&restSubIdUpd)
3933 params.SetTimeToWait("w200ms")
3934
3935 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
3936 assert.Equal(t, restSubId2, "")
3937
3938 // Del
3939 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3940
3941 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3942 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3943
3944 // Wait that subs is cleaned
3945 waitSubsCleanup(t, e2SubsId, 10)
3946 mainCtrl.VerifyCounterValues(t)
3947}
3948
3949//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03003950// TestRESTSubReqAndSubDelOkTwoE2termParallel
3951//
3952// stub stub stub
3953// +-------+ +---------+ +---------+ +---------+
3954// | xapp | | submgr | | e2term1 | | e2term2 |
3955// +-------+ +---------+ +---------+ +---------+
3956// | | | |
3957// | | | |
3958// | | | |
3959// | RESTSubReq1 | | |
3960// |---------------->| | |
3961// | | | |
3962// | RESTSubResp1 | | |
3963// |<----------------| | |
3964// | | SubReq1 | |
3965// | |------------->| |
3966// | | | |
3967// | RESTSubReq2 | | |
3968// |---------------->| | |
3969// | | | |
3970// | RESTSubResp2 | | |
3971// |<----------------| | |
3972// | | SubReq2 | |
3973// | |---------------------------->|
3974// | | | |
3975// | | SubResp1 | |
3976// | |<-------------| |
3977// | RESTNotif1 | | |
3978// |<----------------| | |
3979// | | SubResp2 | |
3980// | |<----------------------------|
3981// | RESTNotif2 | | |
3982// |<----------------| | |
3983// | | | |
3984// | [SUBS 1 DELETE] | |
3985// | | | |
3986// | [SUBS 2 DELETE] | |
3987// | | | |
3988//
3989//-----------------------------------------------------------------------------
3990func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
3991 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
3992
3993 // Init counter check
3994 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003995 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003996 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003997 Counter{cSubReqToE2, 2},
3998 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003999 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004000 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004001 Counter{cSubDelReqToE2, 2},
4002 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004003 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004004 })
4005
4006 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004007
4008 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004009 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004010 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4011 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4012
4013 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004014 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004015 params.SetMeid("RAN_NAME_11")
4016 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4017 // would not work as notification would not be received
4018 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4019 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4020
4021 // Resp1
4022 xappConn1.ExpectRESTNotification(t, restSubId1)
4023 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4024 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4025 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
4026
4027 // Resp2
4028 xappConn2.ExpectRESTNotification(t, restSubId2)
4029 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4030 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4031 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
4032
4033 // Delete1
4034 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4035 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4036 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4037
4038 // Wait that subs is cleaned
4039 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4040
4041 // Delete2
4042 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4043 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4044 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4045
4046 // Wait that subs is cleaned
4047 waitSubsCleanup(t, e2SubsId2, 10)
4048
4049 mainCtrl.VerifyCounterValues(t)
4050}
4051
4052//-----------------------------------------------------------------------------
4053// TestRESTSubReqAsn1EncodeFail
4054//
4055// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4056// stub stub
4057// +-------+ +---------+ +---------+
4058// | xapp | | submgr | | e2term |
4059// +-------+ +---------+ +---------+
4060// | | |
4061// | RESTSubReq | |
4062// |---------------->| |
4063// | | |
4064// | RESTSubResp | |
4065// |<----------------| |
4066// | RESTSubDelReq | |
4067// |---------------->| |
4068// | RESTSubDelResp | |
4069// | unsuccess | |
4070// |<----------------| |
4071// | | |
4072//
4073//-----------------------------------------------------------------------------
4074func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4075 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4076
4077 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
4078
4079}
4080
4081//-----------------------------------------------------------------------------
4082// TestRESTSubReqInsertAndSubDelOk
4083//
4084// stub stub
4085// +-------+ +---------+ +---------+
4086// | xapp | | submgr | | e2term |
4087// +-------+ +---------+ +---------+
4088// | | |
4089// | RestSubReq | |
4090// |---------------->| |
4091// | | |
4092// | RESTSubResp | |
4093// |<----------------| |
4094// | | |
4095// | | SubReq |
4096// | |------------->|
4097// | | |
4098// | | SubResp |
4099// | |<-------------|
4100// | RESTNotif | |
4101// |<----------------| |
4102// | ... | ... |
4103// | | |
4104// | RESTSubDelReq | |
4105// |---------------->| |
4106// | | |
4107// | | SubDelReq |
4108// | |------------->|
4109// | | |
4110// | | SubDelResp |
4111// | |<-------------|
4112// | | |
4113// | RESTSubDelResp| |
4114// |<----------------| |
4115//
4116//-----------------------------------------------------------------------------
4117func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4118 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4119
4120 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004121 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004122 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004123 Counter{cSubReqToE2, 1},
4124 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004125 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004126 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004127 Counter{cSubDelReqToE2, 1},
4128 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004129 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004130 })
4131
4132 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004133
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004134 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004135 params.SetSubActionTypes("insert")
4136
4137 // Req
4138 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4139
4140 // Del
4141 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4142
4143 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4144 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4145
4146 // Wait that subs is cleaned
4147 waitSubsCleanup(t, e2SubsId, 10)
4148 mainCtrl.VerifyCounterValues(t)
4149}
4150
4151//-----------------------------------------------------------------------------
4152// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4153//
4154// stub stub
4155// +-------+ +---------+ +---------+
4156// | xapp | | submgr | | e2term |
4157// +-------+ +---------+ +---------+
4158// | | |
4159// | RESTSubReq | |
4160// |------------->| |
4161// | | |
4162// | | SubReq |
4163// | |------------->|
4164// | | |
4165// | | SubResp |
4166// | <----|
4167// | |
4168// | Submgr restart |
4169// | |
4170// | | |
4171// | | SubDelReq |
4172// | |------------->|
4173// | | |
4174// | | SubDelResp |
4175// | |<-------------|
4176// | | |
4177//
4178//-----------------------------------------------------------------------------
4179func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4180 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4181
4182 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004183 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004184 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004185 Counter{cSubReqToE2, 1},
4186 Counter{cSubDelReqFromXapp, 1},
4187 Counter{cSubDelReqToE2, 1},
4188 Counter{cSubDelRespFromE2, 1},
4189 })
4190
4191 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004192
4193 // Remove possible existing subscription
4194 mainCtrl.removeExistingSubscriptions(t)
4195
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004196 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004197
4198 //Req
4199 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
4200 restSubId := xappConn1.SendRESTSubsReq(t, params)
4201 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4202
4203 e2termConn1.RecvSubsReq(t)
4204
4205 mainCtrl.SetResetTestFlag(t, false)
4206
4207 mainCtrl.SimulateRestart(t)
4208 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4209
4210 //Del
4211 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4212 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4213
4214 xappConn1.TestMsgChanEmpty(t)
4215 xappConn2.TestMsgChanEmpty(t)
4216 e2termConn1.TestMsgChanEmpty(t)
4217 mainCtrl.wait_registry_empty(t, 10)
4218
4219 mainCtrl.VerifyCounterValues(t)
4220}
4221
4222//-----------------------------------------------------------------------------
4223// TestRESTSubReqAndSubDelOkWithRestartInMiddle
4224//
4225// stub stub
4226// +-------+ +---------+ +---------+
4227// | xapp | | submgr | | e2term |
4228// +-------+ +---------+ +---------+
4229// | | |
4230// | RESTSubReq | |
4231// |---------------->| |
4232// | | |
4233// | RESTSubResp | |
4234// |<----------------| |
4235// | | SubReq |
4236// | |------------->|
4237// | | |
4238// | | SubResp |
4239// | |<-------------|
4240// | | |
4241// | RESTNotif | |
4242// |<----------------| |
4243// | | |
4244// | |
4245// | Submgr restart |
4246// | | |
4247// | RESTSubDelReq | |
4248// |---------------->| |
4249// | | |
4250// | | SubDelReq |
4251// | |------------->|
4252// | | |
4253// | | SubDelResp |
4254// | |<-------------|
4255// | | |
4256// | RESTSubDelResp | |
4257// |<----------------| |
4258//
4259//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004260
archaggeafbf95f2021-04-14 08:54:05 +03004261func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4262 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4263
4264 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004265 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004266 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004267 Counter{cSubReqToE2, 1},
4268 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004269 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004270 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004271 Counter{cSubDelReqToE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004272 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004273 })
4274
4275 // Remove possible existing subscription
4276 mainCtrl.removeExistingSubscriptions(t)
4277
4278 var params *teststube2ap.RESTSubsReqParams = nil
4279
4280 // Create subscription
4281 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4282 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4283
4284 // Check subscription
4285 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4286
4287 // When SDL support for the REST Interface is added
4288 // the submgr restart statement below should be removed
4289 // from the comment.
4290
4291 // mainCtrl.SimulateRestart(t)
4292 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4293
4294 // Check subscription
4295 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4296
4297 // Delete subscription
4298 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4299
4300 //Wait that subs is cleaned
4301 waitSubsCleanup(t, e2SubsId, 10)
4302
4303 mainCtrl.VerifyCounterValues(t)
4304}
4305
4306//-----------------------------------------------------------------------------
4307// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4308//
4309// stub stub
4310// +-------+ +-------+ +---------+ +---------+
4311// | xapp2 | | xapp1 | | submgr | | e2term |
4312// +-------+ +-------+ +---------+ +---------+
4313// | | | |
4314// | | RESTSubReq1 | |
4315// | |---------------->| |
4316// | | | |
4317// | | RESTSubResp1 | |
4318// | |<----------------| |
4319// | | | |
4320// | | | SubReq1 |
4321// | | |------------->|
4322// | | | SubResp1 |
4323// | | |<-------------|
4324// | | RESTNotif1 | |
4325// | |<----------------| |
4326// | | | |
4327// | RESTSubReq2 | |
4328// |------------------------------>| |
4329// | | | |
4330// | RESTSubResp2 | |
4331// |<------------------------------| |
4332// | | | |
4333// | | RESTNotif2 | |
4334// |<------------------------------| |
4335// | | | |
4336// | | Submgr restart |
4337// | | | |
4338// | | RESTSubDelReq1 | |
4339// | |---------------->| |
4340// | | | |
4341// | | RESTSubDelResp1 | |
4342// | |<----------------| |
4343// | | | |
4344// | | Submgr restart |
4345// | | | |
4346// | RESTSubDelReq2 | |
4347// |------------------------------>| |
4348// | | | |
4349// | RESTSubDelResp2 | |
4350// |<------------------------------| |
4351// | | | |
4352// | | | SubDelReq2 |
4353// | | |------------->|
4354// | | | |
4355// | | | SubDelResp2 |
4356// | | |<-------------|
4357// | | | |
4358//
4359//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004360
archaggeafbf95f2021-04-14 08:54:05 +03004361func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4362 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4363
4364 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004365 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004366 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004367 Counter{cSubReqToE2, 1},
4368 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004369 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004370 Counter{cMergedSubscriptions, 1},
4371 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004372 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004373 Counter{cSubDelReqToE2, 1},
4374 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004375 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004376 })
4377
4378 // Remove possible existing subscription
4379 mainCtrl.removeExistingSubscriptions(t)
4380
4381 var params *teststube2ap.RESTSubsReqParams = nil
4382
4383 // Create subscription 1
4384 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4385 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4386
4387 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004388 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004389 params.SetMeid("RAN_NAME_1")
4390 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4391 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
4392 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4393 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4394 e2SubsId2 := <-xappConn2.RESTNotification
4395 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4396
4397 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4398
4399 // When SDL support for the REST Interface is added
4400 // the submgr restart statement below should be removed
4401 // from the comment.
4402
4403 // mainCtrl.SimulateRestart(t)
4404 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4405
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004406 // Delete subscription 1, and wait until it has removed the first endpoint
4407 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004408 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004409 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004410
4411 // When SDL support for the REST Interface is added
4412 // the submgr restart statement below should be removed
4413 // from the comment.
4414
4415 // mainCtrl.SimulateRestart(t)
4416 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004417 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4418
4419 // Delete subscription 2
4420 deleteXapp2Subscription(t, &restSubId2)
4421
4422 //Wait that subs is cleaned
4423 waitSubsCleanup(t, e2SubsId2, 10)
4424
4425 mainCtrl.VerifyCounterValues(t)
4426}
4427
4428//-----------------------------------------------------------------------------
4429// TestRESTReportSubReqAndSubDelOk
4430//
4431// stub stub
4432// +-------+ +---------+ +---------+
4433// | xapp | | submgr | | e2term |
4434// +-------+ +---------+ +---------+
4435// | | |
4436// | RestSubReq | |
4437// |---------------->| |
4438// | | |
4439// | RESTSubResp | |
4440// |<----------------| |
4441// | | |
4442// | | SubReq |
4443// | |------------->|
4444// | | |
4445// | | SubResp |
4446// | |<-------------|
4447// | RESTNotif | |
4448// |<----------------| |
4449// | | SubReq |
4450// | |------------->|
4451// | | |
4452// | | SubResp |
4453// | |<-------------|
4454// | RESTNotif | |
4455// |<----------------| |
4456// | ... | ... |
4457// | | |
4458// | | |
4459// | RESTSubDelReq | |
4460// |---------------->| |
4461// | | |
4462// | | SubDelReq |
4463// | |------------->|
4464// | | |
4465// | | SubDelResp |
4466// | |<-------------|
4467// | | |
4468// | RESTSubDelResp| |
4469// |<----------------| |
4470//
4471//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004472
archaggeafbf95f2021-04-14 08:54:05 +03004473func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
4474 CaseBegin("TestRESTReportSubReqAndSubDelOk")
4475 subReqCount := 1
archaggeafbf95f2021-04-14 08:54:05 +03004476 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004477 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004478}
4479
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004480func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
4481 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004482
4483 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004484 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004485 restSubId := xappConn1.SendRESTSubsReq(t, params)
4486
4487 var e2SubsId []uint32
4488 for i := 0; i < subReqCount; i++ {
4489 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4490 xappConn1.ExpectRESTNotification(t, restSubId)
4491
4492 e2termConn1.SendSubsResp(t, crereq, cremsg)
4493 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4494 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4495 e2SubsId = append(e2SubsId, instanceId)
4496 resp, _ := xapp.Subscription.QuerySubscriptions()
4497 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
4498 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
4499 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
4500
4501 }
4502
4503 // Del
4504 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4505
4506 for i := 0; i < subReqCount; i++ {
4507 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4508 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4509 }
4510
4511 // Wait that subs is cleaned
4512 for i := 0; i < subReqCount; i++ {
4513 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4514 }
4515
4516 xappConn1.TestMsgChanEmpty(t)
4517 e2termConn1.TestMsgChanEmpty(t)
4518 mainCtrl.wait_registry_empty(t, 10)
4519}
4520
4521/*
4522func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
4523 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
4524
4525 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004526 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004527 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004528
4529 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03004530 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004531 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004532}
4533*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004534func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
4535 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004536
4537 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004538 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004539 restSubId := xappConn1.SendRESTSubsReq(t, params)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004540 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004541 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
4542
4543 var e2SubsId []uint32
4544 for i := 0; i < subReqCount; i++ {
4545 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4546 xappConn1.ExpectRESTNotification(t, restSubId)
4547 e2termConn1.SendSubsResp(t, crereq, cremsg)
4548 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4549 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4550 e2SubsId = append(e2SubsId, instanceId)
4551 }
4552
4553 // Del
4554 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4555
4556 for i := 0; i < subReqCount; i++ {
4557 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4558 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4559 }
4560
4561 // Wait that subs is cleaned
4562 for i := 0; i < subReqCount; i++ {
4563 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4564 }
4565 xappConn1.TestMsgChanEmpty(t)
4566 e2termConn1.TestMsgChanEmpty(t)
4567 mainCtrl.wait_registry_empty(t, 10)
4568}
4569
archaggeafbf95f2021-04-14 08:54:05 +03004570func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
4571
4572 subReqCount := 2
4573
4574 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004575 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004576 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004577 Counter{cSubReqToE2, 2},
4578 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004579 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004580 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004581 Counter{cSubDelReqToE2, 2},
4582 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004583 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004584 })
4585
4586 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004587 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004588 restSubId := xappConn1.SendRESTSubsReq(t, params)
4589 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4590
4591 assert.Equal(t, len(e2SubsIds), 2)
4592
4593 // Del
4594 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4595 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4596
4597 xappConn1.TestMsgChanEmpty(t)
4598 e2termConn1.TestMsgChanEmpty(t)
4599 mainCtrl.wait_registry_empty(t, 10)
4600
4601 mainCtrl.VerifyCounterValues(t)
4602}
archaggeafbf95f2021-04-14 08:54:05 +03004603func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
4604
4605 subReqCount := 19
4606
4607 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004608 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004609 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004610 Counter{cSubReqToE2, 19},
4611 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004612 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004613 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004614 Counter{cSubDelReqToE2, 19},
4615 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004616 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004617 })
4618
4619 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004620 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004621 restSubId := xappConn1.SendRESTSubsReq(t, params)
4622 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4623
4624 assert.Equal(t, len(e2SubsIds), 19)
4625
4626 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4627 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4628
4629 xappConn1.TestMsgChanEmpty(t)
4630 e2termConn1.TestMsgChanEmpty(t)
4631 mainCtrl.wait_registry_empty(t, 10)
4632
4633 mainCtrl.VerifyCounterValues(t)
4634}
archaggeafbf95f2021-04-14 08:54:05 +03004635func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
4636
4637 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004638
4639 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004640 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004641 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004642 Counter{cSubReqToE2, uint64(subReqCount)},
4643 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004644 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004645 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004646 Counter{cSubDelReqToE2, uint64(subReqCount)},
4647 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004648 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004649 })
4650
4651 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004652 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004653 restSubId := xappConn1.SendRESTSubsReq(t, params)
4654 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4655
4656 assert.Equal(t, len(e2SubsIds), subReqCount)
4657
4658 // Del
4659 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4660 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4661
4662 xappConn1.TestMsgChanEmpty(t)
4663 e2termConn1.TestMsgChanEmpty(t)
4664 mainCtrl.wait_registry_empty(t, 10)
4665
4666 mainCtrl.VerifyCounterValues(t)
4667}
Markku Virtanenda34eec2021-05-20 08:22:04 +00004668
archaggeafbf95f2021-04-14 08:54:05 +03004669func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
4670
4671 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004672
4673 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004674 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004675 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004676 Counter{cSubReqToE2, uint64(subReqCount)},
4677 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004678 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004679 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004680 Counter{cSubDelReqToE2, uint64(subReqCount)},
4681 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004682 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004683 })
4684
4685 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004686 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004687 restSubId := xappConn1.SendRESTSubsReq(t, params)
4688 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4689
4690 assert.Equal(t, len(e2SubsIds), subReqCount)
4691
4692 // Del
4693 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4694 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4695
4696 xappConn1.TestMsgChanEmpty(t)
4697 e2termConn1.TestMsgChanEmpty(t)
4698 mainCtrl.wait_registry_empty(t, 10)
4699
4700 mainCtrl.VerifyCounterValues(t)
4701}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004702
archaggeafbf95f2021-04-14 08:54:05 +03004703func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
4704
4705 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03004706
4707 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004708 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004709 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004710 Counter{cSubReqToE2, uint64(subReqCount)},
4711 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004712 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004713 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004714 Counter{cSubDelReqToE2, uint64(subReqCount)},
4715 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004716 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004717 })
4718
4719 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004720 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004721 restSubId := xappConn1.SendRESTSubsReq(t, params)
4722 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4723
4724 assert.Equal(t, len(e2SubsIds), subReqCount)
4725
4726 // Del
4727 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4728 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4729
4730 xappConn1.TestMsgChanEmpty(t)
4731 e2termConn1.TestMsgChanEmpty(t)
4732 mainCtrl.wait_registry_empty(t, 10)
4733
4734 mainCtrl.VerifyCounterValues(t)
4735}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004736
4737func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
4738 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
4739
4740 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004741 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004742 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004743 Counter{cSubReqToE2, 2},
4744 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004745 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004746 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004747 Counter{cSubDelReqToE2, 2},
4748 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004749 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004750 })
4751
4752 // Req1
4753 var params *teststube2ap.RESTSubsReqParams = nil
4754
4755 //Subs Create
4756 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4757 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4758
4759 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4760
4761 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004762 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004763 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00004764 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004765 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
4766
4767 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4768 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4769 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4770 xappConn2.ExpectRESTNotification(t, restSubId2)
4771 e2termConn1.SendSubsResp(t, crereq, cremsg)
4772 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4773
4774 deleteXapp1Subscription(t, &restSubId1)
4775 deleteXapp2Subscription(t, &restSubId2)
4776
4777 waitSubsCleanup(t, e2SubsId1, 10)
4778 waitSubsCleanup(t, e2SubsId2, 10)
4779
4780 mainCtrl.VerifyCounterValues(t)
4781
4782}
4783
4784func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
4785 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
4786
4787 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004788 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004789 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004790 Counter{cSubReqToE2, 2},
4791 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004792 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004793 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004794 Counter{cSubDelReqToE2, 2},
4795 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004796 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004797 })
4798
4799 // Req1
4800 var params *teststube2ap.RESTSubsReqParams = nil
4801
4802 //Subs Create
4803 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4804 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4805
4806 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4807
4808 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004809 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004810 params.SetMeid("RAN_NAME_1")
4811
4812 actionId := int64(1)
4813 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00004814 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004815 subsequestActionType := "continue"
4816 timeToWait := "w10ms"
4817 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4818
4819 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4820 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4821 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4822 xappConn2.ExpectRESTNotification(t, restSubId2)
4823 e2termConn1.SendSubsResp(t, crereq, cremsg)
4824 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4825
4826 deleteXapp1Subscription(t, &restSubId1)
4827 deleteXapp2Subscription(t, &restSubId2)
4828
4829 waitSubsCleanup(t, e2SubsId1, 10)
4830 waitSubsCleanup(t, e2SubsId2, 10)
4831
4832 mainCtrl.VerifyCounterValues(t)
4833
4834}
4835
4836func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
4837 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
4838
4839 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004840 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004841 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004842 Counter{cSubReqToE2, 2},
4843 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004844 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004845 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004846 Counter{cSubDelReqToE2, 2},
4847 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004848 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004849 })
4850
4851 // Req1
4852 var params *teststube2ap.RESTSubsReqParams = nil
4853
4854 //Subs Create
4855 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4856 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4857
4858 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4859
4860 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004861 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004862 params.SetMeid("RAN_NAME_1")
4863 params.SetSubActionIDs(int64(2))
4864
4865 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4866 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4867 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4868 xappConn2.ExpectRESTNotification(t, restSubId2)
4869 e2termConn1.SendSubsResp(t, crereq, cremsg)
4870 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4871
4872 deleteXapp1Subscription(t, &restSubId1)
4873 deleteXapp2Subscription(t, &restSubId2)
4874
4875 waitSubsCleanup(t, e2SubsId1, 10)
4876 waitSubsCleanup(t, e2SubsId2, 10)
4877
4878 mainCtrl.VerifyCounterValues(t)
4879
4880}
4881
4882func TestRESTSubReqDiffActionType(t *testing.T) {
4883 CaseBegin("TestRESTSubReqDiffActionType")
4884
4885 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004886 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004887 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004888 Counter{cSubReqToE2, 2},
4889 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004890 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004891 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004892 Counter{cSubDelReqToE2, 2},
4893 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004894 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004895 })
4896
4897 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004898 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004899
4900 //Subs Create
4901 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4902 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4903
4904 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4905
4906 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004907 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004908 params.SetMeid("RAN_NAME_1")
4909
4910 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4911 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4912 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4913 xappConn2.ExpectRESTNotification(t, restSubId2)
4914 e2termConn1.SendSubsResp(t, crereq, cremsg)
4915 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4916
4917 deleteXapp1Subscription(t, &restSubId1)
4918 deleteXapp2Subscription(t, &restSubId2)
4919
4920 waitSubsCleanup(t, e2SubsId1, 10)
4921 waitSubsCleanup(t, e2SubsId2, 10)
4922
4923 mainCtrl.VerifyCounterValues(t)
4924
4925}
4926
4927func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
4928 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
4929
4930 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004931 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004932 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004933 Counter{cSubReqToE2, 2},
4934 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004935 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004936 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004937 Counter{cSubDelReqToE2, 2},
4938 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004939 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004940 })
4941
4942 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004943 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004944
4945 //Subs Create
4946 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4947 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4948
4949 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4950
4951 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004952 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004953 params.SetMeid("RAN_NAME_1")
4954
4955 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4956 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4957 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4958 xappConn2.ExpectRESTNotification(t, restSubId2)
4959 e2termConn1.SendSubsResp(t, crereq, cremsg)
4960 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4961
4962 deleteXapp1Subscription(t, &restSubId1)
4963 deleteXapp2Subscription(t, &restSubId2)
4964
4965 waitSubsCleanup(t, e2SubsId1, 10)
4966 waitSubsCleanup(t, e2SubsId2, 10)
4967
4968 mainCtrl.VerifyCounterValues(t)
4969
4970}
4971
4972func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
4973 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
4974
4975 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004976 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004977 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004978 Counter{cSubReqToE2, 2},
4979 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004980 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004981 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004982 Counter{cSubDelReqToE2, 2},
4983 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004984 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004985 })
4986
4987 // Req1
4988 var params *teststube2ap.RESTSubsReqParams = nil
4989
4990 //Subs Create
4991 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4992 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4993
4994 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4995
4996 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004997 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004998 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00004999 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005000 params.SetSubActionDefinition(actionDefinition)
5001
5002 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5003 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5004 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5005 xappConn2.ExpectRESTNotification(t, restSubId2)
5006 e2termConn1.SendSubsResp(t, crereq, cremsg)
5007 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5008
5009 deleteXapp1Subscription(t, &restSubId1)
5010 deleteXapp2Subscription(t, &restSubId2)
5011
5012 waitSubsCleanup(t, e2SubsId1, 10)
5013 waitSubsCleanup(t, e2SubsId2, 10)
5014
5015 mainCtrl.VerifyCounterValues(t)
5016
5017}
5018
5019func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5020 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5021
5022 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005023 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005024 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005025 Counter{cSubReqToE2, 2},
5026 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005027 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005028 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005029 Counter{cSubDelReqToE2, 2},
5030 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005031 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005032 })
5033
5034 // Req1
5035 var params *teststube2ap.RESTSubsReqParams = nil
5036
5037 //Subs Create
5038 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5039 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5040
5041 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5042
5043 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005044 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005045 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005046 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005047 params.SetSubActionDefinition(actionDefinition)
5048
5049 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5050 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5051 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5052 xappConn2.ExpectRESTNotification(t, restSubId2)
5053 e2termConn1.SendSubsResp(t, crereq, cremsg)
5054 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5055
5056 deleteXapp1Subscription(t, &restSubId1)
5057 deleteXapp2Subscription(t, &restSubId2)
5058
5059 waitSubsCleanup(t, e2SubsId1, 10)
5060 waitSubsCleanup(t, e2SubsId2, 10)
5061
5062 mainCtrl.VerifyCounterValues(t)
5063
5064}
5065
5066func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5067 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5068
5069 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005070 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005071 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005072 Counter{cSubReqToE2, 2},
5073 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005074 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005075 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005076 Counter{cSubDelReqToE2, 2},
5077 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005078 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005079 })
5080
5081 // Req1
5082 var params *teststube2ap.RESTSubsReqParams = nil
5083
5084 //Subs Create
5085 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5086 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5087
5088 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5089
5090 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005091 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005092 params.SetMeid("RAN_NAME_1")
5093 params.SetTimeToWait("w200ms")
5094 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5095 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5096 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5097 xappConn2.ExpectRESTNotification(t, restSubId2)
5098 e2termConn1.SendSubsResp(t, crereq, cremsg)
5099 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5100
5101 deleteXapp1Subscription(t, &restSubId1)
5102 deleteXapp2Subscription(t, &restSubId2)
5103
5104 waitSubsCleanup(t, e2SubsId1, 10)
5105 waitSubsCleanup(t, e2SubsId2, 10)
5106
5107 mainCtrl.VerifyCounterValues(t)
5108
5109}
5110
Anssi Mannila51122392021-05-25 11:51:31 +03005111//-----------------------------------------------------------------------------
5112// TestRESTUnpackSubscriptionResponseDecodeFail
5113//
5114// stub stub
5115// +-------+ +---------+ +---------+
5116// | xapp | | submgr | | e2term |
5117// +-------+ +---------+ +---------+
5118// | | |
5119// | RestSubReq | |
5120// |---------------->| |
5121// | | |
5122// | RESTSubResp | |
5123// |<----------------| |
5124// | | |
5125// | | SubReq |
5126// | |------------->|
5127// | | |
5128// | | SubResp | ASN.1 decode fails
5129// | |<-------------|
5130// | | |
5131// | | SubReq |
5132// | |------------->|
5133// | | |
5134// | | SubFail | Duplicated action
5135// | |<-------------|
5136// | RESTNotif (fail)| |
5137// |<----------------| |
5138// | | SubDelReq |
5139// | |------------->|
5140// | | |
5141// | | SubDelResp |
5142// | |<-------------|
5143//
5144//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005145
Anssi Mannila51122392021-05-25 11:51:31 +03005146func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
5147 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5148 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005149
5150 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005151 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005152 restSubId := xappConn1.SendRESTSubsReq(t, params)
5153
5154 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5155 // Decode of this response fails which will result resending original request
5156 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5157
5158 _, cremsg = e2termConn1.RecvSubsReq(t)
5159
Markku Virtanen55d2a282021-06-04 14:46:56 +03005160 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005161
5162 // Subscription already created in E2 Node.
5163 fparams := &teststube2ap.E2StubSubsFailParams{}
5164 fparams.Set(crereq)
5165 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5166 e2termConn1.SendSubsFail(t, fparams, cremsg)
5167
5168 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5169 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5170
5171 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5172 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5173
5174 // Wait that subs is cleaned
5175 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5176
5177 xappConn1.TestMsgChanEmpty(t)
5178 e2termConn1.TestMsgChanEmpty(t)
5179 mainCtrl.wait_registry_empty(t, 10)
5180}
5181
5182//-----------------------------------------------------------------------------
5183// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5184//
5185// stub stub
5186// +-------+ +---------+ +---------+
5187// | xapp | | submgr | | e2term |
5188// +-------+ +---------+ +---------+
5189// | | |
5190// | RestSubReq | |
5191// |---------------->| |
5192// | | |
5193// | RESTSubResp | |
5194// |<----------------| |
5195// | | |
5196// | | SubReq |
5197// | |------------->|
5198// | | |
5199// | | SubResp | Unknown instanceId
5200// | |<-------------|
5201// | | |
5202// | | SubReq |
5203// | |------------->|
5204// | | |
5205// | | SubFail | Duplicated action
5206// | |<-------------|
5207// | RESTNotif (fail)| |
5208// |<----------------| |
5209// | | SubDelReq |
5210// | |------------->|
5211// | | |
5212// | | SubDelResp |
5213// | |<-------------|
5214//
5215//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005216
Anssi Mannila51122392021-05-25 11:51:31 +03005217func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
5218 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5219 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005220
5221 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005222 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005223 restSubId := xappConn1.SendRESTSubsReq(t, params)
5224
5225 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5226
5227 // Unknown instanceId in this response which will result resending original request
5228 orgInstanceId := crereq.RequestId.InstanceId
5229 crereq.RequestId.InstanceId = 0
5230 e2termConn1.SendSubsResp(t, crereq, cremsg)
5231
5232 _, cremsg = e2termConn1.RecvSubsReq(t)
5233
Markku Virtanen55d2a282021-06-04 14:46:56 +03005234 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005235
5236 // Subscription already created in E2 Node.
5237 fparams := &teststube2ap.E2StubSubsFailParams{}
5238 fparams.Set(crereq)
5239 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5240 e2termConn1.SendSubsFail(t, fparams, cremsg)
5241
5242 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5243 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5244
5245 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5246 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5247
5248 // Wait that subs is cleaned
5249 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
5250
5251 xappConn1.TestMsgChanEmpty(t)
5252 e2termConn1.TestMsgChanEmpty(t)
5253 mainCtrl.wait_registry_empty(t, 10)
5254}
5255
5256//-----------------------------------------------------------------------------
5257// TestRESTUnpackSubscriptionResponseNoTransaction
5258//
5259// stub stub
5260// +-------+ +---------+ +---------+
5261// | xapp | | submgr | | e2term |
5262// +-------+ +---------+ +---------+
5263// | | |
5264// | RestSubReq | |
5265// |---------------->| |
5266// | | |
5267// | RESTSubResp | |
5268// |<----------------| |
5269// | | |
5270// | | SubReq |
5271// | |------------->|
5272// | | |
5273// | | SubResp | No transaction for the response
5274// | |<-------------|
5275// | | |
5276// | | SubReq |
5277// | |------------->|
5278// | | |
5279// | | SubFail | Duplicated action
5280// | |<-------------|
5281// | RESTNotif (fail)| |
5282// |<----------------| |
5283// | | SubDelReq |
5284// | |------------->|
5285// | | |
5286// | | SubDelResp |
5287// | |<-------------|
5288// | | |
5289// | | SubDelReq |
5290// | |------------->|
5291// | | |
5292// | | SubDelResp |
5293// | |<-------------|
5294//
5295//-----------------------------------------------------------------------------
5296func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
5297 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5298 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005299
5300 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005301 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005302 restSubId := xappConn1.SendRESTSubsReq(t, params)
5303
5304 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5305
5306 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5307 // No transaction exist for this response which will result resending original request
5308 e2termConn1.SendSubsResp(t, crereq, cremsg)
5309
5310 _, cremsg = e2termConn1.RecvSubsReq(t)
5311
Markku Virtanen55d2a282021-06-04 14:46:56 +03005312 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005313
5314 // Subscription already created in E2 Node.
5315 fparams := &teststube2ap.E2StubSubsFailParams{}
5316 fparams.Set(crereq)
5317 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5318 e2termConn1.SendSubsFail(t, fparams, cremsg)
5319
5320 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5321 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5322
5323 // Resending happens because there no transaction
5324 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5325 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5326
5327 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5328 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5329
5330 // Wait that subs is cleaned
5331 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5332
5333 xappConn1.TestMsgChanEmpty(t)
5334 e2termConn1.TestMsgChanEmpty(t)
5335 mainCtrl.wait_registry_empty(t, 10)
5336
5337}
5338
5339//-----------------------------------------------------------------------------
5340// TestRESTUnpackSubscriptionFailureDecodeFail
5341//
5342// stub stub
5343// +-------+ +---------+ +---------+
5344// | xapp | | submgr | | e2term |
5345// +-------+ +---------+ +---------+
5346// | | |
5347// | RestSubReq | |
5348// |---------------->| |
5349// | | |
5350// | RESTSubResp | |
5351// |<----------------| |
5352// | | |
5353// | | SubReq |
5354// | |------------->|
5355// | | |
5356// | | SubFail | ASN.1 decode fails
5357// | |<-------------|
5358// | | |
5359// | | SubReq |
5360// | |------------->|
5361// | | |
5362// | | SubFail | Duplicated action
5363// | |<-------------|
5364// | RESTNotif (fail)| |
5365// |<----------------| |
5366// | | SubDelReq |
5367// | |------------->|
5368// | | |
5369// | | SubDelResp |
5370// | |<-------------|
5371//
5372//-----------------------------------------------------------------------------
5373func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
5374 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5375 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005376
5377 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005378 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005379 restSubId := xappConn1.SendRESTSubsReq(t, params)
5380
5381 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5382
5383 // Decode of this response fails which will result resending original request
5384 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5385
5386 _, cremsg = e2termConn1.RecvSubsReq(t)
5387
Markku Virtanen55d2a282021-06-04 14:46:56 +03005388 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005389
5390 // Subscription already created in E2 Node.
5391 fparams := &teststube2ap.E2StubSubsFailParams{}
5392 fparams.Set(crereq)
5393 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5394 e2termConn1.SendSubsFail(t, fparams, cremsg)
5395
5396 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5397 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5398
5399 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5400 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5401
5402 // Wait that subs is cleaned
5403 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5404
5405 xappConn1.TestMsgChanEmpty(t)
5406 e2termConn1.TestMsgChanEmpty(t)
5407 mainCtrl.wait_registry_empty(t, 10)
5408}
5409
5410//-----------------------------------------------------------------------------
5411// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5412//
5413// stub stub
5414// +-------+ +---------+ +---------+
5415// | xapp | | submgr | | e2term |
5416// +-------+ +---------+ +---------+
5417// | | |
5418// | RestSubReq | |
5419// |---------------->| |
5420// | | |
5421// | RESTSubResp | |
5422// |<----------------| |
5423// | | |
5424// | | SubReq |
5425// | |------------->|
5426// | | |
5427// | | SubFail | Unknown instanceId
5428// | |<-------------|
5429// | | |
5430// | | SubReq |
5431// | |------------->|
5432// | | |
5433// | | SubFail | Duplicated action
5434// | |<-------------|
5435// | RESTNotif (fail)| |
5436// |<----------------| |
5437// | | SubDelReq |
5438// | |------------->|
5439// | | |
5440// | | SubDelResp |
5441// | |<-------------|
5442//
5443//-----------------------------------------------------------------------------
5444func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
5445 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
5446 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005447
5448 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005449 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005450 restSubId := xappConn1.SendRESTSubsReq(t, params)
5451
5452 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5453
5454 // Unknown instanceId in this response which will result resending original request
5455 fparams := &teststube2ap.E2StubSubsFailParams{}
5456 fparams.Set(crereq)
5457 fparams.Fail.RequestId.InstanceId = 0
5458 e2termConn1.SendSubsFail(t, fparams, cremsg)
5459
5460 _, cremsg = e2termConn1.RecvSubsReq(t)
5461
Markku Virtanen55d2a282021-06-04 14:46:56 +03005462 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005463
5464 // Subscription already created in E2 Node.
5465 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5466 e2termConn1.SendSubsFail(t, fparams, cremsg)
5467
5468 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5469 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5470
5471 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5472 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5473
5474 // Wait that subs is cleaned
5475 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5476
5477 xappConn1.TestMsgChanEmpty(t)
5478 e2termConn1.TestMsgChanEmpty(t)
5479 mainCtrl.wait_registry_empty(t, 10)
5480}
5481
5482//-----------------------------------------------------------------------------
5483// TestRESTUnpackSubscriptionFailureNoTransaction
5484//
5485// stub stub
5486// +-------+ +---------+ +---------+
5487// | xapp | | submgr | | e2term |
5488// +-------+ +---------+ +---------+
5489// | | |
5490// | RestSubReq | |
5491// |---------------->| |
5492// | | |
5493// | RESTSubResp | |
5494// |<----------------| |
5495// | | |
5496// | | SubReq |
5497// | |------------->|
5498// | | |
5499// | | SubFail | No transaction for the response
5500// | |<-------------|
5501// | | |
5502// | | SubReq |
5503// | |------------->|
5504// | | |
5505// | | SubFail | Duplicated action
5506// | |<-------------|
5507// | RESTNotif (fail)| |
5508// |<----------------| |
5509// | | SubDelReq |
5510// | |------------->|
5511// | | |
5512// | | SubDelResp |
5513// | |<-------------|
5514//
5515//-----------------------------------------------------------------------------
5516func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
5517 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
5518 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005519
5520 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005521 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005522 restSubId := xappConn1.SendRESTSubsReq(t, params)
5523
5524 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5525
5526 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5527
5528 // No transaction exist for this response which will result resending original request
5529 fparams := &teststube2ap.E2StubSubsFailParams{}
5530 fparams.Set(crereq)
5531 e2termConn1.SendSubsFail(t, fparams, cremsg)
5532
5533 _, cremsg = e2termConn1.RecvSubsReq(t)
5534
Markku Virtanen55d2a282021-06-04 14:46:56 +03005535 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005536
5537 // Subscription already created in E2 Node.
5538 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5539 e2termConn1.SendSubsFail(t, fparams, cremsg)
5540
5541 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5542 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5543
5544 // Resending happens because there no transaction
5545 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5546 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5547
5548 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5549 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5550
5551 // Wait that subs is cleaned
5552 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5553
5554 xappConn1.TestMsgChanEmpty(t)
5555 e2termConn1.TestMsgChanEmpty(t)
5556 mainCtrl.wait_registry_empty(t, 10)
5557}
5558
5559//-----------------------------------------------------------------------------
5560// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
5561//
5562// stub stub
5563// +-------+ +---------+ +---------+
5564// | xapp | | submgr | | e2term |
5565// +-------+ +---------+ +---------+
5566// | | |
5567// | [SUBS CREATE] |
5568// | | |
5569// | | |
5570// | RESTSubDelReq | |
5571// |---------------->| |
5572// | | |
5573// | RESTSubDelResp | |
5574// |<----------------| |
5575// | | |
5576// | | SubDelReq |
5577// | |------------->|
5578// | | |
5579// | | SubDelResp | ASN.1 decode fails
5580// | |<-------------|
5581// | | |
5582// | | SubDelReq |
5583// | |------------->|
5584// | | |
5585// | | SubDelFail | Subscription does exist any more
5586// | |<-------------|
5587// | | |
5588//
5589//-----------------------------------------------------------------------------
5590func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
5591 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
5592
5593 // Req
5594 var params *teststube2ap.RESTSubsReqParams = nil
5595 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5596
5597 // Del
5598 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5599
5600 // E2t: Receive 1st SubsDelReq
5601 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5602
5603 // Decode of this response fails which will result resending original request
5604 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
5605
5606 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5607 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5608
5609 // Subscription does not exist in in E2 Node.
5610 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5611
5612 // Wait that subs is cleaned
5613 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5614
5615 xappConn1.TestMsgChanEmpty(t)
5616 e2termConn1.TestMsgChanEmpty(t)
5617 mainCtrl.wait_registry_empty(t, 10)
5618}
5619
5620//-----------------------------------------------------------------------------
5621// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
5622//
5623// stub stub
5624// +-------+ +---------+ +---------+
5625// | xapp | | submgr | | e2term |
5626// +-------+ +---------+ +---------+
5627// | | |
5628// | [SUBS CREATE] |
5629// | | |
5630// | | |
5631// | RESTSubDelReq | |
5632// |---------------->| |
5633// | | |
5634// | RESTSubDelResp | |
5635// |<----------------| |
5636// | | |
5637// | | SubDelReq |
5638// | |------------->|
5639// | | |
5640// | | SubDelResp | Unknown instanceId
5641// | |<-------------|
5642// | | |
5643// | | SubDelReq |
5644// | |------------->|
5645// | | |
5646// | | SubDelFail | Subscription does exist any more
5647// | |<-------------|
5648//
5649//-----------------------------------------------------------------------------
5650func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
5651 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
5652
5653 // Req
5654 var params *teststube2ap.RESTSubsReqParams = nil
5655 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5656
5657 // Del
5658 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5659
5660 // E2t: Receive 1st SubsDelReq
5661 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5662
5663 // Unknown instanceId in this response which will result resending original request
5664 delreq.RequestId.InstanceId = 0
5665 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5666
5667 // E2t: Receive 2nd SubsDelReq
5668 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5669
5670 // Subscription does not exist in in E2 Node.
5671 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5672
5673 // Wait that subs is cleaned
5674 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5675
5676 xappConn1.TestMsgChanEmpty(t)
5677 e2termConn1.TestMsgChanEmpty(t)
5678 mainCtrl.wait_registry_empty(t, 10)
5679}
5680
5681//-----------------------------------------------------------------------------
5682// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
5683//
5684// stub stub
5685// +-------+ +---------+ +---------+
5686// | xapp | | submgr | | e2term |
5687// +-------+ +---------+ +---------+
5688// | | |
5689// | [SUBS CREATE] |
5690// | | |
5691// | | |
5692// | RESTSubDelReq | |
5693// |---------------->| |
5694// | | |
5695// | RESTSubDelResp | |
5696// |<----------------| |
5697// | | |
5698// | | SubDelReq |
5699// | |------------->|
5700// | | |
5701// | | SubDelResp | No transaction for the response
5702// | |<-------------|
5703// | | |
5704// | | SubDelReq |
5705// | |------------->|
5706// | | |
5707// | | SubDelFail | Subscription does exist any more
5708// | |<-------------|
5709//
5710//-----------------------------------------------------------------------------
5711func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
5712 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
5713
5714 // Req
5715 var params *teststube2ap.RESTSubsReqParams = nil
5716 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5717
5718 // Del
5719 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5720
5721 // E2t: Receive 1st SubsDelReq
5722 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5723
5724 mainCtrl.MakeTransactionNil(t, e2SubsId)
5725
5726 // No transaction exist for this response which will result resending original request
5727 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5728
5729 // E2t: Receive 2nd SubsDelReq
5730 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5731
5732 // Subscription does not exist in in E2 Node.
5733 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5734
5735 // Wait that subs is cleaned
5736 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5737
5738 xappConn1.TestMsgChanEmpty(t)
5739 e2termConn1.TestMsgChanEmpty(t)
5740 mainCtrl.wait_registry_empty(t, 10)
5741}
5742
5743//-----------------------------------------------------------------------------
5744// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
5745//
5746// stub stub
5747// +-------+ +---------+ +---------+
5748// | xapp | | submgr | | e2term |
5749// +-------+ +---------+ +---------+
5750// | | |
5751// | [SUBS CREATE] |
5752// | | |
5753// | | |
5754// | RESTSubDelReq | |
5755// |---------------->| |
5756// | | |
5757// | RESTSubDelResp | |
5758// |<----------------| |
5759// | | |
5760// | | SubDelReq |
5761// | |------------->|
5762// | | |
5763// | | SubDelFail | ASN.1 decode fails
5764// | |<-------------|
5765// | | |
5766// | | SubDelReq |
5767// | |------------->|
5768// | | |
5769// | | SubDelFail | Subscription does exist any more
5770// | |<-------------|
5771//
5772//-----------------------------------------------------------------------------
5773func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
5774 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
5775
5776 // Req
5777 var params *teststube2ap.RESTSubsReqParams = nil
5778 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5779
5780 // Del
5781 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5782
5783 // E2t: Receive 1st SubsDelReq
5784 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5785
5786 // Decode of this response fails which will result resending original request
5787 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
5788
5789 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5790 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5791
5792 // Subscription does not exist in in E2 Node.
5793 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5794
5795 // Wait that subs is cleaned
5796 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5797
5798 xappConn1.TestMsgChanEmpty(t)
5799 e2termConn1.TestMsgChanEmpty(t)
5800 mainCtrl.wait_registry_empty(t, 10)
5801}
5802
5803//-----------------------------------------------------------------------------
5804// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
5805//
5806// stub stub
5807// +-------+ +---------+ +---------+
5808// | xapp | | submgr | | e2term |
5809// +-------+ +---------+ +---------+
5810// | | |
5811// | [SUBS CREATE] |
5812// | | |
5813// | | |
5814// | RESTSubDelReq | |
5815// |---------------->| |
5816// | | |
5817// | RESTSubDelResp | |
5818// |<----------------| |
5819// | | |
5820// | | SubDelReq |
5821// | |------------->|
5822// | | |
5823// | | SubDelFail | Unknown instanceId
5824// | |<-------------|
5825// | | |
5826// | | SubDelReq |
5827// | |------------->|
5828// | | |
5829// | | SubDelFail | Subscription does exist any more
5830// | |<-------------|
5831//
5832//-----------------------------------------------------------------------------
5833func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
5834 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
5835
5836 // Req
5837 var params *teststube2ap.RESTSubsReqParams = nil
5838 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5839
5840 // Del
5841 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5842
5843 // E2t: Receive 1st SubsDelReq
5844 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5845
5846 // Unknown instanceId in this response which will result resending original request
5847 delreq.RequestId.InstanceId = 0
5848 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5849
5850 // E2t: Receive 2nd SubsDelReq
5851 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5852
5853 // Subscription does not exist in in E2 Node.
5854 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5855
5856 // Wait that subs is cleaned
5857 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5858
5859 xappConn1.TestMsgChanEmpty(t)
5860 e2termConn1.TestMsgChanEmpty(t)
5861 mainCtrl.wait_registry_empty(t, 10)
5862}
5863
5864//-----------------------------------------------------------------------------
5865// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
5866//
5867// stub stub
5868// +-------+ +---------+ +---------+
5869// | xapp | | submgr | | e2term |
5870// +-------+ +---------+ +---------+
5871// | | |
5872// | [SUBS CREATE] |
5873// | | |
5874// | | |
5875// | RESTSubDelReq | |
5876// |---------------->| |
5877// | | |
5878// | RESTSubDelResp | |
5879// |<----------------| |
5880// | | |
5881// | | SubDelReq |
5882// | |------------->|
5883// | | |
5884// | | SubDelFail | No transaction for the response
5885// | |<-------------|
5886// | | |
5887// | | SubDelReq |
5888// | |------------->|
5889// | | |
5890// | | SubDelFail | Subscription does exist any more
5891// | |<-------------|
5892//
5893//-----------------------------------------------------------------------------
5894func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
5895 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
5896
5897 // Req
5898 var params *teststube2ap.RESTSubsReqParams = nil
5899 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5900
5901 // Del
5902 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5903
5904 // E2t: Receive 1st SubsDelReq
5905 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5906
5907 mainCtrl.MakeTransactionNil(t, e2SubsId)
5908
5909 // No transaction exist for this response which will result resending original request
5910 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5911
5912 // E2t: Receive 2nd SubsDelReq
5913 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5914
5915 // Subscription does not exist in in E2 Node.
5916 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5917
5918 // Wait that subs is cleaned
5919 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5920
5921 xappConn1.TestMsgChanEmpty(t)
5922 e2termConn1.TestMsgChanEmpty(t)
5923 mainCtrl.wait_registry_empty(t, 10)
5924}
5925
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005926//-----------------------------------------------------------------------------
5927// TestRESTSubReqFailAsn1PackSubReqError
5928//
5929// stub stub
5930// +-------+ +---------+ +---------+
5931// | xapp | | submgr | | e2term |
5932// +-------+ +---------+ +---------+
5933// | | |
5934// | RESTSubReq | |
5935// |---------------->| |
5936// | | |
5937// | RESTSubResp | |
5938// |<----------------| |
5939// | | |
5940// | ASN.1 encode fails |
5941// | | |
5942// | | SubDelReq |
5943// | |------------->|
5944// | | |
5945// | | SubDelFail |
5946// | |<-------------|
5947// | | |
5948// | RESTNotif | |
5949// | unsuccess | |
5950// |<----------------| |
5951// | | |
5952// | [SUBS DELETE] |
5953// | | |
5954//
5955//-----------------------------------------------------------------------------
5956func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
5957
5958 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005959 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005960 Counter{cRestSubRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005961 Counter{cSubDelReqToE2, 1},
5962 Counter{cSubDelFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005963 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005964 })
5965
5966 subReqCount := 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005967
5968 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005969 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005970 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
5971
5972 // Req
5973 restSubId := xappConn1.SendRESTSubsReq(t, params)
5974 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5975
5976 // E2t: Receive SubsDelReq
5977 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03005978 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005979
5980 // Subscription does not exist in in E2 Node.
5981 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5982
5983 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5984 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
5985
5986 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
5987 // Wait that subs is cleaned
5988 waitSubsCleanup(t, e2SubsId, 10)
5989 mainCtrl.VerifyCounterValues(t)
5990}
5991
archaggeafbf95f2021-04-14 08:54:05 +03005992////////////////////////////////////////////////////////////////////////////////////
5993// Services for UT cases
5994////////////////////////////////////////////////////////////////////////////////////
5995const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005996const host string = "localhost"
5997
5998func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
5999 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006000 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006001 }
6002 restSubId := fromXappConn.SendRESTSubsReq(t, params)
6003 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6004
6005 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
6006 fromXappConn.ExpectRESTNotification(t, restSubId)
6007 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
6008 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
6009 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6010
6011 return restSubId, e2SubsId
6012}
6013
6014func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
6015
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006016 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006017 if meid != "" {
6018 params.SetMeid(meid)
6019 }
6020 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
6021 restSubId := xappConn2.SendRESTSubsReq(t, params)
6022 xappConn2.ExpectRESTNotification(t, restSubId)
6023 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6024 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
6025 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6026
6027 return restSubId, e2SubsId
6028}
6029
6030func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006031 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006032 restSubId := xappConn1.SendRESTSubsReq(t, params)
6033 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
6034
6035 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6036 xappConn1.ExpectRESTNotification(t, restSubId)
6037 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6038 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6039 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6040
6041 return restSubId, e2SubsId
6042}
6043
6044func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006045 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006046 restSubId := xappConn1.SendRESTSubsReq(t, params)
6047
6048 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6049 fparams1 := &teststube2ap.E2StubSubsFailParams{}
6050 fparams1.Set(crereq1)
6051 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
6052
6053 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
6054 xappConn1.ExpectRESTNotification(t, restSubId)
6055 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
6056 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6057 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
6058
6059 return restSubId, e2SubsId
6060}
6061
6062func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
6063 fromXappConn.SendRESTSubsDelReq(t, restSubId)
6064 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6065 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6066}
6067
6068func deleteXapp1Subscription(t *testing.T, restSubId *string) {
6069 xappConn1.SendRESTSubsDelReq(t, restSubId)
6070 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6071 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6072}
6073
6074func deleteXapp2Subscription(t *testing.T, restSubId *string) {
6075 xappConn2.SendRESTSubsDelReq(t, restSubId)
6076 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6077 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6078}
6079
6080func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
6081 resp, _ := xapp.Subscription.QuerySubscriptions()
6082 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
6083 assert.Equal(t, resp[0].Meid, meid)
6084 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
6085}
6086
6087func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
6088 //Wait that subs is cleaned
6089 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
6090
6091 xappConn1.TestMsgChanEmpty(t)
6092 xappConn2.TestMsgChanEmpty(t)
6093 e2termConn1.TestMsgChanEmpty(t)
6094 mainCtrl.wait_registry_empty(t, timeout)
6095}
6096
6097func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
6098
6099 var e2SubsId []uint32
6100
6101 for i := 0; i < count; i++ {
6102 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
6103 crereq, cremsg := toE2termConn.RecvSubsReq(t)
6104 fromXappConn.ExpectRESTNotification(t, restSubId)
6105 toE2termConn.SendSubsResp(t, crereq, cremsg)
6106 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
6107 e2SubsId = append(e2SubsId, instanceId)
6108 xapp.Logger.Info("TEST: %v", e2SubsId)
6109 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
6110 <-time.After(100 * time.Millisecond)
6111 }
6112 return e2SubsId
6113}
6114
6115func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
6116
6117 for i := 0; i < len(e2SubsIds); i++ {
6118 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
6119 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6120 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6121 <-time.After(1 * time.Second)
6122 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
6123 <-time.After(100 * time.Millisecond)
6124 }
6125
6126 // Wait that subs is cleaned
6127 for i := 0; i < len(e2SubsIds); i++ {
6128 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
6129 }
6130
6131}