blob: 5cc74581bee1d4d33fd5358accb2882f3fa16369 [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 Mannilac7da4ee2021-10-22 09:52:02 +030023 //"os"
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +000024 "strings"
Anssi Mannila4abf1802021-01-28 13:06:46 +020025 "testing"
26 "time"
27
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020028 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000029 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030030 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020031 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020032 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
33 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020034)
35
Markku Virtanenac8bde42021-05-25 09:54:42 +000036func TestSuiteSetup(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030037 // The effect of this call shall endure though the UT suite!
38 // If this causes any issues, the previous interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000039 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000040 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
41
42 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Anssi Mannila3cdd2e02021-10-14 12:35:41 +030043 mainCtrl.c.restDuplicateCtrl.Init()
Markku Virtanenb642a192021-06-09 09:08:14 +000044
Markku Virtanenac8bde42021-05-25 09:54:42 +000045}
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030046func TestRanStatusChangeViaSDLNotification(t *testing.T) {
47
48 // Current UT test cases use these ran names
49 xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
50 xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
51 xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
52
53 mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
54 mainCtrl.c.e2IfState.SubscribeChannels()
55
56 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
57 mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
58 mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
59}
60
61//-----------------------------------------------------------------------------
62// TestRESTSubReqAfterE2ConnBreak
63//
64// stub stub
65// +-------+ +---------+ +---------+
66// | xapp | | submgr | | e2term |
67// +-------+ +---------+ +---------+
68// | | |
69// | [E2 Conn. DOWN] |
70// | | |
71// | RESTSubReq | |
72// |---------------->| |
73// | RESTSubFail | |
74// |<----------------| |
75// | | |
76//
77//-----------------------------------------------------------------------------
78
79func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
80 CaseBegin("TestRESTSubReqAfterE2ConnBreak")
81
82 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
83 Counter{cRestSubReqFromXapp, 1},
84 Counter{cRestReqRejDueE2Down, 1},
85 })
86
87 // E2 disconnect after E2term has received response
88 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
89 // Req
90 const subReqCount int = 1
91 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
92 xappConn1.SendRESTSubsReq(t, params)
93
94 // Restore E2 connection for following test cases
95 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
96
97 mainCtrl.VerifyCounterValues(t)
98}
99
100//-----------------------------------------------------------------------------
101// TestRESTSubReqE2ConnBreak
102//
103// stub stub
104// +-------+ +---------+ +---------+
105// | xapp | | submgr | | e2term |
106// +-------+ +---------+ +---------+
107// | | |
108// | RESTSubReq | |
109// |---------------->| |
110// | RESTSubResp | |
111// |<----------------| |
112// | | SubReq |
113// | |------------->|
114// | | SubResp |
115// | |<-------------|
116// | | |
117// | [E2 Conn. DOWN] |
118// | [Int. SUBS DELETE] |
119// | | |
120// | RESTNotif(unsuccessful) |
121// |<----------------| |
122// | | |
123// | | |
124//
125//-----------------------------------------------------------------------------
126func TestRESTSubReqE2ConnBreak(t *testing.T) {
127 CaseBegin("TestRESTSubReqE2ConnBreak")
128
129 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
130 Counter{cRestSubReqFromXapp, 1},
131 Counter{cRestSubRespToXapp, 1},
132 Counter{cSubReqToE2, 1},
133 Counter{cSubRespFromE2, 1},
134 Counter{cRestSubFailNotifToXapp, 1},
135 })
136
137 // Req
138 const subReqCount int = 1
139 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
140 restSubId := xappConn1.SendRESTSubsReq(t, params)
141
142 crereq, cremsg := e2termConn1.RecvSubsReq(t)
143 xappConn1.ExpectRESTNotification(t, restSubId)
144
145 // E2 disconnect after E2term has received response
146 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
147
148 e2termConn1.SendSubsResp(t, crereq, cremsg)
149 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
150
151 <-time.After(time.Second * 1)
152 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
153 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
154
155 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
156 if err != nil {
157 xapp.Logger.Error("%v", err)
158 } else {
159 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
160 assert.Equal(t, 0, len(register))
161 }
162
163 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
164 if err != nil {
165 xapp.Logger.Error("%v", err)
166 } else {
167 assert.Equal(t, 0, len(restSubscriptions))
168 }
169
170 // Restore E2 connection for following test cases
171 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
172
173 // Wait that subs is cleaned
174 waitSubsCleanup(t, e2SubsId, 10)
175 mainCtrl.VerifyCounterValues(t)
176}
177
178//-----------------------------------------------------------------------------
179// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
180//
181// stub stub
182// +-------+ +---------+ +---------+
183// | xapp | | submgr | | e2term |
184// +-------+ +---------+ +---------+
185// | | |
186// | [SUBS CREATE] |
187// | | |
188// | [E2 Conn. DOWN] |
189// | | |
190// | RESTSubDelReq | |
191// |---------------->| |
192// | | |
193// | RESTSubDelResp | |
194// |<----------------| |
195// | | |
196// | [No valid subscription found] |
197// | | |
198//
199//-----------------------------------------------------------------------------
200func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
201 xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak")
202
203 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
204 Counter{cRestSubReqFromXapp, 1},
205 Counter{cRestSubRespToXapp, 1},
206 Counter{cSubReqToE2, 1},
207 Counter{cSubRespFromE2, 1},
208 Counter{cRestSubNotifToXapp, 1},
209 Counter{cRestSubDelReqFromXapp, 1},
210 Counter{cRestSubDelRespToXapp, 1},
211 })
212
213 // Req
214 var params *teststube2ap.RESTSubsReqParams = nil
215 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
216
217 // E2 disconnect after E2term has received response
218 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
219
220 // Del
221 xappConn1.SendRESTSubsDelReq(t, &restSubId)
222
223 <-time.After(time.Second * 1)
224 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
225 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
226
227 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
228 if err != nil {
229 xapp.Logger.Error("%v", err)
230 } else {
231 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
232 assert.Equal(t, 0, len(register))
233 }
234
235 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
236 if err != nil {
237 xapp.Logger.Error("%v", err)
238 } else {
239 assert.Equal(t, 0, len(restSubscriptions))
240 }
241
242 // Restore E2 connection for following test cases
243 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
244
245 // Wait that subs is cleaned
246 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
247
248 xappConn1.TestMsgChanEmpty(t)
249 e2termConn1.TestMsgChanEmpty(t)
250 mainCtrl.wait_registry_empty(t, 10)
251 mainCtrl.VerifyCounterValues(t)
252}
253
254//-----------------------------------------------------------------------------
255// TestRESTOtherE2ConnectionChanges
256//
257
258// stub stub
259// +-------+ +---------+ +---------+
260// | xapp | | submgr | | e2term |
261// +-------+ +---------+ +---------+
262// | | |
263// | [SUBS CREATE] |
264// | | |
265// | [E2 CONNECTED_SETUP_FAILED] |
266// | [E2 CONNECTING] |
267// | [E2 SHUTTING_DOWN] |
268// | [E2 SHUT_DOWN] |
269// | | |
270// | [SUBS DELETE] |
271// | | |
272//
273//-----------------------------------------------------------------------------
274func TestRESTOtherE2ConnectionChanges(t *testing.T) {
275 xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges")
276
277 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
278 Counter{cRestSubReqFromXapp, 1},
279 Counter{cRestSubRespToXapp, 1},
280 Counter{cSubReqToE2, 1},
281 Counter{cSubRespFromE2, 1},
282 Counter{cRestSubNotifToXapp, 1},
283 Counter{cRestSubDelReqFromXapp, 1},
284 Counter{cSubDelReqToE2, 1},
285 Counter{cSubDelRespFromE2, 1},
286 Counter{cRestSubDelRespToXapp, 1},
287 })
288
289 // Req
290 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
291 restSubId := xappConn1.SendRESTSubsReq(t, params)
292
293 crereq, cremsg := e2termConn1.RecvSubsReq(t)
294 xappConn1.ExpectRESTNotification(t, restSubId)
295 e2termConn1.SendSubsResp(t, crereq, cremsg)
296 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
297
298 // Submgr should not react any other connection state changes than CONNECTED and DISCONNECTED
299 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
300 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
301 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
302 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
303
304 // Del
305 xappConn1.SendRESTSubsDelReq(t, &restSubId)
306 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
307 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
308
309 // Restore E2 connection for following test cases
310 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
311
312 // Wait that subs is cleaned
313 waitSubsCleanup(t, e2SubsId, 10)
314 mainCtrl.VerifyCounterValues(t)
315}
Markku Virtanenac8bde42021-05-25 09:54:42 +0000316
317//-----------------------------------------------------------------------------
318// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
319//
320// stub stub stub
321// +-------+ +---------+ +---------+ +---------+
322// | xapp | | submgr | | e2term | | rtmgr |
323// +-------+ +---------+ +---------+ +---------+
324// | | | |
325// | RESTSubReq | | |
326// |---------------->| | |
327// | | RouteCreate | |
328// | |--------------------------->| // The order of these events may vary
329// | | | |
330// | RESTSubResp | | | // The order of these events may vary
331// |<----------------| | |
332// | | RouteResponse| |
333// | |<---------------------------| // The order of these events may vary
334// | | | |
335// | | SubReq | |
336// | |------------->| | // The order of these events may vary
337// | | | |
338// | | SubResp | |
339// | |<-------------| |
340// | RESTNotif1 | | |
341// |<----------------| | |
342// | | | |
343// | RESTSubDelReq | | |
344// |---------------->| | |
345// | | SubDelReq | |
346// | |------------->| |
347// | | | |
348// | RESTSubDelResp| | |
349// |<----------------| | |
350// | | | |
351// | | SubDelResp | |
352// | |<-------------| |
353// | | | |
354// | | | |
355//
356//-----------------------------------------------------------------------------
357func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000358
359 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
360
361 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
362
363 waitSubsCleanup(t, e2SubsId, 10)
364}
365
Juha Hyttinenfa015662020-01-24 10:05:18 +0200366//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +0000367// TestRESTSubReqAndE1apDeleteReqPackingError
368//
369// stub stub stub
370// +-------+ +---------+ +---------+ +---------+
371// | xapp | | submgr | | e2term | | rtmgr |
372// +-------+ +---------+ +---------+ +---------+
373// | | | |
374// | RESTSubReq | | |
375// |---------------->| | |
376// | | RouteCreate | |
377// | |--------------------------->| // The order of these events may vary
378// | | | |
379// | RESTSubResp | | | // The order of these events may vary
380// |<----------------| | |
381// | | RouteResponse| |
382// | |<---------------------------| // The order of these events may vary
383// | | | |
384// | | SubReq | |
385// | |------------->| | // The order of these events may vary
386// | | | |
387// | | SubResp | |
388// | |<-------------| |
389// | RESTNotif1 | | |
390// |<----------------| | |
391// | | | |
392// | RESTSubDelReq | | |
393// |---------------->| | |
394// | | | |
395// | RESTSubDelResp| | |
396// |<----------------| | |
397// | | | |
398// | | | |
399//
400//-----------------------------------------------------------------------------
401func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
402
403 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
404
405 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
406 xappConn1.SendRESTSubsDelReq(t, &restSubId)
407 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
408
409 waitSubsCleanup(t, e2SubsId, 10)
410}
411
412//-----------------------------------------------------------------------------
413// TestRESTSubReqAndE1apDeleteRespUnpackingError
414//
415// stub stub stub
416// +-------+ +---------+ +---------+ +---------+
417// | xapp | | submgr | | e2term | | rtmgr |
418// +-------+ +---------+ +---------+ +---------+
419// | | | |
420// | RESTSubReq | | |
421// |---------------->| | |
422// | | RouteCreate | |
423// | |--------------------------->| // The order of these events may vary
424// | | | |
425// | RESTSubResp | | | // The order of these events may vary
426// |<----------------| | |
427// | | RouteResponse| |
428// | |<---------------------------| // The order of these events may vary
429// | | | |
430// | | SubReq | |
431// | |------------->| | // The order of these events may vary
432// | | | |
433// | | SubResp | |
434// | |<-------------| |
435// | RESTNotif1 | | |
436// |<----------------| | |
437// | | | |
438// | RESTSubDelReq | | |
439// |---------------->| | |
440// | | SubDelReq | |
441// | |------------->| |
442// | | | |
443// | RESTSubDelResp| | |
444// |<----------------| | | // The order of these events may vary
445// | | | |
446// | | SubDelResp | |
447// | |<-------------| | // 1.st NOK
448// | | | |
449// | | SubDelReq | |
450// | |------------->| |
451// | | | |
452// | | SubDelResp | |
453// | |<-------------| | // 2.nd NOK
454//
455//-----------------------------------------------------------------------------
456
457func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
458
459 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
460
461 xappConn1.SendRESTSubsDelReq(t, &restSubId)
462 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
463 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
464 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
465
466 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
467 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
468
469 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
470
471 waitSubsCleanup(t, e2SubsId, 10)
472}
473
474//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200475// TestSubReqAndRouteNok
476//
477// stub stub
478// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200479// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200480// +-------+ +---------+ +---------+
481// | | |
482// | SubReq | |
483// |------------->| |
484// | | |
485// | | RouteCreate |
486// | |------------->|
487// | | |
488// | | RouteCreate |
489// | | status:400 |
490// | |<-------------|
491// | | |
492// | [SUBS INT DELETE] |
493// | | |
494//
495//-----------------------------------------------------------------------------
496
497func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200498 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200499
Anssi Mannila4abf1802021-01-28 13:06:46 +0200500 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200501 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
502 Counter{cSubReqFromXapp, 1},
503 Counter{cRouteCreateFail, 1},
504 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200505
Juha Hyttinenfa015662020-01-24 10:05:18 +0200506 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300507 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200508 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200509 waiter.WaitResult(t)
510
511 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200512 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200513
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200514 xappConn1.TestMsgChanEmpty(t)
515 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200516 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200517 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200518
519 <-time.After(1 * time.Second)
520 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200521}
522
523//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200524// TestSubReqAndRouteUpdateNok
525
526// stub stub
527// +-------+ +-------+ +---------+ +---------+
528// | xapp2 | | xapp1 | | submgr | | rtmgr |
529// +-------+ +-------+ +---------+ +---------+
530// | | | |
531// | [SUBS CREATE] | |
532// | | | |
533// | | | |
534// | | | |
535// | SubReq (mergeable) | |
536// |--------------------------->| | |
537// | | | |
538// | | | RouteUpdate |
539// | | |------------->|
540// | | | |
541// | | | RouteUpdate |
542// | | | status:400 |
543// | | |<-------------|
544// | | | |
545// | [SUBS INT DELETE] | |
546// | | | |
547// | | | |
548// | [SUBS DELETE] | |
549// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300550
Anssi Mannila4abf1802021-01-28 13:06:46 +0200551func TestSubReqAndRouteUpdateNok(t *testing.T) {
552 CaseBegin("TestSubReqAndRouteUpdateNok")
553
554 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200555 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
556 Counter{cSubReqFromXapp, 2},
557 Counter{cSubReqToE2, 1},
558 Counter{cSubRespFromE2, 1},
559 Counter{cSubRespToXapp, 1},
560 Counter{cRouteCreateUpdateFail, 1},
561 Counter{cSubDelReqFromXapp, 1},
562 Counter{cSubDelReqToE2, 1},
563 Counter{cSubDelRespFromE2, 1},
564 Counter{cSubDelRespToXapp, 1},
565 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200566
567 cretrans := xappConn1.SendSubsReq(t, nil, nil)
568 crereq, cremsg := e2termConn1.RecvSubsReq(t)
569 e2termConn1.SendSubsResp(t, crereq, cremsg)
570 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
571
572 resp, _ := xapp.Subscription.QuerySubscriptions()
573 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
574 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300575 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200576
577 waiter := rtmgrHttp.AllocNextEvent(false)
578 newSubsId := mainCtrl.get_registry_next_subid(t)
579 xappConn2.SendSubsReq(t, nil, nil)
580 waiter.WaitResult(t)
581
582 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
583 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
584
585 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
586 xappConn1.RecvSubsDelResp(t, deltrans)
587
588 //Wait that subs is cleaned
589 mainCtrl.wait_subs_clean(t, newSubsId, 10)
590 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
591
592 xappConn1.TestMsgChanEmpty(t)
593 xappConn2.TestMsgChanEmpty(t)
594 e2termConn1.TestMsgChanEmpty(t)
595 mainCtrl.wait_registry_empty(t, 10)
596
597 mainCtrl.VerifyCounterValues(t)
598}
599
600//-----------------------------------------------------------------------------
601// TestSubDelReqAndRouteDeleteNok
602//
603// stub stub
604// +-------+ +---------+ +---------+ +---------+
605// | xapp | | submgr | | e2term | | rtmgr |
606// +-------+ +---------+ +---------+ +---------+
607// | | | |
608// | [SUBS CREATE] | |
609// | | | |
610// | | | |
611// | | | |
612// | SubDelReq | | |
613// |------------->| | |
614// | | SubDelReq | |
615// | |------------->| |
616// | | SubDelRsp | |
617// | |<-------------| |
618// | SubDelRsp | | |
619// |<-------------| | |
620// | | RouteDelete | |
621// | |---------------------------->|
622// | | | |
623// | | RouteDelete | |
624// | | status:400 | |
625// | |<----------------------------|
626// | | | |
627func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
628 CaseBegin("TestSubDelReqAndRouteDeleteNok")
629
630 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200631 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
632 Counter{cSubReqFromXapp, 1},
633 Counter{cSubReqToE2, 1},
634 Counter{cSubRespFromE2, 1},
635 Counter{cSubRespToXapp, 1},
636 Counter{cSubDelReqFromXapp, 1},
637 Counter{cRouteDeleteFail, 1},
638 Counter{cSubDelReqToE2, 1},
639 Counter{cSubDelRespFromE2, 1},
640 Counter{cSubDelRespToXapp, 1},
641 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200642
643 cretrans := xappConn1.SendSubsReq(t, nil, nil)
644 crereq, cremsg := e2termConn1.RecvSubsReq(t)
645 e2termConn1.SendSubsResp(t, crereq, cremsg)
646 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
647
648 resp, _ := xapp.Subscription.QuerySubscriptions()
649 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
650 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300651 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200652
653 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
654 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
655
656 waiter := rtmgrHttp.AllocNextEvent(false)
657 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
658 waiter.WaitResult(t)
659
660 xappConn1.RecvSubsDelResp(t, deltrans)
661
662 //Wait that subs is cleaned
663 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
664
665 xappConn1.TestMsgChanEmpty(t)
666 xappConn2.TestMsgChanEmpty(t)
667 e2termConn1.TestMsgChanEmpty(t)
668 mainCtrl.wait_registry_empty(t, 10)
669
670 mainCtrl.VerifyCounterValues(t)
671}
672
673//-----------------------------------------------------------------------------
674// TestSubMergeDelAndRouteUpdateNok
675// stub stub
676// +-------+ +-------+ +---------+ +---------+
677// | xapp2 | | xapp1 | | submgr | | e2term |
678// +-------+ +-------+ +---------+ +---------+
679// | | | |
680// | | | |
681// | | | |
682// | | SubReq1 | |
683// | |------------->| |
684// | | | |
685// | | | SubReq1 |
686// | | |------------->|
687// | | | SubResp1 |
688// | | |<-------------|
689// | | SubResp1 | |
690// | |<-------------| |
691// | | | |
692// | SubReq2 | |
693// |--------------------------->| |
694// | | | |
695// | SubResp2 | |
696// |<---------------------------| |
697// | | | |
698// | | SubDelReq 1 | |
699// | |------------->| |
700// | | | RouteUpdate |
701// | | |-----> rtmgr |
702// | | | |
703// | | | RouteUpdate |
704// | | | status:400 |
705// | | |<----- rtmgr |
706// | | | |
707// | | SubDelResp 1 | |
708// | |<-------------| |
709// | | | |
710// | SubDelReq 2 | |
711// |--------------------------->| |
712// | | | |
713// | | | SubDelReq 2 |
714// | | |------------->|
715// | | | |
716// | | | SubDelReq 2 |
717// | | |------------->|
718// | | | |
719// | SubDelResp 2 | |
720// |<---------------------------| |
721//
722//-----------------------------------------------------------------------------
723func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
724 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
725
726 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200727 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
728 Counter{cSubReqFromXapp, 2},
729 Counter{cSubReqToE2, 1},
730 Counter{cSubRespFromE2, 1},
731 Counter{cSubRespToXapp, 2},
732 Counter{cSubDelReqFromXapp, 2},
733 Counter{cRouteDeleteUpdateFail, 1},
734 Counter{cSubDelReqToE2, 1},
735 Counter{cSubDelRespFromE2, 1},
736 Counter{cSubDelRespToXapp, 2},
737 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200738
739 //Req1
740 rparams1 := &teststube2ap.E2StubSubsReqParams{}
741 rparams1.Init()
742 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
743 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
744 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
745 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
746
747 //Req2
748 rparams2 := &teststube2ap.E2StubSubsReqParams{}
749 rparams2.Init()
750 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
751 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
752
753 resp, _ := xapp.Subscription.QuerySubscriptions()
754 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
755 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300756 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200757
758 //Del1
759 waiter := rtmgrHttp.AllocNextEvent(false)
760 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
761 waiter.WaitResult(t)
762
763 xappConn1.RecvSubsDelResp(t, deltrans1)
764
765 //Del2
766 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
767 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
768 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
769 xappConn2.RecvSubsDelResp(t, deltrans2)
770 //Wait that subs is cleaned
771 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
772
773 xappConn1.TestMsgChanEmpty(t)
774 xappConn2.TestMsgChanEmpty(t)
775 e2termConn1.TestMsgChanEmpty(t)
776 mainCtrl.wait_registry_empty(t, 10)
777
778 mainCtrl.VerifyCounterValues(t)
779}
780
781//-----------------------------------------------------------------------------
782
783//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200784// TestSubReqAndSubDelOk
785//
786// stub stub
787// +-------+ +---------+ +---------+
788// | xapp | | submgr | | e2term |
789// +-------+ +---------+ +---------+
790// | | |
791// | SubReq | |
792// |------------->| |
793// | | |
794// | | SubReq |
795// | |------------->|
796// | | |
797// | | SubResp |
798// | |<-------------|
799// | | |
800// | SubResp | |
801// |<-------------| |
802// | | |
803// | | |
804// | SubDelReq | |
805// |------------->| |
806// | | |
807// | | SubDelReq |
808// | |------------->|
809// | | |
810// | | SubDelResp |
811// | |<-------------|
812// | | |
813// | SubDelResp | |
814// |<-------------| |
815//
816//-----------------------------------------------------------------------------
817func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200818 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200819
Anssi Mannila4abf1802021-01-28 13:06:46 +0200820 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200821 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
822 Counter{cSubReqFromXapp, 1},
823 Counter{cSubReqToE2, 1},
824 Counter{cSubRespFromE2, 1},
825 Counter{cSubRespToXapp, 1},
826 Counter{cSubDelReqFromXapp, 1},
827 Counter{cSubDelReqToE2, 1},
828 Counter{cSubDelRespFromE2, 1},
829 Counter{cSubDelRespToXapp, 1},
830 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200831
832 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200833 crereq, cremsg := e2termConn1.RecvSubsReq(t)
834 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200835 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200836
837 resp, _ := xapp.Subscription.QuerySubscriptions()
838 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
839 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300840 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200841
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200842 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200843 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200844
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200845 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200846 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200847
848 //Wait that subs is cleaned
849 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
850
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200851 xappConn1.TestMsgChanEmpty(t)
852 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200853 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200854 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200855
856 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200857}
858
859//-----------------------------------------------------------------------------
860// TestSubReqRetransmission
861//
862// stub stub
863// +-------+ +---------+ +---------+
864// | xapp | | submgr | | e2term |
865// +-------+ +---------+ +---------+
866// | | |
867// | SubReq | |
868// |------------->| |
869// | | |
870// | | SubReq |
871// | |------------->|
872// | | |
873// | SubReq | |
874// | (retrans) | |
875// |------------->| |
876// | | |
877// | | SubResp |
878// | |<-------------|
879// | | |
880// | SubResp | |
881// |<-------------| |
882// | | |
883// | [SUBS DELETE] |
884// | | |
885//
886//-----------------------------------------------------------------------------
887func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200888 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200889
890 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200891 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200892 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200893
894 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200895 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200896 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
897
Juha Hyttinen1683f912020-04-17 10:39:57 +0300898 // hack as there is no real way to see has message be handled.
899 // Previuos counter check just tells that is has been received by submgr
900 // --> artificial delay
901 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200902 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200903 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200904
905 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200906 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200907 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
908 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200909 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200910
911 //Wait that subs is cleaned
912 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
913
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200914 xappConn1.TestMsgChanEmpty(t)
915 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200916 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200917 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200918}
919
920//-----------------------------------------------------------------------------
921// TestSubDelReqRetransmission
922//
923// stub stub
924// +-------+ +---------+ +---------+
925// | xapp | | submgr | | e2term |
926// +-------+ +---------+ +---------+
927// | | |
928// | [SUBS CREATE] |
929// | | |
930// | | |
931// | SubDelReq | |
932// |------------->| |
933// | | |
934// | | SubDelReq |
935// | |------------->|
936// | | |
937// | SubDelReq | |
938// | (same sub) | |
939// | (same xid) | |
940// |------------->| |
941// | | |
942// | | SubDelResp |
943// | |<-------------|
944// | | |
945// | SubDelResp | |
946// |<-------------| |
947//
948//-----------------------------------------------------------------------------
949func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200950 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200951
952 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200953 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200954 crereq, cremsg := e2termConn1.RecvSubsReq(t)
955 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200956 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200957
958 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200959 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200960 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200961
962 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200963 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200964 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
965
Juha Hyttinen1683f912020-04-17 10:39:57 +0300966 // hack as there is no real way to see has message be handled.
967 // Previuos counter check just tells that is has been received by submgr
968 // --> artificial delay
969 <-time.After(1 * time.Second)
970
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200971 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200972 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200973
974 //Wait that subs is cleaned
975 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
976
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200977 xappConn1.TestMsgChanEmpty(t)
978 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200979 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200980 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200981}
982
983//-----------------------------------------------------------------------------
984// TestSubDelReqCollision
985//
986// stub stub
987// +-------+ +---------+ +---------+
988// | xapp | | submgr | | e2term |
989// +-------+ +---------+ +---------+
990// | | |
991// | [SUBS CREATE] |
992// | | |
993// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200994// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200995// |------------->| |
996// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200997// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200998// | |------------->|
999// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001000// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001001// | (same sub) | |
1002// | (diff xid) | |
1003// |------------->| |
1004// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001005// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001006// | |<-------------|
1007// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001008// | SubDelResp 1 | |
1009// |<-------------| |
1010// | | |
1011// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001012// |<-------------| |
1013//
1014//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001015
Juha Hyttinenfa015662020-01-24 10:05:18 +02001016func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001017 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001018
1019 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001020 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001021 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1022 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001023 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001024
1025 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001026 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001027 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001028
Juha Hyttinen3944a222020-01-24 11:51:46 +02001029 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001030 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001031 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1032 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001033 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1034
Juha Hyttinen1683f912020-04-17 10:39:57 +03001035 // hack as there is no real way to see has message be handled.
1036 // Previuos counter check just tells that is has been received by submgr
1037 // --> artificial delay
1038 <-time.After(1 * time.Second)
1039
Juha Hyttinen3944a222020-01-24 11:51:46 +02001040 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001041 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001042
1043 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001044 xappConn1.RecvSubsDelResp(t, nil)
1045 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001046
1047 //Wait that subs is cleaned
1048 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1049
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001050 xappConn1.TestMsgChanEmpty(t)
1051 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001052 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001053 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001054}
1055
1056//-----------------------------------------------------------------------------
1057// TestSubReqAndSubDelOkTwoParallel
1058//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001059// stub stub stub
1060// +-------+ +-------+ +---------+ +---------+
1061// | xapp | | xapp | | submgr | | e2term |
1062// +-------+ +-------+ +---------+ +---------+
1063// | | | |
1064// | | | |
1065// | | | |
1066// | | SubReq1 | |
1067// | |------------->| |
1068// | | | |
1069// | | | SubReq1 |
1070// | | |------------->|
1071// | | | |
1072// | SubReq2 | |
1073// |------------------------>| |
1074// | | | |
1075// | | | SubReq2 |
1076// | | |------------->|
1077// | | | |
1078// | | | SubResp1 |
1079// | | |<-------------|
1080// | | SubResp1 | |
1081// | |<-------------| |
1082// | | | |
1083// | | | SubResp2 |
1084// | | |<-------------|
1085// | SubResp2 | |
1086// |<------------------------| |
1087// | | | |
1088// | | [SUBS 1 DELETE] |
1089// | | | |
1090// | | [SUBS 2 DELETE] |
1091// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001092//
1093//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001094
Juha Hyttinenfa015662020-01-24 10:05:18 +02001095func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001096 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001097
1098 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001099 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001100 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001101 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001102 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001103
1104 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001105 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001106 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001107
1108 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1109 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1110 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1111
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001112 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001113 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001114
1115 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001116 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001117 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001118
1119 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001120 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001121 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001122
1123 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001124 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001125 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1126 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001127 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001128 //Wait that subs is cleaned
1129 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1130
1131 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001132 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001133 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1134 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001135 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001136 //Wait that subs is cleaned
1137 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1138
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001139 xappConn1.TestMsgChanEmpty(t)
1140 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001141 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001142 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001143}
1144
1145//-----------------------------------------------------------------------------
1146// TestSameSubsDiffRan
1147// Same subscription to different RANs
1148//
1149// stub stub
1150// +-------+ +---------+ +---------+
1151// | xapp | | submgr | | e2term |
1152// +-------+ +---------+ +---------+
1153// | | |
1154// | | |
1155// | | |
1156// | SubReq(r1) | |
1157// |------------->| |
1158// | | |
1159// | | SubReq(r1) |
1160// | |------------->|
1161// | | |
1162// | | SubResp(r1) |
1163// | |<-------------|
1164// | | |
1165// | SubResp(r1) | |
1166// |<-------------| |
1167// | | |
1168// | SubReq(r2) | |
1169// |------------->| |
1170// | | |
1171// | | SubReq(r2) |
1172// | |------------->|
1173// | | |
1174// | | SubResp(r2) |
1175// | |<-------------|
1176// | | |
1177// | SubResp(r2) | |
1178// |<-------------| |
1179// | | |
1180// | [SUBS r1 DELETE] |
1181// | | |
1182// | [SUBS r2 DELETE] |
1183// | | |
1184//
1185//-----------------------------------------------------------------------------
1186func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001187 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001188
1189 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001190 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1191 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001192 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1193 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001194 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001195
1196 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001197 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1198 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001199 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1200 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001201 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001202
1203 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001204 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1205 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001206 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1207 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001208 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001209 //Wait that subs is cleaned
1210 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1211
1212 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001213 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1214 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001215 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1216 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001217 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001218 //Wait that subs is cleaned
1219 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1220
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001221 xappConn1.TestMsgChanEmpty(t)
1222 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001223 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001224 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001225}
1226
1227//-----------------------------------------------------------------------------
1228// TestSubReqRetryInSubmgr
1229//
1230// stub stub
1231// +-------+ +---------+ +---------+
1232// | xapp | | submgr | | e2term |
1233// +-------+ +---------+ +---------+
1234// | | |
1235// | SubReq | |
1236// |------------->| |
1237// | | |
1238// | | SubReq |
1239// | |------------->|
1240// | | |
1241// | | |
1242// | | SubReq |
1243// | |------------->|
1244// | | |
1245// | | SubResp |
1246// | |<-------------|
1247// | | |
1248// | SubResp | |
1249// |<-------------| |
1250// | | |
1251// | [SUBS DELETE] |
1252// | | |
1253//
1254//-----------------------------------------------------------------------------
1255
1256func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001257 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001258
1259 // Init counter check
1260 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1261 Counter{cSubReqFromXapp, 1},
1262 Counter{cSubReqToE2, 1},
1263 Counter{cSubReReqToE2, 1},
1264 Counter{cSubRespFromE2, 1},
1265 Counter{cSubRespToXapp, 1},
1266 Counter{cSubDelReqFromXapp, 1},
1267 Counter{cSubDelReqToE2, 1},
1268 Counter{cSubDelRespFromE2, 1},
1269 Counter{cSubDelRespToXapp, 1},
1270 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001271
1272 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001273 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001274
1275 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001276 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001277
1278 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001279 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1280 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001281
1282 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001283 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001284
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001285 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001286 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1287 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001288 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001289
1290 // Wait that subs is cleaned
1291 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1292
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001293 xappConn1.TestMsgChanEmpty(t)
1294 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001295 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001296 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001297
1298 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001299}
1300
1301//-----------------------------------------------------------------------------
1302// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1303//
1304// stub stub
1305// +-------+ +---------+ +---------+
1306// | xapp | | submgr | | e2term |
1307// +-------+ +---------+ +---------+
1308// | | |
1309// | SubReq | |
1310// |------------->| |
1311// | | |
1312// | | SubReq |
1313// | |------------->|
1314// | | |
1315// | | |
1316// | | SubReq |
1317// | |------------->|
1318// | | |
1319// | | SubDelReq |
1320// | |------------->|
1321// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001322// | | SubDelResp |
1323// | |<-------------|
1324// | | |
1325//
1326//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001327func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001328 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001329
1330 // Init counter check
1331 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1332 Counter{cSubReqFromXapp, 1},
1333 Counter{cSubReqToE2, 1},
1334 Counter{cSubReReqToE2, 1},
1335 Counter{cSubReqTimerExpiry, 2},
1336 Counter{cSubDelReqToE2, 1},
1337 Counter{cSubDelRespFromE2, 1},
1338 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001339
1340 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001341 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001342
1343 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001344 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001345
1346 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001347 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001348
1349 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001350 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1351 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001352
1353 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001354 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001355
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001356 xappConn1.TestMsgChanEmpty(t)
1357 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001358 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001359 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001360
1361 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001362}
1363
1364//-----------------------------------------------------------------------------
1365// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1366//
1367// stub stub
1368// +-------+ +---------+ +---------+
1369// | xapp | | submgr | | e2term |
1370// +-------+ +---------+ +---------+
1371// | | |
1372// | SubReq | |
1373// |------------->| |
1374// | | |
1375// | | SubReq |
1376// | |------------->|
1377// | | |
1378// | | |
1379// | | SubReq |
1380// | |------------->|
1381// | | |
1382// | | SubDelReq |
1383// | |------------->|
1384// | | |
1385// | | |
1386// | | SubDelReq |
1387// | |------------->|
1388// | | |
1389// | | |
1390//
1391//-----------------------------------------------------------------------------
1392
1393func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001394 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001395
1396 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1397 Counter{cSubReqFromXapp, 1},
1398 Counter{cSubReqToE2, 1},
1399 Counter{cSubReReqToE2, 1},
1400 Counter{cSubReqTimerExpiry, 2},
1401 Counter{cSubDelReqToE2, 1},
1402 Counter{cSubDelReReqToE2, 1},
1403 Counter{cSubDelReqTimerExpiry, 2},
1404 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001405
1406 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001407 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001408
1409 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001410 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001411
1412 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001413 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001414
1415 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001416 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001417
1418 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001419 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001420
1421 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001422 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001423
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001424 xappConn1.TestMsgChanEmpty(t)
1425 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001426 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001427 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001428
1429 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001430}
1431
1432//-----------------------------------------------------------------------------
1433// TestSubReqSubFailRespInSubmgr
1434//
1435// stub stub
1436// +-------+ +---------+ +---------+
1437// | xapp | | submgr | | e2term |
1438// +-------+ +---------+ +---------+
1439// | | |
1440// | SubReq | |
1441// |------------->| |
1442// | | |
1443// | | SubReq |
1444// | |------------->|
1445// | | |
1446// | | SubFail |
1447// | |<-------------|
1448// | | |
1449// | SubFail | |
1450// |<-------------| |
1451// | | |
1452//
1453//-----------------------------------------------------------------------------
1454
1455func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001456 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001457
1458 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1459 Counter{cSubReqFromXapp, 1},
1460 Counter{cSubReqToE2, 1},
1461 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001462 Counter{cSubFailToXapp, 1},
1463 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001464
1465 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001466 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001467
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001468 // E2t: Receive SubsReq and send SubsFail (first)
1469 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1470 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1471 fparams1.Set(crereq1)
1472 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1473
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001474 // Xapp: Receive SubsFail
1475 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1476
1477 // Wait that subs is cleaned
1478 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1479
1480 xappConn1.TestMsgChanEmpty(t)
1481 xappConn2.TestMsgChanEmpty(t)
1482 e2termConn1.TestMsgChanEmpty(t)
1483 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001484
1485 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001486}
1487
1488//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001489// TestSubDelReqRetryInSubmgr
1490//
1491// stub stub
1492// +-------+ +---------+ +---------+
1493// | xapp | | submgr | | e2term |
1494// +-------+ +---------+ +---------+
1495// | | |
1496// | [SUBS CREATE] |
1497// | | |
1498// | | |
1499// | SubDelReq | |
1500// |------------->| |
1501// | | |
1502// | | SubDelReq |
1503// | |------------->|
1504// | | |
1505// | | SubDelReq |
1506// | |------------->|
1507// | | |
1508// | | SubDelResp |
1509// | |<-------------|
1510// | | |
1511// | SubDelResp | |
1512// |<-------------| |
1513//
1514//-----------------------------------------------------------------------------
1515
1516func TestSubDelReqRetryInSubmgr(t *testing.T) {
1517
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001518 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001519
1520 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001521 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001522 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1523 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001524 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001525
1526 // Subs Delete
1527 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001528 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001529
1530 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001531 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001532
1533 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001534 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1535 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001536
1537 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001538 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001539
1540 // Wait that subs is cleaned
1541 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1542
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001543 xappConn1.TestMsgChanEmpty(t)
1544 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001545 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001546 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001547}
1548
1549//-----------------------------------------------------------------------------
1550// TestSubDelReqTwoRetriesNoRespInSubmgr
1551//
1552// stub stub
1553// +-------+ +---------+ +---------+
1554// | xapp | | submgr | | e2term |
1555// +-------+ +---------+ +---------+
1556// | | |
1557// | [SUBS CREATE] |
1558// | | |
1559// | | |
1560// | SubDelReq | |
1561// |------------->| |
1562// | | |
1563// | | SubDelReq |
1564// | |------------->|
1565// | | |
1566// | | SubDelReq |
1567// | |------------->|
1568// | | |
1569// | | |
1570// | SubDelResp | |
1571// |<-------------| |
1572//
1573//-----------------------------------------------------------------------------
1574
1575func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1576
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001577 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001578
1579 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001580 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001581 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1582 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001583 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001584
1585 // Subs Delete
1586 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001587 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001588
1589 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001590 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001591
1592 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001593 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001594
1595 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001596 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001597
1598 // Wait that subs is cleaned
1599 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1600
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001601 xappConn1.TestMsgChanEmpty(t)
1602 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001603 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001604 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001605}
1606
1607//-----------------------------------------------------------------------------
1608// TestSubDelReqSubDelFailRespInSubmgr
1609//
1610// stub stub
1611// +-------+ +---------+ +---------+
1612// | xapp | | submgr | | e2term |
1613// +-------+ +---------+ +---------+
1614// | | |
1615// | [SUBS CREATE] |
1616// | | |
1617// | | |
1618// | SubDelReq | |
1619// |------------->| |
1620// | | |
1621// | | SubDelReq |
1622// | |------------->|
1623// | | |
1624// | | SubDelFail |
1625// | |<-------------|
1626// | | |
1627// | SubDelResp | |
1628// |<-------------| |
1629// | | |
1630//
1631//-----------------------------------------------------------------------------
1632
1633func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001634 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001635
1636 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1637 Counter{cSubReqFromXapp, 1},
1638 Counter{cSubReqToE2, 1},
1639 Counter{cSubRespFromE2, 1},
1640 Counter{cSubRespToXapp, 1},
1641 Counter{cSubDelReqFromXapp, 1},
1642 Counter{cSubDelReqToE2, 1},
1643 Counter{cSubDelFailFromE2, 1},
1644 Counter{cSubDelRespToXapp, 1},
1645 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001646
1647 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001648 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001649 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1650 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001651 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001652
1653 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001654 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001655
1656 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001657 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1658 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001659
1660 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001661 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001662
1663 // Wait that subs is cleaned
1664 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1665
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001666 xappConn1.TestMsgChanEmpty(t)
1667 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001668 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001669 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001670
1671 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001672}
1673
1674//-----------------------------------------------------------------------------
1675// TestSubReqAndSubDelOkSameAction
1676//
1677// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001678// +-------+ +-------+ +---------+ +---------+
1679// | xapp2 | | xapp1 | | submgr | | e2term |
1680// +-------+ +-------+ +---------+ +---------+
1681// | | | |
1682// | | | |
1683// | | | |
1684// | | SubReq1 | |
1685// | |------------->| |
1686// | | | |
1687// | | | SubReq1 |
1688// | | |------------->|
1689// | | | SubResp1 |
1690// | | |<-------------|
1691// | | SubResp1 | |
1692// | |<-------------| |
1693// | | | |
1694// | SubReq2 | |
1695// |--------------------------->| |
1696// | | | |
1697// | SubResp2 | |
1698// |<---------------------------| |
1699// | | | |
1700// | | SubDelReq 1 | |
1701// | |------------->| |
1702// | | | |
1703// | | SubDelResp 1 | |
1704// | |<-------------| |
1705// | | | |
1706// | SubDelReq 2 | |
1707// |--------------------------->| |
1708// | | | |
1709// | | | SubDelReq 2 |
1710// | | |------------->|
1711// | | | |
1712// | | | SubDelReq 2 |
1713// | | |------------->|
1714// | | | |
1715// | SubDelResp 2 | |
1716// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001717//
1718//-----------------------------------------------------------------------------
1719func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001720 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001721
Anssi Mannila4abf1802021-01-28 13:06:46 +02001722 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001723 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1724 Counter{cSubReqFromXapp, 2},
1725 Counter{cSubReqToE2, 1},
1726 Counter{cSubRespFromE2, 1},
1727 Counter{cSubRespToXapp, 2},
1728 Counter{cMergedSubscriptions, 1},
1729 Counter{cUnmergedSubscriptions, 1},
1730 Counter{cSubDelReqFromXapp, 2},
1731 Counter{cSubDelReqToE2, 1},
1732 Counter{cSubDelRespFromE2, 1},
1733 Counter{cSubDelRespToXapp, 2},
1734 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001735
Juha Hyttinen3944a222020-01-24 11:51:46 +02001736 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001737 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001738 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001739 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001740 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1741 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001742 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001743
1744 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001745 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001746 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001747 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001748 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001749
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001750 resp, _ := xapp.Subscription.QuerySubscriptions()
1751 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1752 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001753 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001754
Juha Hyttinen3944a222020-01-24 11:51:46 +02001755 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001756 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001757 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001758
1759 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001760 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001761 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1762 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001763 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001764 //Wait that subs is cleaned
1765 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1766
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001767 xappConn1.TestMsgChanEmpty(t)
1768 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001769 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001770 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001771
1772 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001773}
1774
1775//-----------------------------------------------------------------------------
1776// TestSubReqAndSubDelOkSameActionParallel
1777//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001778// stub stub stub
1779// +-------+ +-------+ +---------+ +---------+
1780// | xapp2 | | xapp1 | | submgr | | e2term |
1781// +-------+ +-------+ +---------+ +---------+
1782// | | | |
1783// | | | |
1784// | | | |
1785// | | SubReq1 | |
1786// | |------------->| |
1787// | | | |
1788// | | | SubReq1 |
1789// | | |------------->|
1790// | SubReq2 | |
1791// |--------------------------->| |
1792// | | | SubResp1 |
1793// | | |<-------------|
1794// | | SubResp1 | |
1795// | |<-------------| |
1796// | | | |
1797// | SubResp2 | |
1798// |<---------------------------| |
1799// | | | |
1800// | | SubDelReq 1 | |
1801// | |------------->| |
1802// | | | |
1803// | | SubDelResp 1 | |
1804// | |<-------------| |
1805// | | | |
1806// | SubDelReq 2 | |
1807// |--------------------------->| |
1808// | | | |
1809// | | | SubDelReq 2 |
1810// | | |------------->|
1811// | | | |
1812// | | | SubDelReq 2 |
1813// | | |------------->|
1814// | | | |
1815// | SubDelResp 2 | |
1816// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001817//
1818//-----------------------------------------------------------------------------
1819func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001820 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001821
1822 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001823 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001824 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001825 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001826 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001827
1828 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001829 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001830 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001831 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001832
1833 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001834 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001835 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001836
1837 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001838 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001839
1840 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001841 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1842 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001843
1844 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001845 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001846 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1847 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001848 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001849
1850 //Wait that subs is cleaned
1851 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1852
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001853 xappConn1.TestMsgChanEmpty(t)
1854 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001855 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001856 mainCtrl.wait_registry_empty(t, 10)
1857}
1858
1859//-----------------------------------------------------------------------------
1860// TestSubReqAndSubDelNokSameActionParallel
1861//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001862// stub stub stub
1863// +-------+ +-------+ +---------+ +---------+
1864// | xapp2 | | xapp1 | | submgr | | e2term |
1865// +-------+ +-------+ +---------+ +---------+
1866// | | | |
1867// | | | |
1868// | | | |
1869// | | SubReq1 | |
1870// | |------------->| |
1871// | | | |
1872// | | | SubReq1 |
1873// | | |------------->|
1874// | SubReq2 | |
1875// |--------------------------->| |
1876// | | | SubFail1 |
1877// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001878// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001879// | | SubFail1 | |
1880// | |<-------------| |
1881// | | | |
1882// | SubFail2 | |
1883// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001884//
1885//-----------------------------------------------------------------------------
1886func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001887 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001888
1889 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001890 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001891 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001892 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001893
1894 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001895 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001896
1897 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001898 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001899 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001900 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001901 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001902 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001903
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001904 // E2t: send SubsFail (first)
1905 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1906 fparams1.Set(crereq1)
1907 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1908
Juha Hyttinen3944a222020-01-24 11:51:46 +02001909 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001910 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001911 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001912 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001913
1914 //Wait that subs is cleaned
1915 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1916
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001917 xappConn1.TestMsgChanEmpty(t)
1918 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001919 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001920 mainCtrl.wait_registry_empty(t, 10)
1921}
1922
1923//-----------------------------------------------------------------------------
1924// TestSubReqAndSubDelNoAnswerSameActionParallel
1925//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001926// stub stub stub
1927// +-------+ +-------+ +---------+ +---------+
1928// | xapp2 | | xapp1 | | submgr | | e2term |
1929// +-------+ +-------+ +---------+ +---------+
1930// | | | |
1931// | | | |
1932// | | | |
1933// | | SubReq1 | |
1934// | |------------->| |
1935// | | | |
1936// | | | SubReq1 |
1937// | | |------------->|
1938// | | SubReq2 | |
1939// |--------------------------->| |
1940// | | | |
1941// | | | SubReq1 |
1942// | | |------------->|
1943// | | | |
1944// | | | |
1945// | | | SubDelReq |
1946// | | |------------->|
1947// | | | |
1948// | | | SubDelResp |
1949// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001950//
1951//-----------------------------------------------------------------------------
1952func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001953 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001954
1955 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001956 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001957 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001958 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001959
Juha Hyttinen1683f912020-04-17 10:39:57 +03001960 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001961
1962 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001963 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001964 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001965 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001966 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001967 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001968
1969 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001970 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001971
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001972 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1973 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001974
1975 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001976 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001977
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001978 xappConn1.TestMsgChanEmpty(t)
1979 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001980 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001981 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001982}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001983
1984//----------------------------- Policy cases ---------------------------------
1985//-----------------------------------------------------------------------------
1986// TestSubReqPolicyAndSubDelOk
1987//
1988// stub stub
1989// +-------+ +---------+ +---------+
1990// | xapp | | submgr | | e2term |
1991// +-------+ +---------+ +---------+
1992// | | |
1993// | SubReq | |
1994// |------------->| |
1995// | | |
1996// | | SubReq |
1997// | |------------->|
1998// | | |
1999// | | SubResp |
2000// | |<-------------|
2001// | | |
2002// | SubResp | |
2003// |<-------------| |
2004// | | |
2005// | | |
2006// | SubDelReq | |
2007// |------------->| |
2008// | | |
2009// | | SubDelReq |
2010// | |------------->|
2011// | | |
2012// | | SubDelResp |
2013// | |<-------------|
2014// | | |
2015// | SubDelResp | |
2016// |<-------------| |
2017//
2018//-----------------------------------------------------------------------------
2019func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2020 CaseBegin("TestSubReqAndSubDelOk")
2021
2022 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2023 rparams1.Init()
2024 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2025 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2026
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002027 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2028 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002029 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2030 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002031 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002032
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002033 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002034 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002035
2036 //Wait that subs is cleaned
2037 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2038
2039 xappConn1.TestMsgChanEmpty(t)
2040 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002041 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002042 mainCtrl.wait_registry_empty(t, 10)
2043}
2044
2045//-----------------------------------------------------------------------------
2046// TestSubReqPolicyChangeAndSubDelOk
2047//
2048// stub stub
2049// +-------+ +---------+ +---------+
2050// | xapp | | submgr | | e2term |
2051// +-------+ +---------+ +---------+
2052// | | |
2053// | SubReq | |
2054// |------------->| |
2055// | | |
2056// | | SubReq |
2057// | |------------->|
2058// | | |
2059// | | SubResp |
2060// | |<-------------|
2061// | | |
2062// | SubResp | |
2063// |<-------------| |
2064// | | |
2065// | SubReq | |
2066// |------------->| |
2067// | | |
2068// | | SubReq |
2069// | |------------->|
2070// | | |
2071// | | SubResp |
2072// | |<-------------|
2073// | | |
2074// | SubResp | |
2075// |<-------------| |
2076// | | |
2077// | SubDelReq | |
2078// |------------->| |
2079// | | |
2080// | | SubDelReq |
2081// | |------------->|
2082// | | |
2083// | | SubDelResp |
2084// | |<-------------|
2085// | | |
2086// | SubDelResp | |
2087// |<-------------| |
2088//
2089//-----------------------------------------------------------------------------
2090
2091func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2092 CaseBegin("TestSubReqAndSubDelOk")
2093
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002094 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2095 rparams1.Init()
2096 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2097 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002098
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002099 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2100 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002101 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2102
2103 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002104 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002105 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2106 xappConn1.SendSubsReq(t, rparams1, cretrans)
2107
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002108 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2109 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002110 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2111 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002112 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002113
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002114 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002115 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002116
2117 //Wait that subs is cleaned
2118 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2119
2120 xappConn1.TestMsgChanEmpty(t)
2121 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002122 e2termConn1.TestMsgChanEmpty(t)
2123 mainCtrl.wait_registry_empty(t, 10)
2124}
2125
2126//-----------------------------------------------------------------------------
2127// TestSubReqAndSubDelOkTwoE2termParallel
2128//
2129// stub stub stub
2130// +-------+ +---------+ +---------+ +---------+
2131// | xapp | | submgr | | e2term1 | | e2term2 |
2132// +-------+ +---------+ +---------+ +---------+
2133// | | | |
2134// | | | |
2135// | | | |
2136// | SubReq1 | | |
2137// |------------->| | |
2138// | | | |
2139// | | SubReq1 | |
2140// | |------------->| |
2141// | | | |
2142// | SubReq2 | | |
2143// |------------->| | |
2144// | | | |
2145// | | SubReq2 | |
2146// | |---------------------------->|
2147// | | | |
2148// | | SubResp1 | |
2149// | |<-------------| |
2150// | SubResp1 | | |
2151// |<-------------| | |
2152// | | SubResp2 | |
2153// | |<----------------------------|
2154// | SubResp2 | | |
2155// |<-------------| | |
2156// | | | |
2157// | [SUBS 1 DELETE] | |
2158// | | | |
2159// | [SUBS 2 DELETE] | |
2160// | | | |
2161//
2162//-----------------------------------------------------------------------------
2163func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2164 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2165
2166 //Req1
2167 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2168 xappConn1.SendSubsReq(t, nil, cretrans1)
2169 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2170
2171 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2172 xappConn1.SendSubsReq(t, nil, cretrans2)
2173 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2174
2175 //Resp1
2176 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2177 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2178
2179 //Resp2
2180 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2181 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2182
2183 //Del1
2184 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2185 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2186 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2187 xappConn1.RecvSubsDelResp(t, deltrans1)
2188 //Wait that subs is cleaned
2189 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2190
2191 //Del2
2192 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2193 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2194 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2195 xappConn1.RecvSubsDelResp(t, deltrans2)
2196 //Wait that subs is cleaned
2197 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2198
2199 xappConn1.TestMsgChanEmpty(t)
2200 xappConn2.TestMsgChanEmpty(t)
2201 e2termConn1.TestMsgChanEmpty(t)
2202 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002203 mainCtrl.wait_registry_empty(t, 10)
2204}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002205
2206//-----------------------------------------------------------------------------
2207// TestSubReqInsertAndSubDelOk
2208//
2209// stub stub
2210// +-------+ +---------+ +---------+
2211// | xapp | | submgr | | e2term |
2212// +-------+ +---------+ +---------+
2213// | | |
2214// | SubReq | |
2215// |------------->| |
2216// | | |
2217// | | SubReq |
2218// | |------------->|
2219// | | |
2220// | | SubResp |
2221// | |<-------------|
2222// | | |
2223// | SubResp | |
2224// |<-------------| |
2225// | | |
2226// | | |
2227// | SubDelReq | |
2228// |------------->| |
2229// | | |
2230// | | SubDelReq |
2231// | |------------->|
2232// | | |
2233// | | SubDelResp |
2234// | |<-------------|
2235// | | |
2236// | SubDelResp | |
2237// |<-------------| |
2238//
2239//-----------------------------------------------------------------------------
2240func TestSubReqInsertAndSubDelOk(t *testing.T) {
2241 CaseBegin("TestInsertSubReqAndSubDelOk")
2242
2243 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2244 rparams1.Init()
2245 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2246 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2247
2248 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2249 e2termConn1.SendSubsResp(t, crereq, cremsg)
2250 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2251 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2252 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2253
2254 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2255 xappConn1.RecvSubsDelResp(t, deltrans)
2256
2257 //Wait that subs is cleaned
2258 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2259
2260 xappConn1.TestMsgChanEmpty(t)
2261 xappConn2.TestMsgChanEmpty(t)
2262 e2termConn1.TestMsgChanEmpty(t)
2263 mainCtrl.wait_registry_empty(t, 10)
2264}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002265
2266//-----------------------------------------------------------------------------
2267// TestSubReqRetransmissionWithSameSubIdDiffXid
2268//
2269// This case simulates case where xApp restarts and starts sending same
2270// subscription requests which have already subscribed successfully
2271
2272// stub stub
2273// +-------+ +---------+ +---------+
2274// | xapp | | submgr | | e2term |
2275// +-------+ +---------+ +---------+
2276// | | |
2277// | SubReq | |
2278// |------------->| |
2279// | | |
2280// | | SubReq |
2281// | |------------->|
2282// | | |
2283// | | SubResp |
2284// | |<-------------|
2285// | | |
2286// | SubResp | |
2287// |<-------------| |
2288// | | |
2289// | xApp restart | |
2290// | | |
2291// | SubReq | |
2292// | (retrans with same xApp generated subid but diff xid)
2293// |------------->| |
2294// | | |
2295// | SubResp | |
2296// |<-------------| |
2297// | | |
2298// | [SUBS DELETE] |
2299// | | |
2300//
2301//-----------------------------------------------------------------------------
2302func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2303 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2304
2305 //Subs Create
2306 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2307 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2308 e2termConn1.SendSubsResp(t, crereq, cremsg)
2309 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2310
2311 // xApp restart here
2312 // --> artificial delay
2313 <-time.After(1 * time.Second)
2314
2315 //Subs Create
2316 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2317 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2318
2319 //Subs Delete
2320 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2321 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2322 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2323 xappConn1.RecvSubsDelResp(t, deltrans)
2324
2325 //Wait that subs is cleaned
2326 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2327
2328 xappConn1.TestMsgChanEmpty(t)
2329 xappConn2.TestMsgChanEmpty(t)
2330 e2termConn1.TestMsgChanEmpty(t)
2331 mainCtrl.wait_registry_empty(t, 10)
2332}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002333
2334//-----------------------------------------------------------------------------
2335// TestSubReqNokAndSubDelOkWithRestartInMiddle
2336//
2337// stub stub
2338// +-------+ +---------+ +---------+
2339// | xapp | | submgr | | e2term |
2340// +-------+ +---------+ +---------+
2341// | | |
2342// | SubReq | |
2343// |------------->| |
2344// | | |
2345// | | SubReq |
2346// | |------------->|
2347// | | |
2348// | | SubResp |
2349// | <----|
2350// | |
2351// | Submgr restart |
2352// | |
2353// | | |
2354// | | SubDelReq |
2355// | |------------->|
2356// | | |
2357// | | SubDelResp |
2358// | |<-------------|
2359// | | |
2360//
2361//-----------------------------------------------------------------------------
2362
2363func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2364 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2365
2366 // Remove possible existing subscrition
2367 mainCtrl.removeExistingSubscriptions(t)
2368
2369 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2370 xappConn1.SendSubsReq(t, nil, nil)
2371 e2termConn1.RecvSubsReq(t)
2372 mainCtrl.SetResetTestFlag(t, false)
2373
2374 resp, _ := xapp.Subscription.QuerySubscriptions()
2375 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002376 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002377 e2SubsId := uint32(resp[0].SubscriptionID)
2378 t.Logf("e2SubsId = %v", e2SubsId)
2379
archaggeafbf95f2021-04-14 08:54:05 +03002380 mainCtrl.SimulateRestart(t)
2381 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002382
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002383 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002384 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2385 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2386
2387 // Wait that subs is cleaned
2388 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2389
2390 xappConn1.TestMsgChanEmpty(t)
2391 xappConn2.TestMsgChanEmpty(t)
2392 e2termConn1.TestMsgChanEmpty(t)
2393 mainCtrl.wait_registry_empty(t, 10)
2394}
2395
2396//-----------------------------------------------------------------------------
2397// TestSubReqAndSubDelOkWithRestartInMiddle
2398//
2399// stub stub
2400// +-------+ +---------+ +---------+
2401// | xapp | | submgr | | e2term |
2402// +-------+ +---------+ +---------+
2403// | | |
2404// | SubReq | |
2405// |------------->| |
2406// | | |
2407// | | SubReq |
2408// | |------------->|
2409// | | |
2410// | | SubResp |
2411// | |<-------------|
2412// | | |
2413// | SubResp | |
2414// |<-------------| |
2415// | | |
2416// | |
2417// | Submgr restart |
2418// | |
2419// | SubDelReq | |
2420// |------------->| |
2421// | | |
2422// | | SubDelReq |
2423// | |------------->|
2424// | | |
2425// | | SubDelResp |
2426// | |<-------------|
2427// | | |
2428// | SubDelResp | |
2429// |<-------------| |
2430//
2431//-----------------------------------------------------------------------------
2432
2433func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2434 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2435
2436 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2437 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2438 e2termConn1.SendSubsResp(t, crereq, cremsg)
2439 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2440
2441 // Check subscription
2442 resp, _ := xapp.Subscription.QuerySubscriptions()
2443 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2444 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002445 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002446
2447 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002448 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002449
2450 // Check that subscription is restored correctly after restart
2451 resp, _ = xapp.Subscription.QuerySubscriptions()
2452 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2453 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002454 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002455
2456 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2457 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2458 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2459 xappConn1.RecvSubsDelResp(t, deltrans)
2460
2461 //Wait that subs is cleaned
2462 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2463
2464 xappConn1.TestMsgChanEmpty(t)
2465 xappConn2.TestMsgChanEmpty(t)
2466 e2termConn1.TestMsgChanEmpty(t)
2467 mainCtrl.wait_registry_empty(t, 10)
2468}
2469
2470//-----------------------------------------------------------------------------
2471// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2472//
2473// stub stub
2474// +-------+ +-------+ +---------+ +---------+
2475// | xapp2 | | xapp1 | | submgr | | e2term |
2476// +-------+ +-------+ +---------+ +---------+
2477// | | | |
2478// | | | |
2479// | | | |
2480// | | SubReq1 | |
2481// | |------------->| |
2482// | | | |
2483// | | | SubReq1 |
2484// | | |------------->|
2485// | | | SubResp1 |
2486// | | |<-------------|
2487// | | SubResp1 | |
2488// | |<-------------| |
2489// | | | |
2490// | |
2491// | submgr restart |
2492// | |
2493// | | | |
2494// | | | |
2495// | SubReq2 | |
2496// |--------------------------->| |
2497// | | | |
2498// | SubResp2 | |
2499// |<---------------------------| |
2500// | | | |
2501// | | SubDelReq 1 | |
2502// | |------------->| |
2503// | | | |
2504// | | SubDelResp 1 | |
2505// | |<-------------| |
2506// | | | |
2507// | | | |
2508// | |
2509// | submgr restart |
2510// | |
2511// | | | |
2512// | SubDelReq 2 | |
2513// |--------------------------->| |
2514// | | | |
2515// | | | SubDelReq 2 |
2516// | | |------------->|
2517// | | | |
2518// | | | SubDelReq 2 |
2519// | | |------------->|
2520// | | | |
2521// | SubDelResp 2 | |
2522// |<---------------------------| |
2523//
2524//-----------------------------------------------------------------------------
2525
2526func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2527 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2528
2529 //Req1
2530 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2531 rparams1.Init()
2532 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2533 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2534 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2535 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2536
2537 //Req2
2538 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2539 rparams2.Init()
2540 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2541 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2542
2543 // Check subscription
2544 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2545 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2546 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002547 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002548
2549 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002550 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002551
2552 // Check that subscription is restored correctly after restart
2553 resp, _ = xapp.Subscription.QuerySubscriptions()
2554 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2555 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002556 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002557
2558 //Del1
2559 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2560 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2561 xappConn1.RecvSubsDelResp(t, deltrans1)
2562 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2563
2564 mainCtrl.SimulateRestart(t)
2565 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2566
2567 //Del2
2568 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2569 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2570
2571 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2572 xappConn2.RecvSubsDelResp(t, deltrans2)
2573
2574 //Wait that subs is cleaned
2575 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2576
2577 xappConn1.TestMsgChanEmpty(t)
2578 xappConn2.TestMsgChanEmpty(t)
2579 e2termConn1.TestMsgChanEmpty(t)
2580 mainCtrl.wait_registry_empty(t, 10)
2581}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002582
archaggeafbf95f2021-04-14 08:54:05 +03002583//*****************************************************************************
2584// REST interface test cases
2585//*****************************************************************************
2586
Anssi Mannila47518ae2021-04-16 09:27:07 +03002587//-----------------------------------------------------------------------------
2588// Test debug GET and POST requests
2589//
2590// curl
2591// +-------+ +---------+
2592// | user | | submgr |
2593// +-------+ +---------+
2594// | |
2595// | GET/POST Req |
2596// |------------->|
2597// | Resp |
2598// |<-------------|
2599// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002600func TestGetSubscriptions(t *testing.T) {
2601
2602 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2603}
2604
2605func TestGetSymptomData(t *testing.T) {
2606
2607 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2608}
2609
2610func TestPostdeleteSubId(t *testing.T) {
2611
2612 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2613}
2614
2615func TestPostEmptyDb(t *testing.T) {
2616
2617 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2618}
archaggeafbf95f2021-04-14 08:54:05 +03002619
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002620func TestGetRestSubscriptions(t *testing.T) {
2621
2622 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2623}
2624
archaggeafbf95f2021-04-14 08:54:05 +03002625//-----------------------------------------------------------------------------
2626// TestRESTSubReqAndRouteNok
2627//
2628// stub stub
2629// +-------+ +---------+ +---------+
2630// | xapp | | submgr | | rtmgr |
2631// +-------+ +---------+ +---------+
2632// | | |
2633// | RESTSubReq | |
2634// |---------------->| |
2635// | | |
2636// | RESTSubResp | |
2637// |<----------------| |
2638// | | RouteCreate |
2639// | |------------->|
2640// | | |
2641// | | RouteCreate |
2642// | | status:400 |
2643// | |(Bad request) |
2644// | |<-------------|
2645// | RESTNotif | |
2646// |<----------------| |
2647// | | |
2648// | [SUBS INT DELETE] |
2649// | | |
2650// | RESTSubDelReq | |
2651// |---------------->| |
2652// | RESTSubDelResp | |
2653// |<----------------| |
2654//
2655//-----------------------------------------------------------------------------
2656func TestRESTSubReqAndRouteNok(t *testing.T) {
2657 CaseBegin("TestRESTSubReqAndRouteNok")
2658
2659 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002660 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002661 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002662 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002663 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002664 Counter{cRestSubDelReqFromXapp, 1},
2665 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002666 })
2667
2668 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002669
Markku Virtanenda34eec2021-05-20 08:22:04 +00002670 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2671 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002672 newSubsId := mainCtrl.get_registry_next_subid(t)
2673
2674 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002675 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002676 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002677 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002678 waiter.WaitResult(t)
2679
archaggeafbf95f2021-04-14 08:54:05 +03002680 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002681 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002682
2683 // Del
2684 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2685
2686 // Wait that subs is cleaned
2687 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2688 waitSubsCleanup(t, e2SubsId, 10)
2689 mainCtrl.VerifyCounterValues(t)
2690}
2691
2692func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2693 CaseBegin("TestSubReqAndRouteUpdateNok")
2694
2695 //Init counter check
2696 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002697 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002698 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002699 Counter{cSubReqToE2, 1},
2700 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002701 Counter{cRestSubNotifToXapp, 1},
2702 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002703 Counter{cRouteCreateUpdateFail, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002704 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002705 Counter{cSubDelReqToE2, 1},
2706 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002707 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002708 })
2709
2710 var params *teststube2ap.RESTSubsReqParams = nil
2711
2712 //Subs Create
2713 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2714
2715 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2716
2717 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2718 waiter := rtmgrHttp.AllocNextEvent(false)
2719 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002720 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002721 params.SetMeid("RAN_NAME_1")
2722 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002723 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002724 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002725 waiter.WaitResult(t)
2726 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2727 xappConn2.WaitRESTNotification(t, restSubId2)
2728
2729 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2730
2731 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2732
2733 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2734 //Wait that subs is cleaned
2735 waitSubsCleanup(t, e2SubsId, 10)
2736
2737 mainCtrl.VerifyCounterValues(t)
2738}
2739
2740func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2741 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2742
2743 // Init counter check
2744 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002745 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002746 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002747 Counter{cSubReqToE2, 1},
2748 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002749 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002750 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002751 Counter{cRouteDeleteFail, 1},
2752 Counter{cSubDelReqToE2, 1},
2753 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002754 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002755 })
2756
2757 var params *teststube2ap.RESTSubsReqParams = nil
2758
2759 //Subs Create
2760 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2761
2762 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2763
2764 waiter := rtmgrHttp.AllocNextEvent(false)
2765 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2766 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2767 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2768 waiter.WaitResult(t)
2769
2770 waitSubsCleanup(t, e2SubsId, 10)
2771
2772 mainCtrl.VerifyCounterValues(t)
2773}
2774
2775func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2776 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2777
2778 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002779 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002780 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002781 Counter{cSubReqToE2, 1},
2782 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002783 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002784 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002785 Counter{cRouteDeleteUpdateFail, 1},
2786 Counter{cSubDelReqToE2, 1},
2787 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002788 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002789 })
2790
2791 var params *teststube2ap.RESTSubsReqParams = nil
2792
2793 //Subs Create
2794 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2795
2796 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2797 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2798
2799 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2800
2801 //Del1, this shall fail on rtmgr side
2802 waiter := rtmgrHttp.AllocNextEvent(false)
2803 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2804 waiter.WaitResult(t)
2805
2806 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2807
2808 //Del2
2809 deleteXapp2Subscription(t, &restSubId2)
2810
2811 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002812 mainCtrl.VerifyCounterValues(t)
2813}
2814
2815//-----------------------------------------------------------------------------
2816// TestRESTSubReqRetransmission
2817//
2818// stub stub
2819// +-------+ +---------+ +---------+
2820// | xapp | | submgr | | e2term |
2821// +-------+ +---------+ +---------+
2822// | | |
2823// | RESTSubReq1 | |
2824// |---------------->| |
2825// | | |
2826// | RESTSubResp | |
2827// |<----------------| |
2828// | | SubReq1 |
2829// | |------------->|
2830// | | |
2831// | RESTSubReq2 | |
2832// | (retrans) | |
2833// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002834// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002835// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002836// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002837// | | SubResp1 |
2838// | |<-------------|
2839// | RESTNotif1 | |
2840// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002841// | | |
2842// | [SUBS DELETE] |
2843// | | |
2844//
2845//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002846
archaggeafbf95f2021-04-14 08:54:05 +03002847func TestRESTSubReqRetransmission(t *testing.T) {
2848 CaseBegin("TestRESTSubReqRetransmission")
2849
2850 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002851 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002852 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002853 Counter{cSubReqToE2, 1},
2854 Counter{cSubRespFromE2, 1},
2855 Counter{cRestSubNotifToXapp, 1},
2856 Counter{cRestSubDelReqFromXapp, 1},
2857 Counter{cSubDelReqToE2, 1},
2858 Counter{cSubDelRespFromE2, 1},
2859 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002860 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002861 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002862 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2863 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2864
2865 // Subs Create
2866 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002867
2868 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2869 // gets into execution before the rtmgrg responds for the first one.
2870 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002871 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002872 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenb642a192021-06-09 09:08:14 +00002873 xappConn2.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002874
2875 waiter.WaitResult(t)
2876
Markku Virtanenb642a192021-06-09 09:08:14 +00002877 xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
archaggeafbf95f2021-04-14 08:54:05 +03002878
2879 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2880 // the order is not significant he6re.
2881 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2882 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002883
2884 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002885 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03002886
2887 // Del1
2888 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2889 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2890 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2891
Markku Virtanenb642a192021-06-09 09:08:14 +00002892 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002893
2894 mainCtrl.VerifyCounterValues(t)
2895}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002896
Markku Virtanen42723e22021-06-15 10:09:23 +03002897//-----------------------------------------------------------------------------
2898// stub stub stub
2899// +-------+ +---------+ +---------+ +---------+
2900// | xapp | | submgr | | e2term | | rtmgr |
2901// +-------+ +---------+ +---------+ +---------+
2902// | | | |
2903// | RESTSubReq | | |
2904// |---------------->| | |
2905// | RESTSubResp | | |
2906// |<----------------| | |
2907// | | RouteCreate | |
2908// | |--------------------------->|
2909// | | RouteResponse| |
2910// | |<---------------------------| // The order of these events may vary
2911// | | SubReq | |
2912// | |------------->| | // The order of these events may vary
2913// | | SubResp | |
2914// | |<-------------| |
2915// | RESTNotif1 | | |
2916// |<----------------| | |
2917// | RESTSubReq | | |
2918// | [RETRANS1] | | |
2919// |---------------->| | |
2920// | RESTNotif1 | | |
2921// |<----------------| | |
2922// | RESTSubReq | | |
2923// | [RETRANS2] | | |
2924// |---------------->| | |
2925// | RESTNotif1 | | |
2926// |<----------------| | |
2927// | RESTSubDelReq | | |
2928// |---------------->| | |
2929// | | SubDelReq | |
2930// | |------------->| |
2931// | RESTSubDelResp| | |
2932// |<----------------| | |
2933// | | SubDelResp | |
2934// | |<-------------| |
2935// | | | |
2936//
2937//-----------------------------------------------------------------------------
2938
2939func TestRESTSubReqRetransmissionV2(t *testing.T) {
2940 CaseBegin("TestRESTSubReqRetransmissionV2")
2941
2942 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2943 Counter{cRestSubReqFromXapp, 3},
2944 Counter{cRestSubRespToXapp, 3},
2945 Counter{cSubReqToE2, 1},
2946 Counter{cSubRespFromE2, 1},
2947 Counter{cRestSubNotifToXapp, 3},
2948 Counter{cRestSubDelReqFromXapp, 1},
2949 Counter{cSubDelReqToE2, 1},
2950 Counter{cSubDelRespFromE2, 1},
2951 Counter{cRestSubDelRespToXapp, 1},
2952 })
2953
2954 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2955
2956 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2957
2958 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2959
2960 //1.st resend
2961 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2962
2963 assert.Equal(t, restSubId_resend, restSubId)
2964
2965 <-time.After(100 * time.Millisecond)
2966
2967 //2.nd resend
2968 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2969
2970 assert.Equal(t, restSubId_resend2, restSubId)
2971
2972 <-time.After(100 * time.Millisecond)
2973
2974 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2975
2976 waitSubsCleanup(t, e2SubsId, 10)
2977
2978 //Wait that subs is cleaned
2979 mainCtrl.VerifyCounterValues(t)
2980}
2981
2982//-----------------------------------------------------------------------------
2983// stub stub stub
2984// +-------+ +---------+ +---------+ +---------+
2985// | xapp | | submgr | | e2term | | rtmgr |
2986// +-------+ +---------+ +---------+ +---------+
2987// | | | |
2988// | RESTSubReq | | |
2989// |---------------->| | |
2990// | RESTSubResp | | |
2991// |<----------------| | |
2992// | | RouteCreate | |
2993// | |--------------------------->|
2994// | | RouteResponse| |
2995// | |<---------------------------| // The order of these events may vary
2996// | | SubReq | |
2997// | |------------->| | // The order of these events may vary
2998// | | SubResp | |
2999// | |<-------------| |
3000// | RESTNotif1 | | |
3001// |<----------------| | |
3002// | RESTSubReq | | |
3003// | [RETRANS, with RESTsubsId] | |
3004// |---------------->| | |
3005// | RESTNotif1 | | |
3006// |<----------------| | |
3007// | RESTSubReq | | |
3008// | [RETRANS, without RESTsubsId] | |
3009// |---------------->| | |
3010// | RESTNotif1 | | |
3011// |<----------------| | |
3012// | RESTSubDelReq | | |
3013// |---------------->| | |
3014// | | SubDelReq | |
3015// | |------------->| |
3016// | RESTSubDelResp| | |
3017// |<----------------| | |
3018// | | SubDelResp | |
3019// | |<-------------| |
3020// | | | |
3021//
3022//-----------------------------------------------------------------------------
3023func TestRESTSubReqRetransmissionV3(t *testing.T) {
3024 CaseBegin("TestRESTSubReqRetransmissionV3")
3025
3026 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3027 Counter{cRestSubReqFromXapp, 3},
3028 Counter{cRestSubRespToXapp, 3},
3029 Counter{cSubReqToE2, 1},
3030 Counter{cSubRespFromE2, 1},
3031 Counter{cRestSubNotifToXapp, 3},
3032 Counter{cRestSubDelReqFromXapp, 1},
3033 Counter{cSubDelReqToE2, 1},
3034 Counter{cSubDelRespFromE2, 1},
3035 Counter{cRestSubDelRespToXapp, 1},
3036 })
3037
3038 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3039
3040 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3041
3042 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3043
3044 <-time.After(100 * time.Millisecond)
3045
3046 //1.st resend with subscription ID
3047 params.SetSubscriptionID(&restSubId)
3048 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3049
3050 assert.Equal(t, restSubId_resend, restSubId)
3051
3052 <-time.After(100 * time.Millisecond)
3053
3054 //2.nd resend without subscription ID (faking app restart)
3055 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3056 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3057
3058 assert.Equal(t, restSubId_resend2, restSubId)
3059
3060 <-time.After(100 * time.Millisecond)
3061
3062 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3063
3064 waitSubsCleanup(t, e2SubsId, 10)
3065
3066 //Wait that subs is cleaned
3067 mainCtrl.VerifyCounterValues(t)
3068}
3069
3070//-----------------------------------------------------------------------------
3071// stub stub stub
3072// +-------+ +---------+ +---------+ +---------+
3073// | xapp | | submgr | | e2term | | rtmgr |
3074// +-------+ +---------+ +---------+ +---------+
3075// | | | |
3076// | RESTSubReq | | |
3077// |---------------->| | |
3078// | RESTSubResp | | |
3079// |<----------------| | |
3080// | | RouteCreate | |
3081// | |--------------------------->|
3082// | | RouteResponse| |
3083// | |<---------------------------|
3084// | | SubReq | |
3085// | |------------->| |
3086// | | SubResp | |
3087// | |<-------------| |
3088// | RESTNotif1 | | |
3089// |<----------------| | |
3090// | RESTSubReq | | |
3091// | [with RestSUbsId + one additional e2 subDetail]
3092// |---------------->| | |
3093// | RESTNotif1 | | |
3094// | [for initial e2 subDetail] | |
3095// |<----------------| | |
3096// | | RouteCreate | |
3097// | |--------------------------->|
3098// | | RouteResponse| |
3099// | |<---------------------------|
3100// | | SubReq | |
3101// | |------------->| |
3102// | | SubResp | |
3103// | |<-------------| |
3104// | RESTNotif1 | | |
3105// |<----------------| | |
3106// | RESTSubReq | | |
3107// | [with RESTsubsId initial request] |
3108// |---------------->| | |
3109// | RESTNotif1 | | |
3110// |<----------------| | |
3111// | RESTSubDelReq | | |
3112// |---------------->| | |
3113// | RESTSubDelResp| | |
3114// |<----------------| | |
3115// | | SubDelReq | |
3116// | |------------->| |
3117// | | SubDelResp | |
3118// | |<-------------| |
3119// | | SubDelReq | |
3120// | |------------->| |
3121// | | SubDelResp | |
3122// | |<-------------| |
3123// | | | |
3124//
3125//-----------------------------------------------------------------------------
3126
3127func TestRESTSubReqRetransmissionV4(t *testing.T) {
3128 CaseBegin("TestRESTSubReqRetransmissionV4")
3129
3130 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3131 Counter{cRestSubReqFromXapp, 3},
3132 Counter{cRestSubRespToXapp, 3},
3133 Counter{cSubReqToE2, 2},
3134 Counter{cSubRespFromE2, 2},
3135 Counter{cRestSubNotifToXapp, 4},
3136 Counter{cRestSubDelReqFromXapp, 1},
3137 Counter{cSubDelReqToE2, 2},
3138 Counter{cSubDelRespFromE2, 2},
3139 Counter{cRestSubDelRespToXapp, 1},
3140 })
3141
3142 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3143
3144 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3145
3146 <-time.After(100 * time.Millisecond)
3147
3148 // Send modified requst, this time with e2 subscriptions.
3149 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3150 params2.SetSubscriptionID(&restSubId)
3151
3152 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003153 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003154 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3155 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003156 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3157 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003158
3159 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3160
Markku Virtanen2b512b62021-07-30 12:04:00 +00003161 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003162 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3163 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3164 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3165 assert.NotEqual(t, e2SubsId2, 0)
3166
3167 <-time.After(100 * time.Millisecond)
3168
3169 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3170 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3171 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003172 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003173 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3174 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3175 assert.Equal(t, restSubId_resend, restSubId_resend2)
3176
Markku Virtanen2b512b62021-07-30 12:04:00 +00003177 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3178 assert.Equal(t, e2SubsId, e2SubsId1)
3179
Markku Virtanen42723e22021-06-15 10:09:23 +03003180 // Delete both e2 subscriptions
3181 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3182 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3183 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3184
3185 waitSubsCleanup(t, e2SubsId, 10)
3186
3187 //Wait that subs is cleaned
3188 mainCtrl.VerifyCounterValues(t)
3189}
3190
3191//-----------------------------------------------------------------------------
3192// stub stub stub
3193// +-------+ +---------+ +---------+ +---------+
3194// | xapp | | submgr | | e2term | | rtmgr |
3195// +-------+ +---------+ +---------+ +---------+
3196// | | | |
3197// | RESTSubReq | | |
3198// |---------------->| | |
3199// | RESTSubResp | | |
3200// |<----------------| | |
3201// | | RouteCreate | |
3202// | |--------------------------->|
3203// | | RouteResponse| |
3204// | |<---------------------------|
3205// | | SubReq | |
3206// | |------------->| |
3207// | | SubResp | |
3208// | |<-------------| |
3209// | RESTNotif1 | | |
3210// |<----------------| | |
3211// | RESTSubReq | | |
3212// | [with RestSUbsId + one additional e2 subDetail]
3213// |---------------->| | |
3214// | RESTNotif1 | | |
3215// | [for initial e2 subDetail] | |
3216// |<----------------| | |
3217// | | RouteCreate | |
3218// | |--------------------------->|
3219// | | RouteResponse| |
3220// | |<---------------------------|
3221// | | SubReq | |
3222// | |------------->| |
3223// | | SubResp | |
3224// | |<-------------| |
3225// | RESTNotif1 | | |
3226// |<----------------| | |
3227// | RESTSubReq | | |
3228// | [without RESTsubsId initial request] |
3229// |---------------->| | |
3230// | RESTNotif1 | | |
3231// |<----------------| | |
3232// | RESTSubDelReq | | |
3233// |---------------->| | |
3234// | RESTSubDelResp| | |
3235// |<----------------| | |
3236// | | SubDelReq | |
3237// | |------------->| |
3238// | | SubDelResp | |
3239// | |<-------------| |
3240// | | SubDelReq | |
3241// | |------------->| |
3242// | | SubDelResp | |
3243// | |<-------------| |
3244// | | | |
3245//
3246//-----------------------------------------------------------------------------
3247
3248func TestRESTSubReqRetransmissionV5(t *testing.T) {
3249 CaseBegin("TestRESTSubReqRetransmissionV5")
3250
3251 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3252 Counter{cRestSubReqFromXapp, 3},
3253 Counter{cRestSubRespToXapp, 3},
3254 Counter{cSubReqToE2, 2},
3255 Counter{cSubRespFromE2, 2},
3256 Counter{cRestSubNotifToXapp, 4},
3257 Counter{cRestSubDelReqFromXapp, 1},
3258 Counter{cSubDelReqToE2, 2},
3259 Counter{cSubDelRespFromE2, 2},
3260 Counter{cRestSubDelRespToXapp, 1},
3261 })
3262
3263 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3264
3265 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3266
3267 <-time.After(100 * time.Millisecond)
3268
3269 // Send modified requst, this time with e2 subscriptions.
3270 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3271 params2.SetSubscriptionID(&restSubId)
3272
3273 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003274 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003275 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3276 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3277
Markku Virtanen2b512b62021-07-30 12:04:00 +00003278 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3279 assert.Equal(t, e2SubsId, e2SubsId1)
3280 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3281 xappConn1.DecrementRequestCount()
3282
Markku Virtanen42723e22021-06-15 10:09:23 +03003283 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3284
3285 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3286 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3287 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3288 assert.NotEqual(t, e2SubsId2, 0)
3289
3290 <-time.After(100 * time.Millisecond)
3291
3292 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3293 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003294 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003295 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3296 // md5sum shall find the original request
3297 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3298 assert.Equal(t, restSubId_resend, restSubId_resend2)
3299
Markku Virtanen2b512b62021-07-30 12:04:00 +00003300 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3301 assert.Equal(t, e2SubsId, e2SubsId1)
3302
Markku Virtanen42723e22021-06-15 10:09:23 +03003303 // Delete both e2 subscriptions
3304 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3305 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3306 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3307
3308 waitSubsCleanup(t, e2SubsId, 10)
3309
3310 //Wait that subs is cleaned
3311 mainCtrl.VerifyCounterValues(t)
3312}
3313
3314//-----------------------------------------------------------------------------
3315// stub stub stub
3316// +-------+ +---------+ +---------+ +---------+
3317// | xapp | | submgr | | e2term | | rtmgr |
3318// +-------+ +---------+ +---------+ +---------+
3319// | | | |
3320// | RESTSubReq | | |
3321// |---------------->| | |
3322// | RESTSubResp | | |
3323// |<----------------| | |
3324// | | RouteCreate | |
3325// | |--------------------------->|
3326// | | RouteResponse| |
3327// | |<---------------------------|
3328// | | SubReq | |
3329// | |------------->| |
3330// | | SubResp | |
3331// | |<-------------| |
3332// | RESTNotif1 | | |
3333// |<----------------| | |
3334// | RESTSubReq | | |
3335// | [with RestSUbsId + one additional e2 subDetail]
3336// |---------------->| | |
3337// | RESTNotif1 | | |
3338// | [for initial e2 subDetail] | |
3339// |<----------------| | |
3340// | | RouteCreate | |
3341// | |--------------------------->|
3342// | | RouteResponse| |
3343// | |<---------------------------|
3344// | | SubReq | |
3345// | |------------->| |
3346// | | SubResp | |
3347// | |<-------------| |
3348// | RESTNotif1 | | |
3349// |<----------------| | |
3350// | RESTSubDelReq | | |
3351// |---------------->| | |
3352// | RESTSubDelResp| | |
3353// |<----------------| | |
3354// | | SubDelReq | |
3355// | |------------->| |
3356// | | SubDelResp | |
3357// | |<-------------| |
3358// | | SubDelReq | |
3359// | |------------->| |
3360// | | SubDelResp | |
3361// | |<-------------| |
3362// | RESTSubReq | | |
3363// | [with RESTsubsId initial request] |
3364// |---------------->| | |
3365// | RESTSubResp | | |
3366// |<----------------| | |
3367// | | RouteCreate | |
3368// | |--------------------------->|
3369// | | RouteResponse| |
3370// | |<---------------------------|
3371// | | SubReq | |
3372// | |------------->| |
3373// | | SubResp | |
3374// | |<-------------| |
3375// | RESTNotif1 | | |
3376// |<----------------| | |
3377// | | | |
3378//
3379//-----------------------------------------------------------------------------
3380func TestRESTSubReqRetransmissionV6(t *testing.T) {
3381 CaseBegin("TestRESTSubReqRetransmissionV6")
3382
3383 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3384 Counter{cRestSubReqFromXapp, 3},
3385 Counter{cRestSubRespToXapp, 3},
3386 Counter{cSubReqToE2, 3},
3387 Counter{cSubRespFromE2, 3},
3388 Counter{cRestSubNotifToXapp, 4},
3389 Counter{cRestSubDelReqFromXapp, 2},
3390 Counter{cSubDelReqToE2, 3},
3391 Counter{cSubDelRespFromE2, 3},
3392 Counter{cRestSubDelRespToXapp, 2},
3393 })
3394
3395 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3396
3397 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3398
3399 <-time.After(100 * time.Millisecond)
3400
3401 // Send modified requst, this time with e2 subscriptions.
3402 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3403 params2.SetSubscriptionID(&restSubId)
3404
3405 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003406 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003407 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3408 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3409
Markku Virtanen2b512b62021-07-30 12:04:00 +00003410 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3411 assert.Equal(t, e2SubsId, e2SubsId1)
3412
Markku Virtanen42723e22021-06-15 10:09:23 +03003413 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3414
3415 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3416 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3417 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3418 assert.NotEqual(t, e2SubsId2, 0)
3419
3420 <-time.After(100 * time.Millisecond)
3421
3422 // Delete both e2 subscriptions
3423 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3424 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3425 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3426
3427 waitSubsCleanup(t, e2SubsId, 10)
3428
3429 // Resend the original request, we shall find it's previous md5sum/restsubs
3430 // but the restsubscription has been already removed. This shall trigger a
3431 // fresh create.
3432 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3433
3434 <-time.After(100 * time.Millisecond)
3435
3436 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3437
3438 waitSubsCleanup(t, e2SubsId, 10)
3439
3440 //Wait that subs is cleaned
3441 mainCtrl.VerifyCounterValues(t)
3442}
3443
archaggeafbf95f2021-04-14 08:54:05 +03003444func TestRESTSubDelReqRetransmission(t *testing.T) {
3445 CaseBegin("TestRESTSubDelReqRetransmission")
3446
3447 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003448 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003449 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003450 Counter{cSubReqToE2, 1},
3451 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003452 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003453 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003454 Counter{cSubDelReqToE2, 1},
3455 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003456 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003457 })
3458
3459 var params *teststube2ap.RESTSubsReqParams = nil
3460
3461 //Subs Create
3462 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3463
3464 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3465
3466 //Subs Delete
3467 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3468 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3469
3470 seqBef := mainCtrl.get_msgcounter(t)
3471 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3472 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3473
3474 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3475
3476 waitSubsCleanup(t, e2SubsId, 10)
3477
3478 mainCtrl.VerifyCounterValues(t)
3479}
3480
3481//-----------------------------------------------------------------------------
3482// TestRESTSubReqDelReq
3483//
3484// stub stub
3485// +-------+ +---------+ +---------+
3486// | xapp | | submgr | | e2term |
3487// +-------+ +---------+ +---------+
3488// | | |
3489// | RESTSubReq | |
3490// |---------------->| |
3491// | | |
3492// | RESTSubResp | |
3493// |<----------------| |
3494// | | SubReq |
3495// | |------------->|
3496// | RESTSubDelReq | |
3497// |---------------->| |
3498// | RESTSubDelResp | |
3499// | unsuccess | |
3500// |<----------------| |
3501// | | SubResp |
3502// | |<-------------|
3503// | RESTNotif1 | |
3504// |<----------------| |
3505// | | |
3506// | [SUBS DELETE] |
3507// | | |
3508//
3509//-----------------------------------------------------------------------------
3510func TestRESTSubReqDelReq(t *testing.T) {
3511 CaseBegin("TestRESTSubReqDelReq")
3512
3513 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003514 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003515 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003516 Counter{cSubReqToE2, 1},
3517 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003518 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003519 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003520 Counter{cSubDelReqToE2, 1},
3521 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003522 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003523 })
3524
3525 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003526
3527 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003528 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003529 restSubId := xappConn1.SendRESTSubsReq(t, params)
3530
3531 // Del. This will fail as processing of the subscription
3532 // is still ongoing in submgr. Deletion is not allowed before
3533 // subscription creation has been completed.
3534 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3535 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3536 xappConn1.ExpectRESTNotification(t, restSubId)
3537 e2termConn1.SendSubsResp(t, crereq, cremsg)
3538 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3539
3540 // Retry del
3541 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3542
3543 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3544 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3545
3546 // Wait that subs is cleaned
3547 waitSubsCleanup(t, e2SubsId, 10)
3548 mainCtrl.VerifyCounterValues(t)
3549
3550}
3551
3552func TestRESTSubDelReqCollision(t *testing.T) {
3553 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3554}
3555
3556func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3557 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3558
3559 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003560 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003561 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003562 Counter{cSubReqToE2, 2},
3563 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003564 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003565 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003566 Counter{cSubDelReqToE2, 2},
3567 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003568 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003569 })
3570
3571 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003572 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003573 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003574 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003575
3576 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003577 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003578 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003579 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003580
3581 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3582 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3583
3584 //XappConn1 receives both of the responses
3585 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3586
3587 //Resp1
3588 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3589 //Resp2
3590 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3591
3592 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003593 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003594 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003595 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003596
3597 //Del1
3598 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3599 //Del2
3600 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3601
3602 //Wait that subs is cleaned
3603 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3604 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3605
3606 mainCtrl.VerifyCounterValues(t)
3607
3608}
3609
3610func TestRESTSameSubsDiffRan(t *testing.T) {
3611 CaseBegin("TestRESTSameSubsDiffRan")
3612
3613 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003614 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003615 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003616 Counter{cSubReqToE2, 2},
3617 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003618 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003619 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003620 Counter{cSubDelReqToE2, 2},
3621 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003622 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003623 })
3624
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003625 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003626 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003627 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003628
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003629 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003630 params.SetMeid("RAN_NAME_2")
3631 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003632 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003633
3634 //Del1
3635 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3636 //Del2
3637 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3638
3639 //Wait that subs is cleaned
3640 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3641 waitSubsCleanup(t, e2SubsId2, 10)
3642
3643 mainCtrl.VerifyCounterValues(t)
3644
3645}
3646
3647func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3648 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3649
3650 // Init counter check
3651 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003652 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003653 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003654 Counter{cSubReqToE2, 1},
3655 Counter{cSubReReqToE2, 1},
3656 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003657 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003658 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003659 Counter{cSubDelReqToE2, 1},
3660 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003661 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003662 })
3663
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003664 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003665 restSubId := xappConn1.SendRESTSubsReq(t, params)
3666
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003667 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003668
3669 // Catch the first message and ignore it
3670 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003671 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003672
3673 // The second request is being handled normally
3674 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3675 xappConn1.ExpectRESTNotification(t, restSubId)
3676 e2termConn1.SendSubsResp(t, crereq, cremsg)
3677 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3678
3679 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3680
3681 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3682
3683 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3684 //Wait that subs is cleaned
3685 waitSubsCleanup(t, e2SubsId, 10)
3686
3687 mainCtrl.VerifyCounterValues(t)
3688
3689}
3690
3691//-----------------------------------------------------------------------------
3692// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3693//
3694// stub stub
3695// +-------+ +---------+ +---------+
3696// | xapp | | submgr | | e2term |
3697// +-------+ +---------+ +---------+
3698// | | |
3699// | RESTSubReq | |
3700// |---------------->| |
3701// | | |
3702// | RESTSubResp | |
3703// |<----------------| |
3704// | | SubReq |
3705// | |------------->|
3706// | | |
3707// | | |
3708// | | SubReq |
3709// | |------------->|
3710// | | |
3711// | | SubDelReq |
3712// | |------------->|
3713// | | |
3714// | | |
3715// | | SubDelReq |
3716// | |------------->|
3717// | | |
3718// | | |
3719// | | SubDelResp |
3720// | |<-------------|
3721// | RESTNotif | |
3722// | unsuccess | |
3723// |<----------------| |
3724// | | |
3725// | [SUBS DELETE] |
3726// | | |
3727//
3728//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003729
archaggeafbf95f2021-04-14 08:54:05 +03003730func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3731 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3732
3733 // Init counter check
3734 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003735 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003736 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003737 Counter{cSubReqToE2, 1},
3738 Counter{cSubReReqToE2, 1},
3739 Counter{cSubReqTimerExpiry, 2},
3740 Counter{cSubDelReqToE2, 1},
3741 Counter{cSubDelRespFromE2, 1},
3742 })
3743
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003744 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003745 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003746 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003747
3748 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003749 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003750
3751 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003752 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003753
3754 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003755 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003756 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003757 xappConn1.WaitRESTNotification(t, restSubId)
3758
3759 // Wait that subs is cleaned
3760 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
3761
3762 mainCtrl.VerifyCounterValues(t)
3763}
3764
3765func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3766 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3767
3768 // Init counter check
3769 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003770 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003771 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003772 Counter{cSubReqToE2, 1},
3773 Counter{cSubReReqToE2, 1},
3774 Counter{cSubReqTimerExpiry, 2},
3775 Counter{cSubDelReqToE2, 1},
3776 Counter{cSubDelReqTimerExpiry, 2},
3777 })
3778
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003779 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003780 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003781 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003782
3783 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003784 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003785
3786 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003787 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003788
3789 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003790 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003791
Markku Virtanen55d2a282021-06-04 14:46:56 +03003792 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003793 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003794 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003795
3796 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3797
3798 waitSubsCleanup(t, e2SubsId, 10)
3799
3800 mainCtrl.VerifyCounterValues(t)
3801
3802}
3803
3804//-----------------------------------------------------------------------------
3805// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3806//
3807// stub stub
3808// +-------+ +---------+ +---------+
3809// | xapp | | submgr | | e2term |
3810// +-------+ +---------+ +---------+
3811// | | |
3812// | RESTSubReq | |
3813// |---------------->| |
3814// | | |
3815// | RESTSubResp | |
3816// |<----------------| |
3817// | | SubReq |
3818// | |------------->|
3819// | | |
3820// | | |
3821// | | SubReq |
3822// | |------------->|
3823// | | |
3824// | | SubDelReq |
3825// | |------------->|
3826// | | |
3827// | | |
3828// | | SubDelReq |
3829// | |------------->|
3830// | | |
3831// | | |
3832// | | SubDelResp |
3833// | |<-------------|
3834// | RESTNotif | |
3835// | unsuccess | |
3836// |<----------------| |
3837// | | |
3838// | [SUBS DELETE] |
3839// | | |
3840//
3841//-----------------------------------------------------------------------------
3842func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3843 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3844
3845 // Init counter check
3846 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003847 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003848 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003849 Counter{cSubReqToE2, 1},
3850 Counter{cSubReReqToE2, 1},
3851 Counter{cSubReqTimerExpiry, 2},
3852 Counter{cSubDelReqToE2, 1},
3853 Counter{cSubDelReReqToE2, 1},
3854 Counter{cSubDelReqTimerExpiry, 2},
3855 })
3856
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003857 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003858 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003859 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003860
3861 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003862 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003863
3864 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003865 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003866
3867 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003868 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003869
Markku Virtanen55d2a282021-06-04 14:46:56 +03003870 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003871 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003872 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003873
3874 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3875
3876 waitSubsCleanup(t, e2SubsId, 10)
3877
3878 mainCtrl.VerifyCounterValues(t)
3879}
3880
3881//-----------------------------------------------------------------------------
3882// TestRESTSubReqSubFailRespInSubmgr
3883//
3884// stub stub
3885// +-------+ +---------+ +---------+
3886// | xapp | | submgr | | e2term |
3887// +-------+ +---------+ +---------+
3888// | | |
3889// | RESTSubReq | |
3890// |---------------->| |
3891// | | |
3892// | RESTSubResp | |
3893// |<----------------| |
3894// | | SubReq |
3895// | |------------->|
3896// | | |
3897// | | SubFail |
3898// | |<-------------|
3899// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003900// | RESTNotif | |
3901// | unsuccess | |
3902// |<----------------| |
3903// | | |
3904// | [SUBS DELETE] |
3905// | | |
3906//
3907//-----------------------------------------------------------------------------
3908func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3909 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3910
3911 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003912 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003913 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003914 Counter{cSubReqToE2, 1},
3915 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003916 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003917 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003918 })
3919
3920 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003921 const e2Timeout int64 = 2
3922 const e2RetryCount int64 = 1
3923 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03003924
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003925 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003926 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03003927 restSubId := xappConn1.SendRESTSubsReq(t, params)
3928
3929 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3930 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3931 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02003932 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003933 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3934
archaggeafbf95f2021-04-14 08:54:05 +03003935 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003936 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003937
3938 // REST subscription sill there to be deleted
3939 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3940
3941 // Wait that subs is cleaned
3942 waitSubsCleanup(t, e2SubsId, 10)
3943
3944 mainCtrl.VerifyCounterValues(t)
3945
3946}
3947
3948//-----------------------------------------------------------------------------
3949// TestRESTSubDelReqRetryInSubmgr
3950//
3951// stub stub
3952// +-------+ +---------+ +---------+
3953// | xapp | | submgr | | e2term |
3954// +-------+ +---------+ +---------+
3955// | | |
3956// | [SUBS CREATE] |
3957// | | |
3958// | | |
3959// | RESTSubDelReq | |
3960// |---------------->| |
3961// | | |
3962// | RESTSubDelResp | |
3963// |<----------------| |
3964// | | SubDelReq |
3965// | |------------->|
3966// | | |
3967// | | SubDelReq |
3968// | |------------->|
3969// | | |
3970// | | SubDelResp |
3971// | |<-------------|
3972// | | |
3973//
3974//-----------------------------------------------------------------------------
3975func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3976 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3977
3978 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003979 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003980 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003981 Counter{cSubReqToE2, 1},
3982 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003983 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003984 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003985 Counter{cSubDelReqToE2, 1},
3986 Counter{cSubDelReReqToE2, 1},
3987 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003988 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003989 })
3990 // Req
3991 var params *teststube2ap.RESTSubsReqParams = nil
3992 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3993
3994 // Del
3995 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3996
3997 // E2t: Receive 1st SubsDelReq
3998 e2termConn1.RecvSubsDelReq(t)
3999
4000 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4001 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4002 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4003
4004 //Wait that subs is cleaned
4005 waitSubsCleanup(t, e2SubsId, 10)
4006
4007 mainCtrl.VerifyCounterValues(t)
4008}
4009
4010//-----------------------------------------------------------------------------
4011// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4012//
4013// stub stub
4014// +-------+ +---------+ +---------+
4015// | xapp | | submgr | | e2term |
4016// +-------+ +---------+ +---------+
4017// | | |
4018// | [SUBS CREATE] |
4019// | | |
4020// | | |
4021// | RESTSubDelReq | |
4022// |---------------->| |
4023// | | |
4024// | RESTSubDelResp | |
4025// |<----------------| |
4026// | | SubDelReq |
4027// | |------------->|
4028// | | |
4029// | | SubDelReq |
4030// | |------------->|
4031// | | |
4032// | | |
4033//
4034//-----------------------------------------------------------------------------
4035func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
4036 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
4037
4038 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004039 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004040 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004041 Counter{cSubReqToE2, 1},
4042 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004043 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004044 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004045 Counter{cSubDelReqToE2, 1},
4046 Counter{cSubDelReReqToE2, 1},
4047 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004048 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004049 })
4050
4051 // Req
4052 var params *teststube2ap.RESTSubsReqParams = nil
4053 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4054
4055 // Del
4056 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4057
4058 // E2t: Receive 1st SubsDelReq
4059 e2termConn1.RecvSubsDelReq(t)
4060
4061 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4062 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4063 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4064
4065 //Wait that subs is cleaned
4066 waitSubsCleanup(t, e2SubsId, 10)
4067
4068 mainCtrl.VerifyCounterValues(t)
4069}
4070
4071//-----------------------------------------------------------------------------
4072// TestRESTSubDelReqSubDelFailRespInSubmgr
4073//
4074// stub stub
4075// +-------+ +---------+ +---------+
4076// | xapp | | submgr | | e2term |
4077// +-------+ +---------+ +---------+
4078// | | |
4079// | [SUBS CREATE] |
4080// | | |
4081// | | |
4082// | RESTSubDelReq | |
4083// |---------------->| |
4084// | | |
4085// | RESTSubDelResp | |
4086// |<----------------| |
4087// | | SubDelReq |
4088// | |------------->|
4089// | | |
4090// | | SubDelFail |
4091// | |<-------------|
4092// | | |
4093//
4094//-----------------------------------------------------------------------------
4095func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
4096 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
4097
4098 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004099 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004100 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004101 Counter{cSubReqToE2, 1},
4102 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004103 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004104 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004105 Counter{cSubDelReqToE2, 1},
4106 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004107 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004108 })
4109
4110 // Req
4111 var params *teststube2ap.RESTSubsReqParams = nil
4112 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4113
4114 // Del
4115 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4116
4117 // E2t: Send receive SubsDelReq and send SubsDelFail
4118 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4119 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4120
4121 //Wait that subs is cleaned
4122 waitSubsCleanup(t, e2SubsId, 10)
4123
4124 mainCtrl.VerifyCounterValues(t)
4125}
4126
4127//-----------------------------------------------------------------------------
4128// TestRESTSubReqAndSubDelOkSameAction
4129//
4130// stub stub
4131// +-------+ +-------+ +---------+ +---------+
4132// | xapp2 | | xapp1 | | submgr | | e2term |
4133// +-------+ +-------+ +---------+ +---------+
4134// | | | |
4135// | | RESTSubReq1 | |
4136// | |---------------->| |
4137// | | | |
4138// | | RESTSubResp1 | |
4139// | |<----------------| |
4140// | | | |
4141// | | | SubReq1 |
4142// | | |------------->|
4143// | | | SubResp1 |
4144// | | |<-------------|
4145// | | RESTNotif1 | |
4146// | |<----------------| |
4147// | | | |
4148// | RESTSubReq2 | |
4149// |------------------------------>| |
4150// | | | |
4151// | RESTSubResp2 | |
4152// |<------------------------------| |
4153// | | | |
4154// | | RESTNotif2 | |
4155// |<------------------------------| |
4156// | | | |
4157// | | RESTSubDelReq1 | |
4158// | |---------------->| |
4159// | | | |
4160// | | RESTSubDelResp1 | |
4161// | |<----------------| |
4162// | | | |
4163// | RESTSubDelReq2 | |
4164// |------------------------------>| |
4165// | | | |
4166// | RESTSubDelResp2 | |
4167// |<------------------------------| |
4168// | | | |
4169// | | | SubDelReq2 |
4170// | | |------------->|
4171// | | | |
4172// | | | SubDelResp2 |
4173// | | |<-------------|
4174// | | | |
4175//
4176//-----------------------------------------------------------------------------
4177func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
4178 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
4179
4180 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004181 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004182 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004183 Counter{cSubReqToE2, 1},
4184 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004185 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004186 Counter{cMergedSubscriptions, 1},
4187 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004188 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004189 Counter{cSubDelReqToE2, 1},
4190 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004191 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004192 })
4193
4194 // Req1
4195 var params *teststube2ap.RESTSubsReqParams = nil
4196
4197 //Subs Create
4198 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4199 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4200
4201 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004202 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004203 params.SetMeid("RAN_NAME_1")
4204
4205 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004206 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004207 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004208 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004209 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004210 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004211 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004212 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004213
4214 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4215
4216 // Del1
4217 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4218
4219 // Del2
4220 deleteXapp2Subscription(t, &restSubId2)
4221
4222 //Wait that subs is cleaned
4223 waitSubsCleanup(t, e2SubsId2, 10)
4224
4225 mainCtrl.VerifyCounterValues(t)
4226}
4227
4228//-----------------------------------------------------------------------------
4229// TestSubReqAndSubDelOkSameActionParallel
4230//
4231// stub stub stub
4232// +-------+ +-------+ +---------+ +---------+
4233// | xapp2 | | xapp1 | | submgr | | e2term |
4234// +-------+ +-------+ +---------+ +---------+
4235// | | | |
4236// | | | |
4237// | | | |
4238// | | SubReq1 | |
4239// | |------------->| |
4240// | | | |
4241// | | | SubReq1 |
4242// | | |------------->|
4243// | SubReq2 | |
4244// |--------------------------->| |
4245// | | | SubResp1 |
4246// | | |<-------------|
4247// | | SubResp1 | |
4248// | |<-------------| |
4249// | | | SubReq2 |
4250// | | |------------->|
4251// | | | |
4252// | | | SubResp2 |
4253// | | |<-------------|
4254// | SubResp2 | |
4255// |<---------------------------| |
4256// | | | |
4257// | | SubDelReq 1 | |
4258// | |------------->| |
4259// | | | |
4260// | | SubDelResp 1 | |
4261// | |<-------------| |
4262// | | | |
4263// | SubDelReq 2 | |
4264// |--------------------------->| |
4265// | | | |
4266// | | | SubDelReq 2 |
4267// | | |------------->|
4268// | | | |
4269// | | | SubDelReq 2 |
4270// | | |------------->|
4271// | | | |
4272// | SubDelResp 2 | |
4273// |<---------------------------| |
4274//
4275func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4276 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4277
4278 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004279 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004280 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004281 Counter{cSubReqToE2, 2},
4282 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004283 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004284 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004285 Counter{cSubDelReqToE2, 2},
4286 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004287 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004288 })
4289
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004290 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004291 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4292 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4293
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004294 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004295 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4296
4297 xappConn1.ExpectRESTNotification(t, restSubId1)
4298 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4299 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4300
4301 xappConn2.ExpectRESTNotification(t, restSubId2)
4302 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4303 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4304 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4305
4306 // Del1
4307 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4308 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4309 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4310 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4311
4312 // Del2
4313 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4314 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4315 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4316
4317 waitSubsCleanup(t, e2SubsId2, 10)
4318
4319 mainCtrl.VerifyCounterValues(t)
4320}
4321
4322//-----------------------------------------------------------------------------
4323// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4324//
4325// stub stub stub
4326// +-------+ +-------+ +---------+ +---------+
4327// | xapp2 | | xapp1 | | submgr | | e2term |
4328// +-------+ +-------+ +---------+ +---------+
4329// | | | |
4330// | | | |
4331// | | | |
4332// | | RESTSubReq1 | |
4333// | |---------------->| |
4334// | | | |
4335// | | RESTSubResp1 | |
4336// | |<----------------| |
4337// | | | SubReq1 |
4338// | | |------------->|
4339// | RESTSubReq2 | |
4340// |------------------------------>| |
4341// | | | |
4342// | RESTSubDelResp2 | |
4343// |<------------------------------| |
4344// | | | SubReq1 |
4345// | | |------------->|
4346// | | | |
4347// | | | |
4348// | | | SubDelReq |
4349// | | |------------->|
4350// | | | |
4351// | | | SubDelResp |
4352// | | |<-------------|
4353// | | RESTNotif1 | |
4354// | | unsuccess | |
4355// | |<----------------| |
4356// | RESTNotif2 | |
4357// | | unsuccess | |
4358// |<------------------------------| |
4359// | | | |
4360// | | RESTSubDelReq1 | |
4361// | |---------------->| |
4362// | | | |
4363// | | RESTSubDelResp1 | |
4364// | |<----------------| |
4365// | | | |
4366// | RESTSubDelReq2 | |
4367// |------------------------------>| |
4368// | | | |
4369// | RESTSubDelResp2 | |
4370// |<------------------------------| |
4371//
4372//-----------------------------------------------------------------------------
4373func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4374 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4375
4376 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004377 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004378 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004379 Counter{cSubReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004380 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004381 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004382 Counter{cSubDelReqToE2, 1},
4383 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004384 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004385 })
4386
4387 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004388
4389 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004390 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004391 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4392 crereq1, _ := e2termConn1.RecvSubsReq(t)
4393
4394 // Req2
4395 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004396 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004397 params2.SetMeid("RAN_NAME_1")
4398 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4399 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4400
4401 //Req1 (retransmitted)
4402 e2termConn1.RecvSubsReq(t)
4403
4404 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004405
4406 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004407 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4408
Markku Virtanenda34eec2021-05-20 08:22:04 +00004409 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004410 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004411 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004412 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004413
4414 // Del1
4415 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4416
4417 // Del2
4418 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4419
Markku Virtanenda34eec2021-05-20 08:22:04 +00004420 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4421
archaggeafbf95f2021-04-14 08:54:05 +03004422 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004423 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004424
4425 mainCtrl.VerifyCounterValues(t)
4426}
4427
4428//-----------------------------------------------------------------------------
4429// TestRESTSubReqAndSubDelNokSameActionParallel
4430//
4431// stub stub stub
4432// +-------+ +-------+ +---------+ +---------+
4433// | xapp2 | | xapp1 | | submgr | | e2term |
4434// +-------+ +-------+ +---------+ +---------+
4435// | | | |
4436// | | | |
4437// | | | |
4438// | | RESTSubReq1 | |
4439// | |---------------->| |
4440// | | | |
4441// | | RESTSubResp1 | |
4442// | |<----------------| |
4443// | | | SubReq1 |
4444// | | |------------->|
4445// | RESTSubReq2 | |
4446// |------------------------------>| |
4447// | | | |
4448// | RESTSubDelResp2 | |
4449// |<------------------------------| |
4450// | | | SubFail1 |
4451// | | |<-------------|
4452// | | | |
4453// | | RESTNotif1 | |
4454// | | unsuccess | |
4455// | |<----------------| |
4456// | RESTNotif2 | |
4457// | | unsuccess | |
4458// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03004459// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02004460// | | RESTSubDelReq1 | | There is no need for xApp to send delete for failed subscriptions but some xApp might do so.
archaggeafbf95f2021-04-14 08:54:05 +03004461// | |---------------->| |
4462// | | | |
4463// | | RESTSubDelResp1 | |
4464// | |<----------------| |
4465// | | | |
4466// | RESTSubDelReq2 | |
4467// |------------------------------>| |
4468// | | | |
4469// | RESTSubDelResp2 | |
4470// |<------------------------------| |
4471//
4472//-----------------------------------------------------------------------------
4473func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4474 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4475
4476 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004477 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004478 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004479 Counter{cSubReqToE2, 1},
4480 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004481 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004482 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004483 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004484 })
4485
4486 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004487
4488 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004489 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004490 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4491 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4492
4493 // Req2
4494 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004495 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004496 params2.SetMeid("RAN_NAME_1")
4497 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4498 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4499
4500 // E2t: send SubsFail (first)
4501 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4502 fparams1.Set(crereq1)
4503 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4504
archaggeafbf95f2021-04-14 08:54:05 +03004505 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004506 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004507 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004508 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004509 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004510
4511 // Del1
4512 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4513
4514 // Del2
4515 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4516
4517 //Wait that subs is cleaned
4518 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4519 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4520
4521 mainCtrl.VerifyCounterValues(t)
4522}
4523
4524func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4525 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4526
4527 // Init counter check
4528 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004529 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004530 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004531 Counter{cSubReqToE2, 1},
4532 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004533 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004534 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004535 Counter{cSubDelReqToE2, 1},
4536 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004537 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004538 })
4539
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004540 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004541 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004542 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004543
4544 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4545 xappConn1.ExpectRESTNotification(t, restSubId)
4546 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4547 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004548 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004549
4550 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4551 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4552 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4553
4554 // Wait that subs is cleaned
4555 waitSubsCleanup(t, e2SubsId, 10)
4556 mainCtrl.VerifyCounterValues(t)
4557}
4558
4559//-----------------------------------------------------------------------------
4560// TestRESTSubReqPolicyChangeAndSubDelOk
4561//
4562// stub stub
4563// +-------+ +---------+ +---------+
4564// | xapp | | submgr | | e2term |
4565// +-------+ +---------+ +---------+
4566// | | |
4567// | RESTSubReq | |
4568// |---------------->| |
4569// | | |
4570// | RESTSubResp | |
4571// |<----------------| |
4572// | | SubReq |
4573// | |------------->|
4574// | | |
4575// | | SubResp |
4576// | |<-------------|
4577// | | |
4578// | RESTNotif | |
4579// |<----------------| |
4580// | | |
4581// | RESTSubReq | |
4582// |---------------->| |
4583// | | |
4584// | RESTSubResp | |
4585// |<----------------| |
4586// | | SubReq |
4587// | |------------->|
4588// | | |
4589// | | SubResp |
4590// | |<-------------|
4591// | | |
4592// | RESTNotif | |
4593// |<----------------| |
4594// | | |
4595// | RESTSubDelReq | |
4596// |---------------->| |
4597// | | |
4598// | | SubDelReq |
4599// | |------------->|
4600// | | |
4601// | | SubDelResp |
4602// | |<-------------|
4603// | | |
4604// | RESTSubDelResp | |
4605// |<----------------| |
4606//
4607//-----------------------------------------------------------------------------
4608func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4609 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4610
4611 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004612 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004613 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004614 Counter{cSubReqToE2, 2},
4615 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004616 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004617 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004618 Counter{cSubDelReqToE2, 1},
4619 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004620 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004621 })
4622
4623 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004624 const e2Timeout int64 = 1
4625 const e2RetryCount int64 = 0
4626 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004627
4628 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004629 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004630 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004631 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4632
4633 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004634 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004635
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004636 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004637 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004638 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004639 params.SetTimeToWait("w200ms")
4640 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4641
4642 // Del
4643 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4644
4645 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4646 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4647
4648 // Wait that subs is cleaned
4649 waitSubsCleanup(t, e2SubsId, 10)
4650 mainCtrl.VerifyCounterValues(t)
4651}
4652
4653//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004654// TestRESTSubReqPolicyChangeNOk
4655//
4656// stub stub
4657// +-------+ +---------+ +---------+
4658// | xapp | | submgr | | e2term |
4659// +-------+ +---------+ +---------+
4660// | | |
4661// | RESTSubReq | |
4662// |---------------->| |
4663// | | |
4664// | RESTSubResp | |
4665// |<----------------| |
4666// | | SubReq |
4667// | |------------->|
4668// | | |
4669// | | SubResp |
4670// | |<-------------|
4671// | | |
4672// | RESTNotif | |
4673// |<----------------| |
4674// | | |
4675// | RESTSubReq | |
4676// |---------------->| |
4677// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004678// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004679// | | |
4680// | RESTSubDelReq | |
4681// |---------------->| |
4682// | | |
4683// | | SubDelReq |
4684// | |------------->|
4685// | | |
4686// | | SubDelResp |
4687// | |<-------------|
4688// | | |
4689// | RESTSubDelResp | |
4690// |<----------------| |
4691//
4692//-----------------------------------------------------------------------------
4693func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4694 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4695
4696 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4697 Counter{cRestSubReqFromXapp, 2},
4698 Counter{cRestSubRespToXapp, 1},
4699 Counter{cSubReqToE2, 1},
4700 Counter{cSubRespFromE2, 1},
4701 Counter{cRestSubNotifToXapp, 1},
4702 Counter{cRestSubFailToXapp, 1},
4703 Counter{cRestSubDelReqFromXapp, 1},
4704 Counter{cSubDelReqToE2, 1},
4705 Counter{cSubDelRespFromE2, 1},
4706 Counter{cRestSubDelRespToXapp, 1},
4707 })
4708
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004709 // Req
4710 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4711 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4712
4713 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004714 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4715
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004716 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004717 params.SetSubscriptionID(&restSubIdUpd)
4718 params.SetTimeToWait("w200ms")
4719
4720 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4721 assert.Equal(t, restSubId2, "")
4722
4723 // Del
4724 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4725
4726 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4727 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4728
4729 // Wait that subs is cleaned
4730 waitSubsCleanup(t, e2SubsId, 10)
4731 mainCtrl.VerifyCounterValues(t)
4732}
4733
4734//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004735// TestRESTSubReqAndSubDelOkTwoE2termParallel
4736//
4737// stub stub stub
4738// +-------+ +---------+ +---------+ +---------+
4739// | xapp | | submgr | | e2term1 | | e2term2 |
4740// +-------+ +---------+ +---------+ +---------+
4741// | | | |
4742// | | | |
4743// | | | |
4744// | RESTSubReq1 | | |
4745// |---------------->| | |
4746// | | | |
4747// | RESTSubResp1 | | |
4748// |<----------------| | |
4749// | | SubReq1 | |
4750// | |------------->| |
4751// | | | |
4752// | RESTSubReq2 | | |
4753// |---------------->| | |
4754// | | | |
4755// | RESTSubResp2 | | |
4756// |<----------------| | |
4757// | | SubReq2 | |
4758// | |---------------------------->|
4759// | | | |
4760// | | SubResp1 | |
4761// | |<-------------| |
4762// | RESTNotif1 | | |
4763// |<----------------| | |
4764// | | SubResp2 | |
4765// | |<----------------------------|
4766// | RESTNotif2 | | |
4767// |<----------------| | |
4768// | | | |
4769// | [SUBS 1 DELETE] | |
4770// | | | |
4771// | [SUBS 2 DELETE] | |
4772// | | | |
4773//
4774//-----------------------------------------------------------------------------
4775func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4776 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4777
4778 // Init counter check
4779 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004780 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004781 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004782 Counter{cSubReqToE2, 2},
4783 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004784 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004785 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004786 Counter{cSubDelReqToE2, 2},
4787 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004788 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004789 })
4790
4791 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004792
4793 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004794 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004795 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4796 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4797
4798 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004799 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004800 params.SetMeid("RAN_NAME_11")
4801 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4802 // would not work as notification would not be received
4803 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4804 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4805
4806 // Resp1
4807 xappConn1.ExpectRESTNotification(t, restSubId1)
4808 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4809 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004810 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004811
4812 // Resp2
4813 xappConn2.ExpectRESTNotification(t, restSubId2)
4814 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4815 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004816 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004817
4818 // Delete1
4819 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4820 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4821 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4822
4823 // Wait that subs is cleaned
4824 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4825
4826 // Delete2
4827 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4828 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4829 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4830
4831 // Wait that subs is cleaned
4832 waitSubsCleanup(t, e2SubsId2, 10)
4833
4834 mainCtrl.VerifyCounterValues(t)
4835}
4836
4837//-----------------------------------------------------------------------------
4838// TestRESTSubReqAsn1EncodeFail
4839//
4840// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4841// stub stub
4842// +-------+ +---------+ +---------+
4843// | xapp | | submgr | | e2term |
4844// +-------+ +---------+ +---------+
4845// | | |
4846// | RESTSubReq | |
4847// |---------------->| |
4848// | | |
4849// | RESTSubResp | |
4850// |<----------------| |
4851// | RESTSubDelReq | |
4852// |---------------->| |
4853// | RESTSubDelResp | |
4854// | unsuccess | |
4855// |<----------------| |
4856// | | |
4857//
4858//-----------------------------------------------------------------------------
4859func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4860 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4861
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004862 xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
archaggeafbf95f2021-04-14 08:54:05 +03004863
4864}
4865
4866//-----------------------------------------------------------------------------
4867// TestRESTSubReqInsertAndSubDelOk
4868//
4869// stub stub
4870// +-------+ +---------+ +---------+
4871// | xapp | | submgr | | e2term |
4872// +-------+ +---------+ +---------+
4873// | | |
4874// | RestSubReq | |
4875// |---------------->| |
4876// | | |
4877// | RESTSubResp | |
4878// |<----------------| |
4879// | | |
4880// | | SubReq |
4881// | |------------->|
4882// | | |
4883// | | SubResp |
4884// | |<-------------|
4885// | RESTNotif | |
4886// |<----------------| |
4887// | ... | ... |
4888// | | |
4889// | RESTSubDelReq | |
4890// |---------------->| |
4891// | | |
4892// | | SubDelReq |
4893// | |------------->|
4894// | | |
4895// | | SubDelResp |
4896// | |<-------------|
4897// | | |
4898// | RESTSubDelResp| |
4899// |<----------------| |
4900//
4901//-----------------------------------------------------------------------------
4902func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4903 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4904
4905 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004906 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004907 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004908 Counter{cSubReqToE2, 1},
4909 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004910 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004911 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004912 Counter{cSubDelReqToE2, 1},
4913 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004914 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004915 })
4916
4917 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004918
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004919 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004920 params.SetSubActionTypes("insert")
4921
4922 // Req
4923 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4924
4925 // Del
4926 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4927
4928 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4929 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4930
4931 // Wait that subs is cleaned
4932 waitSubsCleanup(t, e2SubsId, 10)
4933 mainCtrl.VerifyCounterValues(t)
4934}
4935
4936//-----------------------------------------------------------------------------
4937// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4938//
4939// stub stub
4940// +-------+ +---------+ +---------+
4941// | xapp | | submgr | | e2term |
4942// +-------+ +---------+ +---------+
4943// | | |
4944// | RESTSubReq | |
4945// |------------->| |
4946// | | |
4947// | | SubReq |
4948// | |------------->|
4949// | | |
4950// | | SubResp |
4951// | <----|
4952// | |
4953// | Submgr restart |
4954// | |
4955// | | |
4956// | | SubDelReq |
4957// | |------------->|
4958// | | |
4959// | | SubDelResp |
4960// | |<-------------|
4961// | | |
4962//
4963//-----------------------------------------------------------------------------
4964func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4965 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4966
4967 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004968 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004969 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004970 Counter{cSubReqToE2, 1},
4971 Counter{cSubDelReqFromXapp, 1},
4972 Counter{cSubDelReqToE2, 1},
4973 Counter{cSubDelRespFromE2, 1},
4974 })
4975
4976 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004977
4978 // Remove possible existing subscription
4979 mainCtrl.removeExistingSubscriptions(t)
4980
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004981 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004982
4983 //Req
4984 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
4985 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004986 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004987
4988 e2termConn1.RecvSubsReq(t)
4989
4990 mainCtrl.SetResetTestFlag(t, false)
4991
4992 mainCtrl.SimulateRestart(t)
4993 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4994
4995 //Del
4996 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4997 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4998
4999 xappConn1.TestMsgChanEmpty(t)
5000 xappConn2.TestMsgChanEmpty(t)
5001 e2termConn1.TestMsgChanEmpty(t)
5002 mainCtrl.wait_registry_empty(t, 10)
5003
5004 mainCtrl.VerifyCounterValues(t)
5005}
5006
5007//-----------------------------------------------------------------------------
5008// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5009//
5010// stub stub
5011// +-------+ +---------+ +---------+
5012// | xapp | | submgr | | e2term |
5013// +-------+ +---------+ +---------+
5014// | | |
5015// | RESTSubReq | |
5016// |---------------->| |
5017// | | |
5018// | RESTSubResp | |
5019// |<----------------| |
5020// | | SubReq |
5021// | |------------->|
5022// | | |
5023// | | SubResp |
5024// | |<-------------|
5025// | | |
5026// | RESTNotif | |
5027// |<----------------| |
5028// | | |
5029// | |
5030// | Submgr restart |
5031// | | |
5032// | RESTSubDelReq | |
5033// |---------------->| |
5034// | | |
5035// | | SubDelReq |
5036// | |------------->|
5037// | | |
5038// | | SubDelResp |
5039// | |<-------------|
5040// | | |
5041// | RESTSubDelResp | |
5042// |<----------------| |
5043//
5044//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005045
archaggeafbf95f2021-04-14 08:54:05 +03005046func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
5047 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
5048
5049 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005050 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005051 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005052 Counter{cSubReqToE2, 1},
5053 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005054 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005055 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005056 Counter{cSubDelReqToE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005057 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005058 })
5059
5060 // Remove possible existing subscription
5061 mainCtrl.removeExistingSubscriptions(t)
5062
5063 var params *teststube2ap.RESTSubsReqParams = nil
5064
5065 // Create subscription
5066 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005067 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005068
5069 // Check subscription
5070 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5071
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005072 mainCtrl.SimulateRestart(t)
5073 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005074
5075 // Check subscription
5076 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5077
5078 // Delete subscription
5079 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5080
5081 //Wait that subs is cleaned
5082 waitSubsCleanup(t, e2SubsId, 10)
5083
5084 mainCtrl.VerifyCounterValues(t)
5085}
5086
5087//-----------------------------------------------------------------------------
5088// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5089//
5090// stub stub
5091// +-------+ +-------+ +---------+ +---------+
5092// | xapp2 | | xapp1 | | submgr | | e2term |
5093// +-------+ +-------+ +---------+ +---------+
5094// | | | |
5095// | | RESTSubReq1 | |
5096// | |---------------->| |
5097// | | | |
5098// | | RESTSubResp1 | |
5099// | |<----------------| |
5100// | | | |
5101// | | | SubReq1 |
5102// | | |------------->|
5103// | | | SubResp1 |
5104// | | |<-------------|
5105// | | RESTNotif1 | |
5106// | |<----------------| |
5107// | | | |
5108// | RESTSubReq2 | |
5109// |------------------------------>| |
5110// | | | |
5111// | RESTSubResp2 | |
5112// |<------------------------------| |
5113// | | | |
5114// | | RESTNotif2 | |
5115// |<------------------------------| |
5116// | | | |
5117// | | Submgr restart |
5118// | | | |
5119// | | RESTSubDelReq1 | |
5120// | |---------------->| |
5121// | | | |
5122// | | RESTSubDelResp1 | |
5123// | |<----------------| |
5124// | | | |
5125// | | Submgr restart |
5126// | | | |
5127// | RESTSubDelReq2 | |
5128// |------------------------------>| |
5129// | | | |
5130// | RESTSubDelResp2 | |
5131// |<------------------------------| |
5132// | | | |
5133// | | | SubDelReq2 |
5134// | | |------------->|
5135// | | | |
5136// | | | SubDelResp2 |
5137// | | |<-------------|
5138// | | | |
5139//
5140//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005141
archaggeafbf95f2021-04-14 08:54:05 +03005142func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
5143 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
5144
5145 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005146 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005147 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005148 Counter{cSubReqToE2, 1},
5149 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005150 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005151 Counter{cMergedSubscriptions, 1},
5152 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005153 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005154 Counter{cSubDelReqToE2, 1},
5155 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005156 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005157 })
5158
5159 // Remove possible existing subscription
5160 mainCtrl.removeExistingSubscriptions(t)
5161
5162 var params *teststube2ap.RESTSubsReqParams = nil
5163
5164 // Create subscription 1
5165 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005166 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005167
5168 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005169 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005170 params.SetMeid("RAN_NAME_1")
5171 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005172 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005173 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005174 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005175 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005176 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005177
5178 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5179
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005180 mainCtrl.SimulateRestart(t)
5181 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005182
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005183 // Delete subscription 1, and wait until it has removed the first endpoint
5184 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005185 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005186 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005187
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005188 mainCtrl.SimulateRestart(t)
5189 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005190 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5191
5192 // Delete subscription 2
5193 deleteXapp2Subscription(t, &restSubId2)
5194
5195 //Wait that subs is cleaned
5196 waitSubsCleanup(t, e2SubsId2, 10)
5197
5198 mainCtrl.VerifyCounterValues(t)
5199}
5200
5201//-----------------------------------------------------------------------------
5202// TestRESTReportSubReqAndSubDelOk
5203//
5204// stub stub
5205// +-------+ +---------+ +---------+
5206// | xapp | | submgr | | e2term |
5207// +-------+ +---------+ +---------+
5208// | | |
5209// | RestSubReq | |
5210// |---------------->| |
5211// | | |
5212// | RESTSubResp | |
5213// |<----------------| |
5214// | | |
5215// | | SubReq |
5216// | |------------->|
5217// | | |
5218// | | SubResp |
5219// | |<-------------|
5220// | RESTNotif | |
5221// |<----------------| |
5222// | | SubReq |
5223// | |------------->|
5224// | | |
5225// | | SubResp |
5226// | |<-------------|
5227// | RESTNotif | |
5228// |<----------------| |
5229// | ... | ... |
5230// | | |
5231// | | |
5232// | RESTSubDelReq | |
5233// |---------------->| |
5234// | | |
5235// | | SubDelReq |
5236// | |------------->|
5237// | | |
5238// | | SubDelResp |
5239// | |<-------------|
5240// | | |
5241// | RESTSubDelResp| |
5242// |<----------------| |
5243//
5244//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005245
archaggeafbf95f2021-04-14 08:54:05 +03005246func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5247 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005248 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005249 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005250 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005251}
5252
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005253func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005254 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005255
5256 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005257 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005258 restSubId := xappConn1.SendRESTSubsReq(t, params)
5259
5260 var e2SubsId []uint32
5261 for i := 0; i < subReqCount; i++ {
5262 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5263 xappConn1.ExpectRESTNotification(t, restSubId)
5264
5265 e2termConn1.SendSubsResp(t, crereq, cremsg)
5266 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005267 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005268 e2SubsId = append(e2SubsId, instanceId)
5269 resp, _ := xapp.Subscription.QuerySubscriptions()
5270 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5271 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5272 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5273
5274 }
5275
5276 // Del
5277 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5278
5279 for i := 0; i < subReqCount; i++ {
5280 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5281 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5282 }
5283
5284 // Wait that subs is cleaned
5285 for i := 0; i < subReqCount; i++ {
5286 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5287 }
5288
5289 xappConn1.TestMsgChanEmpty(t)
5290 e2termConn1.TestMsgChanEmpty(t)
5291 mainCtrl.wait_registry_empty(t, 10)
5292}
5293
5294/*
5295func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
5296 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5297
5298 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005299 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005300 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005301
5302 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005303 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005304 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005305}
5306*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005307func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005308 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005309
5310 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005311 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005312 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005313
5314 var e2SubsId []uint32
5315 for i := 0; i < subReqCount; i++ {
5316 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5317 xappConn1.ExpectRESTNotification(t, restSubId)
5318 e2termConn1.SendSubsResp(t, crereq, cremsg)
5319 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005320 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005321 e2SubsId = append(e2SubsId, instanceId)
5322 }
5323
5324 // Del
5325 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5326
5327 for i := 0; i < subReqCount; i++ {
5328 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5329 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5330 }
5331
5332 // Wait that subs is cleaned
5333 for i := 0; i < subReqCount; i++ {
5334 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5335 }
5336 xappConn1.TestMsgChanEmpty(t)
5337 e2termConn1.TestMsgChanEmpty(t)
5338 mainCtrl.wait_registry_empty(t, 10)
5339}
5340
archaggeafbf95f2021-04-14 08:54:05 +03005341func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5342
archaggeafbf95f2021-04-14 08:54:05 +03005343 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005344 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005345 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005346 Counter{cSubReqToE2, 2},
5347 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005348 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005349 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005350 Counter{cSubDelReqToE2, 2},
5351 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005352 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005353 })
5354
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005355 const subReqCount int = 2
5356
archaggeafbf95f2021-04-14 08:54:05 +03005357 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005358 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005359 restSubId := xappConn1.SendRESTSubsReq(t, params)
5360 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5361
5362 assert.Equal(t, len(e2SubsIds), 2)
5363
5364 // Del
5365 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5366 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5367
5368 xappConn1.TestMsgChanEmpty(t)
5369 e2termConn1.TestMsgChanEmpty(t)
5370 mainCtrl.wait_registry_empty(t, 10)
5371
5372 mainCtrl.VerifyCounterValues(t)
5373}
archaggeafbf95f2021-04-14 08:54:05 +03005374func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5375
archaggeafbf95f2021-04-14 08:54:05 +03005376 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005377 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005378 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005379 Counter{cSubReqToE2, 19},
5380 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005381 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005382 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005383 Counter{cSubDelReqToE2, 19},
5384 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005385 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005386 })
5387
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005388 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005389 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005390 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005391 restSubId := xappConn1.SendRESTSubsReq(t, params)
5392 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5393
5394 assert.Equal(t, len(e2SubsIds), 19)
5395
5396 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5397 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5398
5399 xappConn1.TestMsgChanEmpty(t)
5400 e2termConn1.TestMsgChanEmpty(t)
5401 mainCtrl.wait_registry_empty(t, 10)
5402
5403 mainCtrl.VerifyCounterValues(t)
5404}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005405
archaggeafbf95f2021-04-14 08:54:05 +03005406func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5407
5408 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005409
5410 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005411 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005412 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005413 Counter{cSubReqToE2, uint64(subReqCount)},
5414 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005415 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005416 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005417 Counter{cSubDelReqToE2, uint64(subReqCount)},
5418 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005419 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005420 })
5421
5422 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005423 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005424 restSubId := xappConn1.SendRESTSubsReq(t, params)
5425 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5426
5427 assert.Equal(t, len(e2SubsIds), subReqCount)
5428
5429 // Del
5430 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5431 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5432
5433 xappConn1.TestMsgChanEmpty(t)
5434 e2termConn1.TestMsgChanEmpty(t)
5435 mainCtrl.wait_registry_empty(t, 10)
5436
5437 mainCtrl.VerifyCounterValues(t)
5438}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005439
archaggeafbf95f2021-04-14 08:54:05 +03005440func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5441
5442 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005443
5444 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005445 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005446 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005447 Counter{cSubReqToE2, uint64(subReqCount)},
5448 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005449 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005450 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005451 Counter{cSubDelReqToE2, uint64(subReqCount)},
5452 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005453 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005454 })
5455
5456 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005457 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005458 restSubId := xappConn1.SendRESTSubsReq(t, params)
5459 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5460
5461 assert.Equal(t, len(e2SubsIds), subReqCount)
5462
5463 // Del
5464 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5465 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5466
5467 xappConn1.TestMsgChanEmpty(t)
5468 e2termConn1.TestMsgChanEmpty(t)
5469 mainCtrl.wait_registry_empty(t, 10)
5470
5471 mainCtrl.VerifyCounterValues(t)
5472}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005473
archaggeafbf95f2021-04-14 08:54:05 +03005474func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5475
5476 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005477
5478 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005479 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005480 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005481 Counter{cSubReqToE2, uint64(subReqCount)},
5482 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005483 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005484 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005485 Counter{cSubDelReqToE2, uint64(subReqCount)},
5486 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005487 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005488 })
5489
5490 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005491 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005492 restSubId := xappConn1.SendRESTSubsReq(t, params)
5493 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5494
5495 assert.Equal(t, len(e2SubsIds), subReqCount)
5496
5497 // Del
5498 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5499 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5500
5501 xappConn1.TestMsgChanEmpty(t)
5502 e2termConn1.TestMsgChanEmpty(t)
5503 mainCtrl.wait_registry_empty(t, 10)
5504
5505 mainCtrl.VerifyCounterValues(t)
5506}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005507
5508func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5509 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5510
5511 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005512 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005513 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005514 Counter{cSubReqToE2, 2},
5515 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005516 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005517 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005518 Counter{cSubDelReqToE2, 2},
5519 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005520 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005521 })
5522
5523 // Req1
5524 var params *teststube2ap.RESTSubsReqParams = nil
5525
5526 //Subs Create
5527 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005528 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005529
5530 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5531
5532 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005533 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005534 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005535 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005536 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5537
5538 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005539 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005540 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5541 xappConn2.ExpectRESTNotification(t, restSubId2)
5542 e2termConn1.SendSubsResp(t, crereq, cremsg)
5543 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5544
5545 deleteXapp1Subscription(t, &restSubId1)
5546 deleteXapp2Subscription(t, &restSubId2)
5547
5548 waitSubsCleanup(t, e2SubsId1, 10)
5549 waitSubsCleanup(t, e2SubsId2, 10)
5550
5551 mainCtrl.VerifyCounterValues(t)
5552
5553}
5554
5555func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5556 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5557
5558 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005559 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005560 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005561 Counter{cSubReqToE2, 2},
5562 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005563 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005564 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005565 Counter{cSubDelReqToE2, 2},
5566 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005567 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005568 })
5569
5570 // Req1
5571 var params *teststube2ap.RESTSubsReqParams = nil
5572
5573 //Subs Create
5574 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005575 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005576
5577 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5578
5579 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005580 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005581 params.SetMeid("RAN_NAME_1")
5582
5583 actionId := int64(1)
5584 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005585 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005586 subsequestActionType := "continue"
5587 timeToWait := "w10ms"
5588 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5589
5590 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005591 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005592 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5593 xappConn2.ExpectRESTNotification(t, restSubId2)
5594 e2termConn1.SendSubsResp(t, crereq, cremsg)
5595 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5596
5597 deleteXapp1Subscription(t, &restSubId1)
5598 deleteXapp2Subscription(t, &restSubId2)
5599
5600 waitSubsCleanup(t, e2SubsId1, 10)
5601 waitSubsCleanup(t, e2SubsId2, 10)
5602
5603 mainCtrl.VerifyCounterValues(t)
5604
5605}
5606
5607func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5608 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5609
5610 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005611 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005612 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005613 Counter{cSubReqToE2, 2},
5614 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005615 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005616 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005617 Counter{cSubDelReqToE2, 2},
5618 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005619 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005620 })
5621
5622 // Req1
5623 var params *teststube2ap.RESTSubsReqParams = nil
5624
5625 //Subs Create
5626 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005627 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005628
5629 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5630
5631 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005632 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005633 params.SetMeid("RAN_NAME_1")
5634 params.SetSubActionIDs(int64(2))
5635
5636 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005637 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005638 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5639 xappConn2.ExpectRESTNotification(t, restSubId2)
5640 e2termConn1.SendSubsResp(t, crereq, cremsg)
5641 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5642
5643 deleteXapp1Subscription(t, &restSubId1)
5644 deleteXapp2Subscription(t, &restSubId2)
5645
5646 waitSubsCleanup(t, e2SubsId1, 10)
5647 waitSubsCleanup(t, e2SubsId2, 10)
5648
5649 mainCtrl.VerifyCounterValues(t)
5650
5651}
5652
5653func TestRESTSubReqDiffActionType(t *testing.T) {
5654 CaseBegin("TestRESTSubReqDiffActionType")
5655
5656 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005657 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005658 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005659 Counter{cSubReqToE2, 2},
5660 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005661 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005662 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005663 Counter{cSubDelReqToE2, 2},
5664 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005665 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005666 })
5667
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005668 const e2Timeout int64 = 2
5669 const e2RetryCount int64 = 2
5670 const routingNeeded bool = true
5671
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005672 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005673 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005674 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005675
5676 //Subs Create
5677 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005678 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005679
5680 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5681
5682 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005683 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005684 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005685 params.SetMeid("RAN_NAME_1")
5686
5687 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005688 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005689 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5690 xappConn2.ExpectRESTNotification(t, restSubId2)
5691 e2termConn1.SendSubsResp(t, crereq, cremsg)
5692 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5693
5694 deleteXapp1Subscription(t, &restSubId1)
5695 deleteXapp2Subscription(t, &restSubId2)
5696
5697 waitSubsCleanup(t, e2SubsId1, 10)
5698 waitSubsCleanup(t, e2SubsId2, 10)
5699
5700 mainCtrl.VerifyCounterValues(t)
5701
5702}
5703
5704func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5705 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5706
5707 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005708 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005709 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005710 Counter{cSubReqToE2, 2},
5711 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005712 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005713 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005714 Counter{cSubDelReqToE2, 2},
5715 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005716 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005717 })
5718
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005719 const e2Timeout int64 = 2
5720 const e2RetryCount int64 = 2
5721 const routingNeeded bool = true
5722
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005723 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005724 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005725 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005726
5727 //Subs Create
5728 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005729 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005730
5731 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5732
5733 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005734 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005735 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005736 params.SetMeid("RAN_NAME_1")
5737
5738 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005739 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005740 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5741 xappConn2.ExpectRESTNotification(t, restSubId2)
5742 e2termConn1.SendSubsResp(t, crereq, cremsg)
5743 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5744
5745 deleteXapp1Subscription(t, &restSubId1)
5746 deleteXapp2Subscription(t, &restSubId2)
5747
5748 waitSubsCleanup(t, e2SubsId1, 10)
5749 waitSubsCleanup(t, e2SubsId2, 10)
5750
5751 mainCtrl.VerifyCounterValues(t)
5752
5753}
5754
5755func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5756 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5757
5758 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005759 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005760 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005761 Counter{cSubReqToE2, 2},
5762 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005763 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005764 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005765 Counter{cSubDelReqToE2, 2},
5766 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005767 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005768 })
5769
5770 // Req1
5771 var params *teststube2ap.RESTSubsReqParams = nil
5772
5773 //Subs Create
5774 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005775 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005776
5777 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5778
5779 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005780 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005781 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005782 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005783 params.SetSubActionDefinition(actionDefinition)
5784
5785 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005786 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005787 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5788 xappConn2.ExpectRESTNotification(t, restSubId2)
5789 e2termConn1.SendSubsResp(t, crereq, cremsg)
5790 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5791
5792 deleteXapp1Subscription(t, &restSubId1)
5793 deleteXapp2Subscription(t, &restSubId2)
5794
5795 waitSubsCleanup(t, e2SubsId1, 10)
5796 waitSubsCleanup(t, e2SubsId2, 10)
5797
5798 mainCtrl.VerifyCounterValues(t)
5799
5800}
5801
5802func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5803 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5804
5805 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005806 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005807 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005808 Counter{cSubReqToE2, 2},
5809 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005810 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005811 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005812 Counter{cSubDelReqToE2, 2},
5813 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005814 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005815 })
5816
5817 // Req1
5818 var params *teststube2ap.RESTSubsReqParams = nil
5819
5820 //Subs Create
5821 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005822 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005823
5824 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5825
5826 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005827 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005828 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005829 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005830 params.SetSubActionDefinition(actionDefinition)
5831
5832 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005833 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005834 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5835 xappConn2.ExpectRESTNotification(t, restSubId2)
5836 e2termConn1.SendSubsResp(t, crereq, cremsg)
5837 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5838
5839 deleteXapp1Subscription(t, &restSubId1)
5840 deleteXapp2Subscription(t, &restSubId2)
5841
5842 waitSubsCleanup(t, e2SubsId1, 10)
5843 waitSubsCleanup(t, e2SubsId2, 10)
5844
5845 mainCtrl.VerifyCounterValues(t)
5846
5847}
5848
5849func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5850 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5851
5852 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005853 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005854 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005855 Counter{cSubReqToE2, 2},
5856 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005857 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005858 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005859 Counter{cSubDelReqToE2, 2},
5860 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005861 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005862 })
5863
5864 // Req1
5865 var params *teststube2ap.RESTSubsReqParams = nil
5866
5867 //Subs Create
5868 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005869 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005870
5871 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5872
5873 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005874 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005875 params.SetMeid("RAN_NAME_1")
5876 params.SetTimeToWait("w200ms")
5877 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005878 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005879 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5880 xappConn2.ExpectRESTNotification(t, restSubId2)
5881 e2termConn1.SendSubsResp(t, crereq, cremsg)
5882 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5883
5884 deleteXapp1Subscription(t, &restSubId1)
5885 deleteXapp2Subscription(t, &restSubId2)
5886
5887 waitSubsCleanup(t, e2SubsId1, 10)
5888 waitSubsCleanup(t, e2SubsId2, 10)
5889
5890 mainCtrl.VerifyCounterValues(t)
5891
5892}
5893
Anssi Mannila51122392021-05-25 11:51:31 +03005894//-----------------------------------------------------------------------------
5895// TestRESTUnpackSubscriptionResponseDecodeFail
5896//
5897// stub stub
5898// +-------+ +---------+ +---------+
5899// | xapp | | submgr | | e2term |
5900// +-------+ +---------+ +---------+
5901// | | |
5902// | RestSubReq | |
5903// |---------------->| |
5904// | | |
5905// | RESTSubResp | |
5906// |<----------------| |
5907// | | |
5908// | | SubReq |
5909// | |------------->|
5910// | | |
5911// | | SubResp | ASN.1 decode fails
5912// | |<-------------|
5913// | | |
5914// | | SubReq |
5915// | |------------->|
5916// | | |
5917// | | SubFail | Duplicated action
5918// | |<-------------|
5919// | RESTNotif (fail)| |
5920// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03005921// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03005922//
5923//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005924
Anssi Mannila51122392021-05-25 11:51:31 +03005925func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005926 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5927 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03005928
5929 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005930 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005931 restSubId := xappConn1.SendRESTSubsReq(t, params)
5932
5933 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5934 // Decode of this response fails which will result resending original request
5935 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5936
5937 _, cremsg = e2termConn1.RecvSubsReq(t)
5938
Markku Virtanen55d2a282021-06-04 14:46:56 +03005939 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005940
5941 // Subscription already created in E2 Node.
5942 fparams := &teststube2ap.E2StubSubsFailParams{}
5943 fparams.Set(crereq)
5944 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5945 e2termConn1.SendSubsFail(t, fparams, cremsg)
5946
Anssi Mannila51122392021-05-25 11:51:31 +03005947 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005948 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03005949
5950 // Wait that subs is cleaned
5951 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5952
5953 xappConn1.TestMsgChanEmpty(t)
5954 e2termConn1.TestMsgChanEmpty(t)
5955 mainCtrl.wait_registry_empty(t, 10)
5956}
5957
5958//-----------------------------------------------------------------------------
5959// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5960//
5961// stub stub
5962// +-------+ +---------+ +---------+
5963// | xapp | | submgr | | e2term |
5964// +-------+ +---------+ +---------+
5965// | | |
5966// | RestSubReq | |
5967// |---------------->| |
5968// | | |
5969// | RESTSubResp | |
5970// |<----------------| |
5971// | | |
5972// | | SubReq |
5973// | |------------->|
5974// | | |
5975// | | SubResp | Unknown instanceId
5976// | |<-------------|
5977// | | |
5978// | | SubReq |
5979// | |------------->|
5980// | | |
5981// | | SubFail | Duplicated action
5982// | |<-------------|
5983// | RESTNotif (fail)| |
5984// |<----------------| |
5985// | | SubDelReq |
5986// | |------------->|
5987// | | |
5988// | | SubDelResp |
5989// | |<-------------|
5990//
5991//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005992
Anssi Mannila51122392021-05-25 11:51:31 +03005993func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005994 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5995 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03005996
5997 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005998 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005999 restSubId := xappConn1.SendRESTSubsReq(t, params)
6000
6001 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6002
6003 // Unknown instanceId in this response which will result resending original request
6004 orgInstanceId := crereq.RequestId.InstanceId
6005 crereq.RequestId.InstanceId = 0
6006 e2termConn1.SendSubsResp(t, crereq, cremsg)
6007
6008 _, cremsg = e2termConn1.RecvSubsReq(t)
6009
Markku Virtanen55d2a282021-06-04 14:46:56 +03006010 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006011
6012 // Subscription already created in E2 Node.
6013 fparams := &teststube2ap.E2StubSubsFailParams{}
6014 fparams.Set(crereq)
6015 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6016 e2termConn1.SendSubsFail(t, fparams, cremsg)
6017
6018 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6019 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6020
6021 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006022 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006023
6024 // Wait that subs is cleaned
6025 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6026
6027 xappConn1.TestMsgChanEmpty(t)
6028 e2termConn1.TestMsgChanEmpty(t)
6029 mainCtrl.wait_registry_empty(t, 10)
6030}
6031
6032//-----------------------------------------------------------------------------
6033// TestRESTUnpackSubscriptionResponseNoTransaction
6034//
6035// stub stub
6036// +-------+ +---------+ +---------+
6037// | xapp | | submgr | | e2term |
6038// +-------+ +---------+ +---------+
6039// | | |
6040// | RestSubReq | |
6041// |---------------->| |
6042// | | |
6043// | RESTSubResp | |
6044// |<----------------| |
6045// | | |
6046// | | SubReq |
6047// | |------------->|
6048// | | |
6049// | | SubResp | No transaction for the response
6050// | |<-------------|
6051// | | |
6052// | | SubReq |
6053// | |------------->|
6054// | | |
6055// | | SubFail | Duplicated action
6056// | |<-------------|
6057// | RESTNotif (fail)| |
6058// |<----------------| |
6059// | | SubDelReq |
6060// | |------------->|
6061// | | |
6062// | | SubDelResp |
6063// | |<-------------|
6064// | | |
6065// | | SubDelReq |
6066// | |------------->|
6067// | | |
6068// | | SubDelResp |
6069// | |<-------------|
6070//
6071//-----------------------------------------------------------------------------
6072func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006073 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
6074 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006075
6076 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006077 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006078 restSubId := xappConn1.SendRESTSubsReq(t, params)
6079
6080 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6081
6082 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6083 // No transaction exist for this response which will result resending original request
6084 e2termConn1.SendSubsResp(t, crereq, cremsg)
6085
6086 _, cremsg = e2termConn1.RecvSubsReq(t)
6087
Markku Virtanen55d2a282021-06-04 14:46:56 +03006088 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006089
6090 // Subscription already created in E2 Node.
6091 fparams := &teststube2ap.E2StubSubsFailParams{}
6092 fparams.Set(crereq)
6093 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6094 e2termConn1.SendSubsFail(t, fparams, cremsg)
6095
6096 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6097 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6098
6099 // Resending happens because there no transaction
6100 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6101 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6102
6103 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006104 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006105
6106 // Wait that subs is cleaned
6107 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6108
6109 xappConn1.TestMsgChanEmpty(t)
6110 e2termConn1.TestMsgChanEmpty(t)
6111 mainCtrl.wait_registry_empty(t, 10)
6112
6113}
6114
6115//-----------------------------------------------------------------------------
6116// TestRESTUnpackSubscriptionFailureDecodeFail
6117//
6118// stub stub
6119// +-------+ +---------+ +---------+
6120// | xapp | | submgr | | e2term |
6121// +-------+ +---------+ +---------+
6122// | | |
6123// | RestSubReq | |
6124// |---------------->| |
6125// | | |
6126// | RESTSubResp | |
6127// |<----------------| |
6128// | | |
6129// | | SubReq |
6130// | |------------->|
6131// | | |
6132// | | SubFail | ASN.1 decode fails
6133// | |<-------------|
6134// | | |
6135// | | SubReq |
6136// | |------------->|
6137// | | |
6138// | | SubFail | Duplicated action
6139// | |<-------------|
6140// | RESTNotif (fail)| |
6141// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006142// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006143//
6144//-----------------------------------------------------------------------------
6145func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006146 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
6147 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006148
6149 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006150 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006151 restSubId := xappConn1.SendRESTSubsReq(t, params)
6152
6153 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6154
6155 // Decode of this response fails which will result resending original request
6156 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
6157
6158 _, cremsg = e2termConn1.RecvSubsReq(t)
6159
Markku Virtanen55d2a282021-06-04 14:46:56 +03006160 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006161
6162 // Subscription already created in E2 Node.
6163 fparams := &teststube2ap.E2StubSubsFailParams{}
6164 fparams.Set(crereq)
6165 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6166 e2termConn1.SendSubsFail(t, fparams, cremsg)
6167
Anssi Mannila51122392021-05-25 11:51:31 +03006168 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006169 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006170
6171 // Wait that subs is cleaned
6172 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6173
6174 xappConn1.TestMsgChanEmpty(t)
6175 e2termConn1.TestMsgChanEmpty(t)
6176 mainCtrl.wait_registry_empty(t, 10)
6177}
6178
6179//-----------------------------------------------------------------------------
6180// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6181//
6182// stub stub
6183// +-------+ +---------+ +---------+
6184// | xapp | | submgr | | e2term |
6185// +-------+ +---------+ +---------+
6186// | | |
6187// | RestSubReq | |
6188// |---------------->| |
6189// | | |
6190// | RESTSubResp | |
6191// |<----------------| |
6192// | | |
6193// | | SubReq |
6194// | |------------->|
6195// | | |
6196// | | SubFail | Unknown instanceId
6197// | |<-------------|
6198// | | |
6199// | | SubReq |
6200// | |------------->|
6201// | | |
6202// | | SubFail | Duplicated action
6203// | |<-------------|
6204// | RESTNotif (fail)| |
6205// |<----------------| |
6206// | | SubDelReq |
6207// | |------------->|
6208// | | |
6209// | | SubDelResp |
6210// | |<-------------|
6211//
6212//-----------------------------------------------------------------------------
6213func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006214 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6215 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006216
6217 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006218 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006219 restSubId := xappConn1.SendRESTSubsReq(t, params)
6220
6221 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6222
6223 // Unknown instanceId in this response which will result resending original request
6224 fparams := &teststube2ap.E2StubSubsFailParams{}
6225 fparams.Set(crereq)
6226 fparams.Fail.RequestId.InstanceId = 0
6227 e2termConn1.SendSubsFail(t, fparams, cremsg)
6228
6229 _, cremsg = e2termConn1.RecvSubsReq(t)
6230
Markku Virtanen55d2a282021-06-04 14:46:56 +03006231 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006232
6233 // Subscription already created in E2 Node.
6234 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6235 e2termConn1.SendSubsFail(t, fparams, cremsg)
6236
6237 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6238 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6239
6240 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006241 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006242
6243 // Wait that subs is cleaned
6244 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6245
6246 xappConn1.TestMsgChanEmpty(t)
6247 e2termConn1.TestMsgChanEmpty(t)
6248 mainCtrl.wait_registry_empty(t, 10)
6249}
6250
6251//-----------------------------------------------------------------------------
6252// TestRESTUnpackSubscriptionFailureNoTransaction
6253//
6254// stub stub
6255// +-------+ +---------+ +---------+
6256// | xapp | | submgr | | e2term |
6257// +-------+ +---------+ +---------+
6258// | | |
6259// | RestSubReq | |
6260// |---------------->| |
6261// | | |
6262// | RESTSubResp | |
6263// |<----------------| |
6264// | | |
6265// | | SubReq |
6266// | |------------->|
6267// | | |
6268// | | SubFail | No transaction for the response
6269// | |<-------------|
6270// | | |
6271// | | SubReq |
6272// | |------------->|
6273// | | |
6274// | | SubFail | Duplicated action
6275// | |<-------------|
6276// | RESTNotif (fail)| |
6277// |<----------------| |
6278// | | SubDelReq |
6279// | |------------->|
6280// | | |
6281// | | SubDelResp |
6282// | |<-------------|
6283//
6284//-----------------------------------------------------------------------------
6285func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006286 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6287 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006288
6289 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006290 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006291 restSubId := xappConn1.SendRESTSubsReq(t, params)
6292
6293 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6294
6295 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6296
6297 // No transaction exist for this response which will result resending original request
6298 fparams := &teststube2ap.E2StubSubsFailParams{}
6299 fparams.Set(crereq)
6300 e2termConn1.SendSubsFail(t, fparams, cremsg)
6301
6302 _, cremsg = e2termConn1.RecvSubsReq(t)
6303
Markku Virtanen55d2a282021-06-04 14:46:56 +03006304 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006305
6306 // Subscription already created in E2 Node.
6307 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6308 e2termConn1.SendSubsFail(t, fparams, cremsg)
6309
6310 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6311 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6312
6313 // Resending happens because there no transaction
6314 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6315 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6316
6317 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006318 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006319
6320 // Wait that subs is cleaned
6321 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6322
6323 xappConn1.TestMsgChanEmpty(t)
6324 e2termConn1.TestMsgChanEmpty(t)
6325 mainCtrl.wait_registry_empty(t, 10)
6326}
6327
6328//-----------------------------------------------------------------------------
6329// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6330//
6331// stub stub
6332// +-------+ +---------+ +---------+
6333// | xapp | | submgr | | e2term |
6334// +-------+ +---------+ +---------+
6335// | | |
6336// | [SUBS CREATE] |
6337// | | |
6338// | | |
6339// | RESTSubDelReq | |
6340// |---------------->| |
6341// | | |
6342// | RESTSubDelResp | |
6343// |<----------------| |
6344// | | |
6345// | | SubDelReq |
6346// | |------------->|
6347// | | |
6348// | | SubDelResp | ASN.1 decode fails
6349// | |<-------------|
6350// | | |
6351// | | SubDelReq |
6352// | |------------->|
6353// | | |
6354// | | SubDelFail | Subscription does exist any more
6355// | |<-------------|
6356// | | |
6357//
6358//-----------------------------------------------------------------------------
6359func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006360 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006361
6362 // Req
6363 var params *teststube2ap.RESTSubsReqParams = nil
6364 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6365
6366 // Del
6367 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6368
6369 // E2t: Receive 1st SubsDelReq
6370 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6371
6372 // Decode of this response fails which will result resending original request
6373 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6374
6375 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6376 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6377
6378 // Subscription does not exist in in E2 Node.
6379 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6380
6381 // Wait that subs is cleaned
6382 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6383
6384 xappConn1.TestMsgChanEmpty(t)
6385 e2termConn1.TestMsgChanEmpty(t)
6386 mainCtrl.wait_registry_empty(t, 10)
6387}
6388
6389//-----------------------------------------------------------------------------
6390// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6391//
6392// stub stub
6393// +-------+ +---------+ +---------+
6394// | xapp | | submgr | | e2term |
6395// +-------+ +---------+ +---------+
6396// | | |
6397// | [SUBS CREATE] |
6398// | | |
6399// | | |
6400// | RESTSubDelReq | |
6401// |---------------->| |
6402// | | |
6403// | RESTSubDelResp | |
6404// |<----------------| |
6405// | | |
6406// | | SubDelReq |
6407// | |------------->|
6408// | | |
6409// | | SubDelResp | Unknown instanceId
6410// | |<-------------|
6411// | | |
6412// | | SubDelReq |
6413// | |------------->|
6414// | | |
6415// | | SubDelFail | Subscription does exist any more
6416// | |<-------------|
6417//
6418//-----------------------------------------------------------------------------
6419func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006420 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006421
6422 // Req
6423 var params *teststube2ap.RESTSubsReqParams = nil
6424 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6425
6426 // Del
6427 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6428
6429 // E2t: Receive 1st SubsDelReq
6430 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6431
6432 // Unknown instanceId in this response which will result resending original request
6433 delreq.RequestId.InstanceId = 0
6434 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6435
6436 // E2t: Receive 2nd SubsDelReq
6437 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6438
6439 // Subscription does not exist in in E2 Node.
6440 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6441
6442 // Wait that subs is cleaned
6443 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6444
6445 xappConn1.TestMsgChanEmpty(t)
6446 e2termConn1.TestMsgChanEmpty(t)
6447 mainCtrl.wait_registry_empty(t, 10)
6448}
6449
6450//-----------------------------------------------------------------------------
6451// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6452//
6453// stub stub
6454// +-------+ +---------+ +---------+
6455// | xapp | | submgr | | e2term |
6456// +-------+ +---------+ +---------+
6457// | | |
6458// | [SUBS CREATE] |
6459// | | |
6460// | | |
6461// | RESTSubDelReq | |
6462// |---------------->| |
6463// | | |
6464// | RESTSubDelResp | |
6465// |<----------------| |
6466// | | |
6467// | | SubDelReq |
6468// | |------------->|
6469// | | |
6470// | | SubDelResp | No transaction for the response
6471// | |<-------------|
6472// | | |
6473// | | SubDelReq |
6474// | |------------->|
6475// | | |
6476// | | SubDelFail | Subscription does exist any more
6477// | |<-------------|
6478//
6479//-----------------------------------------------------------------------------
6480func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006481 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006482
6483 // Req
6484 var params *teststube2ap.RESTSubsReqParams = nil
6485 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6486
6487 // Del
6488 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6489
6490 // E2t: Receive 1st SubsDelReq
6491 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6492
6493 mainCtrl.MakeTransactionNil(t, e2SubsId)
6494
6495 // No transaction exist for this response which will result resending original request
6496 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6497
6498 // E2t: Receive 2nd SubsDelReq
6499 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6500
6501 // Subscription does not exist in in E2 Node.
6502 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6503
6504 // Wait that subs is cleaned
6505 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6506
6507 xappConn1.TestMsgChanEmpty(t)
6508 e2termConn1.TestMsgChanEmpty(t)
6509 mainCtrl.wait_registry_empty(t, 10)
6510}
6511
6512//-----------------------------------------------------------------------------
6513// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6514//
6515// stub stub
6516// +-------+ +---------+ +---------+
6517// | xapp | | submgr | | e2term |
6518// +-------+ +---------+ +---------+
6519// | | |
6520// | [SUBS CREATE] |
6521// | | |
6522// | | |
6523// | RESTSubDelReq | |
6524// |---------------->| |
6525// | | |
6526// | RESTSubDelResp | |
6527// |<----------------| |
6528// | | |
6529// | | SubDelReq |
6530// | |------------->|
6531// | | |
6532// | | SubDelFail | ASN.1 decode fails
6533// | |<-------------|
6534// | | |
6535// | | SubDelReq |
6536// | |------------->|
6537// | | |
6538// | | SubDelFail | Subscription does exist any more
6539// | |<-------------|
6540//
6541//-----------------------------------------------------------------------------
6542func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006543 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006544
6545 // Req
6546 var params *teststube2ap.RESTSubsReqParams = nil
6547 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6548
6549 // Del
6550 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6551
6552 // E2t: Receive 1st SubsDelReq
6553 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6554
6555 // Decode of this response fails which will result resending original request
6556 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6557
6558 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6559 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6560
6561 // Subscription does not exist in in E2 Node.
6562 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6563
6564 // Wait that subs is cleaned
6565 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6566
6567 xappConn1.TestMsgChanEmpty(t)
6568 e2termConn1.TestMsgChanEmpty(t)
6569 mainCtrl.wait_registry_empty(t, 10)
6570}
6571
6572//-----------------------------------------------------------------------------
6573// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6574//
6575// stub stub
6576// +-------+ +---------+ +---------+
6577// | xapp | | submgr | | e2term |
6578// +-------+ +---------+ +---------+
6579// | | |
6580// | [SUBS CREATE] |
6581// | | |
6582// | | |
6583// | RESTSubDelReq | |
6584// |---------------->| |
6585// | | |
6586// | RESTSubDelResp | |
6587// |<----------------| |
6588// | | |
6589// | | SubDelReq |
6590// | |------------->|
6591// | | |
6592// | | SubDelFail | Unknown instanceId
6593// | |<-------------|
6594// | | |
6595// | | SubDelReq |
6596// | |------------->|
6597// | | |
6598// | | SubDelFail | Subscription does exist any more
6599// | |<-------------|
6600//
6601//-----------------------------------------------------------------------------
6602func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006603 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006604
6605 // Req
6606 var params *teststube2ap.RESTSubsReqParams = nil
6607 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6608
6609 // Del
6610 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6611
6612 // E2t: Receive 1st SubsDelReq
6613 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6614
6615 // Unknown instanceId in this response which will result resending original request
6616 delreq.RequestId.InstanceId = 0
6617 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6618
6619 // E2t: Receive 2nd SubsDelReq
6620 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6621
6622 // Subscription does not exist in in E2 Node.
6623 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6624
6625 // Wait that subs is cleaned
6626 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6627
6628 xappConn1.TestMsgChanEmpty(t)
6629 e2termConn1.TestMsgChanEmpty(t)
6630 mainCtrl.wait_registry_empty(t, 10)
6631}
6632
6633//-----------------------------------------------------------------------------
6634// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6635//
6636// stub stub
6637// +-------+ +---------+ +---------+
6638// | xapp | | submgr | | e2term |
6639// +-------+ +---------+ +---------+
6640// | | |
6641// | [SUBS CREATE] |
6642// | | |
6643// | | |
6644// | RESTSubDelReq | |
6645// |---------------->| |
6646// | | |
6647// | RESTSubDelResp | |
6648// |<----------------| |
6649// | | |
6650// | | SubDelReq |
6651// | |------------->|
6652// | | |
6653// | | SubDelFail | No transaction for the response
6654// | |<-------------|
6655// | | |
6656// | | SubDelReq |
6657// | |------------->|
6658// | | |
6659// | | SubDelFail | Subscription does exist any more
6660// | |<-------------|
6661//
6662//-----------------------------------------------------------------------------
6663func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006664 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006665
6666 // Req
6667 var params *teststube2ap.RESTSubsReqParams = nil
6668 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6669
6670 // Del
6671 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6672
6673 // E2t: Receive 1st SubsDelReq
6674 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6675
6676 mainCtrl.MakeTransactionNil(t, e2SubsId)
6677
6678 // No transaction exist for this response which will result resending original request
6679 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6680
6681 // E2t: Receive 2nd SubsDelReq
6682 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6683
6684 // Subscription does not exist in in E2 Node.
6685 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6686
6687 // Wait that subs is cleaned
6688 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6689
6690 xappConn1.TestMsgChanEmpty(t)
6691 e2termConn1.TestMsgChanEmpty(t)
6692 mainCtrl.wait_registry_empty(t, 10)
6693}
6694
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006695//-----------------------------------------------------------------------------
6696// TestRESTSubReqFailAsn1PackSubReqError
6697//
6698// stub stub
6699// +-------+ +---------+ +---------+
6700// | xapp | | submgr | | e2term |
6701// +-------+ +---------+ +---------+
6702// | | |
6703// | RESTSubReq | |
6704// |---------------->| |
6705// | | |
6706// | RESTSubResp | |
6707// |<----------------| |
6708// | | |
6709// | ASN.1 encode fails |
6710// | | |
6711// | | SubDelReq |
6712// | |------------->|
6713// | | |
6714// | | SubDelFail |
6715// | |<-------------|
6716// | | |
6717// | RESTNotif | |
6718// | unsuccess | |
6719// |<----------------| |
6720// | | |
6721// | [SUBS DELETE] |
6722// | | |
6723//
6724//-----------------------------------------------------------------------------
6725func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6726
6727 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006728 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006729 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006730 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006731 })
6732
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006733 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006734
6735 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006736 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006737 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6738
6739 // Req
6740 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006741 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006742
6743 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03006744 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006745
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006746 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006747 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006748
6749 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
6750 // Wait that subs is cleaned
6751 waitSubsCleanup(t, e2SubsId, 10)
6752 mainCtrl.VerifyCounterValues(t)
6753}
6754
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006755func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
6756 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
6757
6758 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6759 Counter{cRestSubReqFromXapp, 2},
6760 Counter{cRestSubRespToXapp, 2},
6761 Counter{cSubReqToE2, 2},
6762 Counter{cSubRespFromE2, 1},
6763 Counter{cRestSubNotifToXapp, 1},
6764 Counter{cRestSubFailNotifToXapp, 1},
6765 Counter{cRestSubDelReqFromXapp, 1},
6766 Counter{cSubDelReqToE2, 1},
6767 Counter{cSubDelRespFromE2, 1},
6768 Counter{cRestSubDelRespToXapp, 1},
6769 })
6770
6771 const e2Timeout int64 = 1
6772 const e2RetryCount int64 = 0
6773 const routingNeeded bool = false
6774
6775 // Req1
6776 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6777 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6778
6779 // Subs Create
6780 restSubId := xappConn1.SendRESTSubsReq(t, params)
6781 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6782
6783 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6784 xappConn1.ExpectRESTNotification(t, restSubId)
6785 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6786 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6787 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6788
6789 // Policy change
6790 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6791 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6792 params.SetSubscriptionID(&restSubId)
6793 params.SetTimeToWait("w200ms")
6794 restSubId = xappConn1.SendRESTSubsReq(t, params)
6795 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6796
6797 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6798 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03006799 // SubsResp is missing, e2SubsId will be 0
6800 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6801 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006802
6803 // Del
6804 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6805 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6806 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6807
6808 waitSubsCleanup(t, e2SubsId, 10)
6809
6810 mainCtrl.VerifyCounterValues(t)
6811}
6812
6813//-----------------------------------------------------------------------------
6814// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
6815//
6816// stub stub
6817// +-------+ +---------+ +---------+
6818// | xapp | | submgr | | e2term |
6819// +-------+ +---------+ +---------+
6820// | | |
6821// | RESTSubReq | |
6822// |---------------->| |
6823// | | |
6824// | RESTSubResp | |
6825// |<----------------| |
6826// | | SubReq |
6827// | |------------->|
6828// | | |
6829// | | SubResp |
6830// | |<-------------|
6831// | | |
6832// | RESTNotif | |
6833// |<----------------| |
6834// | | |
6835// | RESTSubReq | |
6836// |---------------->| |
6837// | | |
6838// | RESTSubResp | |
6839// |<----------------| |
6840// | | SubReq |
6841// | |------------->|
6842// | |
6843// | Submgr restart |
6844// | | |
6845// | RESTSubDelReq | |
6846// |---------------->| |
6847// | | |
6848// | | SubDelReq |
6849// | |------------->|
6850// | | |
6851// | | SubDelResp |
6852// | |<-------------|
6853// | | |
6854// | RESTSubDelResp | |
6855// |<----------------| |
6856//
6857//-----------------------------------------------------------------------------
6858
6859func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
6860 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
6861
6862 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6863 Counter{cRestSubReqFromXapp, 2},
6864 Counter{cRestSubRespToXapp, 2},
6865 Counter{cSubReqToE2, 2},
6866 Counter{cSubRespFromE2, 1},
6867 Counter{cRestSubNotifToXapp, 1},
6868 Counter{cRestSubNotifToXapp, 1},
6869 Counter{cRestSubDelReqFromXapp, 1},
6870 Counter{cSubDelReqToE2, 1},
6871 Counter{cRestSubDelRespToXapp, 1},
6872 })
6873
6874 // Remove possible existing subscription
6875 mainCtrl.removeExistingSubscriptions(t)
6876
6877 const e2Timeout int64 = 1
6878 const e2RetryCount int64 = 0
6879 const routingNeeded bool = false
6880
6881 // Req1
6882 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6883 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6884 // Create subscription
6885 restSubId := xappConn1.SendRESTSubsReq(t, params)
6886 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6887
6888 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6889 xappConn1.ExpectRESTNotification(t, restSubId)
6890 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6891 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6892 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6893
6894 // Check subscription
6895 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6896
6897 // Policy change
6898 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6899 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6900 params.SetSubscriptionID(&restSubId)
6901 params.SetTimeToWait("w200ms")
6902 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
6903 restSubId = xappConn1.SendRESTSubsReq(t, params)
6904 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6905
6906 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6907 mainCtrl.SetResetTestFlag(t, false)
6908
6909 // SubsResp is missing due to submgr restart
6910
6911 mainCtrl.SimulateRestart(t)
6912 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
6913
6914 // Check subscription
6915 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6916
6917 xapp.Logger.Debug("Here 1")
6918 //<-time.After(3 * time.Second)
6919 xapp.Logger.Debug("Here 2")
6920
6921 // Delete subscription
6922 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6923 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6924 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6925
6926 //Wait that subs is cleaned
6927 waitSubsCleanup(t, e2SubsId, 10)
6928
6929 mainCtrl.VerifyCounterValues(t)
6930}
6931
archaggeafbf95f2021-04-14 08:54:05 +03006932////////////////////////////////////////////////////////////////////////////////////
6933// Services for UT cases
6934////////////////////////////////////////////////////////////////////////////////////
6935const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006936const host string = "localhost"
6937
6938func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
6939 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006940 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006941 }
6942 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006943 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006944
6945 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
6946 fromXappConn.ExpectRESTNotification(t, restSubId)
6947 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
6948 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006949 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006950
6951 return restSubId, e2SubsId
6952}
6953
6954func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
6955
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006956 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006957 if meid != "" {
6958 params.SetMeid(meid)
6959 }
6960 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
6961 restSubId := xappConn2.SendRESTSubsReq(t, params)
6962 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006963 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006964 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006965 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006966
6967 return restSubId, e2SubsId
6968}
6969
6970func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006971
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006972 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006973 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006974 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006975
6976 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6977 xappConn1.ExpectRESTNotification(t, restSubId)
6978 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6979 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006980 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006981
6982 return restSubId, e2SubsId
6983}
6984
6985func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006986 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006987 restSubId := xappConn1.SendRESTSubsReq(t, params)
6988
6989 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6990 fparams1 := &teststube2ap.E2StubSubsFailParams{}
6991 fparams1.Set(crereq1)
6992 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
6993
6994 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
6995 xappConn1.ExpectRESTNotification(t, restSubId)
6996 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
6997 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006998 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006999
7000 return restSubId, e2SubsId
7001}
7002
7003func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
7004 fromXappConn.SendRESTSubsDelReq(t, restSubId)
7005 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7006 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7007}
7008
7009func deleteXapp1Subscription(t *testing.T, restSubId *string) {
7010 xappConn1.SendRESTSubsDelReq(t, restSubId)
7011 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7012 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7013}
7014
7015func deleteXapp2Subscription(t *testing.T, restSubId *string) {
7016 xappConn2.SendRESTSubsDelReq(t, restSubId)
7017 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7018 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7019}
7020
7021func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
7022 resp, _ := xapp.Subscription.QuerySubscriptions()
7023 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
7024 assert.Equal(t, resp[0].Meid, meid)
7025 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
7026}
7027
7028func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
7029 //Wait that subs is cleaned
7030 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
7031
7032 xappConn1.TestMsgChanEmpty(t)
7033 xappConn2.TestMsgChanEmpty(t)
7034 e2termConn1.TestMsgChanEmpty(t)
7035 mainCtrl.wait_registry_empty(t, timeout)
7036}
7037
7038func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
7039
7040 var e2SubsId []uint32
7041
7042 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007043 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007044 crereq, cremsg := toE2termConn.RecvSubsReq(t)
7045 fromXappConn.ExpectRESTNotification(t, restSubId)
7046 toE2termConn.SendSubsResp(t, crereq, cremsg)
7047 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
7048 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007049 xapp.Logger.Debug("TEST: %v", e2SubsId)
7050 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007051 <-time.After(100 * time.Millisecond)
7052 }
7053 return e2SubsId
7054}
7055
7056func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
7057
7058 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007059 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007060 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7061 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7062 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007063 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007064 <-time.After(100 * time.Millisecond)
7065 }
7066
7067 // Wait that subs is cleaned
7068 for i := 0; i < len(e2SubsIds); i++ {
7069 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
7070 }
7071
7072}