blob: b3f105d93e072babd9f167146b5d2a6eaf27016f [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 (
Anssi Mannila4abf1802021-01-28 13:06:46 +020023 "testing"
24 "time"
25
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020026 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000027 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020028 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020029 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
30 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020031)
32
Markku Virtanenac8bde42021-05-25 09:54:42 +000033func TestSuiteSetup(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +000034 // The effect of this call shall endure thgough the UT suite!
35 // If this causes any issues, the previout interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000036 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000037 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
38
39 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Markku Virtanenac8bde42021-05-25 09:54:42 +000040}
41
42//-----------------------------------------------------------------------------
43// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
44//
45// stub stub stub
46// +-------+ +---------+ +---------+ +---------+
47// | xapp | | submgr | | e2term | | rtmgr |
48// +-------+ +---------+ +---------+ +---------+
49// | | | |
50// | RESTSubReq | | |
51// |---------------->| | |
52// | | RouteCreate | |
53// | |--------------------------->| // The order of these events may vary
54// | | | |
55// | RESTSubResp | | | // The order of these events may vary
56// |<----------------| | |
57// | | RouteResponse| |
58// | |<---------------------------| // The order of these events may vary
59// | | | |
60// | | SubReq | |
61// | |------------->| | // The order of these events may vary
62// | | | |
63// | | SubResp | |
64// | |<-------------| |
65// | RESTNotif1 | | |
66// |<----------------| | |
67// | | | |
68// | RESTSubDelReq | | |
69// |---------------->| | |
70// | | SubDelReq | |
71// | |------------->| |
72// | | | |
73// | RESTSubDelResp| | |
74// |<----------------| | |
75// | | | |
76// | | SubDelResp | |
77// | |<-------------| |
78// | | | |
79// | | | |
80//
81//-----------------------------------------------------------------------------
82func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +000083
84 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
85
86 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
87
88 waitSubsCleanup(t, e2SubsId, 10)
89}
90
Juha Hyttinenfa015662020-01-24 10:05:18 +020091//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +000092// TestRESTSubReqAndE1apDeleteReqPackingError
93//
94// stub stub stub
95// +-------+ +---------+ +---------+ +---------+
96// | xapp | | submgr | | e2term | | rtmgr |
97// +-------+ +---------+ +---------+ +---------+
98// | | | |
99// | RESTSubReq | | |
100// |---------------->| | |
101// | | RouteCreate | |
102// | |--------------------------->| // The order of these events may vary
103// | | | |
104// | RESTSubResp | | | // The order of these events may vary
105// |<----------------| | |
106// | | RouteResponse| |
107// | |<---------------------------| // The order of these events may vary
108// | | | |
109// | | SubReq | |
110// | |------------->| | // The order of these events may vary
111// | | | |
112// | | SubResp | |
113// | |<-------------| |
114// | RESTNotif1 | | |
115// |<----------------| | |
116// | | | |
117// | RESTSubDelReq | | |
118// |---------------->| | |
119// | | | |
120// | RESTSubDelResp| | |
121// |<----------------| | |
122// | | | |
123// | | | |
124//
125//-----------------------------------------------------------------------------
126func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
127
128 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
129
130 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
131 xappConn1.SendRESTSubsDelReq(t, &restSubId)
132 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
133
134 waitSubsCleanup(t, e2SubsId, 10)
135}
136
137//-----------------------------------------------------------------------------
138// TestRESTSubReqAndE1apDeleteRespUnpackingError
139//
140// stub stub stub
141// +-------+ +---------+ +---------+ +---------+
142// | xapp | | submgr | | e2term | | rtmgr |
143// +-------+ +---------+ +---------+ +---------+
144// | | | |
145// | RESTSubReq | | |
146// |---------------->| | |
147// | | RouteCreate | |
148// | |--------------------------->| // The order of these events may vary
149// | | | |
150// | RESTSubResp | | | // The order of these events may vary
151// |<----------------| | |
152// | | RouteResponse| |
153// | |<---------------------------| // The order of these events may vary
154// | | | |
155// | | SubReq | |
156// | |------------->| | // The order of these events may vary
157// | | | |
158// | | SubResp | |
159// | |<-------------| |
160// | RESTNotif1 | | |
161// |<----------------| | |
162// | | | |
163// | RESTSubDelReq | | |
164// |---------------->| | |
165// | | SubDelReq | |
166// | |------------->| |
167// | | | |
168// | RESTSubDelResp| | |
169// |<----------------| | | // The order of these events may vary
170// | | | |
171// | | SubDelResp | |
172// | |<-------------| | // 1.st NOK
173// | | | |
174// | | SubDelReq | |
175// | |------------->| |
176// | | | |
177// | | SubDelResp | |
178// | |<-------------| | // 2.nd NOK
179//
180//-----------------------------------------------------------------------------
181
182func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
183
184 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
185
186 xappConn1.SendRESTSubsDelReq(t, &restSubId)
187 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
188 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
189 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
190
191 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
192 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
193
194 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
195
196 waitSubsCleanup(t, e2SubsId, 10)
197}
198
199//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200200// TestSubReqAndRouteNok
201//
202// stub stub
203// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200204// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200205// +-------+ +---------+ +---------+
206// | | |
207// | SubReq | |
208// |------------->| |
209// | | |
210// | | RouteCreate |
211// | |------------->|
212// | | |
213// | | RouteCreate |
214// | | status:400 |
215// | |<-------------|
216// | | |
217// | [SUBS INT DELETE] |
218// | | |
219//
220//-----------------------------------------------------------------------------
221
222func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200223 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200224
Anssi Mannila4abf1802021-01-28 13:06:46 +0200225 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200226 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
227 Counter{cSubReqFromXapp, 1},
228 Counter{cRouteCreateFail, 1},
229 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200230
Juha Hyttinenfa015662020-01-24 10:05:18 +0200231 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300232 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200233 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200234 waiter.WaitResult(t)
235
236 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200237 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200238
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200239 xappConn1.TestMsgChanEmpty(t)
240 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200241 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200242 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200243
244 <-time.After(1 * time.Second)
245 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200246}
247
248//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200249// TestSubReqAndRouteUpdateNok
250
251// stub stub
252// +-------+ +-------+ +---------+ +---------+
253// | xapp2 | | xapp1 | | submgr | | rtmgr |
254// +-------+ +-------+ +---------+ +---------+
255// | | | |
256// | [SUBS CREATE] | |
257// | | | |
258// | | | |
259// | | | |
260// | SubReq (mergeable) | |
261// |--------------------------->| | |
262// | | | |
263// | | | RouteUpdate |
264// | | |------------->|
265// | | | |
266// | | | RouteUpdate |
267// | | | status:400 |
268// | | |<-------------|
269// | | | |
270// | [SUBS INT DELETE] | |
271// | | | |
272// | | | |
273// | [SUBS DELETE] | |
274// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300275
Anssi Mannila4abf1802021-01-28 13:06:46 +0200276func TestSubReqAndRouteUpdateNok(t *testing.T) {
277 CaseBegin("TestSubReqAndRouteUpdateNok")
278
279 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200280 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
281 Counter{cSubReqFromXapp, 2},
282 Counter{cSubReqToE2, 1},
283 Counter{cSubRespFromE2, 1},
284 Counter{cSubRespToXapp, 1},
285 Counter{cRouteCreateUpdateFail, 1},
286 Counter{cSubDelReqFromXapp, 1},
287 Counter{cSubDelReqToE2, 1},
288 Counter{cSubDelRespFromE2, 1},
289 Counter{cSubDelRespToXapp, 1},
290 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200291
292 cretrans := xappConn1.SendSubsReq(t, nil, nil)
293 crereq, cremsg := e2termConn1.RecvSubsReq(t)
294 e2termConn1.SendSubsResp(t, crereq, cremsg)
295 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
296
297 resp, _ := xapp.Subscription.QuerySubscriptions()
298 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
299 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300300 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200301
302 waiter := rtmgrHttp.AllocNextEvent(false)
303 newSubsId := mainCtrl.get_registry_next_subid(t)
304 xappConn2.SendSubsReq(t, nil, nil)
305 waiter.WaitResult(t)
306
307 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
308 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
309
310 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
311 xappConn1.RecvSubsDelResp(t, deltrans)
312
313 //Wait that subs is cleaned
314 mainCtrl.wait_subs_clean(t, newSubsId, 10)
315 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
316
317 xappConn1.TestMsgChanEmpty(t)
318 xappConn2.TestMsgChanEmpty(t)
319 e2termConn1.TestMsgChanEmpty(t)
320 mainCtrl.wait_registry_empty(t, 10)
321
322 mainCtrl.VerifyCounterValues(t)
323}
324
325//-----------------------------------------------------------------------------
326// TestSubDelReqAndRouteDeleteNok
327//
328// stub stub
329// +-------+ +---------+ +---------+ +---------+
330// | xapp | | submgr | | e2term | | rtmgr |
331// +-------+ +---------+ +---------+ +---------+
332// | | | |
333// | [SUBS CREATE] | |
334// | | | |
335// | | | |
336// | | | |
337// | SubDelReq | | |
338// |------------->| | |
339// | | SubDelReq | |
340// | |------------->| |
341// | | SubDelRsp | |
342// | |<-------------| |
343// | SubDelRsp | | |
344// |<-------------| | |
345// | | RouteDelete | |
346// | |---------------------------->|
347// | | | |
348// | | RouteDelete | |
349// | | status:400 | |
350// | |<----------------------------|
351// | | | |
352func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
353 CaseBegin("TestSubDelReqAndRouteDeleteNok")
354
355 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200356 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
357 Counter{cSubReqFromXapp, 1},
358 Counter{cSubReqToE2, 1},
359 Counter{cSubRespFromE2, 1},
360 Counter{cSubRespToXapp, 1},
361 Counter{cSubDelReqFromXapp, 1},
362 Counter{cRouteDeleteFail, 1},
363 Counter{cSubDelReqToE2, 1},
364 Counter{cSubDelRespFromE2, 1},
365 Counter{cSubDelRespToXapp, 1},
366 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200367
368 cretrans := xappConn1.SendSubsReq(t, nil, nil)
369 crereq, cremsg := e2termConn1.RecvSubsReq(t)
370 e2termConn1.SendSubsResp(t, crereq, cremsg)
371 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
372
373 resp, _ := xapp.Subscription.QuerySubscriptions()
374 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
375 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300376 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200377
378 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
379 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
380
381 waiter := rtmgrHttp.AllocNextEvent(false)
382 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
383 waiter.WaitResult(t)
384
385 xappConn1.RecvSubsDelResp(t, deltrans)
386
387 //Wait that subs is cleaned
388 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
389
390 xappConn1.TestMsgChanEmpty(t)
391 xappConn2.TestMsgChanEmpty(t)
392 e2termConn1.TestMsgChanEmpty(t)
393 mainCtrl.wait_registry_empty(t, 10)
394
395 mainCtrl.VerifyCounterValues(t)
396}
397
398//-----------------------------------------------------------------------------
399// TestSubMergeDelAndRouteUpdateNok
400// stub stub
401// +-------+ +-------+ +---------+ +---------+
402// | xapp2 | | xapp1 | | submgr | | e2term |
403// +-------+ +-------+ +---------+ +---------+
404// | | | |
405// | | | |
406// | | | |
407// | | SubReq1 | |
408// | |------------->| |
409// | | | |
410// | | | SubReq1 |
411// | | |------------->|
412// | | | SubResp1 |
413// | | |<-------------|
414// | | SubResp1 | |
415// | |<-------------| |
416// | | | |
417// | SubReq2 | |
418// |--------------------------->| |
419// | | | |
420// | SubResp2 | |
421// |<---------------------------| |
422// | | | |
423// | | SubDelReq 1 | |
424// | |------------->| |
425// | | | RouteUpdate |
426// | | |-----> rtmgr |
427// | | | |
428// | | | RouteUpdate |
429// | | | status:400 |
430// | | |<----- rtmgr |
431// | | | |
432// | | SubDelResp 1 | |
433// | |<-------------| |
434// | | | |
435// | SubDelReq 2 | |
436// |--------------------------->| |
437// | | | |
438// | | | SubDelReq 2 |
439// | | |------------->|
440// | | | |
441// | | | SubDelReq 2 |
442// | | |------------->|
443// | | | |
444// | SubDelResp 2 | |
445// |<---------------------------| |
446//
447//-----------------------------------------------------------------------------
448func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
449 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
450
451 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200452 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
453 Counter{cSubReqFromXapp, 2},
454 Counter{cSubReqToE2, 1},
455 Counter{cSubRespFromE2, 1},
456 Counter{cSubRespToXapp, 2},
457 Counter{cSubDelReqFromXapp, 2},
458 Counter{cRouteDeleteUpdateFail, 1},
459 Counter{cSubDelReqToE2, 1},
460 Counter{cSubDelRespFromE2, 1},
461 Counter{cSubDelRespToXapp, 2},
462 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200463
464 //Req1
465 rparams1 := &teststube2ap.E2StubSubsReqParams{}
466 rparams1.Init()
467 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
468 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
469 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
470 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
471
472 //Req2
473 rparams2 := &teststube2ap.E2StubSubsReqParams{}
474 rparams2.Init()
475 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
476 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
477
478 resp, _ := xapp.Subscription.QuerySubscriptions()
479 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
480 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300481 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200482
483 //Del1
484 waiter := rtmgrHttp.AllocNextEvent(false)
485 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
486 waiter.WaitResult(t)
487
488 xappConn1.RecvSubsDelResp(t, deltrans1)
489
490 //Del2
491 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
492 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
493 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
494 xappConn2.RecvSubsDelResp(t, deltrans2)
495 //Wait that subs is cleaned
496 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
497
498 xappConn1.TestMsgChanEmpty(t)
499 xappConn2.TestMsgChanEmpty(t)
500 e2termConn1.TestMsgChanEmpty(t)
501 mainCtrl.wait_registry_empty(t, 10)
502
503 mainCtrl.VerifyCounterValues(t)
504}
505
506//-----------------------------------------------------------------------------
507
508//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200509// TestSubReqAndSubDelOk
510//
511// stub stub
512// +-------+ +---------+ +---------+
513// | xapp | | submgr | | e2term |
514// +-------+ +---------+ +---------+
515// | | |
516// | SubReq | |
517// |------------->| |
518// | | |
519// | | SubReq |
520// | |------------->|
521// | | |
522// | | SubResp |
523// | |<-------------|
524// | | |
525// | SubResp | |
526// |<-------------| |
527// | | |
528// | | |
529// | SubDelReq | |
530// |------------->| |
531// | | |
532// | | SubDelReq |
533// | |------------->|
534// | | |
535// | | SubDelResp |
536// | |<-------------|
537// | | |
538// | SubDelResp | |
539// |<-------------| |
540//
541//-----------------------------------------------------------------------------
542func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200543 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200544
Anssi Mannila4abf1802021-01-28 13:06:46 +0200545 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200546 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
547 Counter{cSubReqFromXapp, 1},
548 Counter{cSubReqToE2, 1},
549 Counter{cSubRespFromE2, 1},
550 Counter{cSubRespToXapp, 1},
551 Counter{cSubDelReqFromXapp, 1},
552 Counter{cSubDelReqToE2, 1},
553 Counter{cSubDelRespFromE2, 1},
554 Counter{cSubDelRespToXapp, 1},
555 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200556
557 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200558 crereq, cremsg := e2termConn1.RecvSubsReq(t)
559 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200560 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200561
562 resp, _ := xapp.Subscription.QuerySubscriptions()
563 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
564 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300565 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200566
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200567 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200568 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200569
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200570 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200571 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200572
573 //Wait that subs is cleaned
574 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
575
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200576 xappConn1.TestMsgChanEmpty(t)
577 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200578 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200579 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200580
581 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200582}
583
584//-----------------------------------------------------------------------------
585// TestSubReqRetransmission
586//
587// stub stub
588// +-------+ +---------+ +---------+
589// | xapp | | submgr | | e2term |
590// +-------+ +---------+ +---------+
591// | | |
592// | SubReq | |
593// |------------->| |
594// | | |
595// | | SubReq |
596// | |------------->|
597// | | |
598// | SubReq | |
599// | (retrans) | |
600// |------------->| |
601// | | |
602// | | SubResp |
603// | |<-------------|
604// | | |
605// | SubResp | |
606// |<-------------| |
607// | | |
608// | [SUBS DELETE] |
609// | | |
610//
611//-----------------------------------------------------------------------------
612func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200613 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200614
615 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200616 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200617 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200618
619 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200620 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200621 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
622
Juha Hyttinen1683f912020-04-17 10:39:57 +0300623 // hack as there is no real way to see has message be handled.
624 // Previuos counter check just tells that is has been received by submgr
625 // --> artificial delay
626 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200627 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200628 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200629
630 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200631 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200632 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
633 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200634 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200635
636 //Wait that subs is cleaned
637 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
638
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200639 xappConn1.TestMsgChanEmpty(t)
640 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200641 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200642 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200643}
644
645//-----------------------------------------------------------------------------
646// TestSubDelReqRetransmission
647//
648// stub stub
649// +-------+ +---------+ +---------+
650// | xapp | | submgr | | e2term |
651// +-------+ +---------+ +---------+
652// | | |
653// | [SUBS CREATE] |
654// | | |
655// | | |
656// | SubDelReq | |
657// |------------->| |
658// | | |
659// | | SubDelReq |
660// | |------------->|
661// | | |
662// | SubDelReq | |
663// | (same sub) | |
664// | (same xid) | |
665// |------------->| |
666// | | |
667// | | SubDelResp |
668// | |<-------------|
669// | | |
670// | SubDelResp | |
671// |<-------------| |
672//
673//-----------------------------------------------------------------------------
674func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200675 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200676
677 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200678 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200679 crereq, cremsg := e2termConn1.RecvSubsReq(t)
680 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200681 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200682
683 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200684 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200685 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200686
687 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200688 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200689 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
690
Juha Hyttinen1683f912020-04-17 10:39:57 +0300691 // hack as there is no real way to see has message be handled.
692 // Previuos counter check just tells that is has been received by submgr
693 // --> artificial delay
694 <-time.After(1 * time.Second)
695
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200696 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200697 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200698
699 //Wait that subs is cleaned
700 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
701
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200702 xappConn1.TestMsgChanEmpty(t)
703 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200704 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200705 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200706}
707
708//-----------------------------------------------------------------------------
709// TestSubDelReqCollision
710//
711// stub stub
712// +-------+ +---------+ +---------+
713// | xapp | | submgr | | e2term |
714// +-------+ +---------+ +---------+
715// | | |
716// | [SUBS CREATE] |
717// | | |
718// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200719// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200720// |------------->| |
721// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200722// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200723// | |------------->|
724// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200725// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200726// | (same sub) | |
727// | (diff xid) | |
728// |------------->| |
729// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200730// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200731// | |<-------------|
732// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200733// | SubDelResp 1 | |
734// |<-------------| |
735// | | |
736// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200737// |<-------------| |
738//
739//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200740
Juha Hyttinenfa015662020-01-24 10:05:18 +0200741func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200742 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200743
744 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200745 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200746 crereq, cremsg := e2termConn1.RecvSubsReq(t)
747 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200748 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200749
750 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200751 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200752 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200753
Juha Hyttinen3944a222020-01-24 11:51:46 +0200754 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200755 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200756 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
757 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200758 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
759
Juha Hyttinen1683f912020-04-17 10:39:57 +0300760 // hack as there is no real way to see has message be handled.
761 // Previuos counter check just tells that is has been received by submgr
762 // --> artificial delay
763 <-time.After(1 * time.Second)
764
Juha Hyttinen3944a222020-01-24 11:51:46 +0200765 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200766 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200767
768 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200769 xappConn1.RecvSubsDelResp(t, nil)
770 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200771
772 //Wait that subs is cleaned
773 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
774
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200775 xappConn1.TestMsgChanEmpty(t)
776 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200777 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200778 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200779}
780
781//-----------------------------------------------------------------------------
782// TestSubReqAndSubDelOkTwoParallel
783//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200784// stub stub stub
785// +-------+ +-------+ +---------+ +---------+
786// | xapp | | xapp | | submgr | | e2term |
787// +-------+ +-------+ +---------+ +---------+
788// | | | |
789// | | | |
790// | | | |
791// | | SubReq1 | |
792// | |------------->| |
793// | | | |
794// | | | SubReq1 |
795// | | |------------->|
796// | | | |
797// | SubReq2 | |
798// |------------------------>| |
799// | | | |
800// | | | SubReq2 |
801// | | |------------->|
802// | | | |
803// | | | SubResp1 |
804// | | |<-------------|
805// | | SubResp1 | |
806// | |<-------------| |
807// | | | |
808// | | | SubResp2 |
809// | | |<-------------|
810// | SubResp2 | |
811// |<------------------------| |
812// | | | |
813// | | [SUBS 1 DELETE] |
814// | | | |
815// | | [SUBS 2 DELETE] |
816// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200817//
818//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +0300819
Juha Hyttinenfa015662020-01-24 10:05:18 +0200820func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200821 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200822
823 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200824 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200825 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200826 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200827 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200828
829 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200830 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200831 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300832
833 rparams2.Req.EventTriggerDefinition.Data.Length = 1
834 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
835 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
836
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200837 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200838 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200839
840 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200841 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200842 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200843
844 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200845 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200846 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200847
848 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200849 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200850 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
851 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200852 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200853 //Wait that subs is cleaned
854 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
855
856 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200857 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200858 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
859 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200860 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200861 //Wait that subs is cleaned
862 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
863
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200864 xappConn1.TestMsgChanEmpty(t)
865 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200866 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200867 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200868}
869
870//-----------------------------------------------------------------------------
871// TestSameSubsDiffRan
872// Same subscription to different RANs
873//
874// stub stub
875// +-------+ +---------+ +---------+
876// | xapp | | submgr | | e2term |
877// +-------+ +---------+ +---------+
878// | | |
879// | | |
880// | | |
881// | SubReq(r1) | |
882// |------------->| |
883// | | |
884// | | SubReq(r1) |
885// | |------------->|
886// | | |
887// | | SubResp(r1) |
888// | |<-------------|
889// | | |
890// | SubResp(r1) | |
891// |<-------------| |
892// | | |
893// | SubReq(r2) | |
894// |------------->| |
895// | | |
896// | | SubReq(r2) |
897// | |------------->|
898// | | |
899// | | SubResp(r2) |
900// | |<-------------|
901// | | |
902// | SubResp(r2) | |
903// |<-------------| |
904// | | |
905// | [SUBS r1 DELETE] |
906// | | |
907// | [SUBS r2 DELETE] |
908// | | |
909//
910//-----------------------------------------------------------------------------
911func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200912 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200913
914 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200915 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
916 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200917 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
918 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200919 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200920
921 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200922 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
923 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200924 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
925 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200926 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200927
928 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200929 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
930 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200931 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
932 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200933 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200934 //Wait that subs is cleaned
935 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
936
937 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200938 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
939 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200940 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
941 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200942 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200943 //Wait that subs is cleaned
944 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
945
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200946 xappConn1.TestMsgChanEmpty(t)
947 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200948 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200949 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200950}
951
952//-----------------------------------------------------------------------------
953// TestSubReqRetryInSubmgr
954//
955// stub stub
956// +-------+ +---------+ +---------+
957// | xapp | | submgr | | e2term |
958// +-------+ +---------+ +---------+
959// | | |
960// | SubReq | |
961// |------------->| |
962// | | |
963// | | SubReq |
964// | |------------->|
965// | | |
966// | | |
967// | | SubReq |
968// | |------------->|
969// | | |
970// | | SubResp |
971// | |<-------------|
972// | | |
973// | SubResp | |
974// |<-------------| |
975// | | |
976// | [SUBS DELETE] |
977// | | |
978//
979//-----------------------------------------------------------------------------
980
981func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200982 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200983
984 // Init counter check
985 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
986 Counter{cSubReqFromXapp, 1},
987 Counter{cSubReqToE2, 1},
988 Counter{cSubReReqToE2, 1},
989 Counter{cSubRespFromE2, 1},
990 Counter{cSubRespToXapp, 1},
991 Counter{cSubDelReqFromXapp, 1},
992 Counter{cSubDelReqToE2, 1},
993 Counter{cSubDelRespFromE2, 1},
994 Counter{cSubDelRespToXapp, 1},
995 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200996
997 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200998 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200999
1000 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001001 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001002
1003 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001004 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1005 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001006
1007 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001008 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001009
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001010 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001011 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1012 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001013 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001014
1015 // Wait that subs is cleaned
1016 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1017
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001018 xappConn1.TestMsgChanEmpty(t)
1019 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001020 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001021 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001022
1023 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001024}
1025
1026//-----------------------------------------------------------------------------
1027// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1028//
1029// stub stub
1030// +-------+ +---------+ +---------+
1031// | xapp | | submgr | | e2term |
1032// +-------+ +---------+ +---------+
1033// | | |
1034// | SubReq | |
1035// |------------->| |
1036// | | |
1037// | | SubReq |
1038// | |------------->|
1039// | | |
1040// | | |
1041// | | SubReq |
1042// | |------------->|
1043// | | |
1044// | | SubDelReq |
1045// | |------------->|
1046// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001047// | | SubDelResp |
1048// | |<-------------|
1049// | | |
1050//
1051//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001052func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001053 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001054
1055 // Init counter check
1056 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1057 Counter{cSubReqFromXapp, 1},
1058 Counter{cSubReqToE2, 1},
1059 Counter{cSubReReqToE2, 1},
1060 Counter{cSubReqTimerExpiry, 2},
1061 Counter{cSubDelReqToE2, 1},
1062 Counter{cSubDelRespFromE2, 1},
1063 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001064
1065 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001066 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001067
1068 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001069 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001070
1071 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001072 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001073
1074 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001075 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1076 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001077
1078 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001079 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001080
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001081 xappConn1.TestMsgChanEmpty(t)
1082 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001083 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001084 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001085
1086 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001087}
1088
1089//-----------------------------------------------------------------------------
1090// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1091//
1092// stub stub
1093// +-------+ +---------+ +---------+
1094// | xapp | | submgr | | e2term |
1095// +-------+ +---------+ +---------+
1096// | | |
1097// | SubReq | |
1098// |------------->| |
1099// | | |
1100// | | SubReq |
1101// | |------------->|
1102// | | |
1103// | | |
1104// | | SubReq |
1105// | |------------->|
1106// | | |
1107// | | SubDelReq |
1108// | |------------->|
1109// | | |
1110// | | |
1111// | | SubDelReq |
1112// | |------------->|
1113// | | |
1114// | | |
1115//
1116//-----------------------------------------------------------------------------
1117
1118func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001119 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001120
1121 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1122 Counter{cSubReqFromXapp, 1},
1123 Counter{cSubReqToE2, 1},
1124 Counter{cSubReReqToE2, 1},
1125 Counter{cSubReqTimerExpiry, 2},
1126 Counter{cSubDelReqToE2, 1},
1127 Counter{cSubDelReReqToE2, 1},
1128 Counter{cSubDelReqTimerExpiry, 2},
1129 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001130
1131 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001132 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001133
1134 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001135 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001136
1137 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001138 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001139
1140 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001141 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001142
1143 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001144 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001145
1146 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001147 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001148
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001149 xappConn1.TestMsgChanEmpty(t)
1150 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001151 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001152 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001153
1154 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001155}
1156
1157//-----------------------------------------------------------------------------
1158// TestSubReqSubFailRespInSubmgr
1159//
1160// stub stub
1161// +-------+ +---------+ +---------+
1162// | xapp | | submgr | | e2term |
1163// +-------+ +---------+ +---------+
1164// | | |
1165// | SubReq | |
1166// |------------->| |
1167// | | |
1168// | | SubReq |
1169// | |------------->|
1170// | | |
1171// | | SubFail |
1172// | |<-------------|
1173// | | |
archaggeafbf95f2021-04-14 08:54:05 +03001174// | | SubDelReq |
1175// | |------------->|
1176// | | |
1177// | | SubDelResp |
1178// | |<-------------|
1179// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001180// | SubFail | |
1181// |<-------------| |
1182// | | |
1183//
1184//-----------------------------------------------------------------------------
1185
1186func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001187 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001188
1189 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1190 Counter{cSubReqFromXapp, 1},
1191 Counter{cSubReqToE2, 1},
1192 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001193 Counter{cSubFailToXapp, 1},
1194 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001195
1196 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001197 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001198
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001199 // E2t: Receive SubsReq and send SubsFail (first)
1200 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1201 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1202 fparams1.Set(crereq1)
1203 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1204
archaggeafbf95f2021-04-14 08:54:05 +03001205 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1206 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1207 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1208
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001209 // Xapp: Receive SubsFail
1210 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1211
1212 // Wait that subs is cleaned
1213 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1214
1215 xappConn1.TestMsgChanEmpty(t)
1216 xappConn2.TestMsgChanEmpty(t)
1217 e2termConn1.TestMsgChanEmpty(t)
1218 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001219
1220 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001221}
1222
1223//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001224// TestSubDelReqRetryInSubmgr
1225//
1226// stub stub
1227// +-------+ +---------+ +---------+
1228// | xapp | | submgr | | e2term |
1229// +-------+ +---------+ +---------+
1230// | | |
1231// | [SUBS CREATE] |
1232// | | |
1233// | | |
1234// | SubDelReq | |
1235// |------------->| |
1236// | | |
1237// | | SubDelReq |
1238// | |------------->|
1239// | | |
1240// | | SubDelReq |
1241// | |------------->|
1242// | | |
1243// | | SubDelResp |
1244// | |<-------------|
1245// | | |
1246// | SubDelResp | |
1247// |<-------------| |
1248//
1249//-----------------------------------------------------------------------------
1250
1251func TestSubDelReqRetryInSubmgr(t *testing.T) {
1252
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001253 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001254
1255 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001256 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001257 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1258 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001259 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001260
1261 // Subs Delete
1262 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001263 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001264
1265 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001266 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001267
1268 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001269 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1270 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001271
1272 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001273 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001274
1275 // Wait that subs is cleaned
1276 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1277
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001278 xappConn1.TestMsgChanEmpty(t)
1279 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001280 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001281 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001282}
1283
1284//-----------------------------------------------------------------------------
1285// TestSubDelReqTwoRetriesNoRespInSubmgr
1286//
1287// stub stub
1288// +-------+ +---------+ +---------+
1289// | xapp | | submgr | | e2term |
1290// +-------+ +---------+ +---------+
1291// | | |
1292// | [SUBS CREATE] |
1293// | | |
1294// | | |
1295// | SubDelReq | |
1296// |------------->| |
1297// | | |
1298// | | SubDelReq |
1299// | |------------->|
1300// | | |
1301// | | SubDelReq |
1302// | |------------->|
1303// | | |
1304// | | |
1305// | SubDelResp | |
1306// |<-------------| |
1307//
1308//-----------------------------------------------------------------------------
1309
1310func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1311
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001312 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001313
1314 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001315 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001316 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1317 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001318 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001319
1320 // Subs Delete
1321 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001322 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001323
1324 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001325 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001326
1327 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001328 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001329
1330 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001331 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001332
1333 // Wait that subs is cleaned
1334 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1335
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001336 xappConn1.TestMsgChanEmpty(t)
1337 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001338 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001339 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001340}
1341
1342//-----------------------------------------------------------------------------
1343// TestSubDelReqSubDelFailRespInSubmgr
1344//
1345// stub stub
1346// +-------+ +---------+ +---------+
1347// | xapp | | submgr | | e2term |
1348// +-------+ +---------+ +---------+
1349// | | |
1350// | [SUBS CREATE] |
1351// | | |
1352// | | |
1353// | SubDelReq | |
1354// |------------->| |
1355// | | |
1356// | | SubDelReq |
1357// | |------------->|
1358// | | |
1359// | | SubDelFail |
1360// | |<-------------|
1361// | | |
1362// | SubDelResp | |
1363// |<-------------| |
1364// | | |
1365//
1366//-----------------------------------------------------------------------------
1367
1368func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001369 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001370
1371 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1372 Counter{cSubReqFromXapp, 1},
1373 Counter{cSubReqToE2, 1},
1374 Counter{cSubRespFromE2, 1},
1375 Counter{cSubRespToXapp, 1},
1376 Counter{cSubDelReqFromXapp, 1},
1377 Counter{cSubDelReqToE2, 1},
1378 Counter{cSubDelFailFromE2, 1},
1379 Counter{cSubDelRespToXapp, 1},
1380 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001381
1382 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001383 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001384 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1385 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001386 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001387
1388 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001389 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001390
1391 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001392 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1393 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001394
1395 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001396 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001397
1398 // Wait that subs is cleaned
1399 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1400
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001401 xappConn1.TestMsgChanEmpty(t)
1402 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001403 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001404 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001405
1406 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001407}
1408
1409//-----------------------------------------------------------------------------
1410// TestSubReqAndSubDelOkSameAction
1411//
1412// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001413// +-------+ +-------+ +---------+ +---------+
1414// | xapp2 | | xapp1 | | submgr | | e2term |
1415// +-------+ +-------+ +---------+ +---------+
1416// | | | |
1417// | | | |
1418// | | | |
1419// | | SubReq1 | |
1420// | |------------->| |
1421// | | | |
1422// | | | SubReq1 |
1423// | | |------------->|
1424// | | | SubResp1 |
1425// | | |<-------------|
1426// | | SubResp1 | |
1427// | |<-------------| |
1428// | | | |
1429// | SubReq2 | |
1430// |--------------------------->| |
1431// | | | |
1432// | SubResp2 | |
1433// |<---------------------------| |
1434// | | | |
1435// | | SubDelReq 1 | |
1436// | |------------->| |
1437// | | | |
1438// | | SubDelResp 1 | |
1439// | |<-------------| |
1440// | | | |
1441// | SubDelReq 2 | |
1442// |--------------------------->| |
1443// | | | |
1444// | | | SubDelReq 2 |
1445// | | |------------->|
1446// | | | |
1447// | | | SubDelReq 2 |
1448// | | |------------->|
1449// | | | |
1450// | SubDelResp 2 | |
1451// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001452//
1453//-----------------------------------------------------------------------------
1454func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001455 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001456
Anssi Mannila4abf1802021-01-28 13:06:46 +02001457 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001458 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1459 Counter{cSubReqFromXapp, 2},
1460 Counter{cSubReqToE2, 1},
1461 Counter{cSubRespFromE2, 1},
1462 Counter{cSubRespToXapp, 2},
1463 Counter{cMergedSubscriptions, 1},
1464 Counter{cUnmergedSubscriptions, 1},
1465 Counter{cSubDelReqFromXapp, 2},
1466 Counter{cSubDelReqToE2, 1},
1467 Counter{cSubDelRespFromE2, 1},
1468 Counter{cSubDelRespToXapp, 2},
1469 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001470
Juha Hyttinen3944a222020-01-24 11:51:46 +02001471 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001472 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001473 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001474 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001475 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1476 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001477 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001478
1479 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001480 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001481 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001482 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001483 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1484 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001485 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001486
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001487 resp, _ := xapp.Subscription.QuerySubscriptions()
1488 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1489 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001490 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001491
Juha Hyttinen3944a222020-01-24 11:51:46 +02001492 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001493 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001494 //e2termConn1.RecvSubsDelReq(t)
1495 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001496 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001497 //Wait that subs is cleaned
1498 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1499
1500 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001501 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001502 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1503 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001504 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001505 //Wait that subs is cleaned
1506 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1507
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001508 xappConn1.TestMsgChanEmpty(t)
1509 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001510 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001511 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001512
1513 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001514}
1515
1516//-----------------------------------------------------------------------------
1517// TestSubReqAndSubDelOkSameActionParallel
1518//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001519// stub stub stub
1520// +-------+ +-------+ +---------+ +---------+
1521// | xapp2 | | xapp1 | | submgr | | e2term |
1522// +-------+ +-------+ +---------+ +---------+
1523// | | | |
1524// | | | |
1525// | | | |
1526// | | SubReq1 | |
1527// | |------------->| |
1528// | | | |
1529// | | | SubReq1 |
1530// | | |------------->|
1531// | SubReq2 | |
1532// |--------------------------->| |
1533// | | | SubResp1 |
1534// | | |<-------------|
1535// | | SubResp1 | |
1536// | |<-------------| |
1537// | | | |
1538// | SubResp2 | |
1539// |<---------------------------| |
1540// | | | |
1541// | | SubDelReq 1 | |
1542// | |------------->| |
1543// | | | |
1544// | | SubDelResp 1 | |
1545// | |<-------------| |
1546// | | | |
1547// | SubDelReq 2 | |
1548// |--------------------------->| |
1549// | | | |
1550// | | | SubDelReq 2 |
1551// | | |------------->|
1552// | | | |
1553// | | | SubDelReq 2 |
1554// | | |------------->|
1555// | | | |
1556// | SubDelResp 2 | |
1557// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001558//
1559//-----------------------------------------------------------------------------
1560func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001561 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001562
1563 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001564 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001565 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001566 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001567 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001568
1569 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001570 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001571 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001572 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001573
1574 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001575 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001576 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001577
1578 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001579 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001580
1581 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001582 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1583 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001584
1585 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001586 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001587 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1588 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001589 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001590
1591 //Wait that subs is cleaned
1592 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1593
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001594 xappConn1.TestMsgChanEmpty(t)
1595 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001596 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001597 mainCtrl.wait_registry_empty(t, 10)
1598}
1599
1600//-----------------------------------------------------------------------------
1601// TestSubReqAndSubDelNokSameActionParallel
1602//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001603// stub stub stub
1604// +-------+ +-------+ +---------+ +---------+
1605// | xapp2 | | xapp1 | | submgr | | e2term |
1606// +-------+ +-------+ +---------+ +---------+
1607// | | | |
1608// | | | |
1609// | | | |
1610// | | SubReq1 | |
1611// | |------------->| |
1612// | | | |
1613// | | | SubReq1 |
1614// | | |------------->|
1615// | SubReq2 | |
1616// |--------------------------->| |
1617// | | | SubFail1 |
1618// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001619// | | | |
archaggeafbf95f2021-04-14 08:54:05 +03001620// | | | SubDelReq |
1621// | | |------------->|
1622// | | | SubDelResp |
1623// | | |<-------------|
1624// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001625// | | SubFail1 | |
1626// | |<-------------| |
1627// | | | |
1628// | SubFail2 | |
1629// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001630//
1631//-----------------------------------------------------------------------------
1632func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001633 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001634
1635 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001636 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001637 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001638 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001639
1640 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001641 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001642
1643 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001644 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001645 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001646 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001647 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001648 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001649
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001650 // E2t: send SubsFail (first)
1651 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1652 fparams1.Set(crereq1)
1653 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1654
archaggeafbf95f2021-04-14 08:54:05 +03001655 // E2t: internal delete
1656 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1657 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1658
Juha Hyttinen3944a222020-01-24 11:51:46 +02001659 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001660 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001661 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001662 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001663
1664 //Wait that subs is cleaned
1665 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1666
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001667 xappConn1.TestMsgChanEmpty(t)
1668 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001669 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001670 mainCtrl.wait_registry_empty(t, 10)
1671}
1672
1673//-----------------------------------------------------------------------------
1674// TestSubReqAndSubDelNoAnswerSameActionParallel
1675//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001676// stub stub stub
1677// +-------+ +-------+ +---------+ +---------+
1678// | xapp2 | | xapp1 | | submgr | | e2term |
1679// +-------+ +-------+ +---------+ +---------+
1680// | | | |
1681// | | | |
1682// | | | |
1683// | | SubReq1 | |
1684// | |------------->| |
1685// | | | |
1686// | | | SubReq1 |
1687// | | |------------->|
1688// | | SubReq2 | |
1689// |--------------------------->| |
1690// | | | |
1691// | | | SubReq1 |
1692// | | |------------->|
1693// | | | |
1694// | | | |
1695// | | | SubDelReq |
1696// | | |------------->|
1697// | | | |
1698// | | | SubDelResp |
1699// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001700//
1701//-----------------------------------------------------------------------------
1702func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001703 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001704
1705 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001706 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001707 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001708 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001709
Juha Hyttinen1683f912020-04-17 10:39:57 +03001710 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001711
1712 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001713 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001714 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001715 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001716 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001717 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001718
1719 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001720 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001721
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001722 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1723 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001724
1725 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001726 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001727
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001728 xappConn1.TestMsgChanEmpty(t)
1729 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001730 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001731 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001732}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001733
1734//----------------------------- Policy cases ---------------------------------
1735//-----------------------------------------------------------------------------
1736// TestSubReqPolicyAndSubDelOk
1737//
1738// stub stub
1739// +-------+ +---------+ +---------+
1740// | xapp | | submgr | | e2term |
1741// +-------+ +---------+ +---------+
1742// | | |
1743// | SubReq | |
1744// |------------->| |
1745// | | |
1746// | | SubReq |
1747// | |------------->|
1748// | | |
1749// | | SubResp |
1750// | |<-------------|
1751// | | |
1752// | SubResp | |
1753// |<-------------| |
1754// | | |
1755// | | |
1756// | SubDelReq | |
1757// |------------->| |
1758// | | |
1759// | | SubDelReq |
1760// | |------------->|
1761// | | |
1762// | | SubDelResp |
1763// | |<-------------|
1764// | | |
1765// | SubDelResp | |
1766// |<-------------| |
1767//
1768//-----------------------------------------------------------------------------
1769func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1770 CaseBegin("TestSubReqAndSubDelOk")
1771
1772 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1773 rparams1.Init()
1774 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1775 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1776
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001777 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1778 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001779 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1780 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001781 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001782
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001783 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001784 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001785
1786 //Wait that subs is cleaned
1787 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1788
1789 xappConn1.TestMsgChanEmpty(t)
1790 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001791 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001792 mainCtrl.wait_registry_empty(t, 10)
1793}
1794
1795//-----------------------------------------------------------------------------
1796// TestSubReqPolicyChangeAndSubDelOk
1797//
1798// stub stub
1799// +-------+ +---------+ +---------+
1800// | xapp | | submgr | | e2term |
1801// +-------+ +---------+ +---------+
1802// | | |
1803// | SubReq | |
1804// |------------->| |
1805// | | |
1806// | | SubReq |
1807// | |------------->|
1808// | | |
1809// | | SubResp |
1810// | |<-------------|
1811// | | |
1812// | SubResp | |
1813// |<-------------| |
1814// | | |
1815// | SubReq | |
1816// |------------->| |
1817// | | |
1818// | | SubReq |
1819// | |------------->|
1820// | | |
1821// | | SubResp |
1822// | |<-------------|
1823// | | |
1824// | SubResp | |
1825// |<-------------| |
1826// | | |
1827// | SubDelReq | |
1828// |------------->| |
1829// | | |
1830// | | SubDelReq |
1831// | |------------->|
1832// | | |
1833// | | SubDelResp |
1834// | |<-------------|
1835// | | |
1836// | SubDelResp | |
1837// |<-------------| |
1838//
1839//-----------------------------------------------------------------------------
1840
1841func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1842 CaseBegin("TestSubReqAndSubDelOk")
1843
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001844 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1845 rparams1.Init()
1846 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1847 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001848
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001849 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1850 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001851 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1852
1853 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001854 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001855 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1856 xappConn1.SendSubsReq(t, rparams1, cretrans)
1857
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001858 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1859 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001860 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1861 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001862 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001863
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001864 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001865 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001866
1867 //Wait that subs is cleaned
1868 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1869
1870 xappConn1.TestMsgChanEmpty(t)
1871 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001872 e2termConn1.TestMsgChanEmpty(t)
1873 mainCtrl.wait_registry_empty(t, 10)
1874}
1875
1876//-----------------------------------------------------------------------------
1877// TestSubReqAndSubDelOkTwoE2termParallel
1878//
1879// stub stub stub
1880// +-------+ +---------+ +---------+ +---------+
1881// | xapp | | submgr | | e2term1 | | e2term2 |
1882// +-------+ +---------+ +---------+ +---------+
1883// | | | |
1884// | | | |
1885// | | | |
1886// | SubReq1 | | |
1887// |------------->| | |
1888// | | | |
1889// | | SubReq1 | |
1890// | |------------->| |
1891// | | | |
1892// | SubReq2 | | |
1893// |------------->| | |
1894// | | | |
1895// | | SubReq2 | |
1896// | |---------------------------->|
1897// | | | |
1898// | | SubResp1 | |
1899// | |<-------------| |
1900// | SubResp1 | | |
1901// |<-------------| | |
1902// | | SubResp2 | |
1903// | |<----------------------------|
1904// | SubResp2 | | |
1905// |<-------------| | |
1906// | | | |
1907// | [SUBS 1 DELETE] | |
1908// | | | |
1909// | [SUBS 2 DELETE] | |
1910// | | | |
1911//
1912//-----------------------------------------------------------------------------
1913func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1914 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1915
1916 //Req1
1917 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1918 xappConn1.SendSubsReq(t, nil, cretrans1)
1919 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1920
1921 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1922 xappConn1.SendSubsReq(t, nil, cretrans2)
1923 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1924
1925 //Resp1
1926 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1927 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1928
1929 //Resp2
1930 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1931 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1932
1933 //Del1
1934 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1935 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1936 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1937 xappConn1.RecvSubsDelResp(t, deltrans1)
1938 //Wait that subs is cleaned
1939 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1940
1941 //Del2
1942 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1943 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1944 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1945 xappConn1.RecvSubsDelResp(t, deltrans2)
1946 //Wait that subs is cleaned
1947 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1948
1949 xappConn1.TestMsgChanEmpty(t)
1950 xappConn2.TestMsgChanEmpty(t)
1951 e2termConn1.TestMsgChanEmpty(t)
1952 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001953 mainCtrl.wait_registry_empty(t, 10)
1954}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001955
1956//-----------------------------------------------------------------------------
1957// TestSubReqInsertAndSubDelOk
1958//
1959// stub stub
1960// +-------+ +---------+ +---------+
1961// | xapp | | submgr | | e2term |
1962// +-------+ +---------+ +---------+
1963// | | |
1964// | SubReq | |
1965// |------------->| |
1966// | | |
1967// | | SubReq |
1968// | |------------->|
1969// | | |
1970// | | SubResp |
1971// | |<-------------|
1972// | | |
1973// | SubResp | |
1974// |<-------------| |
1975// | | |
1976// | | |
1977// | SubDelReq | |
1978// |------------->| |
1979// | | |
1980// | | SubDelReq |
1981// | |------------->|
1982// | | |
1983// | | SubDelResp |
1984// | |<-------------|
1985// | | |
1986// | SubDelResp | |
1987// |<-------------| |
1988//
1989//-----------------------------------------------------------------------------
1990func TestSubReqInsertAndSubDelOk(t *testing.T) {
1991 CaseBegin("TestInsertSubReqAndSubDelOk")
1992
1993 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1994 rparams1.Init()
1995 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1996 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1997
1998 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1999 e2termConn1.SendSubsResp(t, crereq, cremsg)
2000 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2001 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2002 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2003
2004 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2005 xappConn1.RecvSubsDelResp(t, deltrans)
2006
2007 //Wait that subs is cleaned
2008 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2009
2010 xappConn1.TestMsgChanEmpty(t)
2011 xappConn2.TestMsgChanEmpty(t)
2012 e2termConn1.TestMsgChanEmpty(t)
2013 mainCtrl.wait_registry_empty(t, 10)
2014}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002015
2016//-----------------------------------------------------------------------------
2017// TestSubReqRetransmissionWithSameSubIdDiffXid
2018//
2019// This case simulates case where xApp restarts and starts sending same
2020// subscription requests which have already subscribed successfully
2021
2022// stub stub
2023// +-------+ +---------+ +---------+
2024// | xapp | | submgr | | e2term |
2025// +-------+ +---------+ +---------+
2026// | | |
2027// | SubReq | |
2028// |------------->| |
2029// | | |
2030// | | SubReq |
2031// | |------------->|
2032// | | |
2033// | | SubResp |
2034// | |<-------------|
2035// | | |
2036// | SubResp | |
2037// |<-------------| |
2038// | | |
2039// | xApp restart | |
2040// | | |
2041// | SubReq | |
2042// | (retrans with same xApp generated subid but diff xid)
2043// |------------->| |
2044// | | |
2045// | SubResp | |
2046// |<-------------| |
2047// | | |
2048// | [SUBS DELETE] |
2049// | | |
2050//
2051//-----------------------------------------------------------------------------
2052func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2053 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2054
2055 //Subs Create
2056 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2057 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2058 e2termConn1.SendSubsResp(t, crereq, cremsg)
2059 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2060
2061 // xApp restart here
2062 // --> artificial delay
2063 <-time.After(1 * time.Second)
2064
2065 //Subs Create
2066 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2067 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2068
2069 //Subs Delete
2070 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2071 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2072 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2073 xappConn1.RecvSubsDelResp(t, deltrans)
2074
2075 //Wait that subs is cleaned
2076 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2077
2078 xappConn1.TestMsgChanEmpty(t)
2079 xappConn2.TestMsgChanEmpty(t)
2080 e2termConn1.TestMsgChanEmpty(t)
2081 mainCtrl.wait_registry_empty(t, 10)
2082}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002083
2084//-----------------------------------------------------------------------------
2085// TestSubReqNokAndSubDelOkWithRestartInMiddle
2086//
2087// stub stub
2088// +-------+ +---------+ +---------+
2089// | xapp | | submgr | | e2term |
2090// +-------+ +---------+ +---------+
2091// | | |
2092// | SubReq | |
2093// |------------->| |
2094// | | |
2095// | | SubReq |
2096// | |------------->|
2097// | | |
2098// | | SubResp |
2099// | <----|
2100// | |
2101// | Submgr restart |
2102// | |
2103// | | |
2104// | | SubDelReq |
2105// | |------------->|
2106// | | |
2107// | | SubDelResp |
2108// | |<-------------|
2109// | | |
2110//
2111//-----------------------------------------------------------------------------
2112
2113func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2114 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2115
2116 // Remove possible existing subscrition
2117 mainCtrl.removeExistingSubscriptions(t)
2118
2119 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2120 xappConn1.SendSubsReq(t, nil, nil)
2121 e2termConn1.RecvSubsReq(t)
2122 mainCtrl.SetResetTestFlag(t, false)
2123
2124 resp, _ := xapp.Subscription.QuerySubscriptions()
2125 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002126 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002127 e2SubsId := uint32(resp[0].SubscriptionID)
2128 t.Logf("e2SubsId = %v", e2SubsId)
2129
archaggeafbf95f2021-04-14 08:54:05 +03002130 mainCtrl.SimulateRestart(t)
2131 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002132
2133 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2134 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2135
2136 // Wait that subs is cleaned
2137 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2138
2139 xappConn1.TestMsgChanEmpty(t)
2140 xappConn2.TestMsgChanEmpty(t)
2141 e2termConn1.TestMsgChanEmpty(t)
2142 mainCtrl.wait_registry_empty(t, 10)
2143}
2144
2145//-----------------------------------------------------------------------------
2146// TestSubReqAndSubDelOkWithRestartInMiddle
2147//
2148// stub stub
2149// +-------+ +---------+ +---------+
2150// | xapp | | submgr | | e2term |
2151// +-------+ +---------+ +---------+
2152// | | |
2153// | SubReq | |
2154// |------------->| |
2155// | | |
2156// | | SubReq |
2157// | |------------->|
2158// | | |
2159// | | SubResp |
2160// | |<-------------|
2161// | | |
2162// | SubResp | |
2163// |<-------------| |
2164// | | |
2165// | |
2166// | Submgr restart |
2167// | |
2168// | SubDelReq | |
2169// |------------->| |
2170// | | |
2171// | | SubDelReq |
2172// | |------------->|
2173// | | |
2174// | | SubDelResp |
2175// | |<-------------|
2176// | | |
2177// | SubDelResp | |
2178// |<-------------| |
2179//
2180//-----------------------------------------------------------------------------
2181
2182func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2183 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2184
2185 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2186 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2187 e2termConn1.SendSubsResp(t, crereq, cremsg)
2188 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2189
2190 // Check subscription
2191 resp, _ := xapp.Subscription.QuerySubscriptions()
2192 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2193 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002194 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002195
2196 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002197 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002198
2199 // Check that subscription is restored correctly after restart
2200 resp, _ = xapp.Subscription.QuerySubscriptions()
2201 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2202 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002203 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002204
2205 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2206 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2207 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2208 xappConn1.RecvSubsDelResp(t, deltrans)
2209
2210 //Wait that subs is cleaned
2211 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2212
2213 xappConn1.TestMsgChanEmpty(t)
2214 xappConn2.TestMsgChanEmpty(t)
2215 e2termConn1.TestMsgChanEmpty(t)
2216 mainCtrl.wait_registry_empty(t, 10)
2217}
2218
2219//-----------------------------------------------------------------------------
2220// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2221//
2222// stub stub
2223// +-------+ +-------+ +---------+ +---------+
2224// | xapp2 | | xapp1 | | submgr | | e2term |
2225// +-------+ +-------+ +---------+ +---------+
2226// | | | |
2227// | | | |
2228// | | | |
2229// | | SubReq1 | |
2230// | |------------->| |
2231// | | | |
2232// | | | SubReq1 |
2233// | | |------------->|
2234// | | | SubResp1 |
2235// | | |<-------------|
2236// | | SubResp1 | |
2237// | |<-------------| |
2238// | | | |
2239// | |
2240// | submgr restart |
2241// | |
2242// | | | |
2243// | | | |
2244// | SubReq2 | |
2245// |--------------------------->| |
2246// | | | |
2247// | SubResp2 | |
2248// |<---------------------------| |
2249// | | | |
2250// | | SubDelReq 1 | |
2251// | |------------->| |
2252// | | | |
2253// | | SubDelResp 1 | |
2254// | |<-------------| |
2255// | | | |
2256// | | | |
2257// | |
2258// | submgr restart |
2259// | |
2260// | | | |
2261// | SubDelReq 2 | |
2262// |--------------------------->| |
2263// | | | |
2264// | | | SubDelReq 2 |
2265// | | |------------->|
2266// | | | |
2267// | | | SubDelReq 2 |
2268// | | |------------->|
2269// | | | |
2270// | SubDelResp 2 | |
2271// |<---------------------------| |
2272//
2273//-----------------------------------------------------------------------------
2274
2275func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2276 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2277
2278 //Req1
2279 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2280 rparams1.Init()
2281 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2282 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2283 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2284 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2285
2286 //Req2
2287 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2288 rparams2.Init()
2289 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2290 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2291
2292 // Check subscription
2293 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2294 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2295 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002296 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002297
2298 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002299 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002300
2301 // Check that subscription is restored correctly after restart
2302 resp, _ = xapp.Subscription.QuerySubscriptions()
2303 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2304 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002305 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002306
2307 //Del1
2308 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2309 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2310 xappConn1.RecvSubsDelResp(t, deltrans1)
2311 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2312
2313 mainCtrl.SimulateRestart(t)
2314 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2315
2316 //Del2
2317 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2318 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2319
2320 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2321 xappConn2.RecvSubsDelResp(t, deltrans2)
2322
2323 //Wait that subs is cleaned
2324 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2325
2326 xappConn1.TestMsgChanEmpty(t)
2327 xappConn2.TestMsgChanEmpty(t)
2328 e2termConn1.TestMsgChanEmpty(t)
2329 mainCtrl.wait_registry_empty(t, 10)
2330}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002331
archaggeafbf95f2021-04-14 08:54:05 +03002332//*****************************************************************************
2333// REST interface test cases
2334//*****************************************************************************
2335
Anssi Mannila47518ae2021-04-16 09:27:07 +03002336//-----------------------------------------------------------------------------
2337// Test debug GET and POST requests
2338//
2339// curl
2340// +-------+ +---------+
2341// | user | | submgr |
2342// +-------+ +---------+
2343// | |
2344// | GET/POST Req |
2345// |------------->|
2346// | Resp |
2347// |<-------------|
2348// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002349func TestGetSubscriptions(t *testing.T) {
2350
2351 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2352}
2353
2354func TestGetSymptomData(t *testing.T) {
2355
2356 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2357}
2358
2359func TestPostdeleteSubId(t *testing.T) {
2360
2361 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2362}
2363
2364func TestPostEmptyDb(t *testing.T) {
2365
2366 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2367}
archaggeafbf95f2021-04-14 08:54:05 +03002368
2369//-----------------------------------------------------------------------------
2370// TestRESTSubReqAndRouteNok
2371//
2372// stub stub
2373// +-------+ +---------+ +---------+
2374// | xapp | | submgr | | rtmgr |
2375// +-------+ +---------+ +---------+
2376// | | |
2377// | RESTSubReq | |
2378// |---------------->| |
2379// | | |
2380// | RESTSubResp | |
2381// |<----------------| |
2382// | | RouteCreate |
2383// | |------------->|
2384// | | |
2385// | | RouteCreate |
2386// | | status:400 |
2387// | |(Bad request) |
2388// | |<-------------|
2389// | RESTNotif | |
2390// |<----------------| |
2391// | | |
2392// | [SUBS INT DELETE] |
2393// | | |
2394// | RESTSubDelReq | |
2395// |---------------->| |
2396// | RESTSubDelResp | |
2397// |<----------------| |
2398//
2399//-----------------------------------------------------------------------------
2400func TestRESTSubReqAndRouteNok(t *testing.T) {
2401 CaseBegin("TestRESTSubReqAndRouteNok")
2402
2403 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002404 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002405 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002406 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002407 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002408 Counter{cRestSubDelReqFromXapp, 1},
2409 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002410 })
2411
2412 const subReqCount int = 1
Markku Virtanenda34eec2021-05-20 08:22:04 +00002413 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2414 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002415 newSubsId := mainCtrl.get_registry_next_subid(t)
2416
2417 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002418 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002419 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenda34eec2021-05-20 08:22:04 +00002420 xappConn1.ExpectRESTNotification(t, restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002421 waiter.WaitResult(t)
2422
archaggeafbf95f2021-04-14 08:54:05 +03002423 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2424 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2425
2426 // Del
2427 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2428
2429 // Wait that subs is cleaned
2430 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2431 waitSubsCleanup(t, e2SubsId, 10)
2432 mainCtrl.VerifyCounterValues(t)
2433}
2434
2435func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2436 CaseBegin("TestSubReqAndRouteUpdateNok")
2437
2438 //Init counter check
2439 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002440 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002441 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002442 Counter{cSubReqToE2, 1},
2443 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002444 Counter{cRestSubNotifToXapp, 1},
2445 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002446 Counter{cRouteCreateUpdateFail, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002447 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002448 Counter{cSubDelReqToE2, 1},
2449 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002450 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002451 })
2452
2453 var params *teststube2ap.RESTSubsReqParams = nil
2454
2455 //Subs Create
2456 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2457
2458 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2459
2460 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2461 waiter := rtmgrHttp.AllocNextEvent(false)
2462 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002463 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002464 params.SetMeid("RAN_NAME_1")
2465 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2466 xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
2467 xappConn2.ExpectRESTNotification(t, restSubId2)
2468 waiter.WaitResult(t)
2469 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2470 xappConn2.WaitRESTNotification(t, restSubId2)
2471
2472 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2473
2474 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2475
2476 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2477 //Wait that subs is cleaned
2478 waitSubsCleanup(t, e2SubsId, 10)
2479
2480 mainCtrl.VerifyCounterValues(t)
2481}
2482
2483func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2484 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2485
2486 // Init counter check
2487 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002488 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002489 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002490 Counter{cSubReqToE2, 1},
2491 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002492 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002493 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002494 Counter{cRouteDeleteFail, 1},
2495 Counter{cSubDelReqToE2, 1},
2496 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002497 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002498 })
2499
2500 var params *teststube2ap.RESTSubsReqParams = nil
2501
2502 //Subs Create
2503 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2504
2505 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2506
2507 waiter := rtmgrHttp.AllocNextEvent(false)
2508 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2509 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2510 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2511 waiter.WaitResult(t)
2512
2513 waitSubsCleanup(t, e2SubsId, 10)
2514
2515 mainCtrl.VerifyCounterValues(t)
2516}
2517
2518func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2519 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2520
2521 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002522 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002523 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002524 Counter{cSubReqToE2, 1},
2525 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002526 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002527 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002528 Counter{cRouteDeleteUpdateFail, 1},
2529 Counter{cSubDelReqToE2, 1},
2530 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002531 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002532 })
2533
2534 var params *teststube2ap.RESTSubsReqParams = nil
2535
2536 //Subs Create
2537 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2538
2539 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2540 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2541
2542 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2543
2544 //Del1, this shall fail on rtmgr side
2545 waiter := rtmgrHttp.AllocNextEvent(false)
2546 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2547 waiter.WaitResult(t)
2548
2549 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2550
2551 //Del2
2552 deleteXapp2Subscription(t, &restSubId2)
2553
2554 waitSubsCleanup(t, e2SubsId2, 10)
2555
2556 mainCtrl.VerifyCounterValues(t)
2557}
2558
2559//-----------------------------------------------------------------------------
2560// TestRESTSubReqRetransmission
2561//
2562// stub stub
2563// +-------+ +---------+ +---------+
2564// | xapp | | submgr | | e2term |
2565// +-------+ +---------+ +---------+
2566// | | |
2567// | RESTSubReq1 | |
2568// |---------------->| |
2569// | | |
2570// | RESTSubResp | |
2571// |<----------------| |
2572// | | SubReq1 |
2573// | |------------->|
2574// | | |
2575// | RESTSubReq2 | |
2576// | (retrans) | |
2577// |---------------->| |
2578// | | |
2579// | | SubReq2 |
2580// | |------------->|
2581// | RESTSubResp2 | |
2582// |<----------------| |
2583// | | SubResp1 |
2584// | |<-------------|
2585// | RESTNotif1 | |
2586// |<----------------| |
2587// | | SubResp1 |
2588// | |<-------------|
2589// | RESTNotif2 | |
2590// |<----------------| |
2591// | | |
2592// | [SUBS DELETE] |
2593// | | |
2594//
2595//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002596
archaggeafbf95f2021-04-14 08:54:05 +03002597func TestRESTSubReqRetransmission(t *testing.T) {
2598 CaseBegin("TestRESTSubReqRetransmission")
2599
2600 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002601 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002602 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002603 Counter{cSubReqToE2, 2},
2604 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002605 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002606 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002607 Counter{cSubDelReqToE2, 2},
2608 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002609 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002610 })
2611 // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests
2612 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2613 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2614
2615 // Subs Create
2616 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002617
2618 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2619 // gets into execution before the rtmgrg responds for the first one.
2620 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002621 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002622 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2623 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2624
2625 waiter.WaitResult(t)
2626
2627 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2628
2629 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2630 // the order is not significant he6re.
2631 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2632 e2termConn1.SendSubsResp(t, crereq, cremsg)
2633 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2634 e2termConn1.SendSubsResp(t, crereq, cremsg)
2635
2636 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2637 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2638 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2639 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2640
2641 // Del1
2642 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2643 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2644 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2645
archaggeafbf95f2021-04-14 08:54:05 +03002646 // Del2
2647 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
2648 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2649 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2650
Markku Virtanenda34eec2021-05-20 08:22:04 +00002651 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
2652
archaggeafbf95f2021-04-14 08:54:05 +03002653 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2654
2655 mainCtrl.VerifyCounterValues(t)
2656}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002657
archaggeafbf95f2021-04-14 08:54:05 +03002658func TestRESTSubDelReqRetransmission(t *testing.T) {
2659 CaseBegin("TestRESTSubDelReqRetransmission")
2660
2661 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002662 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002663 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002664 Counter{cSubReqToE2, 1},
2665 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002666 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002667 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002668 Counter{cSubDelReqToE2, 1},
2669 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002670 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002671 })
2672
2673 var params *teststube2ap.RESTSubsReqParams = nil
2674
2675 //Subs Create
2676 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2677
2678 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2679
2680 //Subs Delete
2681 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2682 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2683
2684 seqBef := mainCtrl.get_msgcounter(t)
2685 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2686 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
2687
2688 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2689
2690 waitSubsCleanup(t, e2SubsId, 10)
2691
2692 mainCtrl.VerifyCounterValues(t)
2693}
2694
2695//-----------------------------------------------------------------------------
2696// TestRESTSubReqDelReq
2697//
2698// stub stub
2699// +-------+ +---------+ +---------+
2700// | xapp | | submgr | | e2term |
2701// +-------+ +---------+ +---------+
2702// | | |
2703// | RESTSubReq | |
2704// |---------------->| |
2705// | | |
2706// | RESTSubResp | |
2707// |<----------------| |
2708// | | SubReq |
2709// | |------------->|
2710// | RESTSubDelReq | |
2711// |---------------->| |
2712// | RESTSubDelResp | |
2713// | unsuccess | |
2714// |<----------------| |
2715// | | SubResp |
2716// | |<-------------|
2717// | RESTNotif1 | |
2718// |<----------------| |
2719// | | |
2720// | [SUBS DELETE] |
2721// | | |
2722//
2723//-----------------------------------------------------------------------------
2724func TestRESTSubReqDelReq(t *testing.T) {
2725 CaseBegin("TestRESTSubReqDelReq")
2726
2727 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002728 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002729 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002730 Counter{cSubReqToE2, 1},
2731 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002732 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002733 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002734 Counter{cSubDelReqToE2, 1},
2735 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002736 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002737 })
2738
2739 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002740
2741 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002742 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002743 restSubId := xappConn1.SendRESTSubsReq(t, params)
2744
2745 // Del. This will fail as processing of the subscription
2746 // is still ongoing in submgr. Deletion is not allowed before
2747 // subscription creation has been completed.
2748 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2749 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2750 xappConn1.ExpectRESTNotification(t, restSubId)
2751 e2termConn1.SendSubsResp(t, crereq, cremsg)
2752 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2753
2754 // Retry del
2755 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2756
2757 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2758 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2759
2760 // Wait that subs is cleaned
2761 waitSubsCleanup(t, e2SubsId, 10)
2762 mainCtrl.VerifyCounterValues(t)
2763
2764}
2765
2766func TestRESTSubDelReqCollision(t *testing.T) {
2767 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
2768}
2769
2770func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
2771 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
2772
2773 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002774 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002775 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002776 Counter{cSubReqToE2, 2},
2777 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002778 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002779 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002780 Counter{cSubDelReqToE2, 2},
2781 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002782 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002783 })
2784
2785 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002786 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002787 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2788 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2789
2790 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002791 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002792 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2793 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2794
2795 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2796 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2797
2798 //XappConn1 receives both of the responses
2799 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2800
2801 //Resp1
2802 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2803 //Resp2
2804 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2805
2806 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2807 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2808 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2809 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2810
2811 //Del1
2812 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2813 //Del2
2814 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
2815
2816 //Wait that subs is cleaned
2817 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
2818 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2819
2820 mainCtrl.VerifyCounterValues(t)
2821
2822}
2823
2824func TestRESTSameSubsDiffRan(t *testing.T) {
2825 CaseBegin("TestRESTSameSubsDiffRan")
2826
2827 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002828 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002829 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002830 Counter{cSubReqToE2, 2},
2831 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002832 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002833 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002834 Counter{cSubDelReqToE2, 2},
2835 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002836 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002837 })
2838
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002839 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002840 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
2841 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2842
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002843 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002844 params.SetMeid("RAN_NAME_2")
2845 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
2846 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2847
2848 //Del1
2849 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2850 //Del2
2851 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
2852
2853 //Wait that subs is cleaned
2854 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2855 waitSubsCleanup(t, e2SubsId2, 10)
2856
2857 mainCtrl.VerifyCounterValues(t)
2858
2859}
2860
2861func TestRESTSubReqRetryInSubmgr(t *testing.T) {
2862 CaseBegin("TestRESTSubReqRetryInSubmgr start")
2863
2864 // Init counter check
2865 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002866 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002867 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002868 Counter{cSubReqToE2, 1},
2869 Counter{cSubReReqToE2, 1},
2870 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002871 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002872 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002873 Counter{cSubDelReqToE2, 1},
2874 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002875 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002876 })
2877
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002878 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002879 restSubId := xappConn1.SendRESTSubsReq(t, params)
2880
2881 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2882
2883 // Catch the first message and ignore it
2884 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2885 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
2886
2887 // The second request is being handled normally
2888 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2889 xappConn1.ExpectRESTNotification(t, restSubId)
2890 e2termConn1.SendSubsResp(t, crereq, cremsg)
2891 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2892
2893 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2894
2895 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2896
2897 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2898 //Wait that subs is cleaned
2899 waitSubsCleanup(t, e2SubsId, 10)
2900
2901 mainCtrl.VerifyCounterValues(t)
2902
2903}
2904
2905//-----------------------------------------------------------------------------
2906// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2907//
2908// stub stub
2909// +-------+ +---------+ +---------+
2910// | xapp | | submgr | | e2term |
2911// +-------+ +---------+ +---------+
2912// | | |
2913// | RESTSubReq | |
2914// |---------------->| |
2915// | | |
2916// | RESTSubResp | |
2917// |<----------------| |
2918// | | SubReq |
2919// | |------------->|
2920// | | |
2921// | | |
2922// | | SubReq |
2923// | |------------->|
2924// | | |
2925// | | SubDelReq |
2926// | |------------->|
2927// | | |
2928// | | |
2929// | | SubDelReq |
2930// | |------------->|
2931// | | |
2932// | | |
2933// | | SubDelResp |
2934// | |<-------------|
2935// | RESTNotif | |
2936// | unsuccess | |
2937// |<----------------| |
2938// | | |
2939// | [SUBS DELETE] |
2940// | | |
2941//
2942//-----------------------------------------------------------------------------
2943func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
2944 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
2945
2946 // Init counter check
2947 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002948 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002949 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002950 Counter{cSubReqToE2, 1},
2951 Counter{cSubReReqToE2, 1},
2952 Counter{cSubReqTimerExpiry, 2},
2953 Counter{cSubDelReqToE2, 1},
2954 Counter{cSubDelRespFromE2, 1},
2955 })
2956
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002957 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002958 restSubId := xappConn1.SendRESTSubsReq(t, params)
2959 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2960
2961 e2termConn1.RecvSubsReq(t)
2962 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2963
2964 e2termConn1.RecvSubsReq(t)
2965 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2966
2967 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2968 xappConn1.ExpectRESTNotification(t, restSubId)
2969 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2970 // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - TODO: Should we delete this?
2971 xappConn1.WaitRESTNotification(t, restSubId)
2972
2973 // Wait that subs is cleaned
2974 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
2975
2976 mainCtrl.VerifyCounterValues(t)
2977}
2978
2979func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
2980 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
2981
2982 // Init counter check
2983 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002984 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002985 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002986 Counter{cSubReqToE2, 1},
2987 Counter{cSubReReqToE2, 1},
2988 Counter{cSubReqTimerExpiry, 2},
2989 Counter{cSubDelReqToE2, 1},
2990 Counter{cSubDelReqTimerExpiry, 2},
2991 })
2992
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002993 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002994 restSubId := xappConn1.SendRESTSubsReq(t, params)
2995 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2996
2997 e2termConn1.RecvSubsReq(t)
2998 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2999
3000 e2termConn1.RecvSubsReq(t)
3001 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3002
3003 e2termConn1.RecvSubsDelReq(t)
3004 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3005
3006 xappConn1.ExpectRESTNotification(t, restSubId)
3007 e2termConn1.RecvSubsDelReq(t)
3008 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3009
3010 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3011
3012 waitSubsCleanup(t, e2SubsId, 10)
3013
3014 mainCtrl.VerifyCounterValues(t)
3015
3016}
3017
3018//-----------------------------------------------------------------------------
3019// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3020//
3021// stub stub
3022// +-------+ +---------+ +---------+
3023// | xapp | | submgr | | e2term |
3024// +-------+ +---------+ +---------+
3025// | | |
3026// | RESTSubReq | |
3027// |---------------->| |
3028// | | |
3029// | RESTSubResp | |
3030// |<----------------| |
3031// | | SubReq |
3032// | |------------->|
3033// | | |
3034// | | |
3035// | | SubReq |
3036// | |------------->|
3037// | | |
3038// | | SubDelReq |
3039// | |------------->|
3040// | | |
3041// | | |
3042// | | SubDelReq |
3043// | |------------->|
3044// | | |
3045// | | |
3046// | | SubDelResp |
3047// | |<-------------|
3048// | RESTNotif | |
3049// | unsuccess | |
3050// |<----------------| |
3051// | | |
3052// | [SUBS DELETE] |
3053// | | |
3054//
3055//-----------------------------------------------------------------------------
3056func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3057 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3058
3059 // Init counter check
3060 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003061 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003062 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003063 Counter{cSubReqToE2, 1},
3064 Counter{cSubReReqToE2, 1},
3065 Counter{cSubReqTimerExpiry, 2},
3066 Counter{cSubDelReqToE2, 1},
3067 Counter{cSubDelReReqToE2, 1},
3068 Counter{cSubDelReqTimerExpiry, 2},
3069 })
3070
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003071 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003072 restSubId := xappConn1.SendRESTSubsReq(t, params)
3073 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3074
3075 e2termConn1.RecvSubsReq(t)
3076 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3077
3078 e2termConn1.RecvSubsReq(t)
3079 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3080
3081 e2termConn1.RecvSubsDelReq(t)
3082 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3083
3084 xappConn1.ExpectRESTNotification(t, restSubId)
3085 e2termConn1.RecvSubsDelReq(t)
3086 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3087
3088 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3089
3090 waitSubsCleanup(t, e2SubsId, 10)
3091
3092 mainCtrl.VerifyCounterValues(t)
3093}
3094
3095//-----------------------------------------------------------------------------
3096// TestRESTSubReqSubFailRespInSubmgr
3097//
3098// stub stub
3099// +-------+ +---------+ +---------+
3100// | xapp | | submgr | | e2term |
3101// +-------+ +---------+ +---------+
3102// | | |
3103// | RESTSubReq | |
3104// |---------------->| |
3105// | | |
3106// | RESTSubResp | |
3107// |<----------------| |
3108// | | SubReq |
3109// | |------------->|
3110// | | |
3111// | | SubFail |
3112// | |<-------------|
3113// | | |
3114// | | SubDelReq |
3115// | |------------->|
3116// | | |
3117// | | SubDelResp |
3118// | |<-------------|
3119// | | |
3120// | RESTNotif | |
3121// | unsuccess | |
3122// |<----------------| |
3123// | | |
3124// | [SUBS DELETE] |
3125// | | |
3126//
3127//-----------------------------------------------------------------------------
3128func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3129 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3130
3131 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003132 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003133 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003134 Counter{cSubReqToE2, 1},
3135 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003136 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003137 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003138 })
3139
3140 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003141
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003142 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003143 restSubId := xappConn1.SendRESTSubsReq(t, params)
3144
3145 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3146 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3147 fparams1.Set(crereq1)
3148 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3149
3150 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3151 xappConn1.ExpectRESTNotification(t, restSubId)
3152 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3153 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3154 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
3155
3156 // REST subscription sill there to be deleted
3157 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3158
3159 // Wait that subs is cleaned
3160 waitSubsCleanup(t, e2SubsId, 10)
3161
3162 mainCtrl.VerifyCounterValues(t)
3163
3164}
3165
3166//-----------------------------------------------------------------------------
3167// TestRESTSubDelReqRetryInSubmgr
3168//
3169// stub stub
3170// +-------+ +---------+ +---------+
3171// | xapp | | submgr | | e2term |
3172// +-------+ +---------+ +---------+
3173// | | |
3174// | [SUBS CREATE] |
3175// | | |
3176// | | |
3177// | RESTSubDelReq | |
3178// |---------------->| |
3179// | | |
3180// | RESTSubDelResp | |
3181// |<----------------| |
3182// | | SubDelReq |
3183// | |------------->|
3184// | | |
3185// | | SubDelReq |
3186// | |------------->|
3187// | | |
3188// | | SubDelResp |
3189// | |<-------------|
3190// | | |
3191//
3192//-----------------------------------------------------------------------------
3193func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3194 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3195
3196 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003197 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003198 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003199 Counter{cSubReqToE2, 1},
3200 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003201 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003202 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003203 Counter{cSubDelReqToE2, 1},
3204 Counter{cSubDelReReqToE2, 1},
3205 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003206 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003207 })
3208 // Req
3209 var params *teststube2ap.RESTSubsReqParams = nil
3210 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3211
3212 // Del
3213 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3214
3215 // E2t: Receive 1st SubsDelReq
3216 e2termConn1.RecvSubsDelReq(t)
3217
3218 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3219 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3220 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3221
3222 //Wait that subs is cleaned
3223 waitSubsCleanup(t, e2SubsId, 10)
3224
3225 mainCtrl.VerifyCounterValues(t)
3226}
3227
3228//-----------------------------------------------------------------------------
3229// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3230//
3231// stub stub
3232// +-------+ +---------+ +---------+
3233// | xapp | | submgr | | e2term |
3234// +-------+ +---------+ +---------+
3235// | | |
3236// | [SUBS CREATE] |
3237// | | |
3238// | | |
3239// | RESTSubDelReq | |
3240// |---------------->| |
3241// | | |
3242// | RESTSubDelResp | |
3243// |<----------------| |
3244// | | SubDelReq |
3245// | |------------->|
3246// | | |
3247// | | SubDelReq |
3248// | |------------->|
3249// | | |
3250// | | |
3251//
3252//-----------------------------------------------------------------------------
3253func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3254 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3255
3256 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003257 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003258 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003259 Counter{cSubReqToE2, 1},
3260 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003261 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003262 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003263 Counter{cSubDelReqToE2, 1},
3264 Counter{cSubDelReReqToE2, 1},
3265 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003266 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003267 })
3268
3269 // Req
3270 var params *teststube2ap.RESTSubsReqParams = nil
3271 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3272
3273 // Del
3274 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3275
3276 // E2t: Receive 1st SubsDelReq
3277 e2termConn1.RecvSubsDelReq(t)
3278
3279 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3280 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3281 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3282
3283 //Wait that subs is cleaned
3284 waitSubsCleanup(t, e2SubsId, 10)
3285
3286 mainCtrl.VerifyCounterValues(t)
3287}
3288
3289//-----------------------------------------------------------------------------
3290// TestRESTSubDelReqSubDelFailRespInSubmgr
3291//
3292// stub stub
3293// +-------+ +---------+ +---------+
3294// | xapp | | submgr | | e2term |
3295// +-------+ +---------+ +---------+
3296// | | |
3297// | [SUBS CREATE] |
3298// | | |
3299// | | |
3300// | RESTSubDelReq | |
3301// |---------------->| |
3302// | | |
3303// | RESTSubDelResp | |
3304// |<----------------| |
3305// | | SubDelReq |
3306// | |------------->|
3307// | | |
3308// | | SubDelFail |
3309// | |<-------------|
3310// | | |
3311//
3312//-----------------------------------------------------------------------------
3313func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3314 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3315
3316 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003317 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003318 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003319 Counter{cSubReqToE2, 1},
3320 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003321 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003322 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003323 Counter{cSubDelReqToE2, 1},
3324 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003325 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003326 })
3327
3328 // Req
3329 var params *teststube2ap.RESTSubsReqParams = nil
3330 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3331
3332 // Del
3333 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3334
3335 // E2t: Send receive SubsDelReq and send SubsDelFail
3336 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3337 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3338
3339 //Wait that subs is cleaned
3340 waitSubsCleanup(t, e2SubsId, 10)
3341
3342 mainCtrl.VerifyCounterValues(t)
3343}
3344
3345//-----------------------------------------------------------------------------
3346// TestRESTSubReqAndSubDelOkSameAction
3347//
3348// stub stub
3349// +-------+ +-------+ +---------+ +---------+
3350// | xapp2 | | xapp1 | | submgr | | e2term |
3351// +-------+ +-------+ +---------+ +---------+
3352// | | | |
3353// | | RESTSubReq1 | |
3354// | |---------------->| |
3355// | | | |
3356// | | RESTSubResp1 | |
3357// | |<----------------| |
3358// | | | |
3359// | | | SubReq1 |
3360// | | |------------->|
3361// | | | SubResp1 |
3362// | | |<-------------|
3363// | | RESTNotif1 | |
3364// | |<----------------| |
3365// | | | |
3366// | RESTSubReq2 | |
3367// |------------------------------>| |
3368// | | | |
3369// | RESTSubResp2 | |
3370// |<------------------------------| |
3371// | | | |
3372// | | RESTNotif2 | |
3373// |<------------------------------| |
3374// | | | |
3375// | | RESTSubDelReq1 | |
3376// | |---------------->| |
3377// | | | |
3378// | | RESTSubDelResp1 | |
3379// | |<----------------| |
3380// | | | |
3381// | RESTSubDelReq2 | |
3382// |------------------------------>| |
3383// | | | |
3384// | RESTSubDelResp2 | |
3385// |<------------------------------| |
3386// | | | |
3387// | | | SubDelReq2 |
3388// | | |------------->|
3389// | | | |
3390// | | | SubDelResp2 |
3391// | | |<-------------|
3392// | | | |
3393//
3394//-----------------------------------------------------------------------------
3395func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3396 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3397
3398 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003399 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003400 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003401 Counter{cSubReqToE2, 1},
3402 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003403 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003404 Counter{cMergedSubscriptions, 1},
3405 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003406 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003407 Counter{cSubDelReqToE2, 1},
3408 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003409 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003410 })
3411
3412 // Req1
3413 var params *teststube2ap.RESTSubsReqParams = nil
3414
3415 //Subs Create
3416 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3417 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3418
3419 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003420 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003421 params.SetMeid("RAN_NAME_1")
3422
3423 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
3424 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003425 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003426 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003427 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003428 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
3429 e2SubsId2 := <-xappConn2.RESTNotification
3430 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3431
3432 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3433
3434 // Del1
3435 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3436
3437 // Del2
3438 deleteXapp2Subscription(t, &restSubId2)
3439
3440 //Wait that subs is cleaned
3441 waitSubsCleanup(t, e2SubsId2, 10)
3442
3443 mainCtrl.VerifyCounterValues(t)
3444}
3445
3446//-----------------------------------------------------------------------------
3447// TestSubReqAndSubDelOkSameActionParallel
3448//
3449// stub stub stub
3450// +-------+ +-------+ +---------+ +---------+
3451// | xapp2 | | xapp1 | | submgr | | e2term |
3452// +-------+ +-------+ +---------+ +---------+
3453// | | | |
3454// | | | |
3455// | | | |
3456// | | SubReq1 | |
3457// | |------------->| |
3458// | | | |
3459// | | | SubReq1 |
3460// | | |------------->|
3461// | SubReq2 | |
3462// |--------------------------->| |
3463// | | | SubResp1 |
3464// | | |<-------------|
3465// | | SubResp1 | |
3466// | |<-------------| |
3467// | | | SubReq2 |
3468// | | |------------->|
3469// | | | |
3470// | | | SubResp2 |
3471// | | |<-------------|
3472// | SubResp2 | |
3473// |<---------------------------| |
3474// | | | |
3475// | | SubDelReq 1 | |
3476// | |------------->| |
3477// | | | |
3478// | | SubDelResp 1 | |
3479// | |<-------------| |
3480// | | | |
3481// | SubDelReq 2 | |
3482// |--------------------------->| |
3483// | | | |
3484// | | | SubDelReq 2 |
3485// | | |------------->|
3486// | | | |
3487// | | | SubDelReq 2 |
3488// | | |------------->|
3489// | | | |
3490// | SubDelResp 2 | |
3491// |<---------------------------| |
3492//
3493func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
3494 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
3495
3496 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003497 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003498 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003499 Counter{cSubReqToE2, 2},
3500 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003501 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003502 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003503 Counter{cSubDelReqToE2, 2},
3504 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003505 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003506 })
3507
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003508 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003509 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3510 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3511
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003512 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003513 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3514
3515 xappConn1.ExpectRESTNotification(t, restSubId1)
3516 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3517 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3518
3519 xappConn2.ExpectRESTNotification(t, restSubId2)
3520 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3521 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3522 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3523
3524 // Del1
3525 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3526 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3527 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3528 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3529
3530 // Del2
3531 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3532 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
3533 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
3534
3535 waitSubsCleanup(t, e2SubsId2, 10)
3536
3537 mainCtrl.VerifyCounterValues(t)
3538}
3539
3540//-----------------------------------------------------------------------------
3541// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
3542//
3543// stub stub stub
3544// +-------+ +-------+ +---------+ +---------+
3545// | xapp2 | | xapp1 | | submgr | | e2term |
3546// +-------+ +-------+ +---------+ +---------+
3547// | | | |
3548// | | | |
3549// | | | |
3550// | | RESTSubReq1 | |
3551// | |---------------->| |
3552// | | | |
3553// | | RESTSubResp1 | |
3554// | |<----------------| |
3555// | | | SubReq1 |
3556// | | |------------->|
3557// | RESTSubReq2 | |
3558// |------------------------------>| |
3559// | | | |
3560// | RESTSubDelResp2 | |
3561// |<------------------------------| |
3562// | | | SubReq1 |
3563// | | |------------->|
3564// | | | |
3565// | | | |
3566// | | | SubDelReq |
3567// | | |------------->|
3568// | | | |
3569// | | | SubDelResp |
3570// | | |<-------------|
3571// | | RESTNotif1 | |
3572// | | unsuccess | |
3573// | |<----------------| |
3574// | RESTNotif2 | |
3575// | | unsuccess | |
3576// |<------------------------------| |
3577// | | | |
3578// | | RESTSubDelReq1 | |
3579// | |---------------->| |
3580// | | | |
3581// | | RESTSubDelResp1 | |
3582// | |<----------------| |
3583// | | | |
3584// | RESTSubDelReq2 | |
3585// |------------------------------>| |
3586// | | | |
3587// | RESTSubDelResp2 | |
3588// |<------------------------------| |
3589//
3590//-----------------------------------------------------------------------------
3591func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
3592 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
3593
3594 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003595 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003596 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003597 Counter{cSubReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003598 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003599 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003600 Counter{cSubDelReqToE2, 1},
3601 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003602 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003603 })
3604
3605 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003606
3607 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003608 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003609 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
3610 crereq1, _ := e2termConn1.RecvSubsReq(t)
3611
3612 // Req2
3613 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003614 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003615 params2.SetMeid("RAN_NAME_1")
3616 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3617 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3618
3619 //Req1 (retransmitted)
3620 e2termConn1.RecvSubsReq(t)
3621
3622 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00003623
3624 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03003625 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3626
Markku Virtanenda34eec2021-05-20 08:22:04 +00003627 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3628 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3629 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3630 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003631
3632 // Del1
3633 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3634
3635 // Del2
3636 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3637
Markku Virtanenda34eec2021-05-20 08:22:04 +00003638 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
3639
archaggeafbf95f2021-04-14 08:54:05 +03003640 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00003641 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003642
3643 mainCtrl.VerifyCounterValues(t)
3644}
3645
3646//-----------------------------------------------------------------------------
3647// TestRESTSubReqAndSubDelNokSameActionParallel
3648//
3649// stub stub stub
3650// +-------+ +-------+ +---------+ +---------+
3651// | xapp2 | | xapp1 | | submgr | | e2term |
3652// +-------+ +-------+ +---------+ +---------+
3653// | | | |
3654// | | | |
3655// | | | |
3656// | | RESTSubReq1 | |
3657// | |---------------->| |
3658// | | | |
3659// | | RESTSubResp1 | |
3660// | |<----------------| |
3661// | | | SubReq1 |
3662// | | |------------->|
3663// | RESTSubReq2 | |
3664// |------------------------------>| |
3665// | | | |
3666// | RESTSubDelResp2 | |
3667// |<------------------------------| |
3668// | | | SubFail1 |
3669// | | |<-------------|
3670// | | | |
3671// | | RESTNotif1 | |
3672// | | unsuccess | |
3673// | |<----------------| |
3674// | RESTNotif2 | |
3675// | | unsuccess | |
3676// |<------------------------------| |
3677// | | | SubDelReq |
3678// | | |------------->|
3679// | | | SubDelResp |
3680// | | |<-------------|
3681// | | | |
3682// | | RESTSubDelReq1 | |
3683// | |---------------->| |
3684// | | | |
3685// | | RESTSubDelResp1 | |
3686// | |<----------------| |
3687// | | | |
3688// | RESTSubDelReq2 | |
3689// |------------------------------>| |
3690// | | | |
3691// | RESTSubDelResp2 | |
3692// |<------------------------------| |
3693//
3694//-----------------------------------------------------------------------------
3695func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
3696 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
3697
3698 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003699 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003700 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003701 Counter{cSubReqToE2, 1},
3702 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003703 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003704 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003705 Counter{cSubDelReqToE2, 1},
3706 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003707 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003708 })
3709
3710 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003711
3712 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003713 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003714 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3715 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3716
3717 // Req2
3718 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003719 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003720 params2.SetMeid("RAN_NAME_1")
3721 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3722 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3723
3724 // E2t: send SubsFail (first)
3725 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3726 fparams1.Set(crereq1)
3727 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3728
3729 // E2t: internal delete
3730 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3731 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3732 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3733
3734 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3735 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3736 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3737 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3738
3739 // Del1
3740 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3741
3742 // Del2
3743 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3744
3745 //Wait that subs is cleaned
3746 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
3747 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3748
3749 mainCtrl.VerifyCounterValues(t)
3750}
3751
3752func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
3753 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3754
3755 // Init counter check
3756 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003757 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003758 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003759 Counter{cSubReqToE2, 1},
3760 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003761 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003762 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003763 Counter{cSubDelReqToE2, 1},
3764 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003765 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003766 })
3767
3768 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003769
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003770 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003771 restSubId := xappConn1.SendRESTSubsReq(t, params)
3772 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3773
3774 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3775 xappConn1.ExpectRESTNotification(t, restSubId)
3776 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3777 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3778 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
3779
3780 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3781 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3782 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3783
3784 // Wait that subs is cleaned
3785 waitSubsCleanup(t, e2SubsId, 10)
3786 mainCtrl.VerifyCounterValues(t)
3787}
3788
3789//-----------------------------------------------------------------------------
3790// TestRESTSubReqPolicyChangeAndSubDelOk
3791//
3792// stub stub
3793// +-------+ +---------+ +---------+
3794// | xapp | | submgr | | e2term |
3795// +-------+ +---------+ +---------+
3796// | | |
3797// | RESTSubReq | |
3798// |---------------->| |
3799// | | |
3800// | RESTSubResp | |
3801// |<----------------| |
3802// | | SubReq |
3803// | |------------->|
3804// | | |
3805// | | SubResp |
3806// | |<-------------|
3807// | | |
3808// | RESTNotif | |
3809// |<----------------| |
3810// | | |
3811// | RESTSubReq | |
3812// |---------------->| |
3813// | | |
3814// | RESTSubResp | |
3815// |<----------------| |
3816// | | SubReq |
3817// | |------------->|
3818// | | |
3819// | | SubResp |
3820// | |<-------------|
3821// | | |
3822// | RESTNotif | |
3823// |<----------------| |
3824// | | |
3825// | RESTSubDelReq | |
3826// |---------------->| |
3827// | | |
3828// | | SubDelReq |
3829// | |------------->|
3830// | | |
3831// | | SubDelResp |
3832// | |<-------------|
3833// | | |
3834// | RESTSubDelResp | |
3835// |<----------------| |
3836//
3837//-----------------------------------------------------------------------------
3838func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
3839 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3840
3841 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003842 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003843 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003844 Counter{cSubReqToE2, 2},
3845 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003846 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003847 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003848 Counter{cSubDelReqToE2, 1},
3849 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003850 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003851 })
3852
3853 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003854
3855 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003856 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003857 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3858
3859 // Policy change
3860 instanceId := int64(e2SubsId)
3861 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003862 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003863 params.SubsReqParams.SubscriptionDetails[0].InstanceID = &instanceId
3864 params.SetTimeToWait("w200ms")
3865 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3866
3867 // Del
3868 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3869
3870 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3871 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3872
3873 // Wait that subs is cleaned
3874 waitSubsCleanup(t, e2SubsId, 10)
3875 mainCtrl.VerifyCounterValues(t)
3876}
3877
3878//-----------------------------------------------------------------------------
3879// TestRESTSubReqAndSubDelOkTwoE2termParallel
3880//
3881// stub stub stub
3882// +-------+ +---------+ +---------+ +---------+
3883// | xapp | | submgr | | e2term1 | | e2term2 |
3884// +-------+ +---------+ +---------+ +---------+
3885// | | | |
3886// | | | |
3887// | | | |
3888// | RESTSubReq1 | | |
3889// |---------------->| | |
3890// | | | |
3891// | RESTSubResp1 | | |
3892// |<----------------| | |
3893// | | SubReq1 | |
3894// | |------------->| |
3895// | | | |
3896// | RESTSubReq2 | | |
3897// |---------------->| | |
3898// | | | |
3899// | RESTSubResp2 | | |
3900// |<----------------| | |
3901// | | SubReq2 | |
3902// | |---------------------------->|
3903// | | | |
3904// | | SubResp1 | |
3905// | |<-------------| |
3906// | RESTNotif1 | | |
3907// |<----------------| | |
3908// | | SubResp2 | |
3909// | |<----------------------------|
3910// | RESTNotif2 | | |
3911// |<----------------| | |
3912// | | | |
3913// | [SUBS 1 DELETE] | |
3914// | | | |
3915// | [SUBS 2 DELETE] | |
3916// | | | |
3917//
3918//-----------------------------------------------------------------------------
3919func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
3920 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
3921
3922 // Init counter check
3923 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003924 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003925 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003926 Counter{cSubReqToE2, 2},
3927 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003928 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003929 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003930 Counter{cSubDelReqToE2, 2},
3931 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003932 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003933 })
3934
3935 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003936
3937 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003938 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003939 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3940 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3941
3942 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003943 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003944 params.SetMeid("RAN_NAME_11")
3945 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
3946 // would not work as notification would not be received
3947 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3948 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
3949
3950 // Resp1
3951 xappConn1.ExpectRESTNotification(t, restSubId1)
3952 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3953 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3954 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
3955
3956 // Resp2
3957 xappConn2.ExpectRESTNotification(t, restSubId2)
3958 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
3959 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3960 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
3961
3962 // Delete1
3963 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3964 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3965 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3966
3967 // Wait that subs is cleaned
3968 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3969
3970 // Delete2
3971 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
3972 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
3973 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
3974
3975 // Wait that subs is cleaned
3976 waitSubsCleanup(t, e2SubsId2, 10)
3977
3978 mainCtrl.VerifyCounterValues(t)
3979}
3980
3981//-----------------------------------------------------------------------------
3982// TestRESTSubReqAsn1EncodeFail
3983//
3984// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
3985// stub stub
3986// +-------+ +---------+ +---------+
3987// | xapp | | submgr | | e2term |
3988// +-------+ +---------+ +---------+
3989// | | |
3990// | RESTSubReq | |
3991// |---------------->| |
3992// | | |
3993// | RESTSubResp | |
3994// |<----------------| |
3995// | RESTSubDelReq | |
3996// |---------------->| |
3997// | RESTSubDelResp | |
3998// | unsuccess | |
3999// |<----------------| |
4000// | | |
4001//
4002//-----------------------------------------------------------------------------
4003func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4004 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4005
4006 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
4007
4008}
4009
4010//-----------------------------------------------------------------------------
4011// TestRESTSubReqInsertAndSubDelOk
4012//
4013// stub stub
4014// +-------+ +---------+ +---------+
4015// | xapp | | submgr | | e2term |
4016// +-------+ +---------+ +---------+
4017// | | |
4018// | RestSubReq | |
4019// |---------------->| |
4020// | | |
4021// | RESTSubResp | |
4022// |<----------------| |
4023// | | |
4024// | | SubReq |
4025// | |------------->|
4026// | | |
4027// | | SubResp |
4028// | |<-------------|
4029// | RESTNotif | |
4030// |<----------------| |
4031// | ... | ... |
4032// | | |
4033// | RESTSubDelReq | |
4034// |---------------->| |
4035// | | |
4036// | | SubDelReq |
4037// | |------------->|
4038// | | |
4039// | | SubDelResp |
4040// | |<-------------|
4041// | | |
4042// | RESTSubDelResp| |
4043// |<----------------| |
4044//
4045//-----------------------------------------------------------------------------
4046func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4047 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4048
4049 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004050 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004051 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004052 Counter{cSubReqToE2, 1},
4053 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004054 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004055 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004056 Counter{cSubDelReqToE2, 1},
4057 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004058 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004059 })
4060
4061 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004062
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004063 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004064 params.SetSubActionTypes("insert")
4065
4066 // Req
4067 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4068
4069 // Del
4070 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4071
4072 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4073 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4074
4075 // Wait that subs is cleaned
4076 waitSubsCleanup(t, e2SubsId, 10)
4077 mainCtrl.VerifyCounterValues(t)
4078}
4079
4080//-----------------------------------------------------------------------------
4081// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4082//
4083// stub stub
4084// +-------+ +---------+ +---------+
4085// | xapp | | submgr | | e2term |
4086// +-------+ +---------+ +---------+
4087// | | |
4088// | RESTSubReq | |
4089// |------------->| |
4090// | | |
4091// | | SubReq |
4092// | |------------->|
4093// | | |
4094// | | SubResp |
4095// | <----|
4096// | |
4097// | Submgr restart |
4098// | |
4099// | | |
4100// | | SubDelReq |
4101// | |------------->|
4102// | | |
4103// | | SubDelResp |
4104// | |<-------------|
4105// | | |
4106//
4107//-----------------------------------------------------------------------------
4108func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4109 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4110
4111 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004112 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004113 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004114 Counter{cSubReqToE2, 1},
4115 Counter{cSubDelReqFromXapp, 1},
4116 Counter{cSubDelReqToE2, 1},
4117 Counter{cSubDelRespFromE2, 1},
4118 })
4119
4120 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004121
4122 // Remove possible existing subscription
4123 mainCtrl.removeExistingSubscriptions(t)
4124
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004125 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004126
4127 //Req
4128 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
4129 restSubId := xappConn1.SendRESTSubsReq(t, params)
4130 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4131
4132 e2termConn1.RecvSubsReq(t)
4133
4134 mainCtrl.SetResetTestFlag(t, false)
4135
4136 mainCtrl.SimulateRestart(t)
4137 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4138
4139 //Del
4140 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4141 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4142
4143 xappConn1.TestMsgChanEmpty(t)
4144 xappConn2.TestMsgChanEmpty(t)
4145 e2termConn1.TestMsgChanEmpty(t)
4146 mainCtrl.wait_registry_empty(t, 10)
4147
4148 mainCtrl.VerifyCounterValues(t)
4149}
4150
4151//-----------------------------------------------------------------------------
4152// TestRESTSubReqAndSubDelOkWithRestartInMiddle
4153//
4154// stub stub
4155// +-------+ +---------+ +---------+
4156// | xapp | | submgr | | e2term |
4157// +-------+ +---------+ +---------+
4158// | | |
4159// | RESTSubReq | |
4160// |---------------->| |
4161// | | |
4162// | RESTSubResp | |
4163// |<----------------| |
4164// | | SubReq |
4165// | |------------->|
4166// | | |
4167// | | SubResp |
4168// | |<-------------|
4169// | | |
4170// | RESTNotif | |
4171// |<----------------| |
4172// | | |
4173// | |
4174// | Submgr restart |
4175// | | |
4176// | RESTSubDelReq | |
4177// |---------------->| |
4178// | | |
4179// | | SubDelReq |
4180// | |------------->|
4181// | | |
4182// | | SubDelResp |
4183// | |<-------------|
4184// | | |
4185// | RESTSubDelResp | |
4186// |<----------------| |
4187//
4188//-----------------------------------------------------------------------------
4189func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4190 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4191
4192 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004193 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004194 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004195 Counter{cSubReqToE2, 1},
4196 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004197 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004198 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004199 Counter{cSubDelReqToE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004200 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004201 })
4202
4203 // Remove possible existing subscription
4204 mainCtrl.removeExistingSubscriptions(t)
4205
4206 var params *teststube2ap.RESTSubsReqParams = nil
4207
4208 // Create subscription
4209 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4210 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4211
4212 // Check subscription
4213 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4214
4215 // When SDL support for the REST Interface is added
4216 // the submgr restart statement below should be removed
4217 // from the comment.
4218
4219 // mainCtrl.SimulateRestart(t)
4220 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4221
4222 // Check subscription
4223 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4224
4225 // Delete subscription
4226 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4227
4228 //Wait that subs is cleaned
4229 waitSubsCleanup(t, e2SubsId, 10)
4230
4231 mainCtrl.VerifyCounterValues(t)
4232}
4233
4234//-----------------------------------------------------------------------------
4235// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4236//
4237// stub stub
4238// +-------+ +-------+ +---------+ +---------+
4239// | xapp2 | | xapp1 | | submgr | | e2term |
4240// +-------+ +-------+ +---------+ +---------+
4241// | | | |
4242// | | RESTSubReq1 | |
4243// | |---------------->| |
4244// | | | |
4245// | | RESTSubResp1 | |
4246// | |<----------------| |
4247// | | | |
4248// | | | SubReq1 |
4249// | | |------------->|
4250// | | | SubResp1 |
4251// | | |<-------------|
4252// | | RESTNotif1 | |
4253// | |<----------------| |
4254// | | | |
4255// | RESTSubReq2 | |
4256// |------------------------------>| |
4257// | | | |
4258// | RESTSubResp2 | |
4259// |<------------------------------| |
4260// | | | |
4261// | | RESTNotif2 | |
4262// |<------------------------------| |
4263// | | | |
4264// | | Submgr restart |
4265// | | | |
4266// | | RESTSubDelReq1 | |
4267// | |---------------->| |
4268// | | | |
4269// | | RESTSubDelResp1 | |
4270// | |<----------------| |
4271// | | | |
4272// | | Submgr restart |
4273// | | | |
4274// | RESTSubDelReq2 | |
4275// |------------------------------>| |
4276// | | | |
4277// | RESTSubDelResp2 | |
4278// |<------------------------------| |
4279// | | | |
4280// | | | SubDelReq2 |
4281// | | |------------->|
4282// | | | |
4283// | | | SubDelResp2 |
4284// | | |<-------------|
4285// | | | |
4286//
4287//-----------------------------------------------------------------------------
4288func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4289 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4290
4291 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004292 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004293 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004294 Counter{cSubReqToE2, 1},
4295 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004296 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004297 Counter{cMergedSubscriptions, 1},
4298 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004299 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004300 Counter{cSubDelReqToE2, 1},
4301 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004302 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004303 })
4304
4305 // Remove possible existing subscription
4306 mainCtrl.removeExistingSubscriptions(t)
4307
4308 var params *teststube2ap.RESTSubsReqParams = nil
4309
4310 // Create subscription 1
4311 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4312 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4313
4314 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004315 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004316 params.SetMeid("RAN_NAME_1")
4317 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4318 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
4319 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4320 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4321 e2SubsId2 := <-xappConn2.RESTNotification
4322 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4323
4324 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4325
4326 // When SDL support for the REST Interface is added
4327 // the submgr restart statement below should be removed
4328 // from the comment.
4329
4330 // mainCtrl.SimulateRestart(t)
4331 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4332
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004333 // Delete subscription 1, and wait until it has removed the first endpoint
4334 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004335 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004336 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004337
4338 // When SDL support for the REST Interface is added
4339 // the submgr restart statement below should be removed
4340 // from the comment.
4341
4342 // mainCtrl.SimulateRestart(t)
4343 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004344 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4345
4346 // Delete subscription 2
4347 deleteXapp2Subscription(t, &restSubId2)
4348
4349 //Wait that subs is cleaned
4350 waitSubsCleanup(t, e2SubsId2, 10)
4351
4352 mainCtrl.VerifyCounterValues(t)
4353}
4354
4355//-----------------------------------------------------------------------------
4356// TestRESTReportSubReqAndSubDelOk
4357//
4358// stub stub
4359// +-------+ +---------+ +---------+
4360// | xapp | | submgr | | e2term |
4361// +-------+ +---------+ +---------+
4362// | | |
4363// | RestSubReq | |
4364// |---------------->| |
4365// | | |
4366// | RESTSubResp | |
4367// |<----------------| |
4368// | | |
4369// | | SubReq |
4370// | |------------->|
4371// | | |
4372// | | SubResp |
4373// | |<-------------|
4374// | RESTNotif | |
4375// |<----------------| |
4376// | | SubReq |
4377// | |------------->|
4378// | | |
4379// | | SubResp |
4380// | |<-------------|
4381// | RESTNotif | |
4382// |<----------------| |
4383// | ... | ... |
4384// | | |
4385// | | |
4386// | RESTSubDelReq | |
4387// |---------------->| |
4388// | | |
4389// | | SubDelReq |
4390// | |------------->|
4391// | | |
4392// | | SubDelResp |
4393// | |<-------------|
4394// | | |
4395// | RESTSubDelResp| |
4396// |<----------------| |
4397//
4398//-----------------------------------------------------------------------------
4399func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
4400 CaseBegin("TestRESTReportSubReqAndSubDelOk")
4401 subReqCount := 1
archaggeafbf95f2021-04-14 08:54:05 +03004402 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004403 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004404}
4405
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004406func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
4407 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004408
4409 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004410 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004411 restSubId := xappConn1.SendRESTSubsReq(t, params)
4412
4413 var e2SubsId []uint32
4414 for i := 0; i < subReqCount; i++ {
4415 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4416 xappConn1.ExpectRESTNotification(t, restSubId)
4417
4418 e2termConn1.SendSubsResp(t, crereq, cremsg)
4419 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4420 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4421 e2SubsId = append(e2SubsId, instanceId)
4422 resp, _ := xapp.Subscription.QuerySubscriptions()
4423 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
4424 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
4425 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
4426
4427 }
4428
4429 // Del
4430 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4431
4432 for i := 0; i < subReqCount; i++ {
4433 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4434 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4435 }
4436
4437 // Wait that subs is cleaned
4438 for i := 0; i < subReqCount; i++ {
4439 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4440 }
4441
4442 xappConn1.TestMsgChanEmpty(t)
4443 e2termConn1.TestMsgChanEmpty(t)
4444 mainCtrl.wait_registry_empty(t, 10)
4445}
4446
4447/*
4448func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
4449 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
4450
4451 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004452 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004453 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004454
4455 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03004456 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004457 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004458}
4459*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004460func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
4461 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03004462
4463 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004464 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004465 restSubId := xappConn1.SendRESTSubsReq(t, params)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004466 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004467 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
4468
4469 var e2SubsId []uint32
4470 for i := 0; i < subReqCount; i++ {
4471 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4472 xappConn1.ExpectRESTNotification(t, restSubId)
4473 e2termConn1.SendSubsResp(t, crereq, cremsg)
4474 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4475 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4476 e2SubsId = append(e2SubsId, instanceId)
4477 }
4478
4479 // Del
4480 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4481
4482 for i := 0; i < subReqCount; i++ {
4483 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4484 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4485 }
4486
4487 // Wait that subs is cleaned
4488 for i := 0; i < subReqCount; i++ {
4489 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4490 }
4491 xappConn1.TestMsgChanEmpty(t)
4492 e2termConn1.TestMsgChanEmpty(t)
4493 mainCtrl.wait_registry_empty(t, 10)
4494}
4495
archaggeafbf95f2021-04-14 08:54:05 +03004496func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
4497
4498 subReqCount := 2
4499
4500 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004501 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004502 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004503 Counter{cSubReqToE2, 2},
4504 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004505 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004506 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004507 Counter{cSubDelReqToE2, 2},
4508 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004509 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004510 })
4511
4512 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004513 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004514 restSubId := xappConn1.SendRESTSubsReq(t, params)
4515 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4516
4517 assert.Equal(t, len(e2SubsIds), 2)
4518
4519 // Del
4520 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4521 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4522
4523 xappConn1.TestMsgChanEmpty(t)
4524 e2termConn1.TestMsgChanEmpty(t)
4525 mainCtrl.wait_registry_empty(t, 10)
4526
4527 mainCtrl.VerifyCounterValues(t)
4528}
archaggeafbf95f2021-04-14 08:54:05 +03004529func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
4530
4531 subReqCount := 19
4532
4533 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004534 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004535 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004536 Counter{cSubReqToE2, 19},
4537 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004538 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004539 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004540 Counter{cSubDelReqToE2, 19},
4541 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004542 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004543 })
4544
4545 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004546 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004547 restSubId := xappConn1.SendRESTSubsReq(t, params)
4548 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4549
4550 assert.Equal(t, len(e2SubsIds), 19)
4551
4552 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4553 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4554
4555 xappConn1.TestMsgChanEmpty(t)
4556 e2termConn1.TestMsgChanEmpty(t)
4557 mainCtrl.wait_registry_empty(t, 10)
4558
4559 mainCtrl.VerifyCounterValues(t)
4560}
archaggeafbf95f2021-04-14 08:54:05 +03004561func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
4562
4563 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004564
4565 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004566 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004567 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004568 Counter{cSubReqToE2, uint64(subReqCount)},
4569 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004570 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004571 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004572 Counter{cSubDelReqToE2, uint64(subReqCount)},
4573 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004574 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004575 })
4576
4577 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004578 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004579 restSubId := xappConn1.SendRESTSubsReq(t, params)
4580 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4581
4582 assert.Equal(t, len(e2SubsIds), subReqCount)
4583
4584 // Del
4585 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4586 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4587
4588 xappConn1.TestMsgChanEmpty(t)
4589 e2termConn1.TestMsgChanEmpty(t)
4590 mainCtrl.wait_registry_empty(t, 10)
4591
4592 mainCtrl.VerifyCounterValues(t)
4593}
Markku Virtanenda34eec2021-05-20 08:22:04 +00004594
archaggeafbf95f2021-04-14 08:54:05 +03004595func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
4596
4597 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03004598
4599 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004600 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004601 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004602 Counter{cSubReqToE2, uint64(subReqCount)},
4603 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004604 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004605 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004606 Counter{cSubDelReqToE2, uint64(subReqCount)},
4607 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004608 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004609 })
4610
4611 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004612 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004613 restSubId := xappConn1.SendRESTSubsReq(t, params)
4614 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4615
4616 assert.Equal(t, len(e2SubsIds), subReqCount)
4617
4618 // Del
4619 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4620 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4621
4622 xappConn1.TestMsgChanEmpty(t)
4623 e2termConn1.TestMsgChanEmpty(t)
4624 mainCtrl.wait_registry_empty(t, 10)
4625
4626 mainCtrl.VerifyCounterValues(t)
4627}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004628
archaggeafbf95f2021-04-14 08:54:05 +03004629func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
4630
4631 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03004632
4633 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004634 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004635 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004636 Counter{cSubReqToE2, uint64(subReqCount)},
4637 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004638 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004639 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004640 Counter{cSubDelReqToE2, uint64(subReqCount)},
4641 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004642 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004643 })
4644
4645 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004646 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004647 restSubId := xappConn1.SendRESTSubsReq(t, params)
4648 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4649
4650 assert.Equal(t, len(e2SubsIds), subReqCount)
4651
4652 // Del
4653 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4654 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4655
4656 xappConn1.TestMsgChanEmpty(t)
4657 e2termConn1.TestMsgChanEmpty(t)
4658 mainCtrl.wait_registry_empty(t, 10)
4659
4660 mainCtrl.VerifyCounterValues(t)
4661}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004662
4663func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
4664 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
4665
4666 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004667 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004668 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004669 Counter{cSubReqToE2, 2},
4670 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004671 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004672 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004673 Counter{cSubDelReqToE2, 2},
4674 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004675 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004676 })
4677
4678 // Req1
4679 var params *teststube2ap.RESTSubsReqParams = nil
4680
4681 //Subs Create
4682 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4683 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4684
4685 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4686
4687 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004688 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004689 params.SetMeid("RAN_NAME_1")
4690 eventTriggerDefinition := "1234"
4691 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
4692
4693 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4694 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4695 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4696 xappConn2.ExpectRESTNotification(t, restSubId2)
4697 e2termConn1.SendSubsResp(t, crereq, cremsg)
4698 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4699
4700 deleteXapp1Subscription(t, &restSubId1)
4701 deleteXapp2Subscription(t, &restSubId2)
4702
4703 waitSubsCleanup(t, e2SubsId1, 10)
4704 waitSubsCleanup(t, e2SubsId2, 10)
4705
4706 mainCtrl.VerifyCounterValues(t)
4707
4708}
4709
4710func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
4711 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
4712
4713 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004714 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004715 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004716 Counter{cSubReqToE2, 2},
4717 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004718 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004719 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004720 Counter{cSubDelReqToE2, 2},
4721 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004722 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004723 })
4724
4725 // Req1
4726 var params *teststube2ap.RESTSubsReqParams = nil
4727
4728 //Subs Create
4729 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4730 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4731
4732 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4733
4734 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004735 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004736 params.SetMeid("RAN_NAME_1")
4737
4738 actionId := int64(1)
4739 actionType := "report"
4740 actionDefinition := "56781"
4741 subsequestActionType := "continue"
4742 timeToWait := "w10ms"
4743 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4744
4745 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4746 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4747 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4748 xappConn2.ExpectRESTNotification(t, restSubId2)
4749 e2termConn1.SendSubsResp(t, crereq, cremsg)
4750 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4751
4752 deleteXapp1Subscription(t, &restSubId1)
4753 deleteXapp2Subscription(t, &restSubId2)
4754
4755 waitSubsCleanup(t, e2SubsId1, 10)
4756 waitSubsCleanup(t, e2SubsId2, 10)
4757
4758 mainCtrl.VerifyCounterValues(t)
4759
4760}
4761
4762func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
4763 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
4764
4765 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004766 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004767 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004768 Counter{cSubReqToE2, 2},
4769 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004770 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004771 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004772 Counter{cSubDelReqToE2, 2},
4773 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004774 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004775 })
4776
4777 // Req1
4778 var params *teststube2ap.RESTSubsReqParams = nil
4779
4780 //Subs Create
4781 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4782 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4783
4784 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4785
4786 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004787 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004788 params.SetMeid("RAN_NAME_1")
4789 params.SetSubActionIDs(int64(2))
4790
4791 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4792 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4793 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4794 xappConn2.ExpectRESTNotification(t, restSubId2)
4795 e2termConn1.SendSubsResp(t, crereq, cremsg)
4796 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4797
4798 deleteXapp1Subscription(t, &restSubId1)
4799 deleteXapp2Subscription(t, &restSubId2)
4800
4801 waitSubsCleanup(t, e2SubsId1, 10)
4802 waitSubsCleanup(t, e2SubsId2, 10)
4803
4804 mainCtrl.VerifyCounterValues(t)
4805
4806}
4807
4808func TestRESTSubReqDiffActionType(t *testing.T) {
4809 CaseBegin("TestRESTSubReqDiffActionType")
4810
4811 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004812 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004813 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004814 Counter{cSubReqToE2, 2},
4815 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004816 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004817 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004818 Counter{cSubDelReqToE2, 2},
4819 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004820 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004821 })
4822
4823 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004824 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004825
4826 //Subs Create
4827 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4828 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4829
4830 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4831
4832 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004833 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004834 params.SetMeid("RAN_NAME_1")
4835
4836 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4837 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4838 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4839 xappConn2.ExpectRESTNotification(t, restSubId2)
4840 e2termConn1.SendSubsResp(t, crereq, cremsg)
4841 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4842
4843 deleteXapp1Subscription(t, &restSubId1)
4844 deleteXapp2Subscription(t, &restSubId2)
4845
4846 waitSubsCleanup(t, e2SubsId1, 10)
4847 waitSubsCleanup(t, e2SubsId2, 10)
4848
4849 mainCtrl.VerifyCounterValues(t)
4850
4851}
4852
4853func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
4854 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
4855
4856 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004857 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004858 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004859 Counter{cSubReqToE2, 2},
4860 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004861 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004862 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004863 Counter{cSubDelReqToE2, 2},
4864 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004865 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004866 })
4867
4868 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004869 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004870
4871 //Subs Create
4872 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4873 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4874
4875 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4876
4877 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004878 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004879 params.SetMeid("RAN_NAME_1")
4880
4881 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4882 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4883 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4884 xappConn2.ExpectRESTNotification(t, restSubId2)
4885 e2termConn1.SendSubsResp(t, crereq, cremsg)
4886 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4887
4888 deleteXapp1Subscription(t, &restSubId1)
4889 deleteXapp2Subscription(t, &restSubId2)
4890
4891 waitSubsCleanup(t, e2SubsId1, 10)
4892 waitSubsCleanup(t, e2SubsId2, 10)
4893
4894 mainCtrl.VerifyCounterValues(t)
4895
4896}
4897
4898func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
4899 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
4900
4901 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004902 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004903 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004904 Counter{cSubReqToE2, 2},
4905 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004906 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004907 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004908 Counter{cSubDelReqToE2, 2},
4909 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004910 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004911 })
4912
4913 // Req1
4914 var params *teststube2ap.RESTSubsReqParams = nil
4915
4916 //Subs Create
4917 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4918 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4919
4920 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4921
4922 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004923 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004924 params.SetMeid("RAN_NAME_1")
4925 actionDefinition := "5678"
4926 params.SetSubActionDefinition(actionDefinition)
4927
4928 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4929 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4930 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4931 xappConn2.ExpectRESTNotification(t, restSubId2)
4932 e2termConn1.SendSubsResp(t, crereq, cremsg)
4933 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4934
4935 deleteXapp1Subscription(t, &restSubId1)
4936 deleteXapp2Subscription(t, &restSubId2)
4937
4938 waitSubsCleanup(t, e2SubsId1, 10)
4939 waitSubsCleanup(t, e2SubsId2, 10)
4940
4941 mainCtrl.VerifyCounterValues(t)
4942
4943}
4944
4945func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
4946 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
4947
4948 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004949 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004950 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004951 Counter{cSubReqToE2, 2},
4952 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004953 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004954 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004955 Counter{cSubDelReqToE2, 2},
4956 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004957 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004958 })
4959
4960 // Req1
4961 var params *teststube2ap.RESTSubsReqParams = nil
4962
4963 //Subs Create
4964 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4965 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4966
4967 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4968
4969 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004970 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004971 params.SetMeid("RAN_NAME_1")
4972 actionDefinition := "56782"
4973 params.SetSubActionDefinition(actionDefinition)
4974
4975 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4976 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4977 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4978 xappConn2.ExpectRESTNotification(t, restSubId2)
4979 e2termConn1.SendSubsResp(t, crereq, cremsg)
4980 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4981
4982 deleteXapp1Subscription(t, &restSubId1)
4983 deleteXapp2Subscription(t, &restSubId2)
4984
4985 waitSubsCleanup(t, e2SubsId1, 10)
4986 waitSubsCleanup(t, e2SubsId2, 10)
4987
4988 mainCtrl.VerifyCounterValues(t)
4989
4990}
4991
4992func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
4993 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
4994
4995 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004996 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004997 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004998 Counter{cSubReqToE2, 2},
4999 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005000 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005001 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005002 Counter{cSubDelReqToE2, 2},
5003 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005004 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005005 })
5006
5007 // Req1
5008 var params *teststube2ap.RESTSubsReqParams = nil
5009
5010 //Subs Create
5011 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5012 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5013
5014 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5015
5016 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005017 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005018 params.SetMeid("RAN_NAME_1")
5019 params.SetTimeToWait("w200ms")
5020 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5021 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5022 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5023 xappConn2.ExpectRESTNotification(t, restSubId2)
5024 e2termConn1.SendSubsResp(t, crereq, cremsg)
5025 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5026
5027 deleteXapp1Subscription(t, &restSubId1)
5028 deleteXapp2Subscription(t, &restSubId2)
5029
5030 waitSubsCleanup(t, e2SubsId1, 10)
5031 waitSubsCleanup(t, e2SubsId2, 10)
5032
5033 mainCtrl.VerifyCounterValues(t)
5034
5035}
5036
Anssi Mannila51122392021-05-25 11:51:31 +03005037//-----------------------------------------------------------------------------
5038// TestRESTUnpackSubscriptionResponseDecodeFail
5039//
5040// stub stub
5041// +-------+ +---------+ +---------+
5042// | xapp | | submgr | | e2term |
5043// +-------+ +---------+ +---------+
5044// | | |
5045// | RestSubReq | |
5046// |---------------->| |
5047// | | |
5048// | RESTSubResp | |
5049// |<----------------| |
5050// | | |
5051// | | SubReq |
5052// | |------------->|
5053// | | |
5054// | | SubResp | ASN.1 decode fails
5055// | |<-------------|
5056// | | |
5057// | | SubReq |
5058// | |------------->|
5059// | | |
5060// | | SubFail | Duplicated action
5061// | |<-------------|
5062// | RESTNotif (fail)| |
5063// |<----------------| |
5064// | | SubDelReq |
5065// | |------------->|
5066// | | |
5067// | | SubDelResp |
5068// | |<-------------|
5069//
5070//-----------------------------------------------------------------------------
5071func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
5072 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5073 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005074
5075 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005076 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005077 restSubId := xappConn1.SendRESTSubsReq(t, params)
5078
5079 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5080 // Decode of this response fails which will result resending original request
5081 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5082
5083 _, cremsg = e2termConn1.RecvSubsReq(t)
5084
5085 xappConn1.ExpectRESTNotification(t, restSubId)
5086
5087 // Subscription already created in E2 Node.
5088 fparams := &teststube2ap.E2StubSubsFailParams{}
5089 fparams.Set(crereq)
5090 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5091 e2termConn1.SendSubsFail(t, fparams, cremsg)
5092
5093 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5094 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5095
5096 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5097 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5098
5099 // Wait that subs is cleaned
5100 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5101
5102 xappConn1.TestMsgChanEmpty(t)
5103 e2termConn1.TestMsgChanEmpty(t)
5104 mainCtrl.wait_registry_empty(t, 10)
5105}
5106
5107//-----------------------------------------------------------------------------
5108// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5109//
5110// stub stub
5111// +-------+ +---------+ +---------+
5112// | xapp | | submgr | | e2term |
5113// +-------+ +---------+ +---------+
5114// | | |
5115// | RestSubReq | |
5116// |---------------->| |
5117// | | |
5118// | RESTSubResp | |
5119// |<----------------| |
5120// | | |
5121// | | SubReq |
5122// | |------------->|
5123// | | |
5124// | | SubResp | Unknown instanceId
5125// | |<-------------|
5126// | | |
5127// | | SubReq |
5128// | |------------->|
5129// | | |
5130// | | SubFail | Duplicated action
5131// | |<-------------|
5132// | RESTNotif (fail)| |
5133// |<----------------| |
5134// | | SubDelReq |
5135// | |------------->|
5136// | | |
5137// | | SubDelResp |
5138// | |<-------------|
5139//
5140//-----------------------------------------------------------------------------
5141func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
5142 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5143 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005144
5145 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005146 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005147 restSubId := xappConn1.SendRESTSubsReq(t, params)
5148
5149 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5150
5151 // Unknown instanceId in this response which will result resending original request
5152 orgInstanceId := crereq.RequestId.InstanceId
5153 crereq.RequestId.InstanceId = 0
5154 e2termConn1.SendSubsResp(t, crereq, cremsg)
5155
5156 _, cremsg = e2termConn1.RecvSubsReq(t)
5157
5158 xappConn1.ExpectRESTNotification(t, restSubId)
5159
5160 // Subscription already created in E2 Node.
5161 fparams := &teststube2ap.E2StubSubsFailParams{}
5162 fparams.Set(crereq)
5163 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5164 e2termConn1.SendSubsFail(t, fparams, cremsg)
5165
5166 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5167 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5168
5169 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5170 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5171
5172 // Wait that subs is cleaned
5173 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
5174
5175 xappConn1.TestMsgChanEmpty(t)
5176 e2termConn1.TestMsgChanEmpty(t)
5177 mainCtrl.wait_registry_empty(t, 10)
5178}
5179
5180//-----------------------------------------------------------------------------
5181// TestRESTUnpackSubscriptionResponseNoTransaction
5182//
5183// stub stub
5184// +-------+ +---------+ +---------+
5185// | xapp | | submgr | | e2term |
5186// +-------+ +---------+ +---------+
5187// | | |
5188// | RestSubReq | |
5189// |---------------->| |
5190// | | |
5191// | RESTSubResp | |
5192// |<----------------| |
5193// | | |
5194// | | SubReq |
5195// | |------------->|
5196// | | |
5197// | | SubResp | No transaction for the response
5198// | |<-------------|
5199// | | |
5200// | | SubReq |
5201// | |------------->|
5202// | | |
5203// | | SubFail | Duplicated action
5204// | |<-------------|
5205// | RESTNotif (fail)| |
5206// |<----------------| |
5207// | | SubDelReq |
5208// | |------------->|
5209// | | |
5210// | | SubDelResp |
5211// | |<-------------|
5212// | | |
5213// | | SubDelReq |
5214// | |------------->|
5215// | | |
5216// | | SubDelResp |
5217// | |<-------------|
5218//
5219//-----------------------------------------------------------------------------
5220func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
5221 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5222 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005223
5224 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005225 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005226 restSubId := xappConn1.SendRESTSubsReq(t, params)
5227
5228 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5229
5230 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5231 // No transaction exist for this response which will result resending original request
5232 e2termConn1.SendSubsResp(t, crereq, cremsg)
5233
5234 _, cremsg = e2termConn1.RecvSubsReq(t)
5235
5236 xappConn1.ExpectRESTNotification(t, restSubId)
5237
5238 // Subscription already created in E2 Node.
5239 fparams := &teststube2ap.E2StubSubsFailParams{}
5240 fparams.Set(crereq)
5241 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5242 e2termConn1.SendSubsFail(t, fparams, cremsg)
5243
5244 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5245 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5246
5247 // Resending happens because there no transaction
5248 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5249 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5250
5251 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5252 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5253
5254 // Wait that subs is cleaned
5255 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5256
5257 xappConn1.TestMsgChanEmpty(t)
5258 e2termConn1.TestMsgChanEmpty(t)
5259 mainCtrl.wait_registry_empty(t, 10)
5260
5261}
5262
5263//-----------------------------------------------------------------------------
5264// TestRESTUnpackSubscriptionFailureDecodeFail
5265//
5266// stub stub
5267// +-------+ +---------+ +---------+
5268// | xapp | | submgr | | e2term |
5269// +-------+ +---------+ +---------+
5270// | | |
5271// | RestSubReq | |
5272// |---------------->| |
5273// | | |
5274// | RESTSubResp | |
5275// |<----------------| |
5276// | | |
5277// | | SubReq |
5278// | |------------->|
5279// | | |
5280// | | SubFail | ASN.1 decode fails
5281// | |<-------------|
5282// | | |
5283// | | SubReq |
5284// | |------------->|
5285// | | |
5286// | | SubFail | Duplicated action
5287// | |<-------------|
5288// | RESTNotif (fail)| |
5289// |<----------------| |
5290// | | SubDelReq |
5291// | |------------->|
5292// | | |
5293// | | SubDelResp |
5294// | |<-------------|
5295//
5296//-----------------------------------------------------------------------------
5297func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
5298 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5299 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005300
5301 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005302 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005303 restSubId := xappConn1.SendRESTSubsReq(t, params)
5304
5305 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5306
5307 // Decode of this response fails which will result resending original request
5308 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5309
5310 _, cremsg = e2termConn1.RecvSubsReq(t)
5311
5312 xappConn1.ExpectRESTNotification(t, restSubId)
5313
5314 // Subscription already created in E2 Node.
5315 fparams := &teststube2ap.E2StubSubsFailParams{}
5316 fparams.Set(crereq)
5317 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5318 e2termConn1.SendSubsFail(t, fparams, cremsg)
5319
5320 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5321 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5322
5323 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5324 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5325
5326 // Wait that subs is cleaned
5327 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5328
5329 xappConn1.TestMsgChanEmpty(t)
5330 e2termConn1.TestMsgChanEmpty(t)
5331 mainCtrl.wait_registry_empty(t, 10)
5332}
5333
5334//-----------------------------------------------------------------------------
5335// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5336//
5337// stub stub
5338// +-------+ +---------+ +---------+
5339// | xapp | | submgr | | e2term |
5340// +-------+ +---------+ +---------+
5341// | | |
5342// | RestSubReq | |
5343// |---------------->| |
5344// | | |
5345// | RESTSubResp | |
5346// |<----------------| |
5347// | | |
5348// | | SubReq |
5349// | |------------->|
5350// | | |
5351// | | SubFail | Unknown instanceId
5352// | |<-------------|
5353// | | |
5354// | | SubReq |
5355// | |------------->|
5356// | | |
5357// | | SubFail | Duplicated action
5358// | |<-------------|
5359// | RESTNotif (fail)| |
5360// |<----------------| |
5361// | | SubDelReq |
5362// | |------------->|
5363// | | |
5364// | | SubDelResp |
5365// | |<-------------|
5366//
5367//-----------------------------------------------------------------------------
5368func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
5369 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
5370 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005371
5372 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005373 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005374 restSubId := xappConn1.SendRESTSubsReq(t, params)
5375
5376 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5377
5378 // Unknown instanceId in this response which will result resending original request
5379 fparams := &teststube2ap.E2StubSubsFailParams{}
5380 fparams.Set(crereq)
5381 fparams.Fail.RequestId.InstanceId = 0
5382 e2termConn1.SendSubsFail(t, fparams, cremsg)
5383
5384 _, cremsg = e2termConn1.RecvSubsReq(t)
5385
5386 xappConn1.ExpectRESTNotification(t, restSubId)
5387
5388 // Subscription already created in E2 Node.
5389 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5390 e2termConn1.SendSubsFail(t, fparams, cremsg)
5391
5392 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5393 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5394
5395 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5396 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5397
5398 // Wait that subs is cleaned
5399 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5400
5401 xappConn1.TestMsgChanEmpty(t)
5402 e2termConn1.TestMsgChanEmpty(t)
5403 mainCtrl.wait_registry_empty(t, 10)
5404}
5405
5406//-----------------------------------------------------------------------------
5407// TestRESTUnpackSubscriptionFailureNoTransaction
5408//
5409// stub stub
5410// +-------+ +---------+ +---------+
5411// | xapp | | submgr | | e2term |
5412// +-------+ +---------+ +---------+
5413// | | |
5414// | RestSubReq | |
5415// |---------------->| |
5416// | | |
5417// | RESTSubResp | |
5418// |<----------------| |
5419// | | |
5420// | | SubReq |
5421// | |------------->|
5422// | | |
5423// | | SubFail | No transaction for the response
5424// | |<-------------|
5425// | | |
5426// | | SubReq |
5427// | |------------->|
5428// | | |
5429// | | SubFail | Duplicated action
5430// | |<-------------|
5431// | RESTNotif (fail)| |
5432// |<----------------| |
5433// | | SubDelReq |
5434// | |------------->|
5435// | | |
5436// | | SubDelResp |
5437// | |<-------------|
5438//
5439//-----------------------------------------------------------------------------
5440func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
5441 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
5442 subReqCount := 1
Anssi Mannila51122392021-05-25 11:51:31 +03005443
5444 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005445 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005446 restSubId := xappConn1.SendRESTSubsReq(t, params)
5447
5448 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5449
5450 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5451
5452 // No transaction exist for this response which will result resending original request
5453 fparams := &teststube2ap.E2StubSubsFailParams{}
5454 fparams.Set(crereq)
5455 e2termConn1.SendSubsFail(t, fparams, cremsg)
5456
5457 _, cremsg = e2termConn1.RecvSubsReq(t)
5458
5459 xappConn1.ExpectRESTNotification(t, restSubId)
5460
5461 // Subscription already created in E2 Node.
5462 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5463 e2termConn1.SendSubsFail(t, fparams, cremsg)
5464
5465 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5466 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5467
5468 // Resending happens because there no transaction
5469 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5470 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5471
5472 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5473 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5474
5475 // Wait that subs is cleaned
5476 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5477
5478 xappConn1.TestMsgChanEmpty(t)
5479 e2termConn1.TestMsgChanEmpty(t)
5480 mainCtrl.wait_registry_empty(t, 10)
5481}
5482
5483//-----------------------------------------------------------------------------
5484// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
5485//
5486// stub stub
5487// +-------+ +---------+ +---------+
5488// | xapp | | submgr | | e2term |
5489// +-------+ +---------+ +---------+
5490// | | |
5491// | [SUBS CREATE] |
5492// | | |
5493// | | |
5494// | RESTSubDelReq | |
5495// |---------------->| |
5496// | | |
5497// | RESTSubDelResp | |
5498// |<----------------| |
5499// | | |
5500// | | SubDelReq |
5501// | |------------->|
5502// | | |
5503// | | SubDelResp | ASN.1 decode fails
5504// | |<-------------|
5505// | | |
5506// | | SubDelReq |
5507// | |------------->|
5508// | | |
5509// | | SubDelFail | Subscription does exist any more
5510// | |<-------------|
5511// | | |
5512//
5513//-----------------------------------------------------------------------------
5514func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
5515 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
5516
5517 // Req
5518 var params *teststube2ap.RESTSubsReqParams = nil
5519 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5520
5521 // Del
5522 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5523
5524 // E2t: Receive 1st SubsDelReq
5525 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5526
5527 // Decode of this response fails which will result resending original request
5528 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
5529
5530 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5531 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5532
5533 // Subscription does not exist in in E2 Node.
5534 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5535
5536 // Wait that subs is cleaned
5537 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5538
5539 xappConn1.TestMsgChanEmpty(t)
5540 e2termConn1.TestMsgChanEmpty(t)
5541 mainCtrl.wait_registry_empty(t, 10)
5542}
5543
5544//-----------------------------------------------------------------------------
5545// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
5546//
5547// stub stub
5548// +-------+ +---------+ +---------+
5549// | xapp | | submgr | | e2term |
5550// +-------+ +---------+ +---------+
5551// | | |
5552// | [SUBS CREATE] |
5553// | | |
5554// | | |
5555// | RESTSubDelReq | |
5556// |---------------->| |
5557// | | |
5558// | RESTSubDelResp | |
5559// |<----------------| |
5560// | | |
5561// | | SubDelReq |
5562// | |------------->|
5563// | | |
5564// | | SubDelResp | Unknown instanceId
5565// | |<-------------|
5566// | | |
5567// | | SubDelReq |
5568// | |------------->|
5569// | | |
5570// | | SubDelFail | Subscription does exist any more
5571// | |<-------------|
5572//
5573//-----------------------------------------------------------------------------
5574func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
5575 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
5576
5577 // Req
5578 var params *teststube2ap.RESTSubsReqParams = nil
5579 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5580
5581 // Del
5582 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5583
5584 // E2t: Receive 1st SubsDelReq
5585 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5586
5587 // Unknown instanceId in this response which will result resending original request
5588 delreq.RequestId.InstanceId = 0
5589 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5590
5591 // E2t: Receive 2nd SubsDelReq
5592 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5593
5594 // Subscription does not exist in in E2 Node.
5595 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5596
5597 // Wait that subs is cleaned
5598 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5599
5600 xappConn1.TestMsgChanEmpty(t)
5601 e2termConn1.TestMsgChanEmpty(t)
5602 mainCtrl.wait_registry_empty(t, 10)
5603}
5604
5605//-----------------------------------------------------------------------------
5606// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
5607//
5608// stub stub
5609// +-------+ +---------+ +---------+
5610// | xapp | | submgr | | e2term |
5611// +-------+ +---------+ +---------+
5612// | | |
5613// | [SUBS CREATE] |
5614// | | |
5615// | | |
5616// | RESTSubDelReq | |
5617// |---------------->| |
5618// | | |
5619// | RESTSubDelResp | |
5620// |<----------------| |
5621// | | |
5622// | | SubDelReq |
5623// | |------------->|
5624// | | |
5625// | | SubDelResp | No transaction for the response
5626// | |<-------------|
5627// | | |
5628// | | SubDelReq |
5629// | |------------->|
5630// | | |
5631// | | SubDelFail | Subscription does exist any more
5632// | |<-------------|
5633//
5634//-----------------------------------------------------------------------------
5635func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
5636 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
5637
5638 // Req
5639 var params *teststube2ap.RESTSubsReqParams = nil
5640 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5641
5642 // Del
5643 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5644
5645 // E2t: Receive 1st SubsDelReq
5646 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5647
5648 mainCtrl.MakeTransactionNil(t, e2SubsId)
5649
5650 // No transaction exist for this response which will result resending original request
5651 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5652
5653 // E2t: Receive 2nd SubsDelReq
5654 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5655
5656 // Subscription does not exist in in E2 Node.
5657 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5658
5659 // Wait that subs is cleaned
5660 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5661
5662 xappConn1.TestMsgChanEmpty(t)
5663 e2termConn1.TestMsgChanEmpty(t)
5664 mainCtrl.wait_registry_empty(t, 10)
5665}
5666
5667//-----------------------------------------------------------------------------
5668// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
5669//
5670// stub stub
5671// +-------+ +---------+ +---------+
5672// | xapp | | submgr | | e2term |
5673// +-------+ +---------+ +---------+
5674// | | |
5675// | [SUBS CREATE] |
5676// | | |
5677// | | |
5678// | RESTSubDelReq | |
5679// |---------------->| |
5680// | | |
5681// | RESTSubDelResp | |
5682// |<----------------| |
5683// | | |
5684// | | SubDelReq |
5685// | |------------->|
5686// | | |
5687// | | SubDelFail | ASN.1 decode fails
5688// | |<-------------|
5689// | | |
5690// | | SubDelReq |
5691// | |------------->|
5692// | | |
5693// | | SubDelFail | Subscription does exist any more
5694// | |<-------------|
5695//
5696//-----------------------------------------------------------------------------
5697func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
5698 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
5699
5700 // Req
5701 var params *teststube2ap.RESTSubsReqParams = nil
5702 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5703
5704 // Del
5705 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5706
5707 // E2t: Receive 1st SubsDelReq
5708 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5709
5710 // Decode of this response fails which will result resending original request
5711 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
5712
5713 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5714 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5715
5716 // Subscription does not exist in in E2 Node.
5717 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5718
5719 // Wait that subs is cleaned
5720 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5721
5722 xappConn1.TestMsgChanEmpty(t)
5723 e2termConn1.TestMsgChanEmpty(t)
5724 mainCtrl.wait_registry_empty(t, 10)
5725}
5726
5727//-----------------------------------------------------------------------------
5728// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
5729//
5730// stub stub
5731// +-------+ +---------+ +---------+
5732// | xapp | | submgr | | e2term |
5733// +-------+ +---------+ +---------+
5734// | | |
5735// | [SUBS CREATE] |
5736// | | |
5737// | | |
5738// | RESTSubDelReq | |
5739// |---------------->| |
5740// | | |
5741// | RESTSubDelResp | |
5742// |<----------------| |
5743// | | |
5744// | | SubDelReq |
5745// | |------------->|
5746// | | |
5747// | | SubDelFail | Unknown instanceId
5748// | |<-------------|
5749// | | |
5750// | | SubDelReq |
5751// | |------------->|
5752// | | |
5753// | | SubDelFail | Subscription does exist any more
5754// | |<-------------|
5755//
5756//-----------------------------------------------------------------------------
5757func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
5758 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
5759
5760 // Req
5761 var params *teststube2ap.RESTSubsReqParams = nil
5762 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5763
5764 // Del
5765 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5766
5767 // E2t: Receive 1st SubsDelReq
5768 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5769
5770 // Unknown instanceId in this response which will result resending original request
5771 delreq.RequestId.InstanceId = 0
5772 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5773
5774 // E2t: Receive 2nd SubsDelReq
5775 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5776
5777 // Subscription does not exist in in E2 Node.
5778 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5779
5780 // Wait that subs is cleaned
5781 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5782
5783 xappConn1.TestMsgChanEmpty(t)
5784 e2termConn1.TestMsgChanEmpty(t)
5785 mainCtrl.wait_registry_empty(t, 10)
5786}
5787
5788//-----------------------------------------------------------------------------
5789// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
5790//
5791// stub stub
5792// +-------+ +---------+ +---------+
5793// | xapp | | submgr | | e2term |
5794// +-------+ +---------+ +---------+
5795// | | |
5796// | [SUBS CREATE] |
5797// | | |
5798// | | |
5799// | RESTSubDelReq | |
5800// |---------------->| |
5801// | | |
5802// | RESTSubDelResp | |
5803// |<----------------| |
5804// | | |
5805// | | SubDelReq |
5806// | |------------->|
5807// | | |
5808// | | SubDelFail | No transaction for the response
5809// | |<-------------|
5810// | | |
5811// | | SubDelReq |
5812// | |------------->|
5813// | | |
5814// | | SubDelFail | Subscription does exist any more
5815// | |<-------------|
5816//
5817//-----------------------------------------------------------------------------
5818func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
5819 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
5820
5821 // Req
5822 var params *teststube2ap.RESTSubsReqParams = nil
5823 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5824
5825 // Del
5826 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5827
5828 // E2t: Receive 1st SubsDelReq
5829 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5830
5831 mainCtrl.MakeTransactionNil(t, e2SubsId)
5832
5833 // No transaction exist for this response which will result resending original request
5834 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5835
5836 // E2t: Receive 2nd SubsDelReq
5837 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5838
5839 // Subscription does not exist in in E2 Node.
5840 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5841
5842 // Wait that subs is cleaned
5843 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5844
5845 xappConn1.TestMsgChanEmpty(t)
5846 e2termConn1.TestMsgChanEmpty(t)
5847 mainCtrl.wait_registry_empty(t, 10)
5848}
5849
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005850//-----------------------------------------------------------------------------
5851// TestRESTSubReqFailAsn1PackSubReqError
5852//
5853// stub stub
5854// +-------+ +---------+ +---------+
5855// | xapp | | submgr | | e2term |
5856// +-------+ +---------+ +---------+
5857// | | |
5858// | RESTSubReq | |
5859// |---------------->| |
5860// | | |
5861// | RESTSubResp | |
5862// |<----------------| |
5863// | | |
5864// | ASN.1 encode fails |
5865// | | |
5866// | | SubDelReq |
5867// | |------------->|
5868// | | |
5869// | | SubDelFail |
5870// | |<-------------|
5871// | | |
5872// | RESTNotif | |
5873// | unsuccess | |
5874// |<----------------| |
5875// | | |
5876// | [SUBS DELETE] |
5877// | | |
5878//
5879//-----------------------------------------------------------------------------
5880func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
5881
5882 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005883 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005884 Counter{cRestSubRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005885 Counter{cSubDelReqToE2, 1},
5886 Counter{cSubDelFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005887 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005888 })
5889
5890 subReqCount := 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005891
5892 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005893 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005894 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
5895
5896 // Req
5897 restSubId := xappConn1.SendRESTSubsReq(t, params)
5898 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5899
5900 // E2t: Receive SubsDelReq
5901 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5902 xappConn1.ExpectRESTNotification(t, restSubId)
5903
5904 // Subscription does not exist in in E2 Node.
5905 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5906
5907 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5908 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
5909
5910 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
5911 // Wait that subs is cleaned
5912 waitSubsCleanup(t, e2SubsId, 10)
5913 mainCtrl.VerifyCounterValues(t)
5914}
5915
archaggeafbf95f2021-04-14 08:54:05 +03005916////////////////////////////////////////////////////////////////////////////////////
5917// Services for UT cases
5918////////////////////////////////////////////////////////////////////////////////////
5919const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005920const host string = "localhost"
5921
5922func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
5923 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005924 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005925 }
5926 restSubId := fromXappConn.SendRESTSubsReq(t, params)
5927 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5928
5929 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
5930 fromXappConn.ExpectRESTNotification(t, restSubId)
5931 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
5932 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
5933 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5934
5935 return restSubId, e2SubsId
5936}
5937
5938func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
5939
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005940 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005941 if meid != "" {
5942 params.SetMeid(meid)
5943 }
5944 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
5945 restSubId := xappConn2.SendRESTSubsReq(t, params)
5946 xappConn2.ExpectRESTNotification(t, restSubId)
5947 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5948 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
5949 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5950
5951 return restSubId, e2SubsId
5952}
5953
5954func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005955 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005956 restSubId := xappConn1.SendRESTSubsReq(t, params)
5957 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
5958
5959 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5960 xappConn1.ExpectRESTNotification(t, restSubId)
5961 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5962 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5963 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5964
5965 return restSubId, e2SubsId
5966}
5967
5968func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005969 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005970 restSubId := xappConn1.SendRESTSubsReq(t, params)
5971
5972 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5973 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5974 fparams1.Set(crereq1)
5975 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5976
5977 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5978 xappConn1.ExpectRESTNotification(t, restSubId)
5979 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5980 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5981 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
5982
5983 return restSubId, e2SubsId
5984}
5985
5986func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
5987 fromXappConn.SendRESTSubsDelReq(t, restSubId)
5988 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
5989 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
5990}
5991
5992func deleteXapp1Subscription(t *testing.T, restSubId *string) {
5993 xappConn1.SendRESTSubsDelReq(t, restSubId)
5994 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5995 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5996}
5997
5998func deleteXapp2Subscription(t *testing.T, restSubId *string) {
5999 xappConn2.SendRESTSubsDelReq(t, restSubId)
6000 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6001 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6002}
6003
6004func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
6005 resp, _ := xapp.Subscription.QuerySubscriptions()
6006 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
6007 assert.Equal(t, resp[0].Meid, meid)
6008 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
6009}
6010
6011func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
6012 //Wait that subs is cleaned
6013 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
6014
6015 xappConn1.TestMsgChanEmpty(t)
6016 xappConn2.TestMsgChanEmpty(t)
6017 e2termConn1.TestMsgChanEmpty(t)
6018 mainCtrl.wait_registry_empty(t, timeout)
6019}
6020
6021func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
6022
6023 var e2SubsId []uint32
6024
6025 for i := 0; i < count; i++ {
6026 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
6027 crereq, cremsg := toE2termConn.RecvSubsReq(t)
6028 fromXappConn.ExpectRESTNotification(t, restSubId)
6029 toE2termConn.SendSubsResp(t, crereq, cremsg)
6030 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
6031 e2SubsId = append(e2SubsId, instanceId)
6032 xapp.Logger.Info("TEST: %v", e2SubsId)
6033 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
6034 <-time.After(100 * time.Millisecond)
6035 }
6036 return e2SubsId
6037}
6038
6039func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
6040
6041 for i := 0; i < len(e2SubsIds); i++ {
6042 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
6043 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6044 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6045 <-time.After(1 * time.Second)
6046 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
6047 <-time.After(100 * time.Millisecond)
6048 }
6049
6050 // Wait that subs is cleaned
6051 for i := 0; i < len(e2SubsIds); i++ {
6052 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
6053 }
6054
6055}