blob: e6d6646b2900a7359bae8dc0dc5c546debdec10c [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{
2404 Counter{cSubReqFromXapp, 1},
2405 Counter{cRouteCreateFail, 1},
2406 Counter{cSubRespToXapp, 1},
2407 Counter{cSubDelReqFromXapp, 1},
2408 Counter{cSubDelRespToXapp, 1},
2409 })
2410
2411 const subReqCount int = 1
2412 const parameterSet = 1
2413 const actionDefinitionPresent bool = true
2414 const actionParamCount int = 1
Markku Virtanenda34eec2021-05-20 08:22:04 +00002415 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2416 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002417 newSubsId := mainCtrl.get_registry_next_subid(t)
2418
2419 // Req
2420 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2421 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenda34eec2021-05-20 08:22:04 +00002422 xappConn1.ExpectRESTNotification(t, restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002423 waiter.WaitResult(t)
2424
archaggeafbf95f2021-04-14 08:54:05 +03002425 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2426 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2427
2428 // Del
2429 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2430
2431 // Wait that subs is cleaned
2432 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2433 waitSubsCleanup(t, e2SubsId, 10)
2434 mainCtrl.VerifyCounterValues(t)
2435}
2436
2437func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2438 CaseBegin("TestSubReqAndRouteUpdateNok")
2439
2440 //Init counter check
2441 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2442 Counter{cSubReqFromXapp, 2},
2443 Counter{cSubReqToE2, 1},
2444 Counter{cSubRespFromE2, 1},
2445 Counter{cSubRespToXapp, 2},
2446 Counter{cRouteCreateUpdateFail, 1},
2447 Counter{cSubDelReqFromXapp, 1},
2448 Counter{cSubDelReqToE2, 1},
2449 Counter{cSubDelRespFromE2, 1},
2450 Counter{cSubDelRespToXapp, 1},
2451 })
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)
2463 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2464 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{
2488 Counter{cSubReqFromXapp, 1},
2489 Counter{cSubReqToE2, 1},
2490 Counter{cSubRespFromE2, 1},
2491 Counter{cSubRespToXapp, 1},
2492 Counter{cSubDelReqFromXapp, 1},
2493 Counter{cRouteDeleteFail, 1},
2494 Counter{cSubDelReqToE2, 1},
2495 Counter{cSubDelRespFromE2, 1},
2496 Counter{cSubDelRespToXapp, 1},
2497 })
2498
2499 var params *teststube2ap.RESTSubsReqParams = nil
2500
2501 //Subs Create
2502 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2503
2504 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2505
2506 waiter := rtmgrHttp.AllocNextEvent(false)
2507 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2508 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2509 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2510 waiter.WaitResult(t)
2511
2512 waitSubsCleanup(t, e2SubsId, 10)
2513
2514 mainCtrl.VerifyCounterValues(t)
2515}
2516
2517func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2518 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2519
2520 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2521 Counter{cSubReqFromXapp, 2},
2522 Counter{cSubReqToE2, 1},
2523 Counter{cSubRespFromE2, 1},
2524 Counter{cSubRespToXapp, 2},
2525 Counter{cSubDelReqFromXapp, 2},
2526 Counter{cRouteDeleteUpdateFail, 1},
2527 Counter{cSubDelReqToE2, 1},
2528 Counter{cSubDelRespFromE2, 1},
2529 Counter{cSubDelRespToXapp, 2},
2530 })
2531
2532 var params *teststube2ap.RESTSubsReqParams = nil
2533
2534 //Subs Create
2535 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2536
2537 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2538 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2539
2540 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2541
2542 //Del1, this shall fail on rtmgr side
2543 waiter := rtmgrHttp.AllocNextEvent(false)
2544 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2545 waiter.WaitResult(t)
2546
2547 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2548
2549 //Del2
2550 deleteXapp2Subscription(t, &restSubId2)
2551
2552 waitSubsCleanup(t, e2SubsId2, 10)
2553
2554 mainCtrl.VerifyCounterValues(t)
2555}
2556
2557//-----------------------------------------------------------------------------
2558// TestRESTSubReqRetransmission
2559//
2560// stub stub
2561// +-------+ +---------+ +---------+
2562// | xapp | | submgr | | e2term |
2563// +-------+ +---------+ +---------+
2564// | | |
2565// | RESTSubReq1 | |
2566// |---------------->| |
2567// | | |
2568// | RESTSubResp | |
2569// |<----------------| |
2570// | | SubReq1 |
2571// | |------------->|
2572// | | |
2573// | RESTSubReq2 | |
2574// | (retrans) | |
2575// |---------------->| |
2576// | | |
2577// | | SubReq2 |
2578// | |------------->|
2579// | RESTSubResp2 | |
2580// |<----------------| |
2581// | | SubResp1 |
2582// | |<-------------|
2583// | RESTNotif1 | |
2584// |<----------------| |
2585// | | SubResp1 |
2586// | |<-------------|
2587// | RESTNotif2 | |
2588// |<----------------| |
2589// | | |
2590// | [SUBS DELETE] |
2591// | | |
2592//
2593//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002594
archaggeafbf95f2021-04-14 08:54:05 +03002595func TestRESTSubReqRetransmission(t *testing.T) {
2596 CaseBegin("TestRESTSubReqRetransmission")
2597
2598 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2599 Counter{cSubReqFromXapp, 2},
2600 Counter{cSubReqToE2, 2},
2601 Counter{cSubRespFromE2, 2},
2602 Counter{cSubRespToXapp, 2},
2603 Counter{cSubDelReqFromXapp, 2},
2604 Counter{cSubDelReqToE2, 2},
2605 Counter{cSubDelRespFromE2, 2},
2606 Counter{cSubDelRespToXapp, 2},
2607 })
2608 // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests
2609 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2610 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2611
2612 // Subs Create
2613 const subReqCount int = 1
2614 const parameterSet = 1
2615 const actionDefinitionPresent bool = true
2616 const actionParamCount int = 1
2617
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)
2621 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2622 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{
2662 Counter{cSubReqFromXapp, 1},
2663 Counter{cSubReqToE2, 1},
2664 Counter{cSubRespFromE2, 1},
2665 Counter{cSubRespToXapp, 1},
2666 Counter{cSubDelReqFromXapp, 2},
2667 Counter{cSubDelReqToE2, 1},
2668 Counter{cSubDelRespFromE2, 1},
2669 Counter{cSubDelRespToXapp, 1},
2670 })
2671
2672 var params *teststube2ap.RESTSubsReqParams = nil
2673
2674 //Subs Create
2675 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2676
2677 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2678
2679 //Subs Delete
2680 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2681 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2682
2683 seqBef := mainCtrl.get_msgcounter(t)
2684 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2685 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
2686
2687 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2688
2689 waitSubsCleanup(t, e2SubsId, 10)
2690
2691 mainCtrl.VerifyCounterValues(t)
2692}
2693
2694//-----------------------------------------------------------------------------
2695// TestRESTSubReqDelReq
2696//
2697// stub stub
2698// +-------+ +---------+ +---------+
2699// | xapp | | submgr | | e2term |
2700// +-------+ +---------+ +---------+
2701// | | |
2702// | RESTSubReq | |
2703// |---------------->| |
2704// | | |
2705// | RESTSubResp | |
2706// |<----------------| |
2707// | | SubReq |
2708// | |------------->|
2709// | RESTSubDelReq | |
2710// |---------------->| |
2711// | RESTSubDelResp | |
2712// | unsuccess | |
2713// |<----------------| |
2714// | | SubResp |
2715// | |<-------------|
2716// | RESTNotif1 | |
2717// |<----------------| |
2718// | | |
2719// | [SUBS DELETE] |
2720// | | |
2721//
2722//-----------------------------------------------------------------------------
2723func TestRESTSubReqDelReq(t *testing.T) {
2724 CaseBegin("TestRESTSubReqDelReq")
2725
2726 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2727 Counter{cSubReqFromXapp, 1},
2728 Counter{cSubReqToE2, 1},
2729 Counter{cSubRespFromE2, 1},
2730 Counter{cSubRespToXapp, 1},
2731 Counter{cSubDelReqFromXapp, 2},
2732 Counter{cSubDelReqToE2, 1},
2733 Counter{cSubDelRespFromE2, 1},
2734 Counter{cSubDelRespToXapp, 1},
2735 })
2736
2737 const subReqCount int = 1
2738 const parameterSet = 1
2739 const actionDefinitionPresent bool = true
2740 const actionParamCount int = 1
2741
2742 // Req
2743 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2744 restSubId := xappConn1.SendRESTSubsReq(t, params)
2745
2746 // Del. This will fail as processing of the subscription
2747 // is still ongoing in submgr. Deletion is not allowed before
2748 // subscription creation has been completed.
2749 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2750 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2751 xappConn1.ExpectRESTNotification(t, restSubId)
2752 e2termConn1.SendSubsResp(t, crereq, cremsg)
2753 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2754
2755 // Retry del
2756 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2757
2758 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2759 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2760
2761 // Wait that subs is cleaned
2762 waitSubsCleanup(t, e2SubsId, 10)
2763 mainCtrl.VerifyCounterValues(t)
2764
2765}
2766
2767func TestRESTSubDelReqCollision(t *testing.T) {
2768 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
2769}
2770
2771func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
2772 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
2773
2774 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2775 Counter{cSubReqFromXapp, 2},
2776 Counter{cSubReqToE2, 2},
2777 Counter{cSubRespFromE2, 2},
2778 Counter{cSubRespToXapp, 2},
2779 Counter{cSubDelReqFromXapp, 2},
2780 Counter{cSubDelReqToE2, 2},
2781 Counter{cSubDelRespFromE2, 2},
2782 Counter{cSubDelRespToXapp, 2},
2783 })
2784
2785 //Req1
2786 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2787 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2788 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2789
2790 //Req2
2791 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2792 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{
2828 Counter{cSubReqFromXapp, 2},
2829 Counter{cSubReqToE2, 2},
2830 Counter{cSubRespFromE2, 2},
2831 Counter{cSubRespToXapp, 2},
2832 Counter{cSubDelReqFromXapp, 2},
2833 Counter{cSubDelReqToE2, 2},
2834 Counter{cSubDelRespFromE2, 2},
2835 Counter{cSubDelRespToXapp, 2},
2836 })
2837
2838 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2839 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
2840 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2841
2842 params = xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2843 params.SetMeid("RAN_NAME_2")
2844 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
2845 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2846
2847 //Del1
2848 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2849 //Del2
2850 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
2851
2852 //Wait that subs is cleaned
2853 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2854 waitSubsCleanup(t, e2SubsId2, 10)
2855
2856 mainCtrl.VerifyCounterValues(t)
2857
2858}
2859
2860func TestRESTSubReqRetryInSubmgr(t *testing.T) {
2861 CaseBegin("TestRESTSubReqRetryInSubmgr start")
2862
2863 // Init counter check
2864 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2865 Counter{cSubReqFromXapp, 1},
2866 Counter{cSubReqToE2, 1},
2867 Counter{cSubReReqToE2, 1},
2868 Counter{cSubRespFromE2, 1},
2869 Counter{cSubRespToXapp, 1},
2870 Counter{cSubDelReqFromXapp, 1},
2871 Counter{cSubDelReqToE2, 1},
2872 Counter{cSubDelRespFromE2, 1},
2873 Counter{cSubDelRespToXapp, 1},
2874 })
2875
2876 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2877 restSubId := xappConn1.SendRESTSubsReq(t, params)
2878
2879 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2880
2881 // Catch the first message and ignore it
2882 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2883 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
2884
2885 // The second request is being handled normally
2886 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2887 xappConn1.ExpectRESTNotification(t, restSubId)
2888 e2termConn1.SendSubsResp(t, crereq, cremsg)
2889 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2890
2891 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2892
2893 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2894
2895 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2896 //Wait that subs is cleaned
2897 waitSubsCleanup(t, e2SubsId, 10)
2898
2899 mainCtrl.VerifyCounterValues(t)
2900
2901}
2902
2903//-----------------------------------------------------------------------------
2904// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2905//
2906// stub stub
2907// +-------+ +---------+ +---------+
2908// | xapp | | submgr | | e2term |
2909// +-------+ +---------+ +---------+
2910// | | |
2911// | RESTSubReq | |
2912// |---------------->| |
2913// | | |
2914// | RESTSubResp | |
2915// |<----------------| |
2916// | | SubReq |
2917// | |------------->|
2918// | | |
2919// | | |
2920// | | SubReq |
2921// | |------------->|
2922// | | |
2923// | | SubDelReq |
2924// | |------------->|
2925// | | |
2926// | | |
2927// | | SubDelReq |
2928// | |------------->|
2929// | | |
2930// | | |
2931// | | SubDelResp |
2932// | |<-------------|
2933// | RESTNotif | |
2934// | unsuccess | |
2935// |<----------------| |
2936// | | |
2937// | [SUBS DELETE] |
2938// | | |
2939//
2940//-----------------------------------------------------------------------------
2941func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
2942 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
2943
2944 // Init counter check
2945 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2946 Counter{cSubReqFromXapp, 1},
2947 Counter{cSubReqToE2, 1},
2948 Counter{cSubReReqToE2, 1},
2949 Counter{cSubReqTimerExpiry, 2},
2950 Counter{cSubDelReqToE2, 1},
2951 Counter{cSubDelRespFromE2, 1},
2952 })
2953
2954 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2955 restSubId := xappConn1.SendRESTSubsReq(t, params)
2956 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2957
2958 e2termConn1.RecvSubsReq(t)
2959 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2960
2961 e2termConn1.RecvSubsReq(t)
2962 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2963
2964 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2965 xappConn1.ExpectRESTNotification(t, restSubId)
2966 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2967 // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - TODO: Should we delete this?
2968 xappConn1.WaitRESTNotification(t, restSubId)
2969
2970 // Wait that subs is cleaned
2971 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
2972
2973 mainCtrl.VerifyCounterValues(t)
2974}
2975
2976func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
2977 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
2978
2979 // Init counter check
2980 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2981 Counter{cSubReqFromXapp, 1},
2982 Counter{cSubReqToE2, 1},
2983 Counter{cSubReReqToE2, 1},
2984 Counter{cSubReqTimerExpiry, 2},
2985 Counter{cSubDelReqToE2, 1},
2986 Counter{cSubDelReqTimerExpiry, 2},
2987 })
2988
2989 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2990 restSubId := xappConn1.SendRESTSubsReq(t, params)
2991 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2992
2993 e2termConn1.RecvSubsReq(t)
2994 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2995
2996 e2termConn1.RecvSubsReq(t)
2997 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2998
2999 e2termConn1.RecvSubsDelReq(t)
3000 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3001
3002 xappConn1.ExpectRESTNotification(t, restSubId)
3003 e2termConn1.RecvSubsDelReq(t)
3004 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3005
3006 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3007
3008 waitSubsCleanup(t, e2SubsId, 10)
3009
3010 mainCtrl.VerifyCounterValues(t)
3011
3012}
3013
3014//-----------------------------------------------------------------------------
3015// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3016//
3017// stub stub
3018// +-------+ +---------+ +---------+
3019// | xapp | | submgr | | e2term |
3020// +-------+ +---------+ +---------+
3021// | | |
3022// | RESTSubReq | |
3023// |---------------->| |
3024// | | |
3025// | RESTSubResp | |
3026// |<----------------| |
3027// | | SubReq |
3028// | |------------->|
3029// | | |
3030// | | |
3031// | | SubReq |
3032// | |------------->|
3033// | | |
3034// | | SubDelReq |
3035// | |------------->|
3036// | | |
3037// | | |
3038// | | SubDelReq |
3039// | |------------->|
3040// | | |
3041// | | |
3042// | | SubDelResp |
3043// | |<-------------|
3044// | RESTNotif | |
3045// | unsuccess | |
3046// |<----------------| |
3047// | | |
3048// | [SUBS DELETE] |
3049// | | |
3050//
3051//-----------------------------------------------------------------------------
3052func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3053 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3054
3055 // Init counter check
3056 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3057 Counter{cSubReqFromXapp, 1},
3058 Counter{cSubReqToE2, 1},
3059 Counter{cSubReReqToE2, 1},
3060 Counter{cSubReqTimerExpiry, 2},
3061 Counter{cSubDelReqToE2, 1},
3062 Counter{cSubDelReReqToE2, 1},
3063 Counter{cSubDelReqTimerExpiry, 2},
3064 })
3065
3066 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3067 restSubId := xappConn1.SendRESTSubsReq(t, params)
3068 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3069
3070 e2termConn1.RecvSubsReq(t)
3071 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
3072
3073 e2termConn1.RecvSubsReq(t)
3074 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
3075
3076 e2termConn1.RecvSubsDelReq(t)
3077 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
3078
3079 xappConn1.ExpectRESTNotification(t, restSubId)
3080 e2termConn1.RecvSubsDelReq(t)
3081 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
3082
3083 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3084
3085 waitSubsCleanup(t, e2SubsId, 10)
3086
3087 mainCtrl.VerifyCounterValues(t)
3088}
3089
3090//-----------------------------------------------------------------------------
3091// TestRESTSubReqSubFailRespInSubmgr
3092//
3093// stub stub
3094// +-------+ +---------+ +---------+
3095// | xapp | | submgr | | e2term |
3096// +-------+ +---------+ +---------+
3097// | | |
3098// | RESTSubReq | |
3099// |---------------->| |
3100// | | |
3101// | RESTSubResp | |
3102// |<----------------| |
3103// | | SubReq |
3104// | |------------->|
3105// | | |
3106// | | SubFail |
3107// | |<-------------|
3108// | | |
3109// | | SubDelReq |
3110// | |------------->|
3111// | | |
3112// | | SubDelResp |
3113// | |<-------------|
3114// | | |
3115// | RESTNotif | |
3116// | unsuccess | |
3117// |<----------------| |
3118// | | |
3119// | [SUBS DELETE] |
3120// | | |
3121//
3122//-----------------------------------------------------------------------------
3123func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3124 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3125
3126 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3127 Counter{cSubReqFromXapp, 1},
3128 Counter{cSubReqToE2, 1},
3129 Counter{cSubFailFromE2, 1},
3130 Counter{cSubRespToXapp, 1},
3131 Counter{cSubDelReqFromXapp, 1},
3132 })
3133
3134 const subReqCount int = 1
3135 const parameterSet = 1
3136 const actionDefinitionPresent bool = true
3137 const actionParamCount int = 1
3138
3139 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3140 restSubId := xappConn1.SendRESTSubsReq(t, params)
3141
3142 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3143 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3144 fparams1.Set(crereq1)
3145 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3146
3147 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3148 xappConn1.ExpectRESTNotification(t, restSubId)
3149 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3150 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3151 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
3152
3153 // REST subscription sill there to be deleted
3154 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3155
3156 // Wait that subs is cleaned
3157 waitSubsCleanup(t, e2SubsId, 10)
3158
3159 mainCtrl.VerifyCounterValues(t)
3160
3161}
3162
3163//-----------------------------------------------------------------------------
3164// TestRESTSubDelReqRetryInSubmgr
3165//
3166// stub stub
3167// +-------+ +---------+ +---------+
3168// | xapp | | submgr | | e2term |
3169// +-------+ +---------+ +---------+
3170// | | |
3171// | [SUBS CREATE] |
3172// | | |
3173// | | |
3174// | RESTSubDelReq | |
3175// |---------------->| |
3176// | | |
3177// | RESTSubDelResp | |
3178// |<----------------| |
3179// | | SubDelReq |
3180// | |------------->|
3181// | | |
3182// | | SubDelReq |
3183// | |------------->|
3184// | | |
3185// | | SubDelResp |
3186// | |<-------------|
3187// | | |
3188//
3189//-----------------------------------------------------------------------------
3190func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3191 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3192
3193 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3194 Counter{cSubReqFromXapp, 1},
3195 Counter{cSubReqToE2, 1},
3196 Counter{cSubRespFromE2, 1},
3197 Counter{cSubRespToXapp, 1},
3198 Counter{cSubDelReqFromXapp, 1},
3199 Counter{cSubDelReqToE2, 1},
3200 Counter{cSubDelReReqToE2, 1},
3201 Counter{cSubDelRespFromE2, 1},
3202 Counter{cSubDelRespToXapp, 1},
3203 })
3204 // Req
3205 var params *teststube2ap.RESTSubsReqParams = nil
3206 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3207
3208 // Del
3209 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3210
3211 // E2t: Receive 1st SubsDelReq
3212 e2termConn1.RecvSubsDelReq(t)
3213
3214 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3215 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3216 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3217
3218 //Wait that subs is cleaned
3219 waitSubsCleanup(t, e2SubsId, 10)
3220
3221 mainCtrl.VerifyCounterValues(t)
3222}
3223
3224//-----------------------------------------------------------------------------
3225// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3226//
3227// stub stub
3228// +-------+ +---------+ +---------+
3229// | xapp | | submgr | | e2term |
3230// +-------+ +---------+ +---------+
3231// | | |
3232// | [SUBS CREATE] |
3233// | | |
3234// | | |
3235// | RESTSubDelReq | |
3236// |---------------->| |
3237// | | |
3238// | RESTSubDelResp | |
3239// |<----------------| |
3240// | | SubDelReq |
3241// | |------------->|
3242// | | |
3243// | | SubDelReq |
3244// | |------------->|
3245// | | |
3246// | | |
3247//
3248//-----------------------------------------------------------------------------
3249func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3250 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3251
3252 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3253 Counter{cSubReqFromXapp, 1},
3254 Counter{cSubReqToE2, 1},
3255 Counter{cSubRespFromE2, 1},
3256 Counter{cSubRespToXapp, 1},
3257 Counter{cSubDelReqFromXapp, 1},
3258 Counter{cSubDelReqToE2, 1},
3259 Counter{cSubDelReReqToE2, 1},
3260 Counter{cSubDelRespFromE2, 1},
3261 Counter{cSubDelRespToXapp, 1},
3262 })
3263
3264 // Req
3265 var params *teststube2ap.RESTSubsReqParams = nil
3266 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3267
3268 // Del
3269 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3270
3271 // E2t: Receive 1st SubsDelReq
3272 e2termConn1.RecvSubsDelReq(t)
3273
3274 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3275 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3276 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3277
3278 //Wait that subs is cleaned
3279 waitSubsCleanup(t, e2SubsId, 10)
3280
3281 mainCtrl.VerifyCounterValues(t)
3282}
3283
3284//-----------------------------------------------------------------------------
3285// TestRESTSubDelReqSubDelFailRespInSubmgr
3286//
3287// stub stub
3288// +-------+ +---------+ +---------+
3289// | xapp | | submgr | | e2term |
3290// +-------+ +---------+ +---------+
3291// | | |
3292// | [SUBS CREATE] |
3293// | | |
3294// | | |
3295// | RESTSubDelReq | |
3296// |---------------->| |
3297// | | |
3298// | RESTSubDelResp | |
3299// |<----------------| |
3300// | | SubDelReq |
3301// | |------------->|
3302// | | |
3303// | | SubDelFail |
3304// | |<-------------|
3305// | | |
3306//
3307//-----------------------------------------------------------------------------
3308func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3309 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3310
3311 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3312 Counter{cSubReqFromXapp, 1},
3313 Counter{cSubReqToE2, 1},
3314 Counter{cSubRespFromE2, 1},
3315 Counter{cSubRespToXapp, 1},
3316 Counter{cSubDelReqFromXapp, 1},
3317 Counter{cSubDelReqToE2, 1},
3318 Counter{cSubDelFailFromE2, 1},
3319 Counter{cSubDelRespToXapp, 1},
3320 })
3321
3322 // Req
3323 var params *teststube2ap.RESTSubsReqParams = nil
3324 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3325
3326 // Del
3327 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3328
3329 // E2t: Send receive SubsDelReq and send SubsDelFail
3330 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3331 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3332
3333 //Wait that subs is cleaned
3334 waitSubsCleanup(t, e2SubsId, 10)
3335
3336 mainCtrl.VerifyCounterValues(t)
3337}
3338
3339//-----------------------------------------------------------------------------
3340// TestRESTSubReqAndSubDelOkSameAction
3341//
3342// stub stub
3343// +-------+ +-------+ +---------+ +---------+
3344// | xapp2 | | xapp1 | | submgr | | e2term |
3345// +-------+ +-------+ +---------+ +---------+
3346// | | | |
3347// | | RESTSubReq1 | |
3348// | |---------------->| |
3349// | | | |
3350// | | RESTSubResp1 | |
3351// | |<----------------| |
3352// | | | |
3353// | | | SubReq1 |
3354// | | |------------->|
3355// | | | SubResp1 |
3356// | | |<-------------|
3357// | | RESTNotif1 | |
3358// | |<----------------| |
3359// | | | |
3360// | RESTSubReq2 | |
3361// |------------------------------>| |
3362// | | | |
3363// | RESTSubResp2 | |
3364// |<------------------------------| |
3365// | | | |
3366// | | RESTNotif2 | |
3367// |<------------------------------| |
3368// | | | |
3369// | | RESTSubDelReq1 | |
3370// | |---------------->| |
3371// | | | |
3372// | | RESTSubDelResp1 | |
3373// | |<----------------| |
3374// | | | |
3375// | RESTSubDelReq2 | |
3376// |------------------------------>| |
3377// | | | |
3378// | RESTSubDelResp2 | |
3379// |<------------------------------| |
3380// | | | |
3381// | | | SubDelReq2 |
3382// | | |------------->|
3383// | | | |
3384// | | | SubDelResp2 |
3385// | | |<-------------|
3386// | | | |
3387//
3388//-----------------------------------------------------------------------------
3389func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3390 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3391
3392 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3393 Counter{cSubReqFromXapp, 2},
3394 Counter{cSubReqToE2, 1},
3395 Counter{cSubRespFromE2, 1},
3396 Counter{cSubRespToXapp, 2},
3397 Counter{cMergedSubscriptions, 1},
3398 Counter{cUnmergedSubscriptions, 1},
3399 Counter{cSubDelReqFromXapp, 2},
3400 Counter{cSubDelReqToE2, 1},
3401 Counter{cSubDelRespFromE2, 1},
3402 Counter{cSubDelRespToXapp, 2},
3403 })
3404
3405 // Req1
3406 var params *teststube2ap.RESTSubsReqParams = nil
3407
3408 //Subs Create
3409 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3410 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3411
3412 // Req2
3413 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3414 params.SetMeid("RAN_NAME_1")
3415
3416 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
3417 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003418 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003419 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003420 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003421 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
3422 e2SubsId2 := <-xappConn2.RESTNotification
3423 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3424
3425 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3426
3427 // Del1
3428 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3429
3430 // Del2
3431 deleteXapp2Subscription(t, &restSubId2)
3432
3433 //Wait that subs is cleaned
3434 waitSubsCleanup(t, e2SubsId2, 10)
3435
3436 mainCtrl.VerifyCounterValues(t)
3437}
3438
3439//-----------------------------------------------------------------------------
3440// TestSubReqAndSubDelOkSameActionParallel
3441//
3442// stub stub stub
3443// +-------+ +-------+ +---------+ +---------+
3444// | xapp2 | | xapp1 | | submgr | | e2term |
3445// +-------+ +-------+ +---------+ +---------+
3446// | | | |
3447// | | | |
3448// | | | |
3449// | | SubReq1 | |
3450// | |------------->| |
3451// | | | |
3452// | | | SubReq1 |
3453// | | |------------->|
3454// | SubReq2 | |
3455// |--------------------------->| |
3456// | | | SubResp1 |
3457// | | |<-------------|
3458// | | SubResp1 | |
3459// | |<-------------| |
3460// | | | SubReq2 |
3461// | | |------------->|
3462// | | | |
3463// | | | SubResp2 |
3464// | | |<-------------|
3465// | SubResp2 | |
3466// |<---------------------------| |
3467// | | | |
3468// | | SubDelReq 1 | |
3469// | |------------->| |
3470// | | | |
3471// | | SubDelResp 1 | |
3472// | |<-------------| |
3473// | | | |
3474// | SubDelReq 2 | |
3475// |--------------------------->| |
3476// | | | |
3477// | | | SubDelReq 2 |
3478// | | |------------->|
3479// | | | |
3480// | | | SubDelReq 2 |
3481// | | |------------->|
3482// | | | |
3483// | SubDelResp 2 | |
3484// |<---------------------------| |
3485//
3486func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
3487 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
3488
3489 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3490 Counter{cSubReqFromXapp, 2},
3491 Counter{cSubReqToE2, 2},
3492 Counter{cSubRespFromE2, 2},
3493 Counter{cSubRespToXapp, 2},
3494 Counter{cSubDelReqFromXapp, 2},
3495 Counter{cSubDelReqToE2, 2},
3496 Counter{cSubDelRespFromE2, 2},
3497 Counter{cSubDelRespToXapp, 2},
3498 })
3499
3500 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3501 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3502 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3503
3504 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3505 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3506
3507 xappConn1.ExpectRESTNotification(t, restSubId1)
3508 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3509 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3510
3511 xappConn2.ExpectRESTNotification(t, restSubId2)
3512 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3513 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3514 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3515
3516 // Del1
3517 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3518 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3519 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3520 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3521
3522 // Del2
3523 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3524 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
3525 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
3526
3527 waitSubsCleanup(t, e2SubsId2, 10)
3528
3529 mainCtrl.VerifyCounterValues(t)
3530}
3531
3532//-----------------------------------------------------------------------------
3533// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
3534//
3535// stub stub stub
3536// +-------+ +-------+ +---------+ +---------+
3537// | xapp2 | | xapp1 | | submgr | | e2term |
3538// +-------+ +-------+ +---------+ +---------+
3539// | | | |
3540// | | | |
3541// | | | |
3542// | | RESTSubReq1 | |
3543// | |---------------->| |
3544// | | | |
3545// | | RESTSubResp1 | |
3546// | |<----------------| |
3547// | | | SubReq1 |
3548// | | |------------->|
3549// | RESTSubReq2 | |
3550// |------------------------------>| |
3551// | | | |
3552// | RESTSubDelResp2 | |
3553// |<------------------------------| |
3554// | | | SubReq1 |
3555// | | |------------->|
3556// | | | |
3557// | | | |
3558// | | | SubDelReq |
3559// | | |------------->|
3560// | | | |
3561// | | | SubDelResp |
3562// | | |<-------------|
3563// | | RESTNotif1 | |
3564// | | unsuccess | |
3565// | |<----------------| |
3566// | RESTNotif2 | |
3567// | | unsuccess | |
3568// |<------------------------------| |
3569// | | | |
3570// | | RESTSubDelReq1 | |
3571// | |---------------->| |
3572// | | | |
3573// | | RESTSubDelResp1 | |
3574// | |<----------------| |
3575// | | | |
3576// | RESTSubDelReq2 | |
3577// |------------------------------>| |
3578// | | | |
3579// | RESTSubDelResp2 | |
3580// |<------------------------------| |
3581//
3582//-----------------------------------------------------------------------------
3583func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
3584 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
3585
3586 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3587 Counter{cSubReqFromXapp, 2},
3588 Counter{cSubReqToE2, 1},
3589 Counter{cSubRespToXapp, 2},
3590 Counter{cSubDelReqFromXapp, 2},
3591 Counter{cSubDelReqToE2, 1},
3592 Counter{cSubDelRespFromE2, 1},
3593 Counter{cSubDelRespToXapp, 2},
3594 })
3595
3596 const subReqCount int = 1
3597 const parameterSet = 1
3598 const actionDefinitionPresent bool = true
3599 const actionParamCount int = 1
3600
3601 // Req1
3602 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3603 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
3604 crereq1, _ := e2termConn1.RecvSubsReq(t)
3605
3606 // Req2
3607 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
3608 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3609 params2.SetMeid("RAN_NAME_1")
3610 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3611 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3612
3613 //Req1 (retransmitted)
3614 e2termConn1.RecvSubsReq(t)
3615
3616 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00003617
3618 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03003619 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3620
Markku Virtanenda34eec2021-05-20 08:22:04 +00003621 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3622 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3623 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3624 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003625
3626 // Del1
3627 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3628
3629 // Del2
3630 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3631
Markku Virtanenda34eec2021-05-20 08:22:04 +00003632 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
3633
archaggeafbf95f2021-04-14 08:54:05 +03003634 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00003635 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003636
3637 mainCtrl.VerifyCounterValues(t)
3638}
3639
3640//-----------------------------------------------------------------------------
3641// TestRESTSubReqAndSubDelNokSameActionParallel
3642//
3643// stub stub stub
3644// +-------+ +-------+ +---------+ +---------+
3645// | xapp2 | | xapp1 | | submgr | | e2term |
3646// +-------+ +-------+ +---------+ +---------+
3647// | | | |
3648// | | | |
3649// | | | |
3650// | | RESTSubReq1 | |
3651// | |---------------->| |
3652// | | | |
3653// | | RESTSubResp1 | |
3654// | |<----------------| |
3655// | | | SubReq1 |
3656// | | |------------->|
3657// | RESTSubReq2 | |
3658// |------------------------------>| |
3659// | | | |
3660// | RESTSubDelResp2 | |
3661// |<------------------------------| |
3662// | | | SubFail1 |
3663// | | |<-------------|
3664// | | | |
3665// | | RESTNotif1 | |
3666// | | unsuccess | |
3667// | |<----------------| |
3668// | RESTNotif2 | |
3669// | | unsuccess | |
3670// |<------------------------------| |
3671// | | | SubDelReq |
3672// | | |------------->|
3673// | | | SubDelResp |
3674// | | |<-------------|
3675// | | | |
3676// | | RESTSubDelReq1 | |
3677// | |---------------->| |
3678// | | | |
3679// | | RESTSubDelResp1 | |
3680// | |<----------------| |
3681// | | | |
3682// | RESTSubDelReq2 | |
3683// |------------------------------>| |
3684// | | | |
3685// | RESTSubDelResp2 | |
3686// |<------------------------------| |
3687//
3688//-----------------------------------------------------------------------------
3689func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
3690 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
3691
3692 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3693 Counter{cSubReqFromXapp, 2},
3694 Counter{cSubReqToE2, 1},
3695 Counter{cSubFailFromE2, 1},
3696 Counter{cSubRespToXapp, 2},
3697 Counter{cSubDelReqFromXapp, 2},
3698 Counter{cSubDelReqToE2, 1},
3699 Counter{cSubDelRespFromE2, 1},
3700 Counter{cSubDelRespToXapp, 2},
3701 })
3702
3703 const subReqCount int = 1
3704 const parameterSet = 1
3705 const actionDefinitionPresent bool = true
3706 const actionParamCount int = 1
3707
3708 // Req1
3709 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3710 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3711 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3712
3713 // Req2
3714 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
3715 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3716 params2.SetMeid("RAN_NAME_1")
3717 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3718 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3719
3720 // E2t: send SubsFail (first)
3721 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3722 fparams1.Set(crereq1)
3723 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3724
3725 // E2t: internal delete
3726 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3727 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3728 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3729
3730 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3731 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3732 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3733 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3734
3735 // Del1
3736 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3737
3738 // Del2
3739 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3740
3741 //Wait that subs is cleaned
3742 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
3743 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3744
3745 mainCtrl.VerifyCounterValues(t)
3746}
3747
3748func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
3749 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3750
3751 // Init counter check
3752 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3753 Counter{cSubReqFromXapp, 1},
3754 Counter{cSubReqToE2, 1},
3755 Counter{cSubRespFromE2, 1},
3756 Counter{cSubRespToXapp, 1},
3757 Counter{cSubDelReqFromXapp, 1},
3758 Counter{cSubDelReqToE2, 1},
3759 Counter{cSubDelRespFromE2, 1},
3760 Counter{cSubDelRespToXapp, 1},
3761 })
3762
3763 const subReqCount int = 1
3764 const parameterSet = 1
3765 const actionDefinitionPresent bool = true
3766 const actionParamCount int = 1
3767
3768 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3769 restSubId := xappConn1.SendRESTSubsReq(t, params)
3770 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3771
3772 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3773 xappConn1.ExpectRESTNotification(t, restSubId)
3774 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3775 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3776 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
3777
3778 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3779 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3780 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3781
3782 // Wait that subs is cleaned
3783 waitSubsCleanup(t, e2SubsId, 10)
3784 mainCtrl.VerifyCounterValues(t)
3785}
3786
3787//-----------------------------------------------------------------------------
3788// TestRESTSubReqPolicyChangeAndSubDelOk
3789//
3790// stub stub
3791// +-------+ +---------+ +---------+
3792// | xapp | | submgr | | e2term |
3793// +-------+ +---------+ +---------+
3794// | | |
3795// | RESTSubReq | |
3796// |---------------->| |
3797// | | |
3798// | RESTSubResp | |
3799// |<----------------| |
3800// | | SubReq |
3801// | |------------->|
3802// | | |
3803// | | SubResp |
3804// | |<-------------|
3805// | | |
3806// | RESTNotif | |
3807// |<----------------| |
3808// | | |
3809// | RESTSubReq | |
3810// |---------------->| |
3811// | | |
3812// | RESTSubResp | |
3813// |<----------------| |
3814// | | SubReq |
3815// | |------------->|
3816// | | |
3817// | | SubResp |
3818// | |<-------------|
3819// | | |
3820// | RESTNotif | |
3821// |<----------------| |
3822// | | |
3823// | RESTSubDelReq | |
3824// |---------------->| |
3825// | | |
3826// | | SubDelReq |
3827// | |------------->|
3828// | | |
3829// | | SubDelResp |
3830// | |<-------------|
3831// | | |
3832// | RESTSubDelResp | |
3833// |<----------------| |
3834//
3835//-----------------------------------------------------------------------------
3836func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
3837 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3838
3839 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3840 Counter{cSubReqFromXapp, 2},
3841 Counter{cSubReqToE2, 2},
3842 Counter{cSubRespFromE2, 2},
3843 Counter{cSubRespToXapp, 2},
3844 Counter{cSubDelReqFromXapp, 1},
3845 Counter{cSubDelReqToE2, 1},
3846 Counter{cSubDelRespFromE2, 1},
3847 Counter{cSubDelRespToXapp, 1},
3848 })
3849
3850 const subReqCount int = 1
3851 const parameterSet = 1
3852 const actionDefinitionPresent bool = true
3853 const policyParamCount int = 1
3854
3855 // Req
3856 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3857 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3858
3859 // Policy change
3860 instanceId := int64(e2SubsId)
3861 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
3862 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3863 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{
3924 Counter{cSubReqFromXapp, 2},
3925 Counter{cSubReqToE2, 2},
3926 Counter{cSubRespFromE2, 2},
3927 Counter{cSubRespToXapp, 2},
3928 Counter{cSubDelReqFromXapp, 2},
3929 Counter{cSubDelReqToE2, 2},
3930 Counter{cSubDelRespFromE2, 2},
3931 Counter{cSubDelRespToXapp, 2},
3932 })
3933
3934 const subReqCount int = 1
3935 const parameterSet = 1
3936 const actionDefinitionPresent bool = true
3937 const actionParamCount int = 1
3938
3939 // Req1
3940 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3941 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3942 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3943
3944 // Req2
3945 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3946 params.SetMeid("RAN_NAME_11")
3947 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
3948 // would not work as notification would not be received
3949 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3950 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
3951
3952 // Resp1
3953 xappConn1.ExpectRESTNotification(t, restSubId1)
3954 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3955 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3956 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
3957
3958 // Resp2
3959 xappConn2.ExpectRESTNotification(t, restSubId2)
3960 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
3961 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3962 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
3963
3964 // Delete1
3965 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3966 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3967 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3968
3969 // Wait that subs is cleaned
3970 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3971
3972 // Delete2
3973 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
3974 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
3975 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
3976
3977 // Wait that subs is cleaned
3978 waitSubsCleanup(t, e2SubsId2, 10)
3979
3980 mainCtrl.VerifyCounterValues(t)
3981}
3982
3983//-----------------------------------------------------------------------------
3984// TestRESTSubReqAsn1EncodeFail
3985//
3986// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
3987// stub stub
3988// +-------+ +---------+ +---------+
3989// | xapp | | submgr | | e2term |
3990// +-------+ +---------+ +---------+
3991// | | |
3992// | RESTSubReq | |
3993// |---------------->| |
3994// | | |
3995// | RESTSubResp | |
3996// |<----------------| |
3997// | RESTSubDelReq | |
3998// |---------------->| |
3999// | RESTSubDelResp | |
4000// | unsuccess | |
4001// |<----------------| |
4002// | | |
4003//
4004//-----------------------------------------------------------------------------
4005func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4006 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4007
4008 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
4009
4010}
4011
4012//-----------------------------------------------------------------------------
4013// TestRESTSubReqInsertAndSubDelOk
4014//
4015// stub stub
4016// +-------+ +---------+ +---------+
4017// | xapp | | submgr | | e2term |
4018// +-------+ +---------+ +---------+
4019// | | |
4020// | RestSubReq | |
4021// |---------------->| |
4022// | | |
4023// | RESTSubResp | |
4024// |<----------------| |
4025// | | |
4026// | | SubReq |
4027// | |------------->|
4028// | | |
4029// | | SubResp |
4030// | |<-------------|
4031// | RESTNotif | |
4032// |<----------------| |
4033// | ... | ... |
4034// | | |
4035// | RESTSubDelReq | |
4036// |---------------->| |
4037// | | |
4038// | | SubDelReq |
4039// | |------------->|
4040// | | |
4041// | | SubDelResp |
4042// | |<-------------|
4043// | | |
4044// | RESTSubDelResp| |
4045// |<----------------| |
4046//
4047//-----------------------------------------------------------------------------
4048func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4049 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4050
4051 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4052 Counter{cSubReqFromXapp, 1},
4053 Counter{cSubReqToE2, 1},
4054 Counter{cSubRespFromE2, 1},
4055 Counter{cSubRespToXapp, 1},
4056 Counter{cSubDelReqFromXapp, 1},
4057 Counter{cSubDelReqToE2, 1},
4058 Counter{cSubDelRespFromE2, 1},
4059 Counter{cSubDelRespToXapp, 1},
4060 })
4061
4062 const subReqCount int = 1
4063 const parameterSet int = 1
4064 const actionDefinitionPresent bool = true
4065 const actionParamCount int = 1
4066
4067 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4068 params.SetSubActionTypes("insert")
4069
4070 // Req
4071 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4072
4073 // Del
4074 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4075
4076 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4077 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4078
4079 // Wait that subs is cleaned
4080 waitSubsCleanup(t, e2SubsId, 10)
4081 mainCtrl.VerifyCounterValues(t)
4082}
4083
4084//-----------------------------------------------------------------------------
4085// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4086//
4087// stub stub
4088// +-------+ +---------+ +---------+
4089// | xapp | | submgr | | e2term |
4090// +-------+ +---------+ +---------+
4091// | | |
4092// | RESTSubReq | |
4093// |------------->| |
4094// | | |
4095// | | SubReq |
4096// | |------------->|
4097// | | |
4098// | | SubResp |
4099// | <----|
4100// | |
4101// | Submgr restart |
4102// | |
4103// | | |
4104// | | SubDelReq |
4105// | |------------->|
4106// | | |
4107// | | SubDelResp |
4108// | |<-------------|
4109// | | |
4110//
4111//-----------------------------------------------------------------------------
4112func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4113 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4114
4115 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4116 Counter{cSubReqFromXapp, 1},
4117 Counter{cSubReqToE2, 1},
4118 Counter{cSubDelReqFromXapp, 1},
4119 Counter{cSubDelReqToE2, 1},
4120 Counter{cSubDelRespFromE2, 1},
4121 })
4122
4123 const subReqCount int = 1
4124 const parameterSet = 1
4125 const actionDefinitionPresent bool = true
4126 const actionParamCount int = 1
4127
4128 // Remove possible existing subscription
4129 mainCtrl.removeExistingSubscriptions(t)
4130
4131 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4132
4133 //Req
4134 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
4135 restSubId := xappConn1.SendRESTSubsReq(t, params)
4136 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4137
4138 e2termConn1.RecvSubsReq(t)
4139
4140 mainCtrl.SetResetTestFlag(t, false)
4141
4142 mainCtrl.SimulateRestart(t)
4143 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4144
4145 //Del
4146 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4147 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4148
4149 xappConn1.TestMsgChanEmpty(t)
4150 xappConn2.TestMsgChanEmpty(t)
4151 e2termConn1.TestMsgChanEmpty(t)
4152 mainCtrl.wait_registry_empty(t, 10)
4153
4154 mainCtrl.VerifyCounterValues(t)
4155}
4156
4157//-----------------------------------------------------------------------------
4158// TestRESTSubReqAndSubDelOkWithRestartInMiddle
4159//
4160// stub stub
4161// +-------+ +---------+ +---------+
4162// | xapp | | submgr | | e2term |
4163// +-------+ +---------+ +---------+
4164// | | |
4165// | RESTSubReq | |
4166// |---------------->| |
4167// | | |
4168// | RESTSubResp | |
4169// |<----------------| |
4170// | | SubReq |
4171// | |------------->|
4172// | | |
4173// | | SubResp |
4174// | |<-------------|
4175// | | |
4176// | RESTNotif | |
4177// |<----------------| |
4178// | | |
4179// | |
4180// | Submgr restart |
4181// | | |
4182// | RESTSubDelReq | |
4183// |---------------->| |
4184// | | |
4185// | | SubDelReq |
4186// | |------------->|
4187// | | |
4188// | | SubDelResp |
4189// | |<-------------|
4190// | | |
4191// | RESTSubDelResp | |
4192// |<----------------| |
4193//
4194//-----------------------------------------------------------------------------
4195func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4196 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4197
4198 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4199 Counter{cSubReqFromXapp, 1},
4200 Counter{cSubReqToE2, 1},
4201 Counter{cSubRespFromE2, 1},
4202 Counter{cSubRespToXapp, 1},
4203 Counter{cSubDelReqFromXapp, 1},
4204 Counter{cSubDelReqToE2, 1},
4205 Counter{cSubDelRespToXapp, 1},
4206 })
4207
4208 // Remove possible existing subscription
4209 mainCtrl.removeExistingSubscriptions(t)
4210
4211 var params *teststube2ap.RESTSubsReqParams = nil
4212
4213 // Create subscription
4214 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4215 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4216
4217 // Check subscription
4218 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4219
4220 // When SDL support for the REST Interface is added
4221 // the submgr restart statement below should be removed
4222 // from the comment.
4223
4224 // mainCtrl.SimulateRestart(t)
4225 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4226
4227 // Check subscription
4228 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4229
4230 // Delete subscription
4231 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4232
4233 //Wait that subs is cleaned
4234 waitSubsCleanup(t, e2SubsId, 10)
4235
4236 mainCtrl.VerifyCounterValues(t)
4237}
4238
4239//-----------------------------------------------------------------------------
4240// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4241//
4242// stub stub
4243// +-------+ +-------+ +---------+ +---------+
4244// | xapp2 | | xapp1 | | submgr | | e2term |
4245// +-------+ +-------+ +---------+ +---------+
4246// | | | |
4247// | | RESTSubReq1 | |
4248// | |---------------->| |
4249// | | | |
4250// | | RESTSubResp1 | |
4251// | |<----------------| |
4252// | | | |
4253// | | | SubReq1 |
4254// | | |------------->|
4255// | | | SubResp1 |
4256// | | |<-------------|
4257// | | RESTNotif1 | |
4258// | |<----------------| |
4259// | | | |
4260// | RESTSubReq2 | |
4261// |------------------------------>| |
4262// | | | |
4263// | RESTSubResp2 | |
4264// |<------------------------------| |
4265// | | | |
4266// | | RESTNotif2 | |
4267// |<------------------------------| |
4268// | | | |
4269// | | Submgr restart |
4270// | | | |
4271// | | RESTSubDelReq1 | |
4272// | |---------------->| |
4273// | | | |
4274// | | RESTSubDelResp1 | |
4275// | |<----------------| |
4276// | | | |
4277// | | Submgr restart |
4278// | | | |
4279// | RESTSubDelReq2 | |
4280// |------------------------------>| |
4281// | | | |
4282// | RESTSubDelResp2 | |
4283// |<------------------------------| |
4284// | | | |
4285// | | | SubDelReq2 |
4286// | | |------------->|
4287// | | | |
4288// | | | SubDelResp2 |
4289// | | |<-------------|
4290// | | | |
4291//
4292//-----------------------------------------------------------------------------
4293func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4294 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4295
4296 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4297 Counter{cSubReqFromXapp, 2},
4298 Counter{cSubReqToE2, 1},
4299 Counter{cSubRespFromE2, 1},
4300 Counter{cSubRespToXapp, 2},
4301 Counter{cMergedSubscriptions, 1},
4302 Counter{cUnmergedSubscriptions, 1},
4303 Counter{cSubDelReqFromXapp, 2},
4304 Counter{cSubDelReqToE2, 1},
4305 Counter{cSubDelRespFromE2, 1},
4306 Counter{cSubDelRespToXapp, 2},
4307 })
4308
4309 // Remove possible existing subscription
4310 mainCtrl.removeExistingSubscriptions(t)
4311
4312 var params *teststube2ap.RESTSubsReqParams = nil
4313
4314 // Create subscription 1
4315 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4316 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4317
4318 // Create subscription 2 with same action
4319 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4320 params.SetMeid("RAN_NAME_1")
4321 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4322 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
4323 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4324 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4325 e2SubsId2 := <-xappConn2.RESTNotification
4326 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4327
4328 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4329
4330 // When SDL support for the REST Interface is added
4331 // the submgr restart statement below should be removed
4332 // from the comment.
4333
4334 // mainCtrl.SimulateRestart(t)
4335 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4336
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004337 // Delete subscription 1, and wait until it has removed the first endpoint
4338 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004339 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004340 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004341
4342 // When SDL support for the REST Interface is added
4343 // the submgr restart statement below should be removed
4344 // from the comment.
4345
4346 // mainCtrl.SimulateRestart(t)
4347 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004348 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4349
4350 // Delete subscription 2
4351 deleteXapp2Subscription(t, &restSubId2)
4352
4353 //Wait that subs is cleaned
4354 waitSubsCleanup(t, e2SubsId2, 10)
4355
4356 mainCtrl.VerifyCounterValues(t)
4357}
4358
4359//-----------------------------------------------------------------------------
4360// TestRESTReportSubReqAndSubDelOk
4361//
4362// stub stub
4363// +-------+ +---------+ +---------+
4364// | xapp | | submgr | | e2term |
4365// +-------+ +---------+ +---------+
4366// | | |
4367// | RestSubReq | |
4368// |---------------->| |
4369// | | |
4370// | RESTSubResp | |
4371// |<----------------| |
4372// | | |
4373// | | SubReq |
4374// | |------------->|
4375// | | |
4376// | | SubResp |
4377// | |<-------------|
4378// | RESTNotif | |
4379// |<----------------| |
4380// | | SubReq |
4381// | |------------->|
4382// | | |
4383// | | SubResp |
4384// | |<-------------|
4385// | RESTNotif | |
4386// |<----------------| |
4387// | ... | ... |
4388// | | |
4389// | | |
4390// | RESTSubDelReq | |
4391// |---------------->| |
4392// | | |
4393// | | SubDelReq |
4394// | |------------->|
4395// | | |
4396// | | SubDelResp |
4397// | |<-------------|
4398// | | |
4399// | RESTSubDelResp| |
4400// |<----------------| |
4401//
4402//-----------------------------------------------------------------------------
4403func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
4404 CaseBegin("TestRESTReportSubReqAndSubDelOk")
4405 subReqCount := 1
4406 parameterSet := 1 // E2SM-gNB-X2
4407 actionDefinitionPresent := true
4408 actionParamCount := 1
4409 testIndex := 1
4410 RESTReportSubReqAndSubDelOk(t, subReqCount, parameterSet, actionDefinitionPresent, actionParamCount, testIndex)
4411}
4412
4413func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, parameterSet int, actionDefinitionPresent bool, actionParamCount int, testIndex int) {
4414 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with parameter set %v", testIndex)
4415
4416 // Req
4417 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4418 restSubId := xappConn1.SendRESTSubsReq(t, params)
4419
4420 var e2SubsId []uint32
4421 for i := 0; i < subReqCount; i++ {
4422 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4423 xappConn1.ExpectRESTNotification(t, restSubId)
4424
4425 e2termConn1.SendSubsResp(t, crereq, cremsg)
4426 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4427 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4428 e2SubsId = append(e2SubsId, instanceId)
4429 resp, _ := xapp.Subscription.QuerySubscriptions()
4430 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
4431 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
4432 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
4433
4434 }
4435
4436 // Del
4437 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4438
4439 for i := 0; i < subReqCount; i++ {
4440 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4441 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4442 }
4443
4444 // Wait that subs is cleaned
4445 for i := 0; i < subReqCount; i++ {
4446 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4447 }
4448
4449 xappConn1.TestMsgChanEmpty(t)
4450 e2termConn1.TestMsgChanEmpty(t)
4451 mainCtrl.wait_registry_empty(t, 10)
4452}
4453
4454/*
4455func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
4456 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
4457
4458 subReqCount := 2
4459 actionDefinitionPresent := true
4460 policyParamCount := 1
4461 testIndex := 1
4462 RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
4463
4464 subReqCount = 19
4465 actionDefinitionPresent = false
4466 policyParamCount = 0
4467 testIndex = 2
4468 RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
4469}
4470*/
4471func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, actionDefinitionPresent bool, policyParamCount int, testIndex int) {
4472 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with parameter set %v", testIndex)
4473
4474 // Req
4475 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4476 restSubId := xappConn1.SendRESTSubsReq(t, params)
4477 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount, actionDefinitionPresent, policyParamCount)
4478 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
4479
4480 var e2SubsId []uint32
4481 for i := 0; i < subReqCount; i++ {
4482 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4483 xappConn1.ExpectRESTNotification(t, restSubId)
4484 e2termConn1.SendSubsResp(t, crereq, cremsg)
4485 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4486 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4487 e2SubsId = append(e2SubsId, instanceId)
4488 }
4489
4490 // Del
4491 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4492
4493 for i := 0; i < subReqCount; i++ {
4494 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4495 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4496 }
4497
4498 // Wait that subs is cleaned
4499 for i := 0; i < subReqCount; i++ {
4500 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4501 }
4502 xappConn1.TestMsgChanEmpty(t)
4503 e2termConn1.TestMsgChanEmpty(t)
4504 mainCtrl.wait_registry_empty(t, 10)
4505}
4506
archaggeafbf95f2021-04-14 08:54:05 +03004507func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
4508
4509 subReqCount := 2
4510
4511 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4512 Counter{cSubReqFromXapp, 1},
4513 Counter{cSubReqToE2, 2},
4514 Counter{cSubRespFromE2, 2},
4515 Counter{cSubRespToXapp, 2},
4516 Counter{cSubDelReqFromXapp, 1},
4517 Counter{cSubDelReqToE2, 2},
4518 Counter{cSubDelRespFromE2, 2},
4519 Counter{cSubDelRespToXapp, 1},
4520 })
4521
4522 // Req
4523 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4524 restSubId := xappConn1.SendRESTSubsReq(t, params)
4525 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4526
4527 assert.Equal(t, len(e2SubsIds), 2)
4528
4529 // Del
4530 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4531 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4532
4533 xappConn1.TestMsgChanEmpty(t)
4534 e2termConn1.TestMsgChanEmpty(t)
4535 mainCtrl.wait_registry_empty(t, 10)
4536
4537 mainCtrl.VerifyCounterValues(t)
4538}
archaggeafbf95f2021-04-14 08:54:05 +03004539func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
4540
4541 subReqCount := 19
4542
4543 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4544 Counter{cSubReqFromXapp, 1},
4545 Counter{cSubReqToE2, 19},
4546 Counter{cSubRespFromE2, 19},
4547 Counter{cSubRespToXapp, 19},
4548 Counter{cSubDelReqFromXapp, 1},
4549 Counter{cSubDelReqToE2, 19},
4550 Counter{cSubDelRespFromE2, 19},
4551 Counter{cSubDelRespToXapp, 1},
4552 })
4553
4554 // Req
4555 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4556 restSubId := xappConn1.SendRESTSubsReq(t, params)
4557 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4558
4559 assert.Equal(t, len(e2SubsIds), 19)
4560
4561 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4562 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4563
4564 xappConn1.TestMsgChanEmpty(t)
4565 e2termConn1.TestMsgChanEmpty(t)
4566 mainCtrl.wait_registry_empty(t, 10)
4567
4568 mainCtrl.VerifyCounterValues(t)
4569}
archaggeafbf95f2021-04-14 08:54:05 +03004570func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
4571
4572 subReqCount := 2
4573 parameterSet := 1
4574 actionDefinitionPresent := true
4575 actionParamCount := 1
4576
4577 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4578 Counter{cSubReqFromXapp, 1},
4579 Counter{cSubReqToE2, uint64(subReqCount)},
4580 Counter{cSubRespFromE2, uint64(subReqCount)},
4581 Counter{cSubRespToXapp, uint64(subReqCount)},
4582 Counter{cSubDelReqFromXapp, 1},
4583 Counter{cSubDelReqToE2, uint64(subReqCount)},
4584 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4585 Counter{cSubDelRespToXapp, 1},
4586 })
4587
4588 // Req
4589 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4590 restSubId := xappConn1.SendRESTSubsReq(t, params)
4591 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4592
4593 assert.Equal(t, len(e2SubsIds), subReqCount)
4594
4595 // Del
4596 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4597 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4598
4599 xappConn1.TestMsgChanEmpty(t)
4600 e2termConn1.TestMsgChanEmpty(t)
4601 mainCtrl.wait_registry_empty(t, 10)
4602
4603 mainCtrl.VerifyCounterValues(t)
4604}
Markku Virtanenda34eec2021-05-20 08:22:04 +00004605
archaggeafbf95f2021-04-14 08:54:05 +03004606func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
4607
4608 subReqCount := 2
4609 parameterSet := 1
4610 actionDefinitionPresent := false
4611 actionParamCount := 0
4612
4613 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4614 Counter{cSubReqFromXapp, 1},
4615 Counter{cSubReqToE2, uint64(subReqCount)},
4616 Counter{cSubRespFromE2, uint64(subReqCount)},
4617 Counter{cSubRespToXapp, uint64(subReqCount)},
4618 Counter{cSubDelReqFromXapp, 1},
4619 Counter{cSubDelReqToE2, uint64(subReqCount)},
4620 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4621 Counter{cSubDelRespToXapp, 1},
4622 })
4623
4624 // Req
4625 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4626 restSubId := xappConn1.SendRESTSubsReq(t, params)
4627 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4628
4629 assert.Equal(t, len(e2SubsIds), subReqCount)
4630
4631 // Del
4632 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4633 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4634
4635 xappConn1.TestMsgChanEmpty(t)
4636 e2termConn1.TestMsgChanEmpty(t)
4637 mainCtrl.wait_registry_empty(t, 10)
4638
4639 mainCtrl.VerifyCounterValues(t)
4640}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004641
archaggeafbf95f2021-04-14 08:54:05 +03004642func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
4643
4644 subReqCount := 19
4645 parameterSet := 1
4646 actionDefinitionPresent := false
4647 actionParamCount := 0
4648
4649 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4650 Counter{cSubReqFromXapp, 1},
4651 Counter{cSubReqToE2, uint64(subReqCount)},
4652 Counter{cSubRespFromE2, uint64(subReqCount)},
4653 Counter{cSubRespToXapp, uint64(subReqCount)},
4654 Counter{cSubDelReqFromXapp, 1},
4655 Counter{cSubDelReqToE2, uint64(subReqCount)},
4656 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4657 Counter{cSubDelRespToXapp, 1},
4658 })
4659
4660 // Req
4661 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4662 restSubId := xappConn1.SendRESTSubsReq(t, params)
4663 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4664
4665 assert.Equal(t, len(e2SubsIds), subReqCount)
4666
4667 // Del
4668 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4669 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4670
4671 xappConn1.TestMsgChanEmpty(t)
4672 e2termConn1.TestMsgChanEmpty(t)
4673 mainCtrl.wait_registry_empty(t, 10)
4674
4675 mainCtrl.VerifyCounterValues(t)
4676}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004677
4678func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
4679 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
4680
4681 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4682 Counter{cSubReqFromXapp, 2},
4683 Counter{cSubReqToE2, 2},
4684 Counter{cSubRespFromE2, 2},
4685 Counter{cSubRespToXapp, 2},
4686 Counter{cSubDelReqFromXapp, 2},
4687 Counter{cSubDelReqToE2, 2},
4688 Counter{cSubDelRespFromE2, 2},
4689 Counter{cSubDelRespToXapp, 2},
4690 })
4691
4692 // Req1
4693 var params *teststube2ap.RESTSubsReqParams = nil
4694
4695 //Subs Create
4696 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4697 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4698
4699 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4700
4701 // Req2
4702 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4703 params.SetMeid("RAN_NAME_1")
4704 eventTriggerDefinition := "1234"
4705 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
4706
4707 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4708 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4709 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4710 xappConn2.ExpectRESTNotification(t, restSubId2)
4711 e2termConn1.SendSubsResp(t, crereq, cremsg)
4712 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4713
4714 deleteXapp1Subscription(t, &restSubId1)
4715 deleteXapp2Subscription(t, &restSubId2)
4716
4717 waitSubsCleanup(t, e2SubsId1, 10)
4718 waitSubsCleanup(t, e2SubsId2, 10)
4719
4720 mainCtrl.VerifyCounterValues(t)
4721
4722}
4723
4724func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
4725 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
4726
4727 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4728 Counter{cSubReqFromXapp, 2},
4729 Counter{cSubReqToE2, 2},
4730 Counter{cSubRespFromE2, 2},
4731 Counter{cSubRespToXapp, 2},
4732 Counter{cSubDelReqFromXapp, 2},
4733 Counter{cSubDelReqToE2, 2},
4734 Counter{cSubDelRespFromE2, 2},
4735 Counter{cSubDelRespToXapp, 2},
4736 })
4737
4738 // Req1
4739 var params *teststube2ap.RESTSubsReqParams = nil
4740
4741 //Subs Create
4742 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4743 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4744
4745 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4746
4747 // Req2
4748 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4749 params.SetMeid("RAN_NAME_1")
4750
4751 actionId := int64(1)
4752 actionType := "report"
4753 actionDefinition := "56781"
4754 subsequestActionType := "continue"
4755 timeToWait := "w10ms"
4756 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4757
4758 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4759 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4760 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4761 xappConn2.ExpectRESTNotification(t, restSubId2)
4762 e2termConn1.SendSubsResp(t, crereq, cremsg)
4763 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4764
4765 deleteXapp1Subscription(t, &restSubId1)
4766 deleteXapp2Subscription(t, &restSubId2)
4767
4768 waitSubsCleanup(t, e2SubsId1, 10)
4769 waitSubsCleanup(t, e2SubsId2, 10)
4770
4771 mainCtrl.VerifyCounterValues(t)
4772
4773}
4774
4775func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
4776 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
4777
4778 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4779 Counter{cSubReqFromXapp, 2},
4780 Counter{cSubReqToE2, 2},
4781 Counter{cSubRespFromE2, 2},
4782 Counter{cSubRespToXapp, 2},
4783 Counter{cSubDelReqFromXapp, 2},
4784 Counter{cSubDelReqToE2, 2},
4785 Counter{cSubDelRespFromE2, 2},
4786 Counter{cSubDelRespToXapp, 2},
4787 })
4788
4789 // Req1
4790 var params *teststube2ap.RESTSubsReqParams = nil
4791
4792 //Subs Create
4793 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4794 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4795
4796 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4797
4798 // Req2
4799 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4800 params.SetMeid("RAN_NAME_1")
4801 params.SetSubActionIDs(int64(2))
4802
4803 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4804 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4805 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4806 xappConn2.ExpectRESTNotification(t, restSubId2)
4807 e2termConn1.SendSubsResp(t, crereq, cremsg)
4808 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4809
4810 deleteXapp1Subscription(t, &restSubId1)
4811 deleteXapp2Subscription(t, &restSubId2)
4812
4813 waitSubsCleanup(t, e2SubsId1, 10)
4814 waitSubsCleanup(t, e2SubsId2, 10)
4815
4816 mainCtrl.VerifyCounterValues(t)
4817
4818}
4819
4820func TestRESTSubReqDiffActionType(t *testing.T) {
4821 CaseBegin("TestRESTSubReqDiffActionType")
4822
4823 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4824 Counter{cSubReqFromXapp, 2},
4825 Counter{cSubReqToE2, 2},
4826 Counter{cSubRespFromE2, 2},
4827 Counter{cSubRespToXapp, 2},
4828 Counter{cSubDelReqFromXapp, 2},
4829 Counter{cSubDelReqToE2, 2},
4830 Counter{cSubDelRespFromE2, 2},
4831 Counter{cSubDelRespToXapp, 2},
4832 })
4833
4834 // Req1
4835 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4836
4837 //Subs Create
4838 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4839 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4840
4841 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4842
4843 // Req2
4844 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4845 params.SetMeid("RAN_NAME_1")
4846
4847 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4848 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4849 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4850 xappConn2.ExpectRESTNotification(t, restSubId2)
4851 e2termConn1.SendSubsResp(t, crereq, cremsg)
4852 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4853
4854 deleteXapp1Subscription(t, &restSubId1)
4855 deleteXapp2Subscription(t, &restSubId2)
4856
4857 waitSubsCleanup(t, e2SubsId1, 10)
4858 waitSubsCleanup(t, e2SubsId2, 10)
4859
4860 mainCtrl.VerifyCounterValues(t)
4861
4862}
4863
4864func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
4865 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
4866
4867 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4868 Counter{cSubReqFromXapp, 2},
4869 Counter{cSubReqToE2, 2},
4870 Counter{cSubRespFromE2, 2},
4871 Counter{cSubRespToXapp, 2},
4872 Counter{cSubDelReqFromXapp, 2},
4873 Counter{cSubDelReqToE2, 2},
4874 Counter{cSubDelRespFromE2, 2},
4875 Counter{cSubDelRespToXapp, 2},
4876 })
4877
4878 // Req1
4879 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4880
4881 //Subs Create
4882 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4883 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4884
4885 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4886
4887 // Req2
4888 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4889 params.SetMeid("RAN_NAME_1")
4890
4891 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4892 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4893 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4894 xappConn2.ExpectRESTNotification(t, restSubId2)
4895 e2termConn1.SendSubsResp(t, crereq, cremsg)
4896 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4897
4898 deleteXapp1Subscription(t, &restSubId1)
4899 deleteXapp2Subscription(t, &restSubId2)
4900
4901 waitSubsCleanup(t, e2SubsId1, 10)
4902 waitSubsCleanup(t, e2SubsId2, 10)
4903
4904 mainCtrl.VerifyCounterValues(t)
4905
4906}
4907
4908func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
4909 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
4910
4911 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4912 Counter{cSubReqFromXapp, 2},
4913 Counter{cSubReqToE2, 2},
4914 Counter{cSubRespFromE2, 2},
4915 Counter{cSubRespToXapp, 2},
4916 Counter{cSubDelReqFromXapp, 2},
4917 Counter{cSubDelReqToE2, 2},
4918 Counter{cSubDelRespFromE2, 2},
4919 Counter{cSubDelRespToXapp, 2},
4920 })
4921
4922 // Req1
4923 var params *teststube2ap.RESTSubsReqParams = nil
4924
4925 //Subs Create
4926 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4927 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4928
4929 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4930
4931 // Req2
4932 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4933 params.SetMeid("RAN_NAME_1")
4934 actionDefinition := "5678"
4935 params.SetSubActionDefinition(actionDefinition)
4936
4937 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4938 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4939 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4940 xappConn2.ExpectRESTNotification(t, restSubId2)
4941 e2termConn1.SendSubsResp(t, crereq, cremsg)
4942 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4943
4944 deleteXapp1Subscription(t, &restSubId1)
4945 deleteXapp2Subscription(t, &restSubId2)
4946
4947 waitSubsCleanup(t, e2SubsId1, 10)
4948 waitSubsCleanup(t, e2SubsId2, 10)
4949
4950 mainCtrl.VerifyCounterValues(t)
4951
4952}
4953
4954func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
4955 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
4956
4957 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4958 Counter{cSubReqFromXapp, 2},
4959 Counter{cSubReqToE2, 2},
4960 Counter{cSubRespFromE2, 2},
4961 Counter{cSubRespToXapp, 2},
4962 Counter{cSubDelReqFromXapp, 2},
4963 Counter{cSubDelReqToE2, 2},
4964 Counter{cSubDelRespFromE2, 2},
4965 Counter{cSubDelRespToXapp, 2},
4966 })
4967
4968 // Req1
4969 var params *teststube2ap.RESTSubsReqParams = nil
4970
4971 //Subs Create
4972 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4973 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4974
4975 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4976
4977 // Req2
4978 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4979 params.SetMeid("RAN_NAME_1")
4980 actionDefinition := "56782"
4981 params.SetSubActionDefinition(actionDefinition)
4982
4983 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4984 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4985 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4986 xappConn2.ExpectRESTNotification(t, restSubId2)
4987 e2termConn1.SendSubsResp(t, crereq, cremsg)
4988 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4989
4990 deleteXapp1Subscription(t, &restSubId1)
4991 deleteXapp2Subscription(t, &restSubId2)
4992
4993 waitSubsCleanup(t, e2SubsId1, 10)
4994 waitSubsCleanup(t, e2SubsId2, 10)
4995
4996 mainCtrl.VerifyCounterValues(t)
4997
4998}
4999
5000func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5001 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5002
5003 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5004 Counter{cSubReqFromXapp, 2},
5005 Counter{cSubReqToE2, 2},
5006 Counter{cSubRespFromE2, 2},
5007 Counter{cSubRespToXapp, 2},
5008 Counter{cSubDelReqFromXapp, 2},
5009 Counter{cSubDelReqToE2, 2},
5010 Counter{cSubDelRespFromE2, 2},
5011 Counter{cSubDelRespToXapp, 2},
5012 })
5013
5014 // Req1
5015 var params *teststube2ap.RESTSubsReqParams = nil
5016
5017 //Subs Create
5018 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
5019 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
5020
5021 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5022
5023 // Req2
5024 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5025 params.SetMeid("RAN_NAME_1")
5026 params.SetTimeToWait("w200ms")
5027 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5028 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
5029 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5030 xappConn2.ExpectRESTNotification(t, restSubId2)
5031 e2termConn1.SendSubsResp(t, crereq, cremsg)
5032 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5033
5034 deleteXapp1Subscription(t, &restSubId1)
5035 deleteXapp2Subscription(t, &restSubId2)
5036
5037 waitSubsCleanup(t, e2SubsId1, 10)
5038 waitSubsCleanup(t, e2SubsId2, 10)
5039
5040 mainCtrl.VerifyCounterValues(t)
5041
5042}
5043
Anssi Mannila51122392021-05-25 11:51:31 +03005044//-----------------------------------------------------------------------------
5045// TestRESTUnpackSubscriptionResponseDecodeFail
5046//
5047// stub stub
5048// +-------+ +---------+ +---------+
5049// | xapp | | submgr | | e2term |
5050// +-------+ +---------+ +---------+
5051// | | |
5052// | RestSubReq | |
5053// |---------------->| |
5054// | | |
5055// | RESTSubResp | |
5056// |<----------------| |
5057// | | |
5058// | | SubReq |
5059// | |------------->|
5060// | | |
5061// | | SubResp | ASN.1 decode fails
5062// | |<-------------|
5063// | | |
5064// | | SubReq |
5065// | |------------->|
5066// | | |
5067// | | SubFail | Duplicated action
5068// | |<-------------|
5069// | RESTNotif (fail)| |
5070// |<----------------| |
5071// | | SubDelReq |
5072// | |------------->|
5073// | | |
5074// | | SubDelResp |
5075// | |<-------------|
5076//
5077//-----------------------------------------------------------------------------
5078func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
5079 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5080 subReqCount := 1
5081 parameterSet := 1 // E2SM-gNB-X2
5082 actionDefinitionPresent := true
5083 actionParamCount := 1
5084
5085 // Req
5086 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5087 restSubId := xappConn1.SendRESTSubsReq(t, params)
5088
5089 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5090 // Decode of this response fails which will result resending original request
5091 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5092
5093 _, cremsg = e2termConn1.RecvSubsReq(t)
5094
5095 xappConn1.ExpectRESTNotification(t, restSubId)
5096
5097 // Subscription already created in E2 Node.
5098 fparams := &teststube2ap.E2StubSubsFailParams{}
5099 fparams.Set(crereq)
5100 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5101 e2termConn1.SendSubsFail(t, fparams, cremsg)
5102
5103 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5104 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5105
5106 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5107 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5108
5109 // Wait that subs is cleaned
5110 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5111
5112 xappConn1.TestMsgChanEmpty(t)
5113 e2termConn1.TestMsgChanEmpty(t)
5114 mainCtrl.wait_registry_empty(t, 10)
5115}
5116
5117//-----------------------------------------------------------------------------
5118// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5119//
5120// stub stub
5121// +-------+ +---------+ +---------+
5122// | xapp | | submgr | | e2term |
5123// +-------+ +---------+ +---------+
5124// | | |
5125// | RestSubReq | |
5126// |---------------->| |
5127// | | |
5128// | RESTSubResp | |
5129// |<----------------| |
5130// | | |
5131// | | SubReq |
5132// | |------------->|
5133// | | |
5134// | | SubResp | Unknown instanceId
5135// | |<-------------|
5136// | | |
5137// | | SubReq |
5138// | |------------->|
5139// | | |
5140// | | SubFail | Duplicated action
5141// | |<-------------|
5142// | RESTNotif (fail)| |
5143// |<----------------| |
5144// | | SubDelReq |
5145// | |------------->|
5146// | | |
5147// | | SubDelResp |
5148// | |<-------------|
5149//
5150//-----------------------------------------------------------------------------
5151func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
5152 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5153 subReqCount := 1
5154 parameterSet := 1 // E2SM-gNB-X2
5155 actionDefinitionPresent := true
5156 actionParamCount := 1
5157
5158 // Req
5159 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5160 restSubId := xappConn1.SendRESTSubsReq(t, params)
5161
5162 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5163
5164 // Unknown instanceId in this response which will result resending original request
5165 orgInstanceId := crereq.RequestId.InstanceId
5166 crereq.RequestId.InstanceId = 0
5167 e2termConn1.SendSubsResp(t, crereq, cremsg)
5168
5169 _, cremsg = e2termConn1.RecvSubsReq(t)
5170
5171 xappConn1.ExpectRESTNotification(t, restSubId)
5172
5173 // Subscription already created in E2 Node.
5174 fparams := &teststube2ap.E2StubSubsFailParams{}
5175 fparams.Set(crereq)
5176 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5177 e2termConn1.SendSubsFail(t, fparams, cremsg)
5178
5179 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5180 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5181
5182 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5183 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5184
5185 // Wait that subs is cleaned
5186 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
5187
5188 xappConn1.TestMsgChanEmpty(t)
5189 e2termConn1.TestMsgChanEmpty(t)
5190 mainCtrl.wait_registry_empty(t, 10)
5191}
5192
5193//-----------------------------------------------------------------------------
5194// TestRESTUnpackSubscriptionResponseNoTransaction
5195//
5196// stub stub
5197// +-------+ +---------+ +---------+
5198// | xapp | | submgr | | e2term |
5199// +-------+ +---------+ +---------+
5200// | | |
5201// | RestSubReq | |
5202// |---------------->| |
5203// | | |
5204// | RESTSubResp | |
5205// |<----------------| |
5206// | | |
5207// | | SubReq |
5208// | |------------->|
5209// | | |
5210// | | SubResp | No transaction for the response
5211// | |<-------------|
5212// | | |
5213// | | SubReq |
5214// | |------------->|
5215// | | |
5216// | | SubFail | Duplicated action
5217// | |<-------------|
5218// | RESTNotif (fail)| |
5219// |<----------------| |
5220// | | SubDelReq |
5221// | |------------->|
5222// | | |
5223// | | SubDelResp |
5224// | |<-------------|
5225// | | |
5226// | | SubDelReq |
5227// | |------------->|
5228// | | |
5229// | | SubDelResp |
5230// | |<-------------|
5231//
5232//-----------------------------------------------------------------------------
5233func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
5234 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5235 subReqCount := 1
5236 parameterSet := 1 // E2SM-gNB-X2
5237 actionDefinitionPresent := true
5238 actionParamCount := 1
5239
5240 // Req
5241 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5242 restSubId := xappConn1.SendRESTSubsReq(t, params)
5243
5244 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5245
5246 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5247 // No transaction exist for this response which will result resending original request
5248 e2termConn1.SendSubsResp(t, crereq, cremsg)
5249
5250 _, cremsg = e2termConn1.RecvSubsReq(t)
5251
5252 xappConn1.ExpectRESTNotification(t, restSubId)
5253
5254 // Subscription already created in E2 Node.
5255 fparams := &teststube2ap.E2StubSubsFailParams{}
5256 fparams.Set(crereq)
5257 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5258 e2termConn1.SendSubsFail(t, fparams, cremsg)
5259
5260 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5261 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5262
5263 // Resending happens because there no transaction
5264 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5265 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5266
5267 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5268 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5269
5270 // Wait that subs is cleaned
5271 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5272
5273 xappConn1.TestMsgChanEmpty(t)
5274 e2termConn1.TestMsgChanEmpty(t)
5275 mainCtrl.wait_registry_empty(t, 10)
5276
5277}
5278
5279//-----------------------------------------------------------------------------
5280// TestRESTUnpackSubscriptionFailureDecodeFail
5281//
5282// stub stub
5283// +-------+ +---------+ +---------+
5284// | xapp | | submgr | | e2term |
5285// +-------+ +---------+ +---------+
5286// | | |
5287// | RestSubReq | |
5288// |---------------->| |
5289// | | |
5290// | RESTSubResp | |
5291// |<----------------| |
5292// | | |
5293// | | SubReq |
5294// | |------------->|
5295// | | |
5296// | | SubFail | ASN.1 decode fails
5297// | |<-------------|
5298// | | |
5299// | | SubReq |
5300// | |------------->|
5301// | | |
5302// | | SubFail | Duplicated action
5303// | |<-------------|
5304// | RESTNotif (fail)| |
5305// |<----------------| |
5306// | | SubDelReq |
5307// | |------------->|
5308// | | |
5309// | | SubDelResp |
5310// | |<-------------|
5311//
5312//-----------------------------------------------------------------------------
5313func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
5314 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5315 subReqCount := 1
5316 parameterSet := 1 // E2SM-gNB-X2
5317 actionDefinitionPresent := true
5318 actionParamCount := 1
5319
5320 // Req
5321 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5322 restSubId := xappConn1.SendRESTSubsReq(t, params)
5323
5324 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5325
5326 // Decode of this response fails which will result resending original request
5327 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5328
5329 _, cremsg = e2termConn1.RecvSubsReq(t)
5330
5331 xappConn1.ExpectRESTNotification(t, restSubId)
5332
5333 // Subscription already created in E2 Node.
5334 fparams := &teststube2ap.E2StubSubsFailParams{}
5335 fparams.Set(crereq)
5336 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5337 e2termConn1.SendSubsFail(t, fparams, cremsg)
5338
5339 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5340 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5341
5342 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5343 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5344
5345 // Wait that subs is cleaned
5346 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5347
5348 xappConn1.TestMsgChanEmpty(t)
5349 e2termConn1.TestMsgChanEmpty(t)
5350 mainCtrl.wait_registry_empty(t, 10)
5351}
5352
5353//-----------------------------------------------------------------------------
5354// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5355//
5356// stub stub
5357// +-------+ +---------+ +---------+
5358// | xapp | | submgr | | e2term |
5359// +-------+ +---------+ +---------+
5360// | | |
5361// | RestSubReq | |
5362// |---------------->| |
5363// | | |
5364// | RESTSubResp | |
5365// |<----------------| |
5366// | | |
5367// | | SubReq |
5368// | |------------->|
5369// | | |
5370// | | SubFail | Unknown instanceId
5371// | |<-------------|
5372// | | |
5373// | | SubReq |
5374// | |------------->|
5375// | | |
5376// | | SubFail | Duplicated action
5377// | |<-------------|
5378// | RESTNotif (fail)| |
5379// |<----------------| |
5380// | | SubDelReq |
5381// | |------------->|
5382// | | |
5383// | | SubDelResp |
5384// | |<-------------|
5385//
5386//-----------------------------------------------------------------------------
5387func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
5388 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
5389 subReqCount := 1
5390 parameterSet := 1 // E2SM-gNB-X2
5391 actionDefinitionPresent := true
5392 actionParamCount := 1
5393
5394 // Req
5395 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5396 restSubId := xappConn1.SendRESTSubsReq(t, params)
5397
5398 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5399
5400 // Unknown instanceId in this response which will result resending original request
5401 fparams := &teststube2ap.E2StubSubsFailParams{}
5402 fparams.Set(crereq)
5403 fparams.Fail.RequestId.InstanceId = 0
5404 e2termConn1.SendSubsFail(t, fparams, cremsg)
5405
5406 _, cremsg = e2termConn1.RecvSubsReq(t)
5407
5408 xappConn1.ExpectRESTNotification(t, restSubId)
5409
5410 // Subscription already created in E2 Node.
5411 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5412 e2termConn1.SendSubsFail(t, fparams, cremsg)
5413
5414 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5415 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5416
5417 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5418 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5419
5420 // Wait that subs is cleaned
5421 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5422
5423 xappConn1.TestMsgChanEmpty(t)
5424 e2termConn1.TestMsgChanEmpty(t)
5425 mainCtrl.wait_registry_empty(t, 10)
5426}
5427
5428//-----------------------------------------------------------------------------
5429// TestRESTUnpackSubscriptionFailureNoTransaction
5430//
5431// stub stub
5432// +-------+ +---------+ +---------+
5433// | xapp | | submgr | | e2term |
5434// +-------+ +---------+ +---------+
5435// | | |
5436// | RestSubReq | |
5437// |---------------->| |
5438// | | |
5439// | RESTSubResp | |
5440// |<----------------| |
5441// | | |
5442// | | SubReq |
5443// | |------------->|
5444// | | |
5445// | | SubFail | No transaction for the response
5446// | |<-------------|
5447// | | |
5448// | | SubReq |
5449// | |------------->|
5450// | | |
5451// | | SubFail | Duplicated action
5452// | |<-------------|
5453// | RESTNotif (fail)| |
5454// |<----------------| |
5455// | | SubDelReq |
5456// | |------------->|
5457// | | |
5458// | | SubDelResp |
5459// | |<-------------|
5460//
5461//-----------------------------------------------------------------------------
5462func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
5463 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
5464 subReqCount := 1
5465 parameterSet := 1 // E2SM-gNB-X2
5466 actionDefinitionPresent := true
5467 actionParamCount := 1
5468
5469 // Req
5470 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5471 restSubId := xappConn1.SendRESTSubsReq(t, params)
5472
5473 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5474
5475 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5476
5477 // No transaction exist for this response which will result resending original request
5478 fparams := &teststube2ap.E2StubSubsFailParams{}
5479 fparams.Set(crereq)
5480 e2termConn1.SendSubsFail(t, fparams, cremsg)
5481
5482 _, cremsg = e2termConn1.RecvSubsReq(t)
5483
5484 xappConn1.ExpectRESTNotification(t, restSubId)
5485
5486 // Subscription already created in E2 Node.
5487 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5488 e2termConn1.SendSubsFail(t, fparams, cremsg)
5489
5490 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5491 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5492
5493 // Resending happens because there no transaction
5494 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5495 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5496
5497 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5498 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5499
5500 // Wait that subs is cleaned
5501 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5502
5503 xappConn1.TestMsgChanEmpty(t)
5504 e2termConn1.TestMsgChanEmpty(t)
5505 mainCtrl.wait_registry_empty(t, 10)
5506}
5507
5508//-----------------------------------------------------------------------------
5509// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
5510//
5511// stub stub
5512// +-------+ +---------+ +---------+
5513// | xapp | | submgr | | e2term |
5514// +-------+ +---------+ +---------+
5515// | | |
5516// | [SUBS CREATE] |
5517// | | |
5518// | | |
5519// | RESTSubDelReq | |
5520// |---------------->| |
5521// | | |
5522// | RESTSubDelResp | |
5523// |<----------------| |
5524// | | |
5525// | | SubDelReq |
5526// | |------------->|
5527// | | |
5528// | | SubDelResp | ASN.1 decode fails
5529// | |<-------------|
5530// | | |
5531// | | SubDelReq |
5532// | |------------->|
5533// | | |
5534// | | SubDelFail | Subscription does exist any more
5535// | |<-------------|
5536// | | |
5537//
5538//-----------------------------------------------------------------------------
5539func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
5540 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
5541
5542 // Req
5543 var params *teststube2ap.RESTSubsReqParams = nil
5544 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5545
5546 // Del
5547 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5548
5549 // E2t: Receive 1st SubsDelReq
5550 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5551
5552 // Decode of this response fails which will result resending original request
5553 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
5554
5555 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5556 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5557
5558 // Subscription does not exist in in E2 Node.
5559 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5560
5561 // Wait that subs is cleaned
5562 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5563
5564 xappConn1.TestMsgChanEmpty(t)
5565 e2termConn1.TestMsgChanEmpty(t)
5566 mainCtrl.wait_registry_empty(t, 10)
5567}
5568
5569//-----------------------------------------------------------------------------
5570// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
5571//
5572// stub stub
5573// +-------+ +---------+ +---------+
5574// | xapp | | submgr | | e2term |
5575// +-------+ +---------+ +---------+
5576// | | |
5577// | [SUBS CREATE] |
5578// | | |
5579// | | |
5580// | RESTSubDelReq | |
5581// |---------------->| |
5582// | | |
5583// | RESTSubDelResp | |
5584// |<----------------| |
5585// | | |
5586// | | SubDelReq |
5587// | |------------->|
5588// | | |
5589// | | SubDelResp | Unknown instanceId
5590// | |<-------------|
5591// | | |
5592// | | SubDelReq |
5593// | |------------->|
5594// | | |
5595// | | SubDelFail | Subscription does exist any more
5596// | |<-------------|
5597//
5598//-----------------------------------------------------------------------------
5599func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
5600 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
5601
5602 // Req
5603 var params *teststube2ap.RESTSubsReqParams = nil
5604 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5605
5606 // Del
5607 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5608
5609 // E2t: Receive 1st SubsDelReq
5610 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5611
5612 // Unknown instanceId in this response which will result resending original request
5613 delreq.RequestId.InstanceId = 0
5614 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5615
5616 // E2t: Receive 2nd SubsDelReq
5617 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5618
5619 // Subscription does not exist in in E2 Node.
5620 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5621
5622 // Wait that subs is cleaned
5623 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5624
5625 xappConn1.TestMsgChanEmpty(t)
5626 e2termConn1.TestMsgChanEmpty(t)
5627 mainCtrl.wait_registry_empty(t, 10)
5628}
5629
5630//-----------------------------------------------------------------------------
5631// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
5632//
5633// stub stub
5634// +-------+ +---------+ +---------+
5635// | xapp | | submgr | | e2term |
5636// +-------+ +---------+ +---------+
5637// | | |
5638// | [SUBS CREATE] |
5639// | | |
5640// | | |
5641// | RESTSubDelReq | |
5642// |---------------->| |
5643// | | |
5644// | RESTSubDelResp | |
5645// |<----------------| |
5646// | | |
5647// | | SubDelReq |
5648// | |------------->|
5649// | | |
5650// | | SubDelResp | No transaction for the response
5651// | |<-------------|
5652// | | |
5653// | | SubDelReq |
5654// | |------------->|
5655// | | |
5656// | | SubDelFail | Subscription does exist any more
5657// | |<-------------|
5658//
5659//-----------------------------------------------------------------------------
5660func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
5661 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
5662
5663 // Req
5664 var params *teststube2ap.RESTSubsReqParams = nil
5665 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5666
5667 // Del
5668 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5669
5670 // E2t: Receive 1st SubsDelReq
5671 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5672
5673 mainCtrl.MakeTransactionNil(t, e2SubsId)
5674
5675 // No transaction exist for this response which will result resending original request
5676 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5677
5678 // E2t: Receive 2nd SubsDelReq
5679 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5680
5681 // Subscription does not exist in in E2 Node.
5682 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5683
5684 // Wait that subs is cleaned
5685 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5686
5687 xappConn1.TestMsgChanEmpty(t)
5688 e2termConn1.TestMsgChanEmpty(t)
5689 mainCtrl.wait_registry_empty(t, 10)
5690}
5691
5692//-----------------------------------------------------------------------------
5693// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
5694//
5695// stub stub
5696// +-------+ +---------+ +---------+
5697// | xapp | | submgr | | e2term |
5698// +-------+ +---------+ +---------+
5699// | | |
5700// | [SUBS CREATE] |
5701// | | |
5702// | | |
5703// | RESTSubDelReq | |
5704// |---------------->| |
5705// | | |
5706// | RESTSubDelResp | |
5707// |<----------------| |
5708// | | |
5709// | | SubDelReq |
5710// | |------------->|
5711// | | |
5712// | | SubDelFail | ASN.1 decode fails
5713// | |<-------------|
5714// | | |
5715// | | SubDelReq |
5716// | |------------->|
5717// | | |
5718// | | SubDelFail | Subscription does exist any more
5719// | |<-------------|
5720//
5721//-----------------------------------------------------------------------------
5722func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
5723 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
5724
5725 // Req
5726 var params *teststube2ap.RESTSubsReqParams = nil
5727 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5728
5729 // Del
5730 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5731
5732 // E2t: Receive 1st SubsDelReq
5733 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5734
5735 // Decode of this response fails which will result resending original request
5736 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
5737
5738 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5739 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5740
5741 // Subscription does not exist in in E2 Node.
5742 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5743
5744 // Wait that subs is cleaned
5745 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5746
5747 xappConn1.TestMsgChanEmpty(t)
5748 e2termConn1.TestMsgChanEmpty(t)
5749 mainCtrl.wait_registry_empty(t, 10)
5750}
5751
5752//-----------------------------------------------------------------------------
5753// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
5754//
5755// stub stub
5756// +-------+ +---------+ +---------+
5757// | xapp | | submgr | | e2term |
5758// +-------+ +---------+ +---------+
5759// | | |
5760// | [SUBS CREATE] |
5761// | | |
5762// | | |
5763// | RESTSubDelReq | |
5764// |---------------->| |
5765// | | |
5766// | RESTSubDelResp | |
5767// |<----------------| |
5768// | | |
5769// | | SubDelReq |
5770// | |------------->|
5771// | | |
5772// | | SubDelFail | Unknown instanceId
5773// | |<-------------|
5774// | | |
5775// | | SubDelReq |
5776// | |------------->|
5777// | | |
5778// | | SubDelFail | Subscription does exist any more
5779// | |<-------------|
5780//
5781//-----------------------------------------------------------------------------
5782func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
5783 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
5784
5785 // Req
5786 var params *teststube2ap.RESTSubsReqParams = nil
5787 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5788
5789 // Del
5790 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5791
5792 // E2t: Receive 1st SubsDelReq
5793 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5794
5795 // Unknown instanceId in this response which will result resending original request
5796 delreq.RequestId.InstanceId = 0
5797 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5798
5799 // E2t: Receive 2nd SubsDelReq
5800 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5801
5802 // Subscription does not exist in in E2 Node.
5803 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5804
5805 // Wait that subs is cleaned
5806 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5807
5808 xappConn1.TestMsgChanEmpty(t)
5809 e2termConn1.TestMsgChanEmpty(t)
5810 mainCtrl.wait_registry_empty(t, 10)
5811}
5812
5813//-----------------------------------------------------------------------------
5814// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
5815//
5816// stub stub
5817// +-------+ +---------+ +---------+
5818// | xapp | | submgr | | e2term |
5819// +-------+ +---------+ +---------+
5820// | | |
5821// | [SUBS CREATE] |
5822// | | |
5823// | | |
5824// | RESTSubDelReq | |
5825// |---------------->| |
5826// | | |
5827// | RESTSubDelResp | |
5828// |<----------------| |
5829// | | |
5830// | | SubDelReq |
5831// | |------------->|
5832// | | |
5833// | | SubDelFail | No transaction for the response
5834// | |<-------------|
5835// | | |
5836// | | SubDelReq |
5837// | |------------->|
5838// | | |
5839// | | SubDelFail | Subscription does exist any more
5840// | |<-------------|
5841//
5842//-----------------------------------------------------------------------------
5843func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
5844 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
5845
5846 // Req
5847 var params *teststube2ap.RESTSubsReqParams = nil
5848 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5849
5850 // Del
5851 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5852
5853 // E2t: Receive 1st SubsDelReq
5854 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5855
5856 mainCtrl.MakeTransactionNil(t, e2SubsId)
5857
5858 // No transaction exist for this response which will result resending original request
5859 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5860
5861 // E2t: Receive 2nd SubsDelReq
5862 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5863
5864 // Subscription does not exist in in E2 Node.
5865 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5866
5867 // Wait that subs is cleaned
5868 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5869
5870 xappConn1.TestMsgChanEmpty(t)
5871 e2termConn1.TestMsgChanEmpty(t)
5872 mainCtrl.wait_registry_empty(t, 10)
5873}
5874
archaggeafbf95f2021-04-14 08:54:05 +03005875////////////////////////////////////////////////////////////////////////////////////
5876// Services for UT cases
5877////////////////////////////////////////////////////////////////////////////////////
5878const subReqCount int = 1
5879const parameterSet = 1
5880const actionDefinitionPresent bool = true
5881const actionParamCount int = 1
5882const policyParamCount int = 1
5883const host string = "localhost"
5884
5885func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
5886 if params == nil {
5887 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5888 }
5889 restSubId := fromXappConn.SendRESTSubsReq(t, params)
5890 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5891
5892 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
5893 fromXappConn.ExpectRESTNotification(t, restSubId)
5894 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
5895 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
5896 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5897
5898 return restSubId, e2SubsId
5899}
5900
5901func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
5902
5903 params := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5904 if meid != "" {
5905 params.SetMeid(meid)
5906 }
5907 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
5908 restSubId := xappConn2.SendRESTSubsReq(t, params)
5909 xappConn2.ExpectRESTNotification(t, restSubId)
5910 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5911 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
5912 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5913
5914 return restSubId, e2SubsId
5915}
5916
5917func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
5918 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
5919 restSubId := xappConn1.SendRESTSubsReq(t, params)
5920 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
5921
5922 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5923 xappConn1.ExpectRESTNotification(t, restSubId)
5924 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5925 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5926 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5927
5928 return restSubId, e2SubsId
5929}
5930
5931func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
5932 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5933 restSubId := xappConn1.SendRESTSubsReq(t, params)
5934
5935 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5936 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5937 fparams1.Set(crereq1)
5938 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5939
5940 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5941 xappConn1.ExpectRESTNotification(t, restSubId)
5942 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5943 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5944 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
5945
5946 return restSubId, e2SubsId
5947}
5948
5949func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
5950 fromXappConn.SendRESTSubsDelReq(t, restSubId)
5951 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
5952 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
5953}
5954
5955func deleteXapp1Subscription(t *testing.T, restSubId *string) {
5956 xappConn1.SendRESTSubsDelReq(t, restSubId)
5957 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5958 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5959}
5960
5961func deleteXapp2Subscription(t *testing.T, restSubId *string) {
5962 xappConn2.SendRESTSubsDelReq(t, restSubId)
5963 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5964 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5965}
5966
5967func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
5968 resp, _ := xapp.Subscription.QuerySubscriptions()
5969 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
5970 assert.Equal(t, resp[0].Meid, meid)
5971 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
5972}
5973
5974func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
5975 //Wait that subs is cleaned
5976 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
5977
5978 xappConn1.TestMsgChanEmpty(t)
5979 xappConn2.TestMsgChanEmpty(t)
5980 e2termConn1.TestMsgChanEmpty(t)
5981 mainCtrl.wait_registry_empty(t, timeout)
5982}
5983
5984func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
5985
5986 var e2SubsId []uint32
5987
5988 for i := 0; i < count; i++ {
5989 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
5990 crereq, cremsg := toE2termConn.RecvSubsReq(t)
5991 fromXappConn.ExpectRESTNotification(t, restSubId)
5992 toE2termConn.SendSubsResp(t, crereq, cremsg)
5993 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
5994 e2SubsId = append(e2SubsId, instanceId)
5995 xapp.Logger.Info("TEST: %v", e2SubsId)
5996 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
5997 <-time.After(100 * time.Millisecond)
5998 }
5999 return e2SubsId
6000}
6001
6002func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
6003
6004 for i := 0; i < len(e2SubsIds); i++ {
6005 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
6006 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
6007 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
6008 <-time.After(1 * time.Second)
6009 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
6010 <-time.After(100 * time.Millisecond)
6011 }
6012
6013 // Wait that subs is cleaned
6014 for i := 0; i < len(e2SubsIds); i++ {
6015 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
6016 }
6017
6018}