blob: dff639e2029e25c84f63c5b2111620f3f1266d15 [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 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002609 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002610 // 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
Markku Virtanen42723e22021-06-15 10:09:23 +03002645//-----------------------------------------------------------------------------
2646// stub stub stub
2647// +-------+ +---------+ +---------+ +---------+
2648// | xapp | | submgr | | e2term | | rtmgr |
2649// +-------+ +---------+ +---------+ +---------+
2650// | | | |
2651// | RESTSubReq | | |
2652// |---------------->| | |
2653// | RESTSubResp | | |
2654// |<----------------| | |
2655// | | RouteCreate | |
2656// | |--------------------------->|
2657// | | RouteResponse| |
2658// | |<---------------------------| // The order of these events may vary
2659// | | SubReq | |
2660// | |------------->| | // The order of these events may vary
2661// | | SubResp | |
2662// | |<-------------| |
2663// | RESTNotif1 | | |
2664// |<----------------| | |
2665// | RESTSubReq | | |
2666// | [RETRANS1] | | |
2667// |---------------->| | |
2668// | RESTNotif1 | | |
2669// |<----------------| | |
2670// | RESTSubReq | | |
2671// | [RETRANS2] | | |
2672// |---------------->| | |
2673// | RESTNotif1 | | |
2674// |<----------------| | |
2675// | RESTSubDelReq | | |
2676// |---------------->| | |
2677// | | SubDelReq | |
2678// | |------------->| |
2679// | RESTSubDelResp| | |
2680// |<----------------| | |
2681// | | SubDelResp | |
2682// | |<-------------| |
2683// | | | |
2684//
2685//-----------------------------------------------------------------------------
2686
2687func TestRESTSubReqRetransmissionV2(t *testing.T) {
2688 CaseBegin("TestRESTSubReqRetransmissionV2")
2689
2690 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2691 Counter{cRestSubReqFromXapp, 3},
2692 Counter{cRestSubRespToXapp, 3},
2693 Counter{cSubReqToE2, 1},
2694 Counter{cSubRespFromE2, 1},
2695 Counter{cRestSubNotifToXapp, 3},
2696 Counter{cRestSubDelReqFromXapp, 1},
2697 Counter{cSubDelReqToE2, 1},
2698 Counter{cSubDelRespFromE2, 1},
2699 Counter{cRestSubDelRespToXapp, 1},
2700 })
2701
2702 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2703
2704 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2705
2706 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2707
2708 //1.st resend
2709 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2710
2711 assert.Equal(t, restSubId_resend, restSubId)
2712
2713 <-time.After(100 * time.Millisecond)
2714
2715 //2.nd resend
2716 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2717
2718 assert.Equal(t, restSubId_resend2, restSubId)
2719
2720 <-time.After(100 * time.Millisecond)
2721
2722 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2723
2724 waitSubsCleanup(t, e2SubsId, 10)
2725
2726 //Wait that subs is cleaned
2727 mainCtrl.VerifyCounterValues(t)
2728}
2729
2730//-----------------------------------------------------------------------------
2731// stub stub stub
2732// +-------+ +---------+ +---------+ +---------+
2733// | xapp | | submgr | | e2term | | rtmgr |
2734// +-------+ +---------+ +---------+ +---------+
2735// | | | |
2736// | RESTSubReq | | |
2737// |---------------->| | |
2738// | RESTSubResp | | |
2739// |<----------------| | |
2740// | | RouteCreate | |
2741// | |--------------------------->|
2742// | | RouteResponse| |
2743// | |<---------------------------| // The order of these events may vary
2744// | | SubReq | |
2745// | |------------->| | // The order of these events may vary
2746// | | SubResp | |
2747// | |<-------------| |
2748// | RESTNotif1 | | |
2749// |<----------------| | |
2750// | RESTSubReq | | |
2751// | [RETRANS, with RESTsubsId] | |
2752// |---------------->| | |
2753// | RESTNotif1 | | |
2754// |<----------------| | |
2755// | RESTSubReq | | |
2756// | [RETRANS, without RESTsubsId] | |
2757// |---------------->| | |
2758// | RESTNotif1 | | |
2759// |<----------------| | |
2760// | RESTSubDelReq | | |
2761// |---------------->| | |
2762// | | SubDelReq | |
2763// | |------------->| |
2764// | RESTSubDelResp| | |
2765// |<----------------| | |
2766// | | SubDelResp | |
2767// | |<-------------| |
2768// | | | |
2769//
2770//-----------------------------------------------------------------------------
2771func TestRESTSubReqRetransmissionV3(t *testing.T) {
2772 CaseBegin("TestRESTSubReqRetransmissionV3")
2773
2774 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2775 Counter{cRestSubReqFromXapp, 3},
2776 Counter{cRestSubRespToXapp, 3},
2777 Counter{cSubReqToE2, 1},
2778 Counter{cSubRespFromE2, 1},
2779 Counter{cRestSubNotifToXapp, 3},
2780 Counter{cRestSubDelReqFromXapp, 1},
2781 Counter{cSubDelReqToE2, 1},
2782 Counter{cSubDelRespFromE2, 1},
2783 Counter{cRestSubDelRespToXapp, 1},
2784 })
2785
2786 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2787
2788 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2789
2790 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2791
2792 <-time.After(100 * time.Millisecond)
2793
2794 //1.st resend with subscription ID
2795 params.SetSubscriptionID(&restSubId)
2796 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2797
2798 assert.Equal(t, restSubId_resend, restSubId)
2799
2800 <-time.After(100 * time.Millisecond)
2801
2802 //2.nd resend without subscription ID (faking app restart)
2803 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
2804 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2805
2806 assert.Equal(t, restSubId_resend2, restSubId)
2807
2808 <-time.After(100 * time.Millisecond)
2809
2810 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2811
2812 waitSubsCleanup(t, e2SubsId, 10)
2813
2814 //Wait that subs is cleaned
2815 mainCtrl.VerifyCounterValues(t)
2816}
2817
2818//-----------------------------------------------------------------------------
2819// stub stub stub
2820// +-------+ +---------+ +---------+ +---------+
2821// | xapp | | submgr | | e2term | | rtmgr |
2822// +-------+ +---------+ +---------+ +---------+
2823// | | | |
2824// | RESTSubReq | | |
2825// |---------------->| | |
2826// | RESTSubResp | | |
2827// |<----------------| | |
2828// | | RouteCreate | |
2829// | |--------------------------->|
2830// | | RouteResponse| |
2831// | |<---------------------------|
2832// | | SubReq | |
2833// | |------------->| |
2834// | | SubResp | |
2835// | |<-------------| |
2836// | RESTNotif1 | | |
2837// |<----------------| | |
2838// | RESTSubReq | | |
2839// | [with RestSUbsId + one additional e2 subDetail]
2840// |---------------->| | |
2841// | RESTNotif1 | | |
2842// | [for initial e2 subDetail] | |
2843// |<----------------| | |
2844// | | RouteCreate | |
2845// | |--------------------------->|
2846// | | RouteResponse| |
2847// | |<---------------------------|
2848// | | SubReq | |
2849// | |------------->| |
2850// | | SubResp | |
2851// | |<-------------| |
2852// | RESTNotif1 | | |
2853// |<----------------| | |
2854// | RESTSubReq | | |
2855// | [with RESTsubsId initial request] |
2856// |---------------->| | |
2857// | RESTNotif1 | | |
2858// |<----------------| | |
2859// | RESTSubDelReq | | |
2860// |---------------->| | |
2861// | RESTSubDelResp| | |
2862// |<----------------| | |
2863// | | SubDelReq | |
2864// | |------------->| |
2865// | | SubDelResp | |
2866// | |<-------------| |
2867// | | SubDelReq | |
2868// | |------------->| |
2869// | | SubDelResp | |
2870// | |<-------------| |
2871// | | | |
2872//
2873//-----------------------------------------------------------------------------
2874
2875func TestRESTSubReqRetransmissionV4(t *testing.T) {
2876 CaseBegin("TestRESTSubReqRetransmissionV4")
2877
2878 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2879 Counter{cRestSubReqFromXapp, 3},
2880 Counter{cRestSubRespToXapp, 3},
2881 Counter{cSubReqToE2, 2},
2882 Counter{cSubRespFromE2, 2},
2883 Counter{cRestSubNotifToXapp, 4},
2884 Counter{cRestSubDelReqFromXapp, 1},
2885 Counter{cSubDelReqToE2, 2},
2886 Counter{cSubDelRespFromE2, 2},
2887 Counter{cRestSubDelRespToXapp, 1},
2888 })
2889
2890 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2891
2892 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2893
2894 <-time.After(100 * time.Millisecond)
2895
2896 // Send modified requst, this time with e2 subscriptions.
2897 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
2898 params2.SetSubscriptionID(&restSubId)
2899
2900 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00002901 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03002902 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
2903 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00002904 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
2905 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03002906
2907 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2908
Markku Virtanen2b512b62021-07-30 12:04:00 +00002909 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03002910 xappConn1.ExpectRESTNotification(t, restSubId_resend)
2911 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2912 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
2913 assert.NotEqual(t, e2SubsId2, 0)
2914
2915 <-time.After(100 * time.Millisecond)
2916
2917 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
2918 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
2919 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00002920 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03002921 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
2922 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2923 assert.Equal(t, restSubId_resend, restSubId_resend2)
2924
Markku Virtanen2b512b62021-07-30 12:04:00 +00002925 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
2926 assert.Equal(t, e2SubsId, e2SubsId1)
2927
Markku Virtanen42723e22021-06-15 10:09:23 +03002928 // Delete both e2 subscriptions
2929 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2930 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
2931 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
2932
2933 waitSubsCleanup(t, e2SubsId, 10)
2934
2935 //Wait that subs is cleaned
2936 mainCtrl.VerifyCounterValues(t)
2937}
2938
2939//-----------------------------------------------------------------------------
2940// stub stub stub
2941// +-------+ +---------+ +---------+ +---------+
2942// | xapp | | submgr | | e2term | | rtmgr |
2943// +-------+ +---------+ +---------+ +---------+
2944// | | | |
2945// | RESTSubReq | | |
2946// |---------------->| | |
2947// | RESTSubResp | | |
2948// |<----------------| | |
2949// | | RouteCreate | |
2950// | |--------------------------->|
2951// | | RouteResponse| |
2952// | |<---------------------------|
2953// | | SubReq | |
2954// | |------------->| |
2955// | | SubResp | |
2956// | |<-------------| |
2957// | RESTNotif1 | | |
2958// |<----------------| | |
2959// | RESTSubReq | | |
2960// | [with RestSUbsId + one additional e2 subDetail]
2961// |---------------->| | |
2962// | RESTNotif1 | | |
2963// | [for initial e2 subDetail] | |
2964// |<----------------| | |
2965// | | RouteCreate | |
2966// | |--------------------------->|
2967// | | RouteResponse| |
2968// | |<---------------------------|
2969// | | SubReq | |
2970// | |------------->| |
2971// | | SubResp | |
2972// | |<-------------| |
2973// | RESTNotif1 | | |
2974// |<----------------| | |
2975// | RESTSubReq | | |
2976// | [without RESTsubsId initial request] |
2977// |---------------->| | |
2978// | RESTNotif1 | | |
2979// |<----------------| | |
2980// | RESTSubDelReq | | |
2981// |---------------->| | |
2982// | RESTSubDelResp| | |
2983// |<----------------| | |
2984// | | SubDelReq | |
2985// | |------------->| |
2986// | | SubDelResp | |
2987// | |<-------------| |
2988// | | SubDelReq | |
2989// | |------------->| |
2990// | | SubDelResp | |
2991// | |<-------------| |
2992// | | | |
2993//
2994//-----------------------------------------------------------------------------
2995
2996func TestRESTSubReqRetransmissionV5(t *testing.T) {
2997 CaseBegin("TestRESTSubReqRetransmissionV5")
2998
2999 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3000 Counter{cRestSubReqFromXapp, 3},
3001 Counter{cRestSubRespToXapp, 3},
3002 Counter{cSubReqToE2, 2},
3003 Counter{cSubRespFromE2, 2},
3004 Counter{cRestSubNotifToXapp, 4},
3005 Counter{cRestSubDelReqFromXapp, 1},
3006 Counter{cSubDelReqToE2, 2},
3007 Counter{cSubDelRespFromE2, 2},
3008 Counter{cRestSubDelRespToXapp, 1},
3009 })
3010
3011 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3012
3013 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3014
3015 <-time.After(100 * time.Millisecond)
3016
3017 // Send modified requst, this time with e2 subscriptions.
3018 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3019 params2.SetSubscriptionID(&restSubId)
3020
3021 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003022 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003023 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3024 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3025
Markku Virtanen2b512b62021-07-30 12:04:00 +00003026 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3027 assert.Equal(t, e2SubsId, e2SubsId1)
3028 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3029 xappConn1.DecrementRequestCount()
3030
Markku Virtanen42723e22021-06-15 10:09:23 +03003031 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3032
3033 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3034 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3035 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3036 assert.NotEqual(t, e2SubsId2, 0)
3037
3038 <-time.After(100 * time.Millisecond)
3039
3040 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3041 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003042 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003043 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3044 // md5sum shall find the original request
3045 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3046 assert.Equal(t, restSubId_resend, restSubId_resend2)
3047
Markku Virtanen2b512b62021-07-30 12:04:00 +00003048 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3049 assert.Equal(t, e2SubsId, e2SubsId1)
3050
Markku Virtanen42723e22021-06-15 10:09:23 +03003051 // Delete both e2 subscriptions
3052 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3053 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3054 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3055
3056 waitSubsCleanup(t, e2SubsId, 10)
3057
3058 //Wait that subs is cleaned
3059 mainCtrl.VerifyCounterValues(t)
3060}
3061
3062//-----------------------------------------------------------------------------
3063// stub stub stub
3064// +-------+ +---------+ +---------+ +---------+
3065// | xapp | | submgr | | e2term | | rtmgr |
3066// +-------+ +---------+ +---------+ +---------+
3067// | | | |
3068// | RESTSubReq | | |
3069// |---------------->| | |
3070// | RESTSubResp | | |
3071// |<----------------| | |
3072// | | RouteCreate | |
3073// | |--------------------------->|
3074// | | RouteResponse| |
3075// | |<---------------------------|
3076// | | SubReq | |
3077// | |------------->| |
3078// | | SubResp | |
3079// | |<-------------| |
3080// | RESTNotif1 | | |
3081// |<----------------| | |
3082// | RESTSubReq | | |
3083// | [with RestSUbsId + one additional e2 subDetail]
3084// |---------------->| | |
3085// | RESTNotif1 | | |
3086// | [for initial e2 subDetail] | |
3087// |<----------------| | |
3088// | | RouteCreate | |
3089// | |--------------------------->|
3090// | | RouteResponse| |
3091// | |<---------------------------|
3092// | | SubReq | |
3093// | |------------->| |
3094// | | SubResp | |
3095// | |<-------------| |
3096// | RESTNotif1 | | |
3097// |<----------------| | |
3098// | RESTSubDelReq | | |
3099// |---------------->| | |
3100// | RESTSubDelResp| | |
3101// |<----------------| | |
3102// | | SubDelReq | |
3103// | |------------->| |
3104// | | SubDelResp | |
3105// | |<-------------| |
3106// | | SubDelReq | |
3107// | |------------->| |
3108// | | SubDelResp | |
3109// | |<-------------| |
3110// | RESTSubReq | | |
3111// | [with RESTsubsId initial request] |
3112// |---------------->| | |
3113// | RESTSubResp | | |
3114// |<----------------| | |
3115// | | RouteCreate | |
3116// | |--------------------------->|
3117// | | RouteResponse| |
3118// | |<---------------------------|
3119// | | SubReq | |
3120// | |------------->| |
3121// | | SubResp | |
3122// | |<-------------| |
3123// | RESTNotif1 | | |
3124// |<----------------| | |
3125// | | | |
3126//
3127//-----------------------------------------------------------------------------
3128func TestRESTSubReqRetransmissionV6(t *testing.T) {
3129 CaseBegin("TestRESTSubReqRetransmissionV6")
3130
3131 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3132 Counter{cRestSubReqFromXapp, 3},
3133 Counter{cRestSubRespToXapp, 3},
3134 Counter{cSubReqToE2, 3},
3135 Counter{cSubRespFromE2, 3},
3136 Counter{cRestSubNotifToXapp, 4},
3137 Counter{cRestSubDelReqFromXapp, 2},
3138 Counter{cSubDelReqToE2, 3},
3139 Counter{cSubDelRespFromE2, 3},
3140 Counter{cRestSubDelRespToXapp, 2},
3141 })
3142
3143 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3144
3145 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3146
3147 <-time.After(100 * time.Millisecond)
3148
3149 // Send modified requst, this time with e2 subscriptions.
3150 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3151 params2.SetSubscriptionID(&restSubId)
3152
3153 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003154 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003155 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3156 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3157
Markku Virtanen2b512b62021-07-30 12:04:00 +00003158 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3159 assert.Equal(t, e2SubsId, e2SubsId1)
3160
Markku Virtanen42723e22021-06-15 10:09:23 +03003161 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3162
3163 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3164 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3165 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3166 assert.NotEqual(t, e2SubsId2, 0)
3167
3168 <-time.After(100 * time.Millisecond)
3169
3170 // Delete both e2 subscriptions
3171 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3172 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3173 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3174
3175 waitSubsCleanup(t, e2SubsId, 10)
3176
3177 // Resend the original request, we shall find it's previous md5sum/restsubs
3178 // but the restsubscription has been already removed. This shall trigger a
3179 // fresh create.
3180 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3181
3182 <-time.After(100 * time.Millisecond)
3183
3184 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3185
3186 waitSubsCleanup(t, e2SubsId, 10)
3187
3188 //Wait that subs is cleaned
3189 mainCtrl.VerifyCounterValues(t)
3190}
3191
archaggeafbf95f2021-04-14 08:54:05 +03003192func TestRESTSubDelReqRetransmission(t *testing.T) {
3193 CaseBegin("TestRESTSubDelReqRetransmission")
3194
3195 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003196 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003197 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003198 Counter{cSubReqToE2, 1},
3199 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003200 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003201 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003202 Counter{cSubDelReqToE2, 1},
3203 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003204 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003205 })
3206
3207 var params *teststube2ap.RESTSubsReqParams = nil
3208
3209 //Subs Create
3210 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3211
3212 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3213
3214 //Subs Delete
3215 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3216 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3217
3218 seqBef := mainCtrl.get_msgcounter(t)
3219 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3220 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3221
3222 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3223
3224 waitSubsCleanup(t, e2SubsId, 10)
3225
3226 mainCtrl.VerifyCounterValues(t)
3227}
3228
3229//-----------------------------------------------------------------------------
3230// TestRESTSubReqDelReq
3231//
3232// stub stub
3233// +-------+ +---------+ +---------+
3234// | xapp | | submgr | | e2term |
3235// +-------+ +---------+ +---------+
3236// | | |
3237// | RESTSubReq | |
3238// |---------------->| |
3239// | | |
3240// | RESTSubResp | |
3241// |<----------------| |
3242// | | SubReq |
3243// | |------------->|
3244// | RESTSubDelReq | |
3245// |---------------->| |
3246// | RESTSubDelResp | |
3247// | unsuccess | |
3248// |<----------------| |
3249// | | SubResp |
3250// | |<-------------|
3251// | RESTNotif1 | |
3252// |<----------------| |
3253// | | |
3254// | [SUBS DELETE] |
3255// | | |
3256//
3257//-----------------------------------------------------------------------------
3258func TestRESTSubReqDelReq(t *testing.T) {
3259 CaseBegin("TestRESTSubReqDelReq")
3260
3261 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003262 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003263 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003264 Counter{cSubReqToE2, 1},
3265 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003266 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003267 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003268 Counter{cSubDelReqToE2, 1},
3269 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003270 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003271 })
3272
3273 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003274
3275 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003276 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003277 restSubId := xappConn1.SendRESTSubsReq(t, params)
3278
3279 // Del. This will fail as processing of the subscription
3280 // is still ongoing in submgr. Deletion is not allowed before
3281 // subscription creation has been completed.
3282 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3283 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3284 xappConn1.ExpectRESTNotification(t, restSubId)
3285 e2termConn1.SendSubsResp(t, crereq, cremsg)
3286 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3287
3288 // Retry del
3289 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3290
3291 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3292 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3293
3294 // Wait that subs is cleaned
3295 waitSubsCleanup(t, e2SubsId, 10)
3296 mainCtrl.VerifyCounterValues(t)
3297
3298}
3299
3300func TestRESTSubDelReqCollision(t *testing.T) {
3301 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3302}
3303
3304func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3305 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3306
3307 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003308 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003309 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003310 Counter{cSubReqToE2, 2},
3311 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003312 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003313 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003314 Counter{cSubDelReqToE2, 2},
3315 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003316 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003317 })
3318
3319 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003320 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003321 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3322 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
3323
3324 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003325 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003326 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3327 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
3328
3329 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3330 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3331
3332 //XappConn1 receives both of the responses
3333 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3334
3335 //Resp1
3336 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3337 //Resp2
3338 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3339
3340 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3341 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3342 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3343 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3344
3345 //Del1
3346 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3347 //Del2
3348 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3349
3350 //Wait that subs is cleaned
3351 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3352 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3353
3354 mainCtrl.VerifyCounterValues(t)
3355
3356}
3357
3358func TestRESTSameSubsDiffRan(t *testing.T) {
3359 CaseBegin("TestRESTSameSubsDiffRan")
3360
3361 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003362 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003363 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003364 Counter{cSubReqToE2, 2},
3365 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003366 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003367 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003368 Counter{cSubDelReqToE2, 2},
3369 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003370 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003371 })
3372
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003373 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003374 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3375 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
3376
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003377 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003378 params.SetMeid("RAN_NAME_2")
3379 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
3380 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
3381
3382 //Del1
3383 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3384 //Del2
3385 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3386
3387 //Wait that subs is cleaned
3388 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3389 waitSubsCleanup(t, e2SubsId2, 10)
3390
3391 mainCtrl.VerifyCounterValues(t)
3392
3393}
3394
3395func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3396 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3397
3398 // Init counter check
3399 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003400 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003401 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003402 Counter{cSubReqToE2, 1},
3403 Counter{cSubReReqToE2, 1},
3404 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003405 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003406 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003407 Counter{cSubDelReqToE2, 1},
3408 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003409 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003410 })
3411
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003412 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003413 restSubId := xappConn1.SendRESTSubsReq(t, params)
3414
3415 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3416
3417 // Catch the first message and ignore it
3418 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3419 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
3420
3421 // The second request is being handled normally
3422 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3423 xappConn1.ExpectRESTNotification(t, restSubId)
3424 e2termConn1.SendSubsResp(t, crereq, cremsg)
3425 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3426
3427 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3428
3429 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3430
3431 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3432 //Wait that subs is cleaned
3433 waitSubsCleanup(t, e2SubsId, 10)
3434
3435 mainCtrl.VerifyCounterValues(t)
3436
3437}
3438
3439//-----------------------------------------------------------------------------
3440// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3441//
3442// stub stub
3443// +-------+ +---------+ +---------+
3444// | xapp | | submgr | | e2term |
3445// +-------+ +---------+ +---------+
3446// | | |
3447// | RESTSubReq | |
3448// |---------------->| |
3449// | | |
3450// | RESTSubResp | |
3451// |<----------------| |
3452// | | SubReq |
3453// | |------------->|
3454// | | |
3455// | | |
3456// | | SubReq |
3457// | |------------->|
3458// | | |
3459// | | SubDelReq |
3460// | |------------->|
3461// | | |
3462// | | |
3463// | | SubDelReq |
3464// | |------------->|
3465// | | |
3466// | | |
3467// | | SubDelResp |
3468// | |<-------------|
3469// | RESTNotif | |
3470// | unsuccess | |
3471// |<----------------| |
3472// | | |
3473// | [SUBS DELETE] |
3474// | | |
3475//
3476//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003477
archaggeafbf95f2021-04-14 08:54:05 +03003478func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3479 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3480
3481 // Init counter check
3482 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003483 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003484 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003485 Counter{cSubReqToE2, 1},
3486 Counter{cSubReReqToE2, 1},
3487 Counter{cSubReqTimerExpiry, 2},
3488 Counter{cSubDelReqToE2, 1},
3489 Counter{cSubDelRespFromE2, 1},
3490 })
3491
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003492 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003493 restSubId := xappConn1.SendRESTSubsReq(t, params)
3494 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3495
3496 e2termConn1.RecvSubsReq(t)
3497 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3498
3499 e2termConn1.RecvSubsReq(t)
3500 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3501
3502 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003503 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003504 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003505 xappConn1.WaitRESTNotification(t, restSubId)
3506
3507 // Wait that subs is cleaned
3508 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
3509
3510 mainCtrl.VerifyCounterValues(t)
3511}
3512
3513func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3514 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3515
3516 // Init counter check
3517 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003518 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003519 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003520 Counter{cSubReqToE2, 1},
3521 Counter{cSubReReqToE2, 1},
3522 Counter{cSubReqTimerExpiry, 2},
3523 Counter{cSubDelReqToE2, 1},
3524 Counter{cSubDelReqTimerExpiry, 2},
3525 })
3526
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003527 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003528 restSubId := xappConn1.SendRESTSubsReq(t, params)
3529 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3530
3531 e2termConn1.RecvSubsReq(t)
3532 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3533
3534 e2termConn1.RecvSubsReq(t)
3535 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3536
3537 e2termConn1.RecvSubsDelReq(t)
3538 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3539
Markku Virtanen55d2a282021-06-04 14:46:56 +03003540 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003541 e2termConn1.RecvSubsDelReq(t)
3542 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3543
3544 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3545
3546 waitSubsCleanup(t, e2SubsId, 10)
3547
3548 mainCtrl.VerifyCounterValues(t)
3549
3550}
3551
3552//-----------------------------------------------------------------------------
3553// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3554//
3555// stub stub
3556// +-------+ +---------+ +---------+
3557// | xapp | | submgr | | e2term |
3558// +-------+ +---------+ +---------+
3559// | | |
3560// | RESTSubReq | |
3561// |---------------->| |
3562// | | |
3563// | RESTSubResp | |
3564// |<----------------| |
3565// | | SubReq |
3566// | |------------->|
3567// | | |
3568// | | |
3569// | | SubReq |
3570// | |------------->|
3571// | | |
3572// | | SubDelReq |
3573// | |------------->|
3574// | | |
3575// | | |
3576// | | SubDelReq |
3577// | |------------->|
3578// | | |
3579// | | |
3580// | | SubDelResp |
3581// | |<-------------|
3582// | RESTNotif | |
3583// | unsuccess | |
3584// |<----------------| |
3585// | | |
3586// | [SUBS DELETE] |
3587// | | |
3588//
3589//-----------------------------------------------------------------------------
3590func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3591 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3592
3593 // Init counter check
3594 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003595 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003596 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003597 Counter{cSubReqToE2, 1},
3598 Counter{cSubReReqToE2, 1},
3599 Counter{cSubReqTimerExpiry, 2},
3600 Counter{cSubDelReqToE2, 1},
3601 Counter{cSubDelReReqToE2, 1},
3602 Counter{cSubDelReqTimerExpiry, 2},
3603 })
3604
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003605 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003606 restSubId := xappConn1.SendRESTSubsReq(t, params)
3607 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3608
3609 e2termConn1.RecvSubsReq(t)
3610 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3611
3612 e2termConn1.RecvSubsReq(t)
3613 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3614
3615 e2termConn1.RecvSubsDelReq(t)
3616 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3617
Markku Virtanen55d2a282021-06-04 14:46:56 +03003618 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003619 e2termConn1.RecvSubsDelReq(t)
3620 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3621
3622 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3623
3624 waitSubsCleanup(t, e2SubsId, 10)
3625
3626 mainCtrl.VerifyCounterValues(t)
3627}
3628
3629//-----------------------------------------------------------------------------
3630// TestRESTSubReqSubFailRespInSubmgr
3631//
3632// stub stub
3633// +-------+ +---------+ +---------+
3634// | xapp | | submgr | | e2term |
3635// +-------+ +---------+ +---------+
3636// | | |
3637// | RESTSubReq | |
3638// |---------------->| |
3639// | | |
3640// | RESTSubResp | |
3641// |<----------------| |
3642// | | SubReq |
3643// | |------------->|
3644// | | |
3645// | | SubFail |
3646// | |<-------------|
3647// | | |
3648// | | SubDelReq |
3649// | |------------->|
3650// | | |
3651// | | SubDelResp |
3652// | |<-------------|
3653// | | |
3654// | RESTNotif | |
3655// | unsuccess | |
3656// |<----------------| |
3657// | | |
3658// | [SUBS DELETE] |
3659// | | |
3660//
3661//-----------------------------------------------------------------------------
3662func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3663 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3664
3665 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003666 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003667 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003668 Counter{cSubReqToE2, 1},
3669 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003670 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003671 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003672 })
3673
3674 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003675
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003676 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003677 restSubId := xappConn1.SendRESTSubsReq(t, params)
3678
3679 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3680 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3681 fparams1.Set(crereq1)
3682 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3683
3684 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003685 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003686 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3687 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3688 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
3689
3690 // REST subscription sill there to be deleted
3691 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3692
3693 // Wait that subs is cleaned
3694 waitSubsCleanup(t, e2SubsId, 10)
3695
3696 mainCtrl.VerifyCounterValues(t)
3697
3698}
3699
3700//-----------------------------------------------------------------------------
3701// TestRESTSubDelReqRetryInSubmgr
3702//
3703// stub stub
3704// +-------+ +---------+ +---------+
3705// | xapp | | submgr | | e2term |
3706// +-------+ +---------+ +---------+
3707// | | |
3708// | [SUBS CREATE] |
3709// | | |
3710// | | |
3711// | RESTSubDelReq | |
3712// |---------------->| |
3713// | | |
3714// | RESTSubDelResp | |
3715// |<----------------| |
3716// | | SubDelReq |
3717// | |------------->|
3718// | | |
3719// | | SubDelReq |
3720// | |------------->|
3721// | | |
3722// | | SubDelResp |
3723// | |<-------------|
3724// | | |
3725//
3726//-----------------------------------------------------------------------------
3727func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3728 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3729
3730 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003731 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003732 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003733 Counter{cSubReqToE2, 1},
3734 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003735 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003736 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003737 Counter{cSubDelReqToE2, 1},
3738 Counter{cSubDelReReqToE2, 1},
3739 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003740 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003741 })
3742 // Req
3743 var params *teststube2ap.RESTSubsReqParams = nil
3744 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3745
3746 // Del
3747 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3748
3749 // E2t: Receive 1st SubsDelReq
3750 e2termConn1.RecvSubsDelReq(t)
3751
3752 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3753 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3754 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3755
3756 //Wait that subs is cleaned
3757 waitSubsCleanup(t, e2SubsId, 10)
3758
3759 mainCtrl.VerifyCounterValues(t)
3760}
3761
3762//-----------------------------------------------------------------------------
3763// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3764//
3765// stub stub
3766// +-------+ +---------+ +---------+
3767// | xapp | | submgr | | e2term |
3768// +-------+ +---------+ +---------+
3769// | | |
3770// | [SUBS CREATE] |
3771// | | |
3772// | | |
3773// | RESTSubDelReq | |
3774// |---------------->| |
3775// | | |
3776// | RESTSubDelResp | |
3777// |<----------------| |
3778// | | SubDelReq |
3779// | |------------->|
3780// | | |
3781// | | SubDelReq |
3782// | |------------->|
3783// | | |
3784// | | |
3785//
3786//-----------------------------------------------------------------------------
3787func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3788 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3789
3790 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003791 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003792 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003793 Counter{cSubReqToE2, 1},
3794 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003795 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003796 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003797 Counter{cSubDelReqToE2, 1},
3798 Counter{cSubDelReReqToE2, 1},
3799 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003800 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003801 })
3802
3803 // Req
3804 var params *teststube2ap.RESTSubsReqParams = nil
3805 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3806
3807 // Del
3808 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3809
3810 // E2t: Receive 1st SubsDelReq
3811 e2termConn1.RecvSubsDelReq(t)
3812
3813 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3814 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3815 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3816
3817 //Wait that subs is cleaned
3818 waitSubsCleanup(t, e2SubsId, 10)
3819
3820 mainCtrl.VerifyCounterValues(t)
3821}
3822
3823//-----------------------------------------------------------------------------
3824// TestRESTSubDelReqSubDelFailRespInSubmgr
3825//
3826// stub stub
3827// +-------+ +---------+ +---------+
3828// | xapp | | submgr | | e2term |
3829// +-------+ +---------+ +---------+
3830// | | |
3831// | [SUBS CREATE] |
3832// | | |
3833// | | |
3834// | RESTSubDelReq | |
3835// |---------------->| |
3836// | | |
3837// | RESTSubDelResp | |
3838// |<----------------| |
3839// | | SubDelReq |
3840// | |------------->|
3841// | | |
3842// | | SubDelFail |
3843// | |<-------------|
3844// | | |
3845//
3846//-----------------------------------------------------------------------------
3847func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3848 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3849
3850 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003851 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003852 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003853 Counter{cSubReqToE2, 1},
3854 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003855 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003856 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003857 Counter{cSubDelReqToE2, 1},
3858 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003859 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003860 })
3861
3862 // Req
3863 var params *teststube2ap.RESTSubsReqParams = nil
3864 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3865
3866 // Del
3867 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3868
3869 // E2t: Send receive SubsDelReq and send SubsDelFail
3870 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3871 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3872
3873 //Wait that subs is cleaned
3874 waitSubsCleanup(t, e2SubsId, 10)
3875
3876 mainCtrl.VerifyCounterValues(t)
3877}
3878
3879//-----------------------------------------------------------------------------
3880// TestRESTSubReqAndSubDelOkSameAction
3881//
3882// stub stub
3883// +-------+ +-------+ +---------+ +---------+
3884// | xapp2 | | xapp1 | | submgr | | e2term |
3885// +-------+ +-------+ +---------+ +---------+
3886// | | | |
3887// | | RESTSubReq1 | |
3888// | |---------------->| |
3889// | | | |
3890// | | RESTSubResp1 | |
3891// | |<----------------| |
3892// | | | |
3893// | | | SubReq1 |
3894// | | |------------->|
3895// | | | SubResp1 |
3896// | | |<-------------|
3897// | | RESTNotif1 | |
3898// | |<----------------| |
3899// | | | |
3900// | RESTSubReq2 | |
3901// |------------------------------>| |
3902// | | | |
3903// | RESTSubResp2 | |
3904// |<------------------------------| |
3905// | | | |
3906// | | RESTNotif2 | |
3907// |<------------------------------| |
3908// | | | |
3909// | | RESTSubDelReq1 | |
3910// | |---------------->| |
3911// | | | |
3912// | | RESTSubDelResp1 | |
3913// | |<----------------| |
3914// | | | |
3915// | RESTSubDelReq2 | |
3916// |------------------------------>| |
3917// | | | |
3918// | RESTSubDelResp2 | |
3919// |<------------------------------| |
3920// | | | |
3921// | | | SubDelReq2 |
3922// | | |------------->|
3923// | | | |
3924// | | | SubDelResp2 |
3925// | | |<-------------|
3926// | | | |
3927//
3928//-----------------------------------------------------------------------------
3929func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3930 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3931
3932 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003933 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003934 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003935 Counter{cSubReqToE2, 1},
3936 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003937 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003938 Counter{cMergedSubscriptions, 1},
3939 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003940 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003941 Counter{cSubDelReqToE2, 1},
3942 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003943 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003944 })
3945
3946 // Req1
3947 var params *teststube2ap.RESTSubsReqParams = nil
3948
3949 //Subs Create
3950 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3951 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3952
3953 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003954 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003955 params.SetMeid("RAN_NAME_1")
3956
3957 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003958 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003959 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003960 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003961 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003962 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003963 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03003964 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3965
3966 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3967
3968 // Del1
3969 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3970
3971 // Del2
3972 deleteXapp2Subscription(t, &restSubId2)
3973
3974 //Wait that subs is cleaned
3975 waitSubsCleanup(t, e2SubsId2, 10)
3976
3977 mainCtrl.VerifyCounterValues(t)
3978}
3979
3980//-----------------------------------------------------------------------------
3981// TestSubReqAndSubDelOkSameActionParallel
3982//
3983// stub stub stub
3984// +-------+ +-------+ +---------+ +---------+
3985// | xapp2 | | xapp1 | | submgr | | e2term |
3986// +-------+ +-------+ +---------+ +---------+
3987// | | | |
3988// | | | |
3989// | | | |
3990// | | SubReq1 | |
3991// | |------------->| |
3992// | | | |
3993// | | | SubReq1 |
3994// | | |------------->|
3995// | SubReq2 | |
3996// |--------------------------->| |
3997// | | | SubResp1 |
3998// | | |<-------------|
3999// | | SubResp1 | |
4000// | |<-------------| |
4001// | | | SubReq2 |
4002// | | |------------->|
4003// | | | |
4004// | | | SubResp2 |
4005// | | |<-------------|
4006// | SubResp2 | |
4007// |<---------------------------| |
4008// | | | |
4009// | | SubDelReq 1 | |
4010// | |------------->| |
4011// | | | |
4012// | | SubDelResp 1 | |
4013// | |<-------------| |
4014// | | | |
4015// | SubDelReq 2 | |
4016// |--------------------------->| |
4017// | | | |
4018// | | | SubDelReq 2 |
4019// | | |------------->|
4020// | | | |
4021// | | | SubDelReq 2 |
4022// | | |------------->|
4023// | | | |
4024// | SubDelResp 2 | |
4025// |<---------------------------| |
4026//
4027func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4028 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4029
4030 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004031 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004032 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004033 Counter{cSubReqToE2, 2},
4034 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004035 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004036 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004037 Counter{cSubDelReqToE2, 2},
4038 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004039 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004040 })
4041
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004042 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004043 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4044 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4045
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004046 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004047 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4048
4049 xappConn1.ExpectRESTNotification(t, restSubId1)
4050 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4051 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4052
4053 xappConn2.ExpectRESTNotification(t, restSubId2)
4054 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4055 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4056 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4057
4058 // Del1
4059 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4060 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4061 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4062 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4063
4064 // Del2
4065 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4066 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4067 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4068
4069 waitSubsCleanup(t, e2SubsId2, 10)
4070
4071 mainCtrl.VerifyCounterValues(t)
4072}
4073
4074//-----------------------------------------------------------------------------
4075// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4076//
4077// stub stub stub
4078// +-------+ +-------+ +---------+ +---------+
4079// | xapp2 | | xapp1 | | submgr | | e2term |
4080// +-------+ +-------+ +---------+ +---------+
4081// | | | |
4082// | | | |
4083// | | | |
4084// | | RESTSubReq1 | |
4085// | |---------------->| |
4086// | | | |
4087// | | RESTSubResp1 | |
4088// | |<----------------| |
4089// | | | SubReq1 |
4090// | | |------------->|
4091// | RESTSubReq2 | |
4092// |------------------------------>| |
4093// | | | |
4094// | RESTSubDelResp2 | |
4095// |<------------------------------| |
4096// | | | SubReq1 |
4097// | | |------------->|
4098// | | | |
4099// | | | |
4100// | | | SubDelReq |
4101// | | |------------->|
4102// | | | |
4103// | | | SubDelResp |
4104// | | |<-------------|
4105// | | RESTNotif1 | |
4106// | | unsuccess | |
4107// | |<----------------| |
4108// | RESTNotif2 | |
4109// | | unsuccess | |
4110// |<------------------------------| |
4111// | | | |
4112// | | RESTSubDelReq1 | |
4113// | |---------------->| |
4114// | | | |
4115// | | RESTSubDelResp1 | |
4116// | |<----------------| |
4117// | | | |
4118// | RESTSubDelReq2 | |
4119// |------------------------------>| |
4120// | | | |
4121// | RESTSubDelResp2 | |
4122// |<------------------------------| |
4123//
4124//-----------------------------------------------------------------------------
4125func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4126 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4127
4128 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004129 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004130 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004131 Counter{cSubReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004132 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004133 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004134 Counter{cSubDelReqToE2, 1},
4135 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004136 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004137 })
4138
4139 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004140
4141 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004142 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004143 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4144 crereq1, _ := e2termConn1.RecvSubsReq(t)
4145
4146 // Req2
4147 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004148 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004149 params2.SetMeid("RAN_NAME_1")
4150 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4151 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4152
4153 //Req1 (retransmitted)
4154 e2termConn1.RecvSubsReq(t)
4155
4156 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004157
4158 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004159 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4160
Markku Virtanenda34eec2021-05-20 08:22:04 +00004161 e2SubsIdA := <-xappConn1.ListedRESTNotifications
4162 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
4163 e2SubsIdB := <-xappConn1.ListedRESTNotifications
4164 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004165
4166 // Del1
4167 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4168
4169 // Del2
4170 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4171
Markku Virtanenda34eec2021-05-20 08:22:04 +00004172 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4173
archaggeafbf95f2021-04-14 08:54:05 +03004174 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004175 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004176
4177 mainCtrl.VerifyCounterValues(t)
4178}
4179
4180//-----------------------------------------------------------------------------
4181// TestRESTSubReqAndSubDelNokSameActionParallel
4182//
4183// stub stub stub
4184// +-------+ +-------+ +---------+ +---------+
4185// | xapp2 | | xapp1 | | submgr | | e2term |
4186// +-------+ +-------+ +---------+ +---------+
4187// | | | |
4188// | | | |
4189// | | | |
4190// | | RESTSubReq1 | |
4191// | |---------------->| |
4192// | | | |
4193// | | RESTSubResp1 | |
4194// | |<----------------| |
4195// | | | SubReq1 |
4196// | | |------------->|
4197// | RESTSubReq2 | |
4198// |------------------------------>| |
4199// | | | |
4200// | RESTSubDelResp2 | |
4201// |<------------------------------| |
4202// | | | SubFail1 |
4203// | | |<-------------|
4204// | | | |
4205// | | RESTNotif1 | |
4206// | | unsuccess | |
4207// | |<----------------| |
4208// | RESTNotif2 | |
4209// | | unsuccess | |
4210// |<------------------------------| |
4211// | | | SubDelReq |
4212// | | |------------->|
4213// | | | SubDelResp |
4214// | | |<-------------|
4215// | | | |
4216// | | RESTSubDelReq1 | |
4217// | |---------------->| |
4218// | | | |
4219// | | RESTSubDelResp1 | |
4220// | |<----------------| |
4221// | | | |
4222// | RESTSubDelReq2 | |
4223// |------------------------------>| |
4224// | | | |
4225// | RESTSubDelResp2 | |
4226// |<------------------------------| |
4227//
4228//-----------------------------------------------------------------------------
4229func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4230 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4231
4232 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004233 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004234 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004235 Counter{cSubReqToE2, 1},
4236 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004237 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004238 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004239 Counter{cSubDelReqToE2, 1},
4240 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004241 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004242 })
4243
4244 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004245
4246 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004247 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004248 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4249 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4250
4251 // Req2
4252 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004253 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004254 params2.SetMeid("RAN_NAME_1")
4255 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4256 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4257
4258 // E2t: send SubsFail (first)
4259 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4260 fparams1.Set(crereq1)
4261 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4262
4263 // E2t: internal delete
4264 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4265 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4266 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4267
4268 e2SubsIdA := <-xappConn1.ListedRESTNotifications
4269 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
4270 e2SubsIdB := <-xappConn1.ListedRESTNotifications
4271 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
4272
4273 // Del1
4274 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4275
4276 // Del2
4277 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4278
4279 //Wait that subs is cleaned
4280 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4281 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4282
4283 mainCtrl.VerifyCounterValues(t)
4284}
4285
4286func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4287 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4288
4289 // Init counter check
4290 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004291 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004292 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004293 Counter{cSubReqToE2, 1},
4294 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004295 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004296 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004297 Counter{cSubDelReqToE2, 1},
4298 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004299 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004300 })
4301
4302 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004303
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004304 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004305 restSubId := xappConn1.SendRESTSubsReq(t, params)
4306 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
4307
4308 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4309 xappConn1.ExpectRESTNotification(t, restSubId)
4310 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4311 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4312 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
4313
4314 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4315 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4316 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4317
4318 // Wait that subs is cleaned
4319 waitSubsCleanup(t, e2SubsId, 10)
4320 mainCtrl.VerifyCounterValues(t)
4321}
4322
4323//-----------------------------------------------------------------------------
4324// TestRESTSubReqPolicyChangeAndSubDelOk
4325//
4326// stub stub
4327// +-------+ +---------+ +---------+
4328// | xapp | | submgr | | e2term |
4329// +-------+ +---------+ +---------+
4330// | | |
4331// | RESTSubReq | |
4332// |---------------->| |
4333// | | |
4334// | RESTSubResp | |
4335// |<----------------| |
4336// | | SubReq |
4337// | |------------->|
4338// | | |
4339// | | SubResp |
4340// | |<-------------|
4341// | | |
4342// | RESTNotif | |
4343// |<----------------| |
4344// | | |
4345// | RESTSubReq | |
4346// |---------------->| |
4347// | | |
4348// | RESTSubResp | |
4349// |<----------------| |
4350// | | SubReq |
4351// | |------------->|
4352// | | |
4353// | | SubResp |
4354// | |<-------------|
4355// | | |
4356// | RESTNotif | |
4357// |<----------------| |
4358// | | |
4359// | RESTSubDelReq | |
4360// |---------------->| |
4361// | | |
4362// | | SubDelReq |
4363// | |------------->|
4364// | | |
4365// | | SubDelResp |
4366// | |<-------------|
4367// | | |
4368// | RESTSubDelResp | |
4369// |<----------------| |
4370//
4371//-----------------------------------------------------------------------------
4372func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4373 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4374
4375 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004376 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004377 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004378 Counter{cSubReqToE2, 2},
4379 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004380 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004381 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004382 Counter{cSubDelReqToE2, 1},
4383 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004384 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004385 })
4386
4387 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004388
4389 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004390 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004391 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4392
4393 // Policy change
archaggeafbf95f2021-04-14 08:54:05 +03004394 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004395
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004396 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004397 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004398 params.SetTimeToWait("w200ms")
4399 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4400
4401 // Del
4402 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4403
4404 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4405 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4406
4407 // Wait that subs is cleaned
4408 waitSubsCleanup(t, e2SubsId, 10)
4409 mainCtrl.VerifyCounterValues(t)
4410}
4411
4412//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004413// TestRESTSubReqPolicyChangeNOk
4414//
4415// stub stub
4416// +-------+ +---------+ +---------+
4417// | xapp | | submgr | | e2term |
4418// +-------+ +---------+ +---------+
4419// | | |
4420// | RESTSubReq | |
4421// |---------------->| |
4422// | | |
4423// | RESTSubResp | |
4424// |<----------------| |
4425// | | SubReq |
4426// | |------------->|
4427// | | |
4428// | | SubResp |
4429// | |<-------------|
4430// | | |
4431// | RESTNotif | |
4432// |<----------------| |
4433// | | |
4434// | RESTSubReq | |
4435// |---------------->| |
4436// | | |
4437// | RESTSubUpdateFail |
4438// | | |
4439// | RESTSubDelReq | |
4440// |---------------->| |
4441// | | |
4442// | | SubDelReq |
4443// | |------------->|
4444// | | |
4445// | | SubDelResp |
4446// | |<-------------|
4447// | | |
4448// | RESTSubDelResp | |
4449// |<----------------| |
4450//
4451//-----------------------------------------------------------------------------
4452func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4453 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4454
4455 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4456 Counter{cRestSubReqFromXapp, 2},
4457 Counter{cRestSubRespToXapp, 1},
4458 Counter{cSubReqToE2, 1},
4459 Counter{cSubRespFromE2, 1},
4460 Counter{cRestSubNotifToXapp, 1},
4461 Counter{cRestSubFailToXapp, 1},
4462 Counter{cRestSubDelReqFromXapp, 1},
4463 Counter{cSubDelReqToE2, 1},
4464 Counter{cSubDelRespFromE2, 1},
4465 Counter{cRestSubDelRespToXapp, 1},
4466 })
4467
4468 const subReqCount int = 1
4469
4470 // Req
4471 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4472 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4473
4474 // Policy change
4475
4476 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4477
4478 restSubIdUpd := strings.ToUpper(restSubId)
4479 params.SetSubscriptionID(&restSubIdUpd)
4480 params.SetTimeToWait("w200ms")
4481
4482 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4483 assert.Equal(t, restSubId2, "")
4484
4485 // Del
4486 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4487
4488 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4489 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4490
4491 // Wait that subs is cleaned
4492 waitSubsCleanup(t, e2SubsId, 10)
4493 mainCtrl.VerifyCounterValues(t)
4494}
4495
4496//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004497// TestRESTSubReqAndSubDelOkTwoE2termParallel
4498//
4499// stub stub stub
4500// +-------+ +---------+ +---------+ +---------+
4501// | xapp | | submgr | | e2term1 | | e2term2 |
4502// +-------+ +---------+ +---------+ +---------+
4503// | | | |
4504// | | | |
4505// | | | |
4506// | RESTSubReq1 | | |
4507// |---------------->| | |
4508// | | | |
4509// | RESTSubResp1 | | |
4510// |<----------------| | |
4511// | | SubReq1 | |
4512// | |------------->| |
4513// | | | |
4514// | RESTSubReq2 | | |
4515// |---------------->| | |
4516// | | | |
4517// | RESTSubResp2 | | |
4518// |<----------------| | |
4519// | | SubReq2 | |
4520// | |---------------------------->|
4521// | | | |
4522// | | SubResp1 | |
4523// | |<-------------| |
4524// | RESTNotif1 | | |
4525// |<----------------| | |
4526// | | SubResp2 | |
4527// | |<----------------------------|
4528// | RESTNotif2 | | |
4529// |<----------------| | |
4530// | | | |
4531// | [SUBS 1 DELETE] | |
4532// | | | |
4533// | [SUBS 2 DELETE] | |
4534// | | | |
4535//
4536//-----------------------------------------------------------------------------
4537func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4538 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4539
4540 // Init counter check
4541 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004542 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004543 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004544 Counter{cSubReqToE2, 2},
4545 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004546 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004547 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004548 Counter{cSubDelReqToE2, 2},
4549 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004550 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004551 })
4552
4553 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004554
4555 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004556 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004557 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4558 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4559
4560 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004561 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004562 params.SetMeid("RAN_NAME_11")
4563 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4564 // would not work as notification would not be received
4565 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4566 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4567
4568 // Resp1
4569 xappConn1.ExpectRESTNotification(t, restSubId1)
4570 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4571 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4572 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
4573
4574 // Resp2
4575 xappConn2.ExpectRESTNotification(t, restSubId2)
4576 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4577 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4578 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
4579
4580 // Delete1
4581 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4582 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4583 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4584
4585 // Wait that subs is cleaned
4586 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4587
4588 // Delete2
4589 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4590 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4591 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4592
4593 // Wait that subs is cleaned
4594 waitSubsCleanup(t, e2SubsId2, 10)
4595
4596 mainCtrl.VerifyCounterValues(t)
4597}
4598
4599//-----------------------------------------------------------------------------
4600// TestRESTSubReqAsn1EncodeFail
4601//
4602// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4603// stub stub
4604// +-------+ +---------+ +---------+
4605// | xapp | | submgr | | e2term |
4606// +-------+ +---------+ +---------+
4607// | | |
4608// | RESTSubReq | |
4609// |---------------->| |
4610// | | |
4611// | RESTSubResp | |
4612// |<----------------| |
4613// | RESTSubDelReq | |
4614// |---------------->| |
4615// | RESTSubDelResp | |
4616// | unsuccess | |
4617// |<----------------| |
4618// | | |
4619//
4620//-----------------------------------------------------------------------------
4621func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4622 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4623
4624 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
4625
4626}
4627
4628//-----------------------------------------------------------------------------
4629// TestRESTSubReqInsertAndSubDelOk
4630//
4631// stub stub
4632// +-------+ +---------+ +---------+
4633// | xapp | | submgr | | e2term |
4634// +-------+ +---------+ +---------+
4635// | | |
4636// | RestSubReq | |
4637// |---------------->| |
4638// | | |
4639// | RESTSubResp | |
4640// |<----------------| |
4641// | | |
4642// | | SubReq |
4643// | |------------->|
4644// | | |
4645// | | SubResp |
4646// | |<-------------|
4647// | RESTNotif | |
4648// |<----------------| |
4649// | ... | ... |
4650// | | |
4651// | RESTSubDelReq | |
4652// |---------------->| |
4653// | | |
4654// | | SubDelReq |
4655// | |------------->|
4656// | | |
4657// | | SubDelResp |
4658// | |<-------------|
4659// | | |
4660// | RESTSubDelResp| |
4661// |<----------------| |
4662//
4663//-----------------------------------------------------------------------------
4664func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4665 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4666
4667 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004668 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004669 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004670 Counter{cSubReqToE2, 1},
4671 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004672 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004673 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004674 Counter{cSubDelReqToE2, 1},
4675 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004676 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004677 })
4678
4679 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004680
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004681 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004682 params.SetSubActionTypes("insert")
4683
4684 // Req
4685 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4686
4687 // Del
4688 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4689
4690 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4691 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4692
4693 // Wait that subs is cleaned
4694 waitSubsCleanup(t, e2SubsId, 10)
4695 mainCtrl.VerifyCounterValues(t)
4696}
4697
4698//-----------------------------------------------------------------------------
4699// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4700//
4701// stub stub
4702// +-------+ +---------+ +---------+
4703// | xapp | | submgr | | e2term |
4704// +-------+ +---------+ +---------+
4705// | | |
4706// | RESTSubReq | |
4707// |------------->| |
4708// | | |
4709// | | SubReq |
4710// | |------------->|
4711// | | |
4712// | | SubResp |
4713// | <----|
4714// | |
4715// | Submgr restart |
4716// | |
4717// | | |
4718// | | SubDelReq |
4719// | |------------->|
4720// | | |
4721// | | SubDelResp |
4722// | |<-------------|
4723// | | |
4724//
4725//-----------------------------------------------------------------------------
4726func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4727 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4728
4729 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004730 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004731 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004732 Counter{cSubReqToE2, 1},
4733 Counter{cSubDelReqFromXapp, 1},
4734 Counter{cSubDelReqToE2, 1},
4735 Counter{cSubDelRespFromE2, 1},
4736 })
4737
4738 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004739
4740 // Remove possible existing subscription
4741 mainCtrl.removeExistingSubscriptions(t)
4742
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004743 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004744
4745 //Req
4746 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
4747 restSubId := xappConn1.SendRESTSubsReq(t, params)
4748 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4749
4750 e2termConn1.RecvSubsReq(t)
4751
4752 mainCtrl.SetResetTestFlag(t, false)
4753
4754 mainCtrl.SimulateRestart(t)
4755 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4756
4757 //Del
4758 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4759 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4760
4761 xappConn1.TestMsgChanEmpty(t)
4762 xappConn2.TestMsgChanEmpty(t)
4763 e2termConn1.TestMsgChanEmpty(t)
4764 mainCtrl.wait_registry_empty(t, 10)
4765
4766 mainCtrl.VerifyCounterValues(t)
4767}
4768
4769//-----------------------------------------------------------------------------
4770// TestRESTSubReqAndSubDelOkWithRestartInMiddle
4771//
4772// stub stub
4773// +-------+ +---------+ +---------+
4774// | xapp | | submgr | | e2term |
4775// +-------+ +---------+ +---------+
4776// | | |
4777// | RESTSubReq | |
4778// |---------------->| |
4779// | | |
4780// | RESTSubResp | |
4781// |<----------------| |
4782// | | SubReq |
4783// | |------------->|
4784// | | |
4785// | | SubResp |
4786// | |<-------------|
4787// | | |
4788// | RESTNotif | |
4789// |<----------------| |
4790// | | |
4791// | |
4792// | Submgr restart |
4793// | | |
4794// | RESTSubDelReq | |
4795// |---------------->| |
4796// | | |
4797// | | SubDelReq |
4798// | |------------->|
4799// | | |
4800// | | SubDelResp |
4801// | |<-------------|
4802// | | |
4803// | RESTSubDelResp | |
4804// |<----------------| |
4805//
4806//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004807
archaggeafbf95f2021-04-14 08:54:05 +03004808func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4809 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4810
4811 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004812 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004813 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004814 Counter{cSubReqToE2, 1},
4815 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004816 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004817 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004818 Counter{cSubDelReqToE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004819 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004820 })
4821
4822 // Remove possible existing subscription
4823 mainCtrl.removeExistingSubscriptions(t)
4824
4825 var params *teststube2ap.RESTSubsReqParams = nil
4826
4827 // Create subscription
4828 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4829 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4830
4831 // Check subscription
4832 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4833
4834 // When SDL support for the REST Interface is added
4835 // the submgr restart statement below should be removed
4836 // from the comment.
4837
4838 // mainCtrl.SimulateRestart(t)
4839 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4840
4841 // Check subscription
4842 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4843
4844 // Delete subscription
4845 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4846
4847 //Wait that subs is cleaned
4848 waitSubsCleanup(t, e2SubsId, 10)
4849
4850 mainCtrl.VerifyCounterValues(t)
4851}
4852
4853//-----------------------------------------------------------------------------
4854// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4855//
4856// stub stub
4857// +-------+ +-------+ +---------+ +---------+
4858// | xapp2 | | xapp1 | | submgr | | e2term |
4859// +-------+ +-------+ +---------+ +---------+
4860// | | | |
4861// | | RESTSubReq1 | |
4862// | |---------------->| |
4863// | | | |
4864// | | RESTSubResp1 | |
4865// | |<----------------| |
4866// | | | |
4867// | | | SubReq1 |
4868// | | |------------->|
4869// | | | SubResp1 |
4870// | | |<-------------|
4871// | | RESTNotif1 | |
4872// | |<----------------| |
4873// | | | |
4874// | RESTSubReq2 | |
4875// |------------------------------>| |
4876// | | | |
4877// | RESTSubResp2 | |
4878// |<------------------------------| |
4879// | | | |
4880// | | RESTNotif2 | |
4881// |<------------------------------| |
4882// | | | |
4883// | | Submgr restart |
4884// | | | |
4885// | | RESTSubDelReq1 | |
4886// | |---------------->| |
4887// | | | |
4888// | | RESTSubDelResp1 | |
4889// | |<----------------| |
4890// | | | |
4891// | | Submgr restart |
4892// | | | |
4893// | RESTSubDelReq2 | |
4894// |------------------------------>| |
4895// | | | |
4896// | RESTSubDelResp2 | |
4897// |<------------------------------| |
4898// | | | |
4899// | | | SubDelReq2 |
4900// | | |------------->|
4901// | | | |
4902// | | | SubDelResp2 |
4903// | | |<-------------|
4904// | | | |
4905//
4906//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00004907
archaggeafbf95f2021-04-14 08:54:05 +03004908func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4909 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4910
4911 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004912 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004913 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004914 Counter{cSubReqToE2, 1},
4915 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004916 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004917 Counter{cMergedSubscriptions, 1},
4918 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004919 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004920 Counter{cSubDelReqToE2, 1},
4921 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004922 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004923 })
4924
4925 // Remove possible existing subscription
4926 mainCtrl.removeExistingSubscriptions(t)
4927
4928 var params *teststube2ap.RESTSubsReqParams = nil
4929
4930 // Create subscription 1
4931 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4932 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4933
4934 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004935 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004936 params.SetMeid("RAN_NAME_1")
4937 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004938 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03004939 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4940 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004941 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03004942 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4943
4944 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4945
4946 // When SDL support for the REST Interface is added
4947 // the submgr restart statement below should be removed
4948 // from the comment.
4949
4950 // mainCtrl.SimulateRestart(t)
4951 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4952
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004953 // Delete subscription 1, and wait until it has removed the first endpoint
4954 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004955 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004956 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004957
4958 // When SDL support for the REST Interface is added
4959 // the submgr restart statement below should be removed
4960 // from the comment.
4961
4962 // mainCtrl.SimulateRestart(t)
4963 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004964 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4965
4966 // Delete subscription 2
4967 deleteXapp2Subscription(t, &restSubId2)
4968
4969 //Wait that subs is cleaned
4970 waitSubsCleanup(t, e2SubsId2, 10)
4971
4972 mainCtrl.VerifyCounterValues(t)
4973}
4974
4975//-----------------------------------------------------------------------------
4976// TestRESTReportSubReqAndSubDelOk
4977//
4978// stub stub
4979// +-------+ +---------+ +---------+
4980// | xapp | | submgr | | e2term |
4981// +-------+ +---------+ +---------+
4982// | | |
4983// | RestSubReq | |
4984// |---------------->| |
4985// | | |
4986// | RESTSubResp | |
4987// |<----------------| |
4988// | | |
4989// | | SubReq |
4990// | |------------->|
4991// | | |
4992// | | SubResp |
4993// | |<-------------|
4994// | RESTNotif | |
4995// |<----------------| |
4996// | | SubReq |
4997// | |------------->|
4998// | | |
4999// | | SubResp |
5000// | |<-------------|
5001// | RESTNotif | |
5002// |<----------------| |
5003// | ... | ... |
5004// | | |
5005// | | |
5006// | RESTSubDelReq | |
5007// |---------------->| |
5008// | | |
5009// | | SubDelReq |
5010// | |------------->|
5011// | | |
5012// | | SubDelResp |
5013// | |<-------------|
5014// | | |
5015// | RESTSubDelResp| |
5016// |<----------------| |
5017//
5018//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005019
archaggeafbf95f2021-04-14 08:54:05 +03005020func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5021 CaseBegin("TestRESTReportSubReqAndSubDelOk")
5022 subReqCount := 1
archaggeafbf95f2021-04-14 08:54:05 +03005023 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005024 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005025}
5026
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005027func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
5028 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005029
5030 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005031 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005032 restSubId := xappConn1.SendRESTSubsReq(t, params)
5033
5034 var e2SubsId []uint32
5035 for i := 0; i < subReqCount; i++ {
5036 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5037 xappConn1.ExpectRESTNotification(t, restSubId)
5038
5039 e2termConn1.SendSubsResp(t, crereq, cremsg)
5040 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5041 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5042 e2SubsId = append(e2SubsId, instanceId)
5043 resp, _ := xapp.Subscription.QuerySubscriptions()
5044 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5045 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5046 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5047
5048 }
5049
5050 // Del
5051 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5052
5053 for i := 0; i < subReqCount; i++ {
5054 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5055 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5056 }
5057
5058 // Wait that subs is cleaned
5059 for i := 0; i < subReqCount; i++ {
5060 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5061 }
5062
5063 xappConn1.TestMsgChanEmpty(t)
5064 e2termConn1.TestMsgChanEmpty(t)
5065 mainCtrl.wait_registry_empty(t, 10)
5066}
5067
5068/*
5069func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
5070 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5071
5072 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005073 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005074 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005075
5076 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005077 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005078 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005079}
5080*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005081func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
5082 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005083
5084 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005085 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005086 restSubId := xappConn1.SendRESTSubsReq(t, params)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005087 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005088 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
5089
5090 var e2SubsId []uint32
5091 for i := 0; i < subReqCount; i++ {
5092 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5093 xappConn1.ExpectRESTNotification(t, restSubId)
5094 e2termConn1.SendSubsResp(t, crereq, cremsg)
5095 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5096 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5097 e2SubsId = append(e2SubsId, instanceId)
5098 }
5099
5100 // Del
5101 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5102
5103 for i := 0; i < subReqCount; i++ {
5104 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5105 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5106 }
5107
5108 // Wait that subs is cleaned
5109 for i := 0; i < subReqCount; i++ {
5110 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5111 }
5112 xappConn1.TestMsgChanEmpty(t)
5113 e2termConn1.TestMsgChanEmpty(t)
5114 mainCtrl.wait_registry_empty(t, 10)
5115}
5116
archaggeafbf95f2021-04-14 08:54:05 +03005117func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5118
5119 subReqCount := 2
5120
5121 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005122 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005123 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005124 Counter{cSubReqToE2, 2},
5125 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005126 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005127 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005128 Counter{cSubDelReqToE2, 2},
5129 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005130 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005131 })
5132
5133 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005134 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005135 restSubId := xappConn1.SendRESTSubsReq(t, params)
5136 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5137
5138 assert.Equal(t, len(e2SubsIds), 2)
5139
5140 // Del
5141 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5142 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5143
5144 xappConn1.TestMsgChanEmpty(t)
5145 e2termConn1.TestMsgChanEmpty(t)
5146 mainCtrl.wait_registry_empty(t, 10)
5147
5148 mainCtrl.VerifyCounterValues(t)
5149}
archaggeafbf95f2021-04-14 08:54:05 +03005150func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5151
5152 subReqCount := 19
5153
5154 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005155 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005156 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005157 Counter{cSubReqToE2, 19},
5158 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005159 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005160 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005161 Counter{cSubDelReqToE2, 19},
5162 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005163 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005164 })
5165
5166 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005167 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005168 restSubId := xappConn1.SendRESTSubsReq(t, params)
5169 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5170
5171 assert.Equal(t, len(e2SubsIds), 19)
5172
5173 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5174 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5175
5176 xappConn1.TestMsgChanEmpty(t)
5177 e2termConn1.TestMsgChanEmpty(t)
5178 mainCtrl.wait_registry_empty(t, 10)
5179
5180 mainCtrl.VerifyCounterValues(t)
5181}
archaggeafbf95f2021-04-14 08:54:05 +03005182func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5183
5184 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005185
5186 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005187 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005188 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005189 Counter{cSubReqToE2, uint64(subReqCount)},
5190 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005191 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005192 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005193 Counter{cSubDelReqToE2, uint64(subReqCount)},
5194 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005195 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005196 })
5197
5198 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005199 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005200 restSubId := xappConn1.SendRESTSubsReq(t, params)
5201 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5202
5203 assert.Equal(t, len(e2SubsIds), subReqCount)
5204
5205 // Del
5206 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5207 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5208
5209 xappConn1.TestMsgChanEmpty(t)
5210 e2termConn1.TestMsgChanEmpty(t)
5211 mainCtrl.wait_registry_empty(t, 10)
5212
5213 mainCtrl.VerifyCounterValues(t)
5214}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005215
archaggeafbf95f2021-04-14 08:54:05 +03005216func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5217
5218 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005219
5220 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005221 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005222 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005223 Counter{cSubReqToE2, uint64(subReqCount)},
5224 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005225 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005226 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005227 Counter{cSubDelReqToE2, uint64(subReqCount)},
5228 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005229 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005230 })
5231
5232 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005233 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005234 restSubId := xappConn1.SendRESTSubsReq(t, params)
5235 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5236
5237 assert.Equal(t, len(e2SubsIds), subReqCount)
5238
5239 // Del
5240 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5241 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5242
5243 xappConn1.TestMsgChanEmpty(t)
5244 e2termConn1.TestMsgChanEmpty(t)
5245 mainCtrl.wait_registry_empty(t, 10)
5246
5247 mainCtrl.VerifyCounterValues(t)
5248}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005249
archaggeafbf95f2021-04-14 08:54:05 +03005250func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5251
5252 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005253
5254 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005255 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005256 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005257 Counter{cSubReqToE2, uint64(subReqCount)},
5258 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005259 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005260 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005261 Counter{cSubDelReqToE2, uint64(subReqCount)},
5262 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005263 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005264 })
5265
5266 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005267 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005268 restSubId := xappConn1.SendRESTSubsReq(t, params)
5269 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5270
5271 assert.Equal(t, len(e2SubsIds), subReqCount)
5272
5273 // Del
5274 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5275 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5276
5277 xappConn1.TestMsgChanEmpty(t)
5278 e2termConn1.TestMsgChanEmpty(t)
5279 mainCtrl.wait_registry_empty(t, 10)
5280
5281 mainCtrl.VerifyCounterValues(t)
5282}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005283
5284func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5285 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5286
5287 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005288 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005289 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005290 Counter{cSubReqToE2, 2},
5291 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005292 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005293 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005294 Counter{cSubDelReqToE2, 2},
5295 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005296 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005297 })
5298
5299 // Req1
5300 var params *teststube2ap.RESTSubsReqParams = nil
5301
5302 //Subs Create
5303 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5304 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5305
5306 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5307
5308 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005309 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005310 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005311 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005312 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5313
5314 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5315 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5316 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5317 xappConn2.ExpectRESTNotification(t, restSubId2)
5318 e2termConn1.SendSubsResp(t, crereq, cremsg)
5319 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5320
5321 deleteXapp1Subscription(t, &restSubId1)
5322 deleteXapp2Subscription(t, &restSubId2)
5323
5324 waitSubsCleanup(t, e2SubsId1, 10)
5325 waitSubsCleanup(t, e2SubsId2, 10)
5326
5327 mainCtrl.VerifyCounterValues(t)
5328
5329}
5330
5331func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5332 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5333
5334 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005335 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005336 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005337 Counter{cSubReqToE2, 2},
5338 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005339 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005340 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005341 Counter{cSubDelReqToE2, 2},
5342 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005343 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005344 })
5345
5346 // Req1
5347 var params *teststube2ap.RESTSubsReqParams = nil
5348
5349 //Subs Create
5350 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5351 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5352
5353 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5354
5355 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005356 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005357 params.SetMeid("RAN_NAME_1")
5358
5359 actionId := int64(1)
5360 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005361 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005362 subsequestActionType := "continue"
5363 timeToWait := "w10ms"
5364 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5365
5366 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5367 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5368 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5369 xappConn2.ExpectRESTNotification(t, restSubId2)
5370 e2termConn1.SendSubsResp(t, crereq, cremsg)
5371 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5372
5373 deleteXapp1Subscription(t, &restSubId1)
5374 deleteXapp2Subscription(t, &restSubId2)
5375
5376 waitSubsCleanup(t, e2SubsId1, 10)
5377 waitSubsCleanup(t, e2SubsId2, 10)
5378
5379 mainCtrl.VerifyCounterValues(t)
5380
5381}
5382
5383func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5384 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5385
5386 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005387 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005388 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005389 Counter{cSubReqToE2, 2},
5390 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005391 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005392 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005393 Counter{cSubDelReqToE2, 2},
5394 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005395 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005396 })
5397
5398 // Req1
5399 var params *teststube2ap.RESTSubsReqParams = nil
5400
5401 //Subs Create
5402 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5403 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5404
5405 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5406
5407 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005408 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005409 params.SetMeid("RAN_NAME_1")
5410 params.SetSubActionIDs(int64(2))
5411
5412 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5413 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5414 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5415 xappConn2.ExpectRESTNotification(t, restSubId2)
5416 e2termConn1.SendSubsResp(t, crereq, cremsg)
5417 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5418
5419 deleteXapp1Subscription(t, &restSubId1)
5420 deleteXapp2Subscription(t, &restSubId2)
5421
5422 waitSubsCleanup(t, e2SubsId1, 10)
5423 waitSubsCleanup(t, e2SubsId2, 10)
5424
5425 mainCtrl.VerifyCounterValues(t)
5426
5427}
5428
5429func TestRESTSubReqDiffActionType(t *testing.T) {
5430 CaseBegin("TestRESTSubReqDiffActionType")
5431
5432 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005433 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005434 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005435 Counter{cSubReqToE2, 2},
5436 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005437 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005438 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005439 Counter{cSubDelReqToE2, 2},
5440 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005441 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005442 })
5443
5444 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005445 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005446
5447 //Subs Create
5448 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5449 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5450
5451 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5452
5453 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005454 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005455 params.SetMeid("RAN_NAME_1")
5456
5457 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5458 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5459 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5460 xappConn2.ExpectRESTNotification(t, restSubId2)
5461 e2termConn1.SendSubsResp(t, crereq, cremsg)
5462 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5463
5464 deleteXapp1Subscription(t, &restSubId1)
5465 deleteXapp2Subscription(t, &restSubId2)
5466
5467 waitSubsCleanup(t, e2SubsId1, 10)
5468 waitSubsCleanup(t, e2SubsId2, 10)
5469
5470 mainCtrl.VerifyCounterValues(t)
5471
5472}
5473
5474func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5475 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5476
5477 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005478 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005479 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005480 Counter{cSubReqToE2, 2},
5481 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005482 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005483 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005484 Counter{cSubDelReqToE2, 2},
5485 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005486 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005487 })
5488
5489 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005490 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005491
5492 //Subs Create
5493 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5494 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5495
5496 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5497
5498 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005499 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005500 params.SetMeid("RAN_NAME_1")
5501
5502 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5503 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5504 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5505 xappConn2.ExpectRESTNotification(t, restSubId2)
5506 e2termConn1.SendSubsResp(t, crereq, cremsg)
5507 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5508
5509 deleteXapp1Subscription(t, &restSubId1)
5510 deleteXapp2Subscription(t, &restSubId2)
5511
5512 waitSubsCleanup(t, e2SubsId1, 10)
5513 waitSubsCleanup(t, e2SubsId2, 10)
5514
5515 mainCtrl.VerifyCounterValues(t)
5516
5517}
5518
5519func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5520 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5521
5522 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005523 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005524 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005525 Counter{cSubReqToE2, 2},
5526 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005527 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005528 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005529 Counter{cSubDelReqToE2, 2},
5530 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005531 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005532 })
5533
5534 // Req1
5535 var params *teststube2ap.RESTSubsReqParams = nil
5536
5537 //Subs Create
5538 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5539 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5540
5541 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5542
5543 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005544 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005545 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005546 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005547 params.SetSubActionDefinition(actionDefinition)
5548
5549 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5550 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5551 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5552 xappConn2.ExpectRESTNotification(t, restSubId2)
5553 e2termConn1.SendSubsResp(t, crereq, cremsg)
5554 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5555
5556 deleteXapp1Subscription(t, &restSubId1)
5557 deleteXapp2Subscription(t, &restSubId2)
5558
5559 waitSubsCleanup(t, e2SubsId1, 10)
5560 waitSubsCleanup(t, e2SubsId2, 10)
5561
5562 mainCtrl.VerifyCounterValues(t)
5563
5564}
5565
5566func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5567 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5568
5569 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005570 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005571 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005572 Counter{cSubReqToE2, 2},
5573 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005574 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005575 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005576 Counter{cSubDelReqToE2, 2},
5577 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005578 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005579 })
5580
5581 // Req1
5582 var params *teststube2ap.RESTSubsReqParams = nil
5583
5584 //Subs Create
5585 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5586 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5587
5588 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5589
5590 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005591 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005592 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005593 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005594 params.SetSubActionDefinition(actionDefinition)
5595
5596 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5597 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5598 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5599 xappConn2.ExpectRESTNotification(t, restSubId2)
5600 e2termConn1.SendSubsResp(t, crereq, cremsg)
5601 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5602
5603 deleteXapp1Subscription(t, &restSubId1)
5604 deleteXapp2Subscription(t, &restSubId2)
5605
5606 waitSubsCleanup(t, e2SubsId1, 10)
5607 waitSubsCleanup(t, e2SubsId2, 10)
5608
5609 mainCtrl.VerifyCounterValues(t)
5610
5611}
5612
5613func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5614 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5615
5616 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005617 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005618 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005619 Counter{cSubReqToE2, 2},
5620 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005621 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005622 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005623 Counter{cSubDelReqToE2, 2},
5624 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005625 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005626 })
5627
5628 // Req1
5629 var params *teststube2ap.RESTSubsReqParams = nil
5630
5631 //Subs Create
5632 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5633 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5634
5635 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5636
5637 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005638 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005639 params.SetMeid("RAN_NAME_1")
5640 params.SetTimeToWait("w200ms")
5641 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5642 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5643 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5644 xappConn2.ExpectRESTNotification(t, restSubId2)
5645 e2termConn1.SendSubsResp(t, crereq, cremsg)
5646 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5647
5648 deleteXapp1Subscription(t, &restSubId1)
5649 deleteXapp2Subscription(t, &restSubId2)
5650
5651 waitSubsCleanup(t, e2SubsId1, 10)
5652 waitSubsCleanup(t, e2SubsId2, 10)
5653
5654 mainCtrl.VerifyCounterValues(t)
5655
5656}
5657
Anssi Mannila51122392021-05-25 11:51:31 +03005658//-----------------------------------------------------------------------------
5659// TestRESTUnpackSubscriptionResponseDecodeFail
5660//
5661// stub stub
5662// +-------+ +---------+ +---------+
5663// | xapp | | submgr | | e2term |
5664// +-------+ +---------+ +---------+
5665// | | |
5666// | RestSubReq | |
5667// |---------------->| |
5668// | | |
5669// | RESTSubResp | |
5670// |<----------------| |
5671// | | |
5672// | | SubReq |
5673// | |------------->|
5674// | | |
5675// | | SubResp | ASN.1 decode fails
5676// | |<-------------|
5677// | | |
5678// | | SubReq |
5679// | |------------->|
5680// | | |
5681// | | SubFail | Duplicated action
5682// | |<-------------|
5683// | RESTNotif (fail)| |
5684// |<----------------| |
5685// | | SubDelReq |
5686// | |------------->|
5687// | | |
5688// | | SubDelResp |
5689// | |<-------------|
5690//
5691//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005692
Anssi Mannila51122392021-05-25 11:51:31 +03005693func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
5694 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5695 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005696
5697 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005698 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005699 restSubId := xappConn1.SendRESTSubsReq(t, params)
5700
5701 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5702 // Decode of this response fails which will result resending original request
5703 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5704
5705 _, cremsg = e2termConn1.RecvSubsReq(t)
5706
Markku Virtanen55d2a282021-06-04 14:46:56 +03005707 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005708
5709 // Subscription already created in E2 Node.
5710 fparams := &teststube2ap.E2StubSubsFailParams{}
5711 fparams.Set(crereq)
5712 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5713 e2termConn1.SendSubsFail(t, fparams, cremsg)
5714
5715 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5716 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5717
5718 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5719 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5720
5721 // Wait that subs is cleaned
5722 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5723
5724 xappConn1.TestMsgChanEmpty(t)
5725 e2termConn1.TestMsgChanEmpty(t)
5726 mainCtrl.wait_registry_empty(t, 10)
5727}
5728
5729//-----------------------------------------------------------------------------
5730// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5731//
5732// stub stub
5733// +-------+ +---------+ +---------+
5734// | xapp | | submgr | | e2term |
5735// +-------+ +---------+ +---------+
5736// | | |
5737// | RestSubReq | |
5738// |---------------->| |
5739// | | |
5740// | RESTSubResp | |
5741// |<----------------| |
5742// | | |
5743// | | SubReq |
5744// | |------------->|
5745// | | |
5746// | | SubResp | Unknown instanceId
5747// | |<-------------|
5748// | | |
5749// | | SubReq |
5750// | |------------->|
5751// | | |
5752// | | SubFail | Duplicated action
5753// | |<-------------|
5754// | RESTNotif (fail)| |
5755// |<----------------| |
5756// | | SubDelReq |
5757// | |------------->|
5758// | | |
5759// | | SubDelResp |
5760// | |<-------------|
5761//
5762//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005763
Anssi Mannila51122392021-05-25 11:51:31 +03005764func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
5765 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5766 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005767
5768 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005769 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005770 restSubId := xappConn1.SendRESTSubsReq(t, params)
5771
5772 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5773
5774 // Unknown instanceId in this response which will result resending original request
5775 orgInstanceId := crereq.RequestId.InstanceId
5776 crereq.RequestId.InstanceId = 0
5777 e2termConn1.SendSubsResp(t, crereq, cremsg)
5778
5779 _, cremsg = e2termConn1.RecvSubsReq(t)
5780
Markku Virtanen55d2a282021-06-04 14:46:56 +03005781 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005782
5783 // Subscription already created in E2 Node.
5784 fparams := &teststube2ap.E2StubSubsFailParams{}
5785 fparams.Set(crereq)
5786 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5787 e2termConn1.SendSubsFail(t, fparams, cremsg)
5788
5789 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5790 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5791
5792 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5793 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5794
5795 // Wait that subs is cleaned
5796 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
5797
5798 xappConn1.TestMsgChanEmpty(t)
5799 e2termConn1.TestMsgChanEmpty(t)
5800 mainCtrl.wait_registry_empty(t, 10)
5801}
5802
5803//-----------------------------------------------------------------------------
5804// TestRESTUnpackSubscriptionResponseNoTransaction
5805//
5806// stub stub
5807// +-------+ +---------+ +---------+
5808// | xapp | | submgr | | e2term |
5809// +-------+ +---------+ +---------+
5810// | | |
5811// | RestSubReq | |
5812// |---------------->| |
5813// | | |
5814// | RESTSubResp | |
5815// |<----------------| |
5816// | | |
5817// | | SubReq |
5818// | |------------->|
5819// | | |
5820// | | SubResp | No transaction for the response
5821// | |<-------------|
5822// | | |
5823// | | SubReq |
5824// | |------------->|
5825// | | |
5826// | | SubFail | Duplicated action
5827// | |<-------------|
5828// | RESTNotif (fail)| |
5829// |<----------------| |
5830// | | SubDelReq |
5831// | |------------->|
5832// | | |
5833// | | SubDelResp |
5834// | |<-------------|
5835// | | |
5836// | | SubDelReq |
5837// | |------------->|
5838// | | |
5839// | | SubDelResp |
5840// | |<-------------|
5841//
5842//-----------------------------------------------------------------------------
5843func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
5844 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5845 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005846
5847 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005848 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005849 restSubId := xappConn1.SendRESTSubsReq(t, params)
5850
5851 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5852
5853 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5854 // No transaction exist for this response which will result resending original request
5855 e2termConn1.SendSubsResp(t, crereq, cremsg)
5856
5857 _, cremsg = e2termConn1.RecvSubsReq(t)
5858
Markku Virtanen55d2a282021-06-04 14:46:56 +03005859 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005860
5861 // Subscription already created in E2 Node.
5862 fparams := &teststube2ap.E2StubSubsFailParams{}
5863 fparams.Set(crereq)
5864 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5865 e2termConn1.SendSubsFail(t, fparams, cremsg)
5866
5867 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5868 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5869
5870 // Resending happens because there no transaction
5871 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5872 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5873
5874 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5875 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5876
5877 // Wait that subs is cleaned
5878 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5879
5880 xappConn1.TestMsgChanEmpty(t)
5881 e2termConn1.TestMsgChanEmpty(t)
5882 mainCtrl.wait_registry_empty(t, 10)
5883
5884}
5885
5886//-----------------------------------------------------------------------------
5887// TestRESTUnpackSubscriptionFailureDecodeFail
5888//
5889// stub stub
5890// +-------+ +---------+ +---------+
5891// | xapp | | submgr | | e2term |
5892// +-------+ +---------+ +---------+
5893// | | |
5894// | RestSubReq | |
5895// |---------------->| |
5896// | | |
5897// | RESTSubResp | |
5898// |<----------------| |
5899// | | |
5900// | | SubReq |
5901// | |------------->|
5902// | | |
5903// | | SubFail | ASN.1 decode fails
5904// | |<-------------|
5905// | | |
5906// | | SubReq |
5907// | |------------->|
5908// | | |
5909// | | SubFail | Duplicated action
5910// | |<-------------|
5911// | RESTNotif (fail)| |
5912// |<----------------| |
5913// | | SubDelReq |
5914// | |------------->|
5915// | | |
5916// | | SubDelResp |
5917// | |<-------------|
5918//
5919//-----------------------------------------------------------------------------
5920func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
5921 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5922 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005923
5924 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005925 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005926 restSubId := xappConn1.SendRESTSubsReq(t, params)
5927
5928 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5929
5930 // Decode of this response fails which will result resending original request
5931 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5932
5933 _, cremsg = e2termConn1.RecvSubsReq(t)
5934
Markku Virtanen55d2a282021-06-04 14:46:56 +03005935 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005936
5937 // Subscription already created in E2 Node.
5938 fparams := &teststube2ap.E2StubSubsFailParams{}
5939 fparams.Set(crereq)
5940 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5941 e2termConn1.SendSubsFail(t, fparams, cremsg)
5942
5943 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5944 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5945
5946 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5947 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5948
5949 // Wait that subs is cleaned
5950 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5951
5952 xappConn1.TestMsgChanEmpty(t)
5953 e2termConn1.TestMsgChanEmpty(t)
5954 mainCtrl.wait_registry_empty(t, 10)
5955}
5956
5957//-----------------------------------------------------------------------------
5958// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5959//
5960// stub stub
5961// +-------+ +---------+ +---------+
5962// | xapp | | submgr | | e2term |
5963// +-------+ +---------+ +---------+
5964// | | |
5965// | RestSubReq | |
5966// |---------------->| |
5967// | | |
5968// | RESTSubResp | |
5969// |<----------------| |
5970// | | |
5971// | | SubReq |
5972// | |------------->|
5973// | | |
5974// | | SubFail | Unknown instanceId
5975// | |<-------------|
5976// | | |
5977// | | SubReq |
5978// | |------------->|
5979// | | |
5980// | | SubFail | Duplicated action
5981// | |<-------------|
5982// | RESTNotif (fail)| |
5983// |<----------------| |
5984// | | SubDelReq |
5985// | |------------->|
5986// | | |
5987// | | SubDelResp |
5988// | |<-------------|
5989//
5990//-----------------------------------------------------------------------------
5991func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
5992 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
5993 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005994
5995 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005996 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005997 restSubId := xappConn1.SendRESTSubsReq(t, params)
5998
5999 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6000
6001 // Unknown instanceId in this response which will result resending original request
6002 fparams := &teststube2ap.E2StubSubsFailParams{}
6003 fparams.Set(crereq)
6004 fparams.Fail.RequestId.InstanceId = 0
6005 e2termConn1.SendSubsFail(t, fparams, cremsg)
6006
6007 _, cremsg = e2termConn1.RecvSubsReq(t)
6008
Markku Virtanen55d2a282021-06-04 14:46:56 +03006009 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006010
6011 // Subscription already created in E2 Node.
6012 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6013 e2termConn1.SendSubsFail(t, fparams, cremsg)
6014
6015 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6016 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6017
6018 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
6019 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
6020
6021 // Wait that subs is cleaned
6022 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6023
6024 xappConn1.TestMsgChanEmpty(t)
6025 e2termConn1.TestMsgChanEmpty(t)
6026 mainCtrl.wait_registry_empty(t, 10)
6027}
6028
6029//-----------------------------------------------------------------------------
6030// TestRESTUnpackSubscriptionFailureNoTransaction
6031//
6032// stub stub
6033// +-------+ +---------+ +---------+
6034// | xapp | | submgr | | e2term |
6035// +-------+ +---------+ +---------+
6036// | | |
6037// | RestSubReq | |
6038// |---------------->| |
6039// | | |
6040// | RESTSubResp | |
6041// |<----------------| |
6042// | | |
6043// | | SubReq |
6044// | |------------->|
6045// | | |
6046// | | SubFail | No transaction for the response
6047// | |<-------------|
6048// | | |
6049// | | SubReq |
6050// | |------------->|
6051// | | |
6052// | | SubFail | Duplicated action
6053// | |<-------------|
6054// | RESTNotif (fail)| |
6055// |<----------------| |
6056// | | SubDelReq |
6057// | |------------->|
6058// | | |
6059// | | SubDelResp |
6060// | |<-------------|
6061//
6062//-----------------------------------------------------------------------------
6063func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
6064 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6065 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03006066
6067 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006068 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006069 restSubId := xappConn1.SendRESTSubsReq(t, params)
6070
6071 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6072
6073 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6074
6075 // No transaction exist for this response which will result resending original request
6076 fparams := &teststube2ap.E2StubSubsFailParams{}
6077 fparams.Set(crereq)
6078 e2termConn1.SendSubsFail(t, fparams, cremsg)
6079
6080 _, cremsg = e2termConn1.RecvSubsReq(t)
6081
Markku Virtanen55d2a282021-06-04 14:46:56 +03006082 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006083
6084 // Subscription already created in E2 Node.
6085 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6086 e2termConn1.SendSubsFail(t, fparams, cremsg)
6087
6088 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6089 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6090
6091 // Resending happens because there no transaction
6092 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6093 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6094
6095 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
6096 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
6097
6098 // Wait that subs is cleaned
6099 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6100
6101 xappConn1.TestMsgChanEmpty(t)
6102 e2termConn1.TestMsgChanEmpty(t)
6103 mainCtrl.wait_registry_empty(t, 10)
6104}
6105
6106//-----------------------------------------------------------------------------
6107// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6108//
6109// stub stub
6110// +-------+ +---------+ +---------+
6111// | xapp | | submgr | | e2term |
6112// +-------+ +---------+ +---------+
6113// | | |
6114// | [SUBS CREATE] |
6115// | | |
6116// | | |
6117// | RESTSubDelReq | |
6118// |---------------->| |
6119// | | |
6120// | RESTSubDelResp | |
6121// |<----------------| |
6122// | | |
6123// | | SubDelReq |
6124// | |------------->|
6125// | | |
6126// | | SubDelResp | ASN.1 decode fails
6127// | |<-------------|
6128// | | |
6129// | | SubDelReq |
6130// | |------------->|
6131// | | |
6132// | | SubDelFail | Subscription does exist any more
6133// | |<-------------|
6134// | | |
6135//
6136//-----------------------------------------------------------------------------
6137func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
6138 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
6139
6140 // Req
6141 var params *teststube2ap.RESTSubsReqParams = nil
6142 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6143
6144 // Del
6145 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6146
6147 // E2t: Receive 1st SubsDelReq
6148 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6149
6150 // Decode of this response fails which will result resending original request
6151 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6152
6153 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6154 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6155
6156 // Subscription does not exist in in E2 Node.
6157 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6158
6159 // Wait that subs is cleaned
6160 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6161
6162 xappConn1.TestMsgChanEmpty(t)
6163 e2termConn1.TestMsgChanEmpty(t)
6164 mainCtrl.wait_registry_empty(t, 10)
6165}
6166
6167//-----------------------------------------------------------------------------
6168// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6169//
6170// stub stub
6171// +-------+ +---------+ +---------+
6172// | xapp | | submgr | | e2term |
6173// +-------+ +---------+ +---------+
6174// | | |
6175// | [SUBS CREATE] |
6176// | | |
6177// | | |
6178// | RESTSubDelReq | |
6179// |---------------->| |
6180// | | |
6181// | RESTSubDelResp | |
6182// |<----------------| |
6183// | | |
6184// | | SubDelReq |
6185// | |------------->|
6186// | | |
6187// | | SubDelResp | Unknown instanceId
6188// | |<-------------|
6189// | | |
6190// | | SubDelReq |
6191// | |------------->|
6192// | | |
6193// | | SubDelFail | Subscription does exist any more
6194// | |<-------------|
6195//
6196//-----------------------------------------------------------------------------
6197func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
6198 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
6199
6200 // Req
6201 var params *teststube2ap.RESTSubsReqParams = nil
6202 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6203
6204 // Del
6205 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6206
6207 // E2t: Receive 1st SubsDelReq
6208 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6209
6210 // Unknown instanceId in this response which will result resending original request
6211 delreq.RequestId.InstanceId = 0
6212 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6213
6214 // E2t: Receive 2nd SubsDelReq
6215 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6216
6217 // Subscription does not exist in in E2 Node.
6218 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6219
6220 // Wait that subs is cleaned
6221 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6222
6223 xappConn1.TestMsgChanEmpty(t)
6224 e2termConn1.TestMsgChanEmpty(t)
6225 mainCtrl.wait_registry_empty(t, 10)
6226}
6227
6228//-----------------------------------------------------------------------------
6229// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6230//
6231// stub stub
6232// +-------+ +---------+ +---------+
6233// | xapp | | submgr | | e2term |
6234// +-------+ +---------+ +---------+
6235// | | |
6236// | [SUBS CREATE] |
6237// | | |
6238// | | |
6239// | RESTSubDelReq | |
6240// |---------------->| |
6241// | | |
6242// | RESTSubDelResp | |
6243// |<----------------| |
6244// | | |
6245// | | SubDelReq |
6246// | |------------->|
6247// | | |
6248// | | SubDelResp | No transaction for the response
6249// | |<-------------|
6250// | | |
6251// | | SubDelReq |
6252// | |------------->|
6253// | | |
6254// | | SubDelFail | Subscription does exist any more
6255// | |<-------------|
6256//
6257//-----------------------------------------------------------------------------
6258func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
6259 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
6260
6261 // Req
6262 var params *teststube2ap.RESTSubsReqParams = nil
6263 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6264
6265 // Del
6266 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6267
6268 // E2t: Receive 1st SubsDelReq
6269 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6270
6271 mainCtrl.MakeTransactionNil(t, e2SubsId)
6272
6273 // No transaction exist for this response which will result resending original request
6274 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6275
6276 // E2t: Receive 2nd SubsDelReq
6277 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6278
6279 // Subscription does not exist in in E2 Node.
6280 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6281
6282 // Wait that subs is cleaned
6283 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6284
6285 xappConn1.TestMsgChanEmpty(t)
6286 e2termConn1.TestMsgChanEmpty(t)
6287 mainCtrl.wait_registry_empty(t, 10)
6288}
6289
6290//-----------------------------------------------------------------------------
6291// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6292//
6293// stub stub
6294// +-------+ +---------+ +---------+
6295// | xapp | | submgr | | e2term |
6296// +-------+ +---------+ +---------+
6297// | | |
6298// | [SUBS CREATE] |
6299// | | |
6300// | | |
6301// | RESTSubDelReq | |
6302// |---------------->| |
6303// | | |
6304// | RESTSubDelResp | |
6305// |<----------------| |
6306// | | |
6307// | | SubDelReq |
6308// | |------------->|
6309// | | |
6310// | | SubDelFail | ASN.1 decode fails
6311// | |<-------------|
6312// | | |
6313// | | SubDelReq |
6314// | |------------->|
6315// | | |
6316// | | SubDelFail | Subscription does exist any more
6317// | |<-------------|
6318//
6319//-----------------------------------------------------------------------------
6320func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
6321 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
6322
6323 // Req
6324 var params *teststube2ap.RESTSubsReqParams = nil
6325 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6326
6327 // Del
6328 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6329
6330 // E2t: Receive 1st SubsDelReq
6331 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6332
6333 // Decode of this response fails which will result resending original request
6334 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6335
6336 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6337 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6338
6339 // Subscription does not exist in in E2 Node.
6340 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6341
6342 // Wait that subs is cleaned
6343 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6344
6345 xappConn1.TestMsgChanEmpty(t)
6346 e2termConn1.TestMsgChanEmpty(t)
6347 mainCtrl.wait_registry_empty(t, 10)
6348}
6349
6350//-----------------------------------------------------------------------------
6351// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6352//
6353// stub stub
6354// +-------+ +---------+ +---------+
6355// | xapp | | submgr | | e2term |
6356// +-------+ +---------+ +---------+
6357// | | |
6358// | [SUBS CREATE] |
6359// | | |
6360// | | |
6361// | RESTSubDelReq | |
6362// |---------------->| |
6363// | | |
6364// | RESTSubDelResp | |
6365// |<----------------| |
6366// | | |
6367// | | SubDelReq |
6368// | |------------->|
6369// | | |
6370// | | SubDelFail | Unknown instanceId
6371// | |<-------------|
6372// | | |
6373// | | SubDelReq |
6374// | |------------->|
6375// | | |
6376// | | SubDelFail | Subscription does exist any more
6377// | |<-------------|
6378//
6379//-----------------------------------------------------------------------------
6380func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
6381 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
6382
6383 // Req
6384 var params *teststube2ap.RESTSubsReqParams = nil
6385 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6386
6387 // Del
6388 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6389
6390 // E2t: Receive 1st SubsDelReq
6391 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6392
6393 // Unknown instanceId in this response which will result resending original request
6394 delreq.RequestId.InstanceId = 0
6395 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6396
6397 // E2t: Receive 2nd SubsDelReq
6398 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6399
6400 // Subscription does not exist in in E2 Node.
6401 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6402
6403 // Wait that subs is cleaned
6404 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6405
6406 xappConn1.TestMsgChanEmpty(t)
6407 e2termConn1.TestMsgChanEmpty(t)
6408 mainCtrl.wait_registry_empty(t, 10)
6409}
6410
6411//-----------------------------------------------------------------------------
6412// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6413//
6414// stub stub
6415// +-------+ +---------+ +---------+
6416// | xapp | | submgr | | e2term |
6417// +-------+ +---------+ +---------+
6418// | | |
6419// | [SUBS CREATE] |
6420// | | |
6421// | | |
6422// | RESTSubDelReq | |
6423// |---------------->| |
6424// | | |
6425// | RESTSubDelResp | |
6426// |<----------------| |
6427// | | |
6428// | | SubDelReq |
6429// | |------------->|
6430// | | |
6431// | | SubDelFail | No transaction for the response
6432// | |<-------------|
6433// | | |
6434// | | SubDelReq |
6435// | |------------->|
6436// | | |
6437// | | SubDelFail | Subscription does exist any more
6438// | |<-------------|
6439//
6440//-----------------------------------------------------------------------------
6441func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
6442 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
6443
6444 // Req
6445 var params *teststube2ap.RESTSubsReqParams = nil
6446 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6447
6448 // Del
6449 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6450
6451 // E2t: Receive 1st SubsDelReq
6452 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6453
6454 mainCtrl.MakeTransactionNil(t, e2SubsId)
6455
6456 // No transaction exist for this response which will result resending original request
6457 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6458
6459 // E2t: Receive 2nd SubsDelReq
6460 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6461
6462 // Subscription does not exist in in E2 Node.
6463 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6464
6465 // Wait that subs is cleaned
6466 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6467
6468 xappConn1.TestMsgChanEmpty(t)
6469 e2termConn1.TestMsgChanEmpty(t)
6470 mainCtrl.wait_registry_empty(t, 10)
6471}
6472
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006473//-----------------------------------------------------------------------------
6474// TestRESTSubReqFailAsn1PackSubReqError
6475//
6476// stub stub
6477// +-------+ +---------+ +---------+
6478// | xapp | | submgr | | e2term |
6479// +-------+ +---------+ +---------+
6480// | | |
6481// | RESTSubReq | |
6482// |---------------->| |
6483// | | |
6484// | RESTSubResp | |
6485// |<----------------| |
6486// | | |
6487// | ASN.1 encode fails |
6488// | | |
6489// | | SubDelReq |
6490// | |------------->|
6491// | | |
6492// | | SubDelFail |
6493// | |<-------------|
6494// | | |
6495// | RESTNotif | |
6496// | unsuccess | |
6497// |<----------------| |
6498// | | |
6499// | [SUBS DELETE] |
6500// | | |
6501//
6502//-----------------------------------------------------------------------------
6503func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6504
6505 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006506 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006507 Counter{cRestSubRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006508 Counter{cSubDelReqToE2, 1},
6509 Counter{cSubDelFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006510 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006511 })
6512
6513 subReqCount := 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006514
6515 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006516 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006517 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6518
6519 // Req
6520 restSubId := xappConn1.SendRESTSubsReq(t, params)
6521 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6522
6523 // E2t: Receive SubsDelReq
6524 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03006525 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006526
6527 // Subscription does not exist in in E2 Node.
6528 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6529
6530 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6531 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
6532
6533 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
6534 // Wait that subs is cleaned
6535 waitSubsCleanup(t, e2SubsId, 10)
6536 mainCtrl.VerifyCounterValues(t)
6537}
6538
archaggeafbf95f2021-04-14 08:54:05 +03006539////////////////////////////////////////////////////////////////////////////////////
6540// Services for UT cases
6541////////////////////////////////////////////////////////////////////////////////////
6542const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006543const host string = "localhost"
6544
6545func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
6546 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006547 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006548 }
6549 restSubId := fromXappConn.SendRESTSubsReq(t, params)
6550 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6551
6552 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
6553 fromXappConn.ExpectRESTNotification(t, restSubId)
6554 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
6555 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
6556 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6557
6558 return restSubId, e2SubsId
6559}
6560
6561func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
6562
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006563 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006564 if meid != "" {
6565 params.SetMeid(meid)
6566 }
6567 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
6568 restSubId := xappConn2.SendRESTSubsReq(t, params)
6569 xappConn2.ExpectRESTNotification(t, restSubId)
6570 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
6571 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
6572 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6573
6574 return restSubId, e2SubsId
6575}
6576
6577func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006578 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006579 restSubId := xappConn1.SendRESTSubsReq(t, params)
6580 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
6581
6582 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6583 xappConn1.ExpectRESTNotification(t, restSubId)
6584 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6585 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6586 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
6587
6588 return restSubId, e2SubsId
6589}
6590
6591func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006592 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006593 restSubId := xappConn1.SendRESTSubsReq(t, params)
6594
6595 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6596 fparams1 := &teststube2ap.E2StubSubsFailParams{}
6597 fparams1.Set(crereq1)
6598 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
6599
6600 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
6601 xappConn1.ExpectRESTNotification(t, restSubId)
6602 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
6603 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6604 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
6605
6606 return restSubId, e2SubsId
6607}
6608
6609func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
6610 fromXappConn.SendRESTSubsDelReq(t, restSubId)
6611 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6612 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6613}
6614
6615func deleteXapp1Subscription(t *testing.T, restSubId *string) {
6616 xappConn1.SendRESTSubsDelReq(t, restSubId)
6617 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6618 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6619}
6620
6621func deleteXapp2Subscription(t *testing.T, restSubId *string) {
6622 xappConn2.SendRESTSubsDelReq(t, restSubId)
6623 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6624 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6625}
6626
6627func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
6628 resp, _ := xapp.Subscription.QuerySubscriptions()
6629 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
6630 assert.Equal(t, resp[0].Meid, meid)
6631 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
6632}
6633
6634func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
6635 //Wait that subs is cleaned
6636 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
6637
6638 xappConn1.TestMsgChanEmpty(t)
6639 xappConn2.TestMsgChanEmpty(t)
6640 e2termConn1.TestMsgChanEmpty(t)
6641 mainCtrl.wait_registry_empty(t, timeout)
6642}
6643
6644func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
6645
6646 var e2SubsId []uint32
6647
6648 for i := 0; i < count; i++ {
6649 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
6650 crereq, cremsg := toE2termConn.RecvSubsReq(t)
6651 fromXappConn.ExpectRESTNotification(t, restSubId)
6652 toE2termConn.SendSubsResp(t, crereq, cremsg)
6653 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
6654 e2SubsId = append(e2SubsId, instanceId)
6655 xapp.Logger.Info("TEST: %v", e2SubsId)
6656 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
6657 <-time.After(100 * time.Millisecond)
6658 }
6659 return e2SubsId
6660}
6661
6662func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
6663
6664 for i := 0; i < len(e2SubsIds); i++ {
6665 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
6666 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6667 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6668 <-time.After(1 * time.Second)
6669 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
6670 <-time.After(100 * time.Millisecond)
6671 }
6672
6673 // Wait that subs is cleaned
6674 for i := 0; i < len(e2SubsIds); i++ {
6675 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
6676 }
6677
6678}