blob: fd411bf9578845322eb1d4441907fdf4392fb590 [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// | | |
archaggeafbf95f2021-04-14 08:54:05 +03001449// | | SubDelReq |
1450// | |------------->|
1451// | | |
1452// | | SubDelResp |
1453// | |<-------------|
1454// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001455// | SubFail | |
1456// |<-------------| |
1457// | | |
1458//
1459//-----------------------------------------------------------------------------
1460
1461func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001462 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001463
1464 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1465 Counter{cSubReqFromXapp, 1},
1466 Counter{cSubReqToE2, 1},
1467 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001468 Counter{cSubFailToXapp, 1},
1469 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001470
1471 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001472 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001473
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001474 // E2t: Receive SubsReq and send SubsFail (first)
1475 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1476 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1477 fparams1.Set(crereq1)
1478 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1479
archaggeafbf95f2021-04-14 08:54:05 +03001480 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1481 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1482 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1483
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001484 // Xapp: Receive SubsFail
1485 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1486
1487 // Wait that subs is cleaned
1488 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1489
1490 xappConn1.TestMsgChanEmpty(t)
1491 xappConn2.TestMsgChanEmpty(t)
1492 e2termConn1.TestMsgChanEmpty(t)
1493 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001494
1495 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001496}
1497
1498//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001499// TestSubDelReqRetryInSubmgr
1500//
1501// stub stub
1502// +-------+ +---------+ +---------+
1503// | xapp | | submgr | | e2term |
1504// +-------+ +---------+ +---------+
1505// | | |
1506// | [SUBS CREATE] |
1507// | | |
1508// | | |
1509// | SubDelReq | |
1510// |------------->| |
1511// | | |
1512// | | SubDelReq |
1513// | |------------->|
1514// | | |
1515// | | SubDelReq |
1516// | |------------->|
1517// | | |
1518// | | SubDelResp |
1519// | |<-------------|
1520// | | |
1521// | SubDelResp | |
1522// |<-------------| |
1523//
1524//-----------------------------------------------------------------------------
1525
1526func TestSubDelReqRetryInSubmgr(t *testing.T) {
1527
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001528 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001529
1530 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001531 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001532 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1533 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001534 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001535
1536 // Subs Delete
1537 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001538 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001539
1540 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001541 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001542
1543 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001544 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1545 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001546
1547 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001548 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001549
1550 // Wait that subs is cleaned
1551 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1552
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001553 xappConn1.TestMsgChanEmpty(t)
1554 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001555 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001556 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001557}
1558
1559//-----------------------------------------------------------------------------
1560// TestSubDelReqTwoRetriesNoRespInSubmgr
1561//
1562// stub stub
1563// +-------+ +---------+ +---------+
1564// | xapp | | submgr | | e2term |
1565// +-------+ +---------+ +---------+
1566// | | |
1567// | [SUBS CREATE] |
1568// | | |
1569// | | |
1570// | SubDelReq | |
1571// |------------->| |
1572// | | |
1573// | | SubDelReq |
1574// | |------------->|
1575// | | |
1576// | | SubDelReq |
1577// | |------------->|
1578// | | |
1579// | | |
1580// | SubDelResp | |
1581// |<-------------| |
1582//
1583//-----------------------------------------------------------------------------
1584
1585func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1586
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001587 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001588
1589 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001590 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001591 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1592 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001593 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001594
1595 // Subs Delete
1596 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001597 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001598
1599 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001600 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001601
1602 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001603 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001604
1605 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001606 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001607
1608 // Wait that subs is cleaned
1609 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1610
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001611 xappConn1.TestMsgChanEmpty(t)
1612 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001613 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001614 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001615}
1616
1617//-----------------------------------------------------------------------------
1618// TestSubDelReqSubDelFailRespInSubmgr
1619//
1620// stub stub
1621// +-------+ +---------+ +---------+
1622// | xapp | | submgr | | e2term |
1623// +-------+ +---------+ +---------+
1624// | | |
1625// | [SUBS CREATE] |
1626// | | |
1627// | | |
1628// | SubDelReq | |
1629// |------------->| |
1630// | | |
1631// | | SubDelReq |
1632// | |------------->|
1633// | | |
1634// | | SubDelFail |
1635// | |<-------------|
1636// | | |
1637// | SubDelResp | |
1638// |<-------------| |
1639// | | |
1640//
1641//-----------------------------------------------------------------------------
1642
1643func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001644 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001645
1646 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1647 Counter{cSubReqFromXapp, 1},
1648 Counter{cSubReqToE2, 1},
1649 Counter{cSubRespFromE2, 1},
1650 Counter{cSubRespToXapp, 1},
1651 Counter{cSubDelReqFromXapp, 1},
1652 Counter{cSubDelReqToE2, 1},
1653 Counter{cSubDelFailFromE2, 1},
1654 Counter{cSubDelRespToXapp, 1},
1655 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001656
1657 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001658 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001659 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1660 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001661 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001662
1663 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001664 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001665
1666 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001667 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1668 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001669
1670 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001671 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001672
1673 // Wait that subs is cleaned
1674 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1675
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001676 xappConn1.TestMsgChanEmpty(t)
1677 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001678 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001679 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001680
1681 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001682}
1683
1684//-----------------------------------------------------------------------------
1685// TestSubReqAndSubDelOkSameAction
1686//
1687// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001688// +-------+ +-------+ +---------+ +---------+
1689// | xapp2 | | xapp1 | | submgr | | e2term |
1690// +-------+ +-------+ +---------+ +---------+
1691// | | | |
1692// | | | |
1693// | | | |
1694// | | SubReq1 | |
1695// | |------------->| |
1696// | | | |
1697// | | | SubReq1 |
1698// | | |------------->|
1699// | | | SubResp1 |
1700// | | |<-------------|
1701// | | SubResp1 | |
1702// | |<-------------| |
1703// | | | |
1704// | SubReq2 | |
1705// |--------------------------->| |
1706// | | | |
1707// | SubResp2 | |
1708// |<---------------------------| |
1709// | | | |
1710// | | SubDelReq 1 | |
1711// | |------------->| |
1712// | | | |
1713// | | SubDelResp 1 | |
1714// | |<-------------| |
1715// | | | |
1716// | SubDelReq 2 | |
1717// |--------------------------->| |
1718// | | | |
1719// | | | SubDelReq 2 |
1720// | | |------------->|
1721// | | | |
1722// | | | SubDelReq 2 |
1723// | | |------------->|
1724// | | | |
1725// | SubDelResp 2 | |
1726// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001727//
1728//-----------------------------------------------------------------------------
1729func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001730 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001731
Anssi Mannila4abf1802021-01-28 13:06:46 +02001732 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001733 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1734 Counter{cSubReqFromXapp, 2},
1735 Counter{cSubReqToE2, 1},
1736 Counter{cSubRespFromE2, 1},
1737 Counter{cSubRespToXapp, 2},
1738 Counter{cMergedSubscriptions, 1},
1739 Counter{cUnmergedSubscriptions, 1},
1740 Counter{cSubDelReqFromXapp, 2},
1741 Counter{cSubDelReqToE2, 1},
1742 Counter{cSubDelRespFromE2, 1},
1743 Counter{cSubDelRespToXapp, 2},
1744 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001745
Juha Hyttinen3944a222020-01-24 11:51:46 +02001746 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001747 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001748 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001749 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001750 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1751 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001752 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001753
1754 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001755 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001756 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001757 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001758 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1759 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001760 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001761
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001762 resp, _ := xapp.Subscription.QuerySubscriptions()
1763 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1764 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001765 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001766
Juha Hyttinen3944a222020-01-24 11:51:46 +02001767 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001768 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001769 //e2termConn1.RecvSubsDelReq(t)
1770 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001771 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001772 //Wait that subs is cleaned
1773 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1774
1775 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001776 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001777 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1778 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001779 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001780 //Wait that subs is cleaned
1781 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1782
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001783 xappConn1.TestMsgChanEmpty(t)
1784 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001785 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001786 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001787
1788 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001789}
1790
1791//-----------------------------------------------------------------------------
1792// TestSubReqAndSubDelOkSameActionParallel
1793//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001794// stub stub stub
1795// +-------+ +-------+ +---------+ +---------+
1796// | xapp2 | | xapp1 | | submgr | | e2term |
1797// +-------+ +-------+ +---------+ +---------+
1798// | | | |
1799// | | | |
1800// | | | |
1801// | | SubReq1 | |
1802// | |------------->| |
1803// | | | |
1804// | | | SubReq1 |
1805// | | |------------->|
1806// | SubReq2 | |
1807// |--------------------------->| |
1808// | | | SubResp1 |
1809// | | |<-------------|
1810// | | SubResp1 | |
1811// | |<-------------| |
1812// | | | |
1813// | SubResp2 | |
1814// |<---------------------------| |
1815// | | | |
1816// | | SubDelReq 1 | |
1817// | |------------->| |
1818// | | | |
1819// | | SubDelResp 1 | |
1820// | |<-------------| |
1821// | | | |
1822// | SubDelReq 2 | |
1823// |--------------------------->| |
1824// | | | |
1825// | | | SubDelReq 2 |
1826// | | |------------->|
1827// | | | |
1828// | | | SubDelReq 2 |
1829// | | |------------->|
1830// | | | |
1831// | SubDelResp 2 | |
1832// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001833//
1834//-----------------------------------------------------------------------------
1835func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001836 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001837
1838 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001839 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001840 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001841 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001842 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001843
1844 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001845 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001846 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001847 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001848
1849 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001850 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001851 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001852
1853 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001854 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001855
1856 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001857 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1858 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001859
1860 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001861 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001862 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1863 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001864 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001865
1866 //Wait that subs is cleaned
1867 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1868
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001869 xappConn1.TestMsgChanEmpty(t)
1870 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001871 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001872 mainCtrl.wait_registry_empty(t, 10)
1873}
1874
1875//-----------------------------------------------------------------------------
1876// TestSubReqAndSubDelNokSameActionParallel
1877//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001878// stub stub stub
1879// +-------+ +-------+ +---------+ +---------+
1880// | xapp2 | | xapp1 | | submgr | | e2term |
1881// +-------+ +-------+ +---------+ +---------+
1882// | | | |
1883// | | | |
1884// | | | |
1885// | | SubReq1 | |
1886// | |------------->| |
1887// | | | |
1888// | | | SubReq1 |
1889// | | |------------->|
1890// | SubReq2 | |
1891// |--------------------------->| |
1892// | | | SubFail1 |
1893// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001894// | | | |
archaggeafbf95f2021-04-14 08:54:05 +03001895// | | | SubDelReq |
1896// | | |------------->|
1897// | | | SubDelResp |
1898// | | |<-------------|
1899// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001900// | | SubFail1 | |
1901// | |<-------------| |
1902// | | | |
1903// | SubFail2 | |
1904// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001905//
1906//-----------------------------------------------------------------------------
1907func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001908 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001909
1910 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001911 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001912 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001913 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001914
1915 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001916 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001917
1918 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001919 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001920 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001921 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001922 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001923 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001924
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001925 // E2t: send SubsFail (first)
1926 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1927 fparams1.Set(crereq1)
1928 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1929
archaggeafbf95f2021-04-14 08:54:05 +03001930 // E2t: internal delete
1931 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1932 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1933
Juha Hyttinen3944a222020-01-24 11:51:46 +02001934 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001935 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001936 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001937 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001938
1939 //Wait that subs is cleaned
1940 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1941
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001942 xappConn1.TestMsgChanEmpty(t)
1943 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001944 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001945 mainCtrl.wait_registry_empty(t, 10)
1946}
1947
1948//-----------------------------------------------------------------------------
1949// TestSubReqAndSubDelNoAnswerSameActionParallel
1950//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001951// stub stub stub
1952// +-------+ +-------+ +---------+ +---------+
1953// | xapp2 | | xapp1 | | submgr | | e2term |
1954// +-------+ +-------+ +---------+ +---------+
1955// | | | |
1956// | | | |
1957// | | | |
1958// | | SubReq1 | |
1959// | |------------->| |
1960// | | | |
1961// | | | SubReq1 |
1962// | | |------------->|
1963// | | SubReq2 | |
1964// |--------------------------->| |
1965// | | | |
1966// | | | SubReq1 |
1967// | | |------------->|
1968// | | | |
1969// | | | |
1970// | | | SubDelReq |
1971// | | |------------->|
1972// | | | |
1973// | | | SubDelResp |
1974// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001975//
1976//-----------------------------------------------------------------------------
1977func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001978 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001979
1980 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001981 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001982 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001983 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001984
Juha Hyttinen1683f912020-04-17 10:39:57 +03001985 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001986
1987 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001988 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001989 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001990 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001991 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001992 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001993
1994 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001995 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001996
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001997 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1998 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001999
2000 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03002001 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002002
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002003 xappConn1.TestMsgChanEmpty(t)
2004 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002005 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002006 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02002007}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002008
2009//----------------------------- Policy cases ---------------------------------
2010//-----------------------------------------------------------------------------
2011// TestSubReqPolicyAndSubDelOk
2012//
2013// stub stub
2014// +-------+ +---------+ +---------+
2015// | xapp | | submgr | | e2term |
2016// +-------+ +---------+ +---------+
2017// | | |
2018// | SubReq | |
2019// |------------->| |
2020// | | |
2021// | | SubReq |
2022// | |------------->|
2023// | | |
2024// | | SubResp |
2025// | |<-------------|
2026// | | |
2027// | SubResp | |
2028// |<-------------| |
2029// | | |
2030// | | |
2031// | SubDelReq | |
2032// |------------->| |
2033// | | |
2034// | | SubDelReq |
2035// | |------------->|
2036// | | |
2037// | | SubDelResp |
2038// | |<-------------|
2039// | | |
2040// | SubDelResp | |
2041// |<-------------| |
2042//
2043//-----------------------------------------------------------------------------
2044func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2045 CaseBegin("TestSubReqAndSubDelOk")
2046
2047 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2048 rparams1.Init()
2049 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2050 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2051
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002052 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2053 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002054 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2055 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002056 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002057
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002058 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002059 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002060
2061 //Wait that subs is cleaned
2062 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2063
2064 xappConn1.TestMsgChanEmpty(t)
2065 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002066 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002067 mainCtrl.wait_registry_empty(t, 10)
2068}
2069
2070//-----------------------------------------------------------------------------
2071// TestSubReqPolicyChangeAndSubDelOk
2072//
2073// stub stub
2074// +-------+ +---------+ +---------+
2075// | xapp | | submgr | | e2term |
2076// +-------+ +---------+ +---------+
2077// | | |
2078// | SubReq | |
2079// |------------->| |
2080// | | |
2081// | | SubReq |
2082// | |------------->|
2083// | | |
2084// | | SubResp |
2085// | |<-------------|
2086// | | |
2087// | SubResp | |
2088// |<-------------| |
2089// | | |
2090// | SubReq | |
2091// |------------->| |
2092// | | |
2093// | | SubReq |
2094// | |------------->|
2095// | | |
2096// | | SubResp |
2097// | |<-------------|
2098// | | |
2099// | SubResp | |
2100// |<-------------| |
2101// | | |
2102// | SubDelReq | |
2103// |------------->| |
2104// | | |
2105// | | SubDelReq |
2106// | |------------->|
2107// | | |
2108// | | SubDelResp |
2109// | |<-------------|
2110// | | |
2111// | SubDelResp | |
2112// |<-------------| |
2113//
2114//-----------------------------------------------------------------------------
2115
2116func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2117 CaseBegin("TestSubReqAndSubDelOk")
2118
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002119 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2120 rparams1.Init()
2121 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2122 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002123
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002124 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2125 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002126 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2127
2128 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002129 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002130 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2131 xappConn1.SendSubsReq(t, rparams1, cretrans)
2132
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002133 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2134 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002135 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2136 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002137 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002138
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002139 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002140 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002141
2142 //Wait that subs is cleaned
2143 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2144
2145 xappConn1.TestMsgChanEmpty(t)
2146 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002147 e2termConn1.TestMsgChanEmpty(t)
2148 mainCtrl.wait_registry_empty(t, 10)
2149}
2150
2151//-----------------------------------------------------------------------------
2152// TestSubReqAndSubDelOkTwoE2termParallel
2153//
2154// stub stub stub
2155// +-------+ +---------+ +---------+ +---------+
2156// | xapp | | submgr | | e2term1 | | e2term2 |
2157// +-------+ +---------+ +---------+ +---------+
2158// | | | |
2159// | | | |
2160// | | | |
2161// | SubReq1 | | |
2162// |------------->| | |
2163// | | | |
2164// | | SubReq1 | |
2165// | |------------->| |
2166// | | | |
2167// | SubReq2 | | |
2168// |------------->| | |
2169// | | | |
2170// | | SubReq2 | |
2171// | |---------------------------->|
2172// | | | |
2173// | | SubResp1 | |
2174// | |<-------------| |
2175// | SubResp1 | | |
2176// |<-------------| | |
2177// | | SubResp2 | |
2178// | |<----------------------------|
2179// | SubResp2 | | |
2180// |<-------------| | |
2181// | | | |
2182// | [SUBS 1 DELETE] | |
2183// | | | |
2184// | [SUBS 2 DELETE] | |
2185// | | | |
2186//
2187//-----------------------------------------------------------------------------
2188func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2189 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2190
2191 //Req1
2192 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2193 xappConn1.SendSubsReq(t, nil, cretrans1)
2194 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2195
2196 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2197 xappConn1.SendSubsReq(t, nil, cretrans2)
2198 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2199
2200 //Resp1
2201 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2202 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2203
2204 //Resp2
2205 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2206 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2207
2208 //Del1
2209 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2210 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2211 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2212 xappConn1.RecvSubsDelResp(t, deltrans1)
2213 //Wait that subs is cleaned
2214 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2215
2216 //Del2
2217 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2218 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2219 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2220 xappConn1.RecvSubsDelResp(t, deltrans2)
2221 //Wait that subs is cleaned
2222 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2223
2224 xappConn1.TestMsgChanEmpty(t)
2225 xappConn2.TestMsgChanEmpty(t)
2226 e2termConn1.TestMsgChanEmpty(t)
2227 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002228 mainCtrl.wait_registry_empty(t, 10)
2229}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002230
2231//-----------------------------------------------------------------------------
2232// TestSubReqInsertAndSubDelOk
2233//
2234// stub stub
2235// +-------+ +---------+ +---------+
2236// | xapp | | submgr | | e2term |
2237// +-------+ +---------+ +---------+
2238// | | |
2239// | SubReq | |
2240// |------------->| |
2241// | | |
2242// | | SubReq |
2243// | |------------->|
2244// | | |
2245// | | SubResp |
2246// | |<-------------|
2247// | | |
2248// | SubResp | |
2249// |<-------------| |
2250// | | |
2251// | | |
2252// | SubDelReq | |
2253// |------------->| |
2254// | | |
2255// | | SubDelReq |
2256// | |------------->|
2257// | | |
2258// | | SubDelResp |
2259// | |<-------------|
2260// | | |
2261// | SubDelResp | |
2262// |<-------------| |
2263//
2264//-----------------------------------------------------------------------------
2265func TestSubReqInsertAndSubDelOk(t *testing.T) {
2266 CaseBegin("TestInsertSubReqAndSubDelOk")
2267
2268 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2269 rparams1.Init()
2270 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2271 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2272
2273 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2274 e2termConn1.SendSubsResp(t, crereq, cremsg)
2275 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2276 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2277 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2278
2279 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2280 xappConn1.RecvSubsDelResp(t, deltrans)
2281
2282 //Wait that subs is cleaned
2283 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2284
2285 xappConn1.TestMsgChanEmpty(t)
2286 xappConn2.TestMsgChanEmpty(t)
2287 e2termConn1.TestMsgChanEmpty(t)
2288 mainCtrl.wait_registry_empty(t, 10)
2289}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002290
2291//-----------------------------------------------------------------------------
2292// TestSubReqRetransmissionWithSameSubIdDiffXid
2293//
2294// This case simulates case where xApp restarts and starts sending same
2295// subscription requests which have already subscribed successfully
2296
2297// stub stub
2298// +-------+ +---------+ +---------+
2299// | xapp | | submgr | | e2term |
2300// +-------+ +---------+ +---------+
2301// | | |
2302// | SubReq | |
2303// |------------->| |
2304// | | |
2305// | | SubReq |
2306// | |------------->|
2307// | | |
2308// | | SubResp |
2309// | |<-------------|
2310// | | |
2311// | SubResp | |
2312// |<-------------| |
2313// | | |
2314// | xApp restart | |
2315// | | |
2316// | SubReq | |
2317// | (retrans with same xApp generated subid but diff xid)
2318// |------------->| |
2319// | | |
2320// | SubResp | |
2321// |<-------------| |
2322// | | |
2323// | [SUBS DELETE] |
2324// | | |
2325//
2326//-----------------------------------------------------------------------------
2327func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2328 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2329
2330 //Subs Create
2331 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2332 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2333 e2termConn1.SendSubsResp(t, crereq, cremsg)
2334 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2335
2336 // xApp restart here
2337 // --> artificial delay
2338 <-time.After(1 * time.Second)
2339
2340 //Subs Create
2341 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2342 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2343
2344 //Subs Delete
2345 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2346 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2347 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2348 xappConn1.RecvSubsDelResp(t, deltrans)
2349
2350 //Wait that subs is cleaned
2351 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2352
2353 xappConn1.TestMsgChanEmpty(t)
2354 xappConn2.TestMsgChanEmpty(t)
2355 e2termConn1.TestMsgChanEmpty(t)
2356 mainCtrl.wait_registry_empty(t, 10)
2357}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002358
2359//-----------------------------------------------------------------------------
2360// TestSubReqNokAndSubDelOkWithRestartInMiddle
2361//
2362// stub stub
2363// +-------+ +---------+ +---------+
2364// | xapp | | submgr | | e2term |
2365// +-------+ +---------+ +---------+
2366// | | |
2367// | SubReq | |
2368// |------------->| |
2369// | | |
2370// | | SubReq |
2371// | |------------->|
2372// | | |
2373// | | SubResp |
2374// | <----|
2375// | |
2376// | Submgr restart |
2377// | |
2378// | | |
2379// | | SubDelReq |
2380// | |------------->|
2381// | | |
2382// | | SubDelResp |
2383// | |<-------------|
2384// | | |
2385//
2386//-----------------------------------------------------------------------------
2387
2388func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2389 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2390
2391 // Remove possible existing subscrition
2392 mainCtrl.removeExistingSubscriptions(t)
2393
2394 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2395 xappConn1.SendSubsReq(t, nil, nil)
2396 e2termConn1.RecvSubsReq(t)
2397 mainCtrl.SetResetTestFlag(t, false)
2398
2399 resp, _ := xapp.Subscription.QuerySubscriptions()
2400 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002401 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002402 e2SubsId := uint32(resp[0].SubscriptionID)
2403 t.Logf("e2SubsId = %v", e2SubsId)
2404
archaggeafbf95f2021-04-14 08:54:05 +03002405 mainCtrl.SimulateRestart(t)
2406 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002407
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002408 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002409 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2410 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2411
2412 // Wait that subs is cleaned
2413 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2414
2415 xappConn1.TestMsgChanEmpty(t)
2416 xappConn2.TestMsgChanEmpty(t)
2417 e2termConn1.TestMsgChanEmpty(t)
2418 mainCtrl.wait_registry_empty(t, 10)
2419}
2420
2421//-----------------------------------------------------------------------------
2422// TestSubReqAndSubDelOkWithRestartInMiddle
2423//
2424// stub stub
2425// +-------+ +---------+ +---------+
2426// | xapp | | submgr | | e2term |
2427// +-------+ +---------+ +---------+
2428// | | |
2429// | SubReq | |
2430// |------------->| |
2431// | | |
2432// | | SubReq |
2433// | |------------->|
2434// | | |
2435// | | SubResp |
2436// | |<-------------|
2437// | | |
2438// | SubResp | |
2439// |<-------------| |
2440// | | |
2441// | |
2442// | Submgr restart |
2443// | |
2444// | SubDelReq | |
2445// |------------->| |
2446// | | |
2447// | | SubDelReq |
2448// | |------------->|
2449// | | |
2450// | | SubDelResp |
2451// | |<-------------|
2452// | | |
2453// | SubDelResp | |
2454// |<-------------| |
2455//
2456//-----------------------------------------------------------------------------
2457
2458func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2459 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2460
2461 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2462 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2463 e2termConn1.SendSubsResp(t, crereq, cremsg)
2464 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2465
2466 // Check subscription
2467 resp, _ := xapp.Subscription.QuerySubscriptions()
2468 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2469 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002470 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002471
2472 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002473 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002474
2475 // Check that subscription is restored correctly after restart
2476 resp, _ = xapp.Subscription.QuerySubscriptions()
2477 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2478 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002479 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002480
2481 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2482 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2483 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2484 xappConn1.RecvSubsDelResp(t, deltrans)
2485
2486 //Wait that subs is cleaned
2487 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2488
2489 xappConn1.TestMsgChanEmpty(t)
2490 xappConn2.TestMsgChanEmpty(t)
2491 e2termConn1.TestMsgChanEmpty(t)
2492 mainCtrl.wait_registry_empty(t, 10)
2493}
2494
2495//-----------------------------------------------------------------------------
2496// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2497//
2498// stub stub
2499// +-------+ +-------+ +---------+ +---------+
2500// | xapp2 | | xapp1 | | submgr | | e2term |
2501// +-------+ +-------+ +---------+ +---------+
2502// | | | |
2503// | | | |
2504// | | | |
2505// | | SubReq1 | |
2506// | |------------->| |
2507// | | | |
2508// | | | SubReq1 |
2509// | | |------------->|
2510// | | | SubResp1 |
2511// | | |<-------------|
2512// | | SubResp1 | |
2513// | |<-------------| |
2514// | | | |
2515// | |
2516// | submgr restart |
2517// | |
2518// | | | |
2519// | | | |
2520// | SubReq2 | |
2521// |--------------------------->| |
2522// | | | |
2523// | SubResp2 | |
2524// |<---------------------------| |
2525// | | | |
2526// | | SubDelReq 1 | |
2527// | |------------->| |
2528// | | | |
2529// | | SubDelResp 1 | |
2530// | |<-------------| |
2531// | | | |
2532// | | | |
2533// | |
2534// | submgr restart |
2535// | |
2536// | | | |
2537// | SubDelReq 2 | |
2538// |--------------------------->| |
2539// | | | |
2540// | | | SubDelReq 2 |
2541// | | |------------->|
2542// | | | |
2543// | | | SubDelReq 2 |
2544// | | |------------->|
2545// | | | |
2546// | SubDelResp 2 | |
2547// |<---------------------------| |
2548//
2549//-----------------------------------------------------------------------------
2550
2551func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2552 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2553
2554 //Req1
2555 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2556 rparams1.Init()
2557 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2558 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2559 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2560 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2561
2562 //Req2
2563 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2564 rparams2.Init()
2565 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2566 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2567
2568 // Check subscription
2569 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2570 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2571 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002572 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002573
2574 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002575 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002576
2577 // Check that subscription is restored correctly after restart
2578 resp, _ = xapp.Subscription.QuerySubscriptions()
2579 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2580 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002581 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002582
2583 //Del1
2584 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2585 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2586 xappConn1.RecvSubsDelResp(t, deltrans1)
2587 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2588
2589 mainCtrl.SimulateRestart(t)
2590 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2591
2592 //Del2
2593 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2594 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2595
2596 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2597 xappConn2.RecvSubsDelResp(t, deltrans2)
2598
2599 //Wait that subs is cleaned
2600 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2601
2602 xappConn1.TestMsgChanEmpty(t)
2603 xappConn2.TestMsgChanEmpty(t)
2604 e2termConn1.TestMsgChanEmpty(t)
2605 mainCtrl.wait_registry_empty(t, 10)
2606}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002607
archaggeafbf95f2021-04-14 08:54:05 +03002608//*****************************************************************************
2609// REST interface test cases
2610//*****************************************************************************
2611
Anssi Mannila47518ae2021-04-16 09:27:07 +03002612//-----------------------------------------------------------------------------
2613// Test debug GET and POST requests
2614//
2615// curl
2616// +-------+ +---------+
2617// | user | | submgr |
2618// +-------+ +---------+
2619// | |
2620// | GET/POST Req |
2621// |------------->|
2622// | Resp |
2623// |<-------------|
2624// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002625func TestGetSubscriptions(t *testing.T) {
2626
2627 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2628}
2629
2630func TestGetSymptomData(t *testing.T) {
2631
2632 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2633}
2634
2635func TestPostdeleteSubId(t *testing.T) {
2636
2637 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2638}
2639
2640func TestPostEmptyDb(t *testing.T) {
2641
2642 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2643}
archaggeafbf95f2021-04-14 08:54:05 +03002644
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002645func TestGetRestSubscriptions(t *testing.T) {
2646
2647 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2648}
2649
archaggeafbf95f2021-04-14 08:54:05 +03002650//-----------------------------------------------------------------------------
2651// TestRESTSubReqAndRouteNok
2652//
2653// stub stub
2654// +-------+ +---------+ +---------+
2655// | xapp | | submgr | | rtmgr |
2656// +-------+ +---------+ +---------+
2657// | | |
2658// | RESTSubReq | |
2659// |---------------->| |
2660// | | |
2661// | RESTSubResp | |
2662// |<----------------| |
2663// | | RouteCreate |
2664// | |------------->|
2665// | | |
2666// | | RouteCreate |
2667// | | status:400 |
2668// | |(Bad request) |
2669// | |<-------------|
2670// | RESTNotif | |
2671// |<----------------| |
2672// | | |
2673// | [SUBS INT DELETE] |
2674// | | |
2675// | RESTSubDelReq | |
2676// |---------------->| |
2677// | RESTSubDelResp | |
2678// |<----------------| |
2679//
2680//-----------------------------------------------------------------------------
2681func TestRESTSubReqAndRouteNok(t *testing.T) {
2682 CaseBegin("TestRESTSubReqAndRouteNok")
2683
2684 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002685 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002686 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002687 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002688 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002689 Counter{cRestSubDelReqFromXapp, 1},
2690 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002691 })
2692
2693 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002694
Markku Virtanenda34eec2021-05-20 08:22:04 +00002695 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2696 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002697 newSubsId := mainCtrl.get_registry_next_subid(t)
2698
2699 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002700 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002701 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002702 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002703 waiter.WaitResult(t)
2704
archaggeafbf95f2021-04-14 08:54:05 +03002705 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002706 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002707
2708 // Del
2709 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2710
2711 // Wait that subs is cleaned
2712 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2713 waitSubsCleanup(t, e2SubsId, 10)
2714 mainCtrl.VerifyCounterValues(t)
2715}
2716
2717func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2718 CaseBegin("TestSubReqAndRouteUpdateNok")
2719
2720 //Init counter check
2721 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002722 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002723 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002724 Counter{cSubReqToE2, 1},
2725 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002726 Counter{cRestSubNotifToXapp, 1},
2727 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002728 Counter{cRouteCreateUpdateFail, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002729 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002730 Counter{cSubDelReqToE2, 1},
2731 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002732 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002733 })
2734
2735 var params *teststube2ap.RESTSubsReqParams = nil
2736
2737 //Subs Create
2738 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2739
2740 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2741
2742 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2743 waiter := rtmgrHttp.AllocNextEvent(false)
2744 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002745 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002746 params.SetMeid("RAN_NAME_1")
2747 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002748 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002749 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002750 waiter.WaitResult(t)
2751 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2752 xappConn2.WaitRESTNotification(t, restSubId2)
2753
2754 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2755
2756 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2757
2758 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2759 //Wait that subs is cleaned
2760 waitSubsCleanup(t, e2SubsId, 10)
2761
2762 mainCtrl.VerifyCounterValues(t)
2763}
2764
2765func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2766 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2767
2768 // Init counter check
2769 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002770 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002771 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002772 Counter{cSubReqToE2, 1},
2773 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002774 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002775 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002776 Counter{cRouteDeleteFail, 1},
2777 Counter{cSubDelReqToE2, 1},
2778 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002779 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002780 })
2781
2782 var params *teststube2ap.RESTSubsReqParams = nil
2783
2784 //Subs Create
2785 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2786
2787 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2788
2789 waiter := rtmgrHttp.AllocNextEvent(false)
2790 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2791 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2792 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2793 waiter.WaitResult(t)
2794
2795 waitSubsCleanup(t, e2SubsId, 10)
2796
2797 mainCtrl.VerifyCounterValues(t)
2798}
2799
2800func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2801 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2802
2803 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002804 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002805 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002806 Counter{cSubReqToE2, 1},
2807 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002808 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002809 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002810 Counter{cRouteDeleteUpdateFail, 1},
2811 Counter{cSubDelReqToE2, 1},
2812 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002813 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002814 })
2815
2816 var params *teststube2ap.RESTSubsReqParams = nil
2817
2818 //Subs Create
2819 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2820
2821 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2822 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2823
2824 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2825
2826 //Del1, this shall fail on rtmgr side
2827 waiter := rtmgrHttp.AllocNextEvent(false)
2828 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2829 waiter.WaitResult(t)
2830
2831 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2832
2833 //Del2
2834 deleteXapp2Subscription(t, &restSubId2)
2835
2836 waitSubsCleanup(t, e2SubsId2, 10)
2837
2838 mainCtrl.VerifyCounterValues(t)
2839}
2840
2841//-----------------------------------------------------------------------------
2842// TestRESTSubReqRetransmission
2843//
2844// stub stub
2845// +-------+ +---------+ +---------+
2846// | xapp | | submgr | | e2term |
2847// +-------+ +---------+ +---------+
2848// | | |
2849// | RESTSubReq1 | |
2850// |---------------->| |
2851// | | |
2852// | RESTSubResp | |
2853// |<----------------| |
2854// | | SubReq1 |
2855// | |------------->|
2856// | | |
2857// | RESTSubReq2 | |
2858// | (retrans) | |
2859// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002860// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002861// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002862// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002863// | | SubResp1 |
2864// | |<-------------|
2865// | RESTNotif1 | |
2866// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002867// | | |
2868// | [SUBS DELETE] |
2869// | | |
2870//
2871//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002872
archaggeafbf95f2021-04-14 08:54:05 +03002873func TestRESTSubReqRetransmission(t *testing.T) {
2874 CaseBegin("TestRESTSubReqRetransmission")
2875
2876 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002877 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002878 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002879 Counter{cSubReqToE2, 1},
2880 Counter{cSubRespFromE2, 1},
2881 Counter{cRestSubNotifToXapp, 1},
2882 Counter{cRestSubDelReqFromXapp, 1},
2883 Counter{cSubDelReqToE2, 1},
2884 Counter{cSubDelRespFromE2, 1},
2885 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002886 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002887 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002888 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2889 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2890
2891 // Subs Create
2892 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002893
2894 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2895 // gets into execution before the rtmgrg responds for the first one.
2896 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002897 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002898 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenb642a192021-06-09 09:08:14 +00002899 xappConn2.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002900
2901 waiter.WaitResult(t)
2902
Markku Virtanenb642a192021-06-09 09:08:14 +00002903 xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
archaggeafbf95f2021-04-14 08:54:05 +03002904
2905 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2906 // the order is not significant he6re.
2907 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2908 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002909
2910 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002911 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03002912
2913 // Del1
2914 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2915 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2916 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2917
Markku Virtanenb642a192021-06-09 09:08:14 +00002918 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002919
2920 mainCtrl.VerifyCounterValues(t)
2921}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002922
Markku Virtanen42723e22021-06-15 10:09:23 +03002923//-----------------------------------------------------------------------------
2924// stub stub stub
2925// +-------+ +---------+ +---------+ +---------+
2926// | xapp | | submgr | | e2term | | rtmgr |
2927// +-------+ +---------+ +---------+ +---------+
2928// | | | |
2929// | RESTSubReq | | |
2930// |---------------->| | |
2931// | RESTSubResp | | |
2932// |<----------------| | |
2933// | | RouteCreate | |
2934// | |--------------------------->|
2935// | | RouteResponse| |
2936// | |<---------------------------| // The order of these events may vary
2937// | | SubReq | |
2938// | |------------->| | // The order of these events may vary
2939// | | SubResp | |
2940// | |<-------------| |
2941// | RESTNotif1 | | |
2942// |<----------------| | |
2943// | RESTSubReq | | |
2944// | [RETRANS1] | | |
2945// |---------------->| | |
2946// | RESTNotif1 | | |
2947// |<----------------| | |
2948// | RESTSubReq | | |
2949// | [RETRANS2] | | |
2950// |---------------->| | |
2951// | RESTNotif1 | | |
2952// |<----------------| | |
2953// | RESTSubDelReq | | |
2954// |---------------->| | |
2955// | | SubDelReq | |
2956// | |------------->| |
2957// | RESTSubDelResp| | |
2958// |<----------------| | |
2959// | | SubDelResp | |
2960// | |<-------------| |
2961// | | | |
2962//
2963//-----------------------------------------------------------------------------
2964
2965func TestRESTSubReqRetransmissionV2(t *testing.T) {
2966 CaseBegin("TestRESTSubReqRetransmissionV2")
2967
2968 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2969 Counter{cRestSubReqFromXapp, 3},
2970 Counter{cRestSubRespToXapp, 3},
2971 Counter{cSubReqToE2, 1},
2972 Counter{cSubRespFromE2, 1},
2973 Counter{cRestSubNotifToXapp, 3},
2974 Counter{cRestSubDelReqFromXapp, 1},
2975 Counter{cSubDelReqToE2, 1},
2976 Counter{cSubDelRespFromE2, 1},
2977 Counter{cRestSubDelRespToXapp, 1},
2978 })
2979
2980 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2981
2982 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2983
2984 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2985
2986 //1.st resend
2987 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2988
2989 assert.Equal(t, restSubId_resend, restSubId)
2990
2991 <-time.After(100 * time.Millisecond)
2992
2993 //2.nd resend
2994 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2995
2996 assert.Equal(t, restSubId_resend2, restSubId)
2997
2998 <-time.After(100 * time.Millisecond)
2999
3000 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3001
3002 waitSubsCleanup(t, e2SubsId, 10)
3003
3004 //Wait that subs is cleaned
3005 mainCtrl.VerifyCounterValues(t)
3006}
3007
3008//-----------------------------------------------------------------------------
3009// stub stub stub
3010// +-------+ +---------+ +---------+ +---------+
3011// | xapp | | submgr | | e2term | | rtmgr |
3012// +-------+ +---------+ +---------+ +---------+
3013// | | | |
3014// | RESTSubReq | | |
3015// |---------------->| | |
3016// | RESTSubResp | | |
3017// |<----------------| | |
3018// | | RouteCreate | |
3019// | |--------------------------->|
3020// | | RouteResponse| |
3021// | |<---------------------------| // The order of these events may vary
3022// | | SubReq | |
3023// | |------------->| | // The order of these events may vary
3024// | | SubResp | |
3025// | |<-------------| |
3026// | RESTNotif1 | | |
3027// |<----------------| | |
3028// | RESTSubReq | | |
3029// | [RETRANS, with RESTsubsId] | |
3030// |---------------->| | |
3031// | RESTNotif1 | | |
3032// |<----------------| | |
3033// | RESTSubReq | | |
3034// | [RETRANS, without RESTsubsId] | |
3035// |---------------->| | |
3036// | RESTNotif1 | | |
3037// |<----------------| | |
3038// | RESTSubDelReq | | |
3039// |---------------->| | |
3040// | | SubDelReq | |
3041// | |------------->| |
3042// | RESTSubDelResp| | |
3043// |<----------------| | |
3044// | | SubDelResp | |
3045// | |<-------------| |
3046// | | | |
3047//
3048//-----------------------------------------------------------------------------
3049func TestRESTSubReqRetransmissionV3(t *testing.T) {
3050 CaseBegin("TestRESTSubReqRetransmissionV3")
3051
3052 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3053 Counter{cRestSubReqFromXapp, 3},
3054 Counter{cRestSubRespToXapp, 3},
3055 Counter{cSubReqToE2, 1},
3056 Counter{cSubRespFromE2, 1},
3057 Counter{cRestSubNotifToXapp, 3},
3058 Counter{cRestSubDelReqFromXapp, 1},
3059 Counter{cSubDelReqToE2, 1},
3060 Counter{cSubDelRespFromE2, 1},
3061 Counter{cRestSubDelRespToXapp, 1},
3062 })
3063
3064 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3065
3066 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3067
3068 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3069
3070 <-time.After(100 * time.Millisecond)
3071
3072 //1.st resend with subscription ID
3073 params.SetSubscriptionID(&restSubId)
3074 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3075
3076 assert.Equal(t, restSubId_resend, restSubId)
3077
3078 <-time.After(100 * time.Millisecond)
3079
3080 //2.nd resend without subscription ID (faking app restart)
3081 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3082 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3083
3084 assert.Equal(t, restSubId_resend2, restSubId)
3085
3086 <-time.After(100 * time.Millisecond)
3087
3088 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3089
3090 waitSubsCleanup(t, e2SubsId, 10)
3091
3092 //Wait that subs is cleaned
3093 mainCtrl.VerifyCounterValues(t)
3094}
3095
3096//-----------------------------------------------------------------------------
3097// stub stub stub
3098// +-------+ +---------+ +---------+ +---------+
3099// | xapp | | submgr | | e2term | | rtmgr |
3100// +-------+ +---------+ +---------+ +---------+
3101// | | | |
3102// | RESTSubReq | | |
3103// |---------------->| | |
3104// | RESTSubResp | | |
3105// |<----------------| | |
3106// | | RouteCreate | |
3107// | |--------------------------->|
3108// | | RouteResponse| |
3109// | |<---------------------------|
3110// | | SubReq | |
3111// | |------------->| |
3112// | | SubResp | |
3113// | |<-------------| |
3114// | RESTNotif1 | | |
3115// |<----------------| | |
3116// | RESTSubReq | | |
3117// | [with RestSUbsId + one additional e2 subDetail]
3118// |---------------->| | |
3119// | RESTNotif1 | | |
3120// | [for initial e2 subDetail] | |
3121// |<----------------| | |
3122// | | RouteCreate | |
3123// | |--------------------------->|
3124// | | RouteResponse| |
3125// | |<---------------------------|
3126// | | SubReq | |
3127// | |------------->| |
3128// | | SubResp | |
3129// | |<-------------| |
3130// | RESTNotif1 | | |
3131// |<----------------| | |
3132// | RESTSubReq | | |
3133// | [with RESTsubsId initial request] |
3134// |---------------->| | |
3135// | RESTNotif1 | | |
3136// |<----------------| | |
3137// | RESTSubDelReq | | |
3138// |---------------->| | |
3139// | RESTSubDelResp| | |
3140// |<----------------| | |
3141// | | SubDelReq | |
3142// | |------------->| |
3143// | | SubDelResp | |
3144// | |<-------------| |
3145// | | SubDelReq | |
3146// | |------------->| |
3147// | | SubDelResp | |
3148// | |<-------------| |
3149// | | | |
3150//
3151//-----------------------------------------------------------------------------
3152
3153func TestRESTSubReqRetransmissionV4(t *testing.T) {
3154 CaseBegin("TestRESTSubReqRetransmissionV4")
3155
3156 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3157 Counter{cRestSubReqFromXapp, 3},
3158 Counter{cRestSubRespToXapp, 3},
3159 Counter{cSubReqToE2, 2},
3160 Counter{cSubRespFromE2, 2},
3161 Counter{cRestSubNotifToXapp, 4},
3162 Counter{cRestSubDelReqFromXapp, 1},
3163 Counter{cSubDelReqToE2, 2},
3164 Counter{cSubDelRespFromE2, 2},
3165 Counter{cRestSubDelRespToXapp, 1},
3166 })
3167
3168 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3169
3170 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3171
3172 <-time.After(100 * time.Millisecond)
3173
3174 // Send modified requst, this time with e2 subscriptions.
3175 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3176 params2.SetSubscriptionID(&restSubId)
3177
3178 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003179 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003180 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3181 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003182 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3183 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003184
3185 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3186
Markku Virtanen2b512b62021-07-30 12:04:00 +00003187 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003188 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3189 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3190 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3191 assert.NotEqual(t, e2SubsId2, 0)
3192
3193 <-time.After(100 * time.Millisecond)
3194
3195 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3196 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3197 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003198 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003199 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3200 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3201 assert.Equal(t, restSubId_resend, restSubId_resend2)
3202
Markku Virtanen2b512b62021-07-30 12:04:00 +00003203 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3204 assert.Equal(t, e2SubsId, e2SubsId1)
3205
Markku Virtanen42723e22021-06-15 10:09:23 +03003206 // Delete both e2 subscriptions
3207 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3208 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3209 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3210
3211 waitSubsCleanup(t, e2SubsId, 10)
3212
3213 //Wait that subs is cleaned
3214 mainCtrl.VerifyCounterValues(t)
3215}
3216
3217//-----------------------------------------------------------------------------
3218// stub stub stub
3219// +-------+ +---------+ +---------+ +---------+
3220// | xapp | | submgr | | e2term | | rtmgr |
3221// +-------+ +---------+ +---------+ +---------+
3222// | | | |
3223// | RESTSubReq | | |
3224// |---------------->| | |
3225// | RESTSubResp | | |
3226// |<----------------| | |
3227// | | RouteCreate | |
3228// | |--------------------------->|
3229// | | RouteResponse| |
3230// | |<---------------------------|
3231// | | SubReq | |
3232// | |------------->| |
3233// | | SubResp | |
3234// | |<-------------| |
3235// | RESTNotif1 | | |
3236// |<----------------| | |
3237// | RESTSubReq | | |
3238// | [with RestSUbsId + one additional e2 subDetail]
3239// |---------------->| | |
3240// | RESTNotif1 | | |
3241// | [for initial e2 subDetail] | |
3242// |<----------------| | |
3243// | | RouteCreate | |
3244// | |--------------------------->|
3245// | | RouteResponse| |
3246// | |<---------------------------|
3247// | | SubReq | |
3248// | |------------->| |
3249// | | SubResp | |
3250// | |<-------------| |
3251// | RESTNotif1 | | |
3252// |<----------------| | |
3253// | RESTSubReq | | |
3254// | [without RESTsubsId initial request] |
3255// |---------------->| | |
3256// | RESTNotif1 | | |
3257// |<----------------| | |
3258// | RESTSubDelReq | | |
3259// |---------------->| | |
3260// | RESTSubDelResp| | |
3261// |<----------------| | |
3262// | | SubDelReq | |
3263// | |------------->| |
3264// | | SubDelResp | |
3265// | |<-------------| |
3266// | | SubDelReq | |
3267// | |------------->| |
3268// | | SubDelResp | |
3269// | |<-------------| |
3270// | | | |
3271//
3272//-----------------------------------------------------------------------------
3273
3274func TestRESTSubReqRetransmissionV5(t *testing.T) {
3275 CaseBegin("TestRESTSubReqRetransmissionV5")
3276
3277 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3278 Counter{cRestSubReqFromXapp, 3},
3279 Counter{cRestSubRespToXapp, 3},
3280 Counter{cSubReqToE2, 2},
3281 Counter{cSubRespFromE2, 2},
3282 Counter{cRestSubNotifToXapp, 4},
3283 Counter{cRestSubDelReqFromXapp, 1},
3284 Counter{cSubDelReqToE2, 2},
3285 Counter{cSubDelRespFromE2, 2},
3286 Counter{cRestSubDelRespToXapp, 1},
3287 })
3288
3289 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3290
3291 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3292
3293 <-time.After(100 * time.Millisecond)
3294
3295 // Send modified requst, this time with e2 subscriptions.
3296 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3297 params2.SetSubscriptionID(&restSubId)
3298
3299 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003300 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003301 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3302 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3303
Markku Virtanen2b512b62021-07-30 12:04:00 +00003304 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3305 assert.Equal(t, e2SubsId, e2SubsId1)
3306 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3307 xappConn1.DecrementRequestCount()
3308
Markku Virtanen42723e22021-06-15 10:09:23 +03003309 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3310
3311 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3312 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3313 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3314 assert.NotEqual(t, e2SubsId2, 0)
3315
3316 <-time.After(100 * time.Millisecond)
3317
3318 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3319 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003320 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003321 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3322 // md5sum shall find the original request
3323 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3324 assert.Equal(t, restSubId_resend, restSubId_resend2)
3325
Markku Virtanen2b512b62021-07-30 12:04:00 +00003326 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3327 assert.Equal(t, e2SubsId, e2SubsId1)
3328
Markku Virtanen42723e22021-06-15 10:09:23 +03003329 // Delete both e2 subscriptions
3330 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3331 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3332 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3333
3334 waitSubsCleanup(t, e2SubsId, 10)
3335
3336 //Wait that subs is cleaned
3337 mainCtrl.VerifyCounterValues(t)
3338}
3339
3340//-----------------------------------------------------------------------------
3341// stub stub stub
3342// +-------+ +---------+ +---------+ +---------+
3343// | xapp | | submgr | | e2term | | rtmgr |
3344// +-------+ +---------+ +---------+ +---------+
3345// | | | |
3346// | RESTSubReq | | |
3347// |---------------->| | |
3348// | RESTSubResp | | |
3349// |<----------------| | |
3350// | | RouteCreate | |
3351// | |--------------------------->|
3352// | | RouteResponse| |
3353// | |<---------------------------|
3354// | | SubReq | |
3355// | |------------->| |
3356// | | SubResp | |
3357// | |<-------------| |
3358// | RESTNotif1 | | |
3359// |<----------------| | |
3360// | RESTSubReq | | |
3361// | [with RestSUbsId + one additional e2 subDetail]
3362// |---------------->| | |
3363// | RESTNotif1 | | |
3364// | [for initial e2 subDetail] | |
3365// |<----------------| | |
3366// | | RouteCreate | |
3367// | |--------------------------->|
3368// | | RouteResponse| |
3369// | |<---------------------------|
3370// | | SubReq | |
3371// | |------------->| |
3372// | | SubResp | |
3373// | |<-------------| |
3374// | RESTNotif1 | | |
3375// |<----------------| | |
3376// | RESTSubDelReq | | |
3377// |---------------->| | |
3378// | RESTSubDelResp| | |
3379// |<----------------| | |
3380// | | SubDelReq | |
3381// | |------------->| |
3382// | | SubDelResp | |
3383// | |<-------------| |
3384// | | SubDelReq | |
3385// | |------------->| |
3386// | | SubDelResp | |
3387// | |<-------------| |
3388// | RESTSubReq | | |
3389// | [with RESTsubsId initial request] |
3390// |---------------->| | |
3391// | RESTSubResp | | |
3392// |<----------------| | |
3393// | | RouteCreate | |
3394// | |--------------------------->|
3395// | | RouteResponse| |
3396// | |<---------------------------|
3397// | | SubReq | |
3398// | |------------->| |
3399// | | SubResp | |
3400// | |<-------------| |
3401// | RESTNotif1 | | |
3402// |<----------------| | |
3403// | | | |
3404//
3405//-----------------------------------------------------------------------------
3406func TestRESTSubReqRetransmissionV6(t *testing.T) {
3407 CaseBegin("TestRESTSubReqRetransmissionV6")
3408
3409 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3410 Counter{cRestSubReqFromXapp, 3},
3411 Counter{cRestSubRespToXapp, 3},
3412 Counter{cSubReqToE2, 3},
3413 Counter{cSubRespFromE2, 3},
3414 Counter{cRestSubNotifToXapp, 4},
3415 Counter{cRestSubDelReqFromXapp, 2},
3416 Counter{cSubDelReqToE2, 3},
3417 Counter{cSubDelRespFromE2, 3},
3418 Counter{cRestSubDelRespToXapp, 2},
3419 })
3420
3421 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3422
3423 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3424
3425 <-time.After(100 * time.Millisecond)
3426
3427 // Send modified requst, this time with e2 subscriptions.
3428 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3429 params2.SetSubscriptionID(&restSubId)
3430
3431 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003432 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003433 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3434 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3435
Markku Virtanen2b512b62021-07-30 12:04:00 +00003436 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3437 assert.Equal(t, e2SubsId, e2SubsId1)
3438
Markku Virtanen42723e22021-06-15 10:09:23 +03003439 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3440
3441 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3442 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3443 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3444 assert.NotEqual(t, e2SubsId2, 0)
3445
3446 <-time.After(100 * time.Millisecond)
3447
3448 // Delete both e2 subscriptions
3449 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3450 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3451 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3452
3453 waitSubsCleanup(t, e2SubsId, 10)
3454
3455 // Resend the original request, we shall find it's previous md5sum/restsubs
3456 // but the restsubscription has been already removed. This shall trigger a
3457 // fresh create.
3458 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3459
3460 <-time.After(100 * time.Millisecond)
3461
3462 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3463
3464 waitSubsCleanup(t, e2SubsId, 10)
3465
3466 //Wait that subs is cleaned
3467 mainCtrl.VerifyCounterValues(t)
3468}
3469
archaggeafbf95f2021-04-14 08:54:05 +03003470func TestRESTSubDelReqRetransmission(t *testing.T) {
3471 CaseBegin("TestRESTSubDelReqRetransmission")
3472
3473 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003474 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003475 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003476 Counter{cSubReqToE2, 1},
3477 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003478 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003479 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003480 Counter{cSubDelReqToE2, 1},
3481 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003482 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003483 })
3484
3485 var params *teststube2ap.RESTSubsReqParams = nil
3486
3487 //Subs Create
3488 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3489
3490 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3491
3492 //Subs Delete
3493 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3494 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3495
3496 seqBef := mainCtrl.get_msgcounter(t)
3497 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3498 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3499
3500 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3501
3502 waitSubsCleanup(t, e2SubsId, 10)
3503
3504 mainCtrl.VerifyCounterValues(t)
3505}
3506
3507//-----------------------------------------------------------------------------
3508// TestRESTSubReqDelReq
3509//
3510// stub stub
3511// +-------+ +---------+ +---------+
3512// | xapp | | submgr | | e2term |
3513// +-------+ +---------+ +---------+
3514// | | |
3515// | RESTSubReq | |
3516// |---------------->| |
3517// | | |
3518// | RESTSubResp | |
3519// |<----------------| |
3520// | | SubReq |
3521// | |------------->|
3522// | RESTSubDelReq | |
3523// |---------------->| |
3524// | RESTSubDelResp | |
3525// | unsuccess | |
3526// |<----------------| |
3527// | | SubResp |
3528// | |<-------------|
3529// | RESTNotif1 | |
3530// |<----------------| |
3531// | | |
3532// | [SUBS DELETE] |
3533// | | |
3534//
3535//-----------------------------------------------------------------------------
3536func TestRESTSubReqDelReq(t *testing.T) {
3537 CaseBegin("TestRESTSubReqDelReq")
3538
3539 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003540 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003541 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003542 Counter{cSubReqToE2, 1},
3543 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003544 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003545 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003546 Counter{cSubDelReqToE2, 1},
3547 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003548 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003549 })
3550
3551 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003552
3553 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003554 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003555 restSubId := xappConn1.SendRESTSubsReq(t, params)
3556
3557 // Del. This will fail as processing of the subscription
3558 // is still ongoing in submgr. Deletion is not allowed before
3559 // subscription creation has been completed.
3560 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3561 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3562 xappConn1.ExpectRESTNotification(t, restSubId)
3563 e2termConn1.SendSubsResp(t, crereq, cremsg)
3564 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3565
3566 // Retry del
3567 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3568
3569 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3570 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3571
3572 // Wait that subs is cleaned
3573 waitSubsCleanup(t, e2SubsId, 10)
3574 mainCtrl.VerifyCounterValues(t)
3575
3576}
3577
3578func TestRESTSubDelReqCollision(t *testing.T) {
3579 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3580}
3581
3582func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3583 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3584
3585 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003586 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003587 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003588 Counter{cSubReqToE2, 2},
3589 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003590 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003591 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003592 Counter{cSubDelReqToE2, 2},
3593 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003594 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003595 })
3596
3597 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003598 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003599 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003600 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003601
3602 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003603 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003604 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003605 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003606
3607 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3608 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3609
3610 //XappConn1 receives both of the responses
3611 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3612
3613 //Resp1
3614 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3615 //Resp2
3616 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3617
3618 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003619 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003620 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003621 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003622
3623 //Del1
3624 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3625 //Del2
3626 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3627
3628 //Wait that subs is cleaned
3629 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3630 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3631
3632 mainCtrl.VerifyCounterValues(t)
3633
3634}
3635
3636func TestRESTSameSubsDiffRan(t *testing.T) {
3637 CaseBegin("TestRESTSameSubsDiffRan")
3638
3639 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003640 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003641 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003642 Counter{cSubReqToE2, 2},
3643 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003644 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003645 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003646 Counter{cSubDelReqToE2, 2},
3647 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003648 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003649 })
3650
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003651 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003652 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003653 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003654
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003655 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003656 params.SetMeid("RAN_NAME_2")
3657 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003658 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003659
3660 //Del1
3661 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3662 //Del2
3663 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3664
3665 //Wait that subs is cleaned
3666 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3667 waitSubsCleanup(t, e2SubsId2, 10)
3668
3669 mainCtrl.VerifyCounterValues(t)
3670
3671}
3672
3673func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3674 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3675
3676 // Init counter check
3677 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003678 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003679 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003680 Counter{cSubReqToE2, 1},
3681 Counter{cSubReReqToE2, 1},
3682 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003683 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003684 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003685 Counter{cSubDelReqToE2, 1},
3686 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003687 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003688 })
3689
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003690 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003691 restSubId := xappConn1.SendRESTSubsReq(t, params)
3692
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003693 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003694
3695 // Catch the first message and ignore it
3696 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003697 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003698
3699 // The second request is being handled normally
3700 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3701 xappConn1.ExpectRESTNotification(t, restSubId)
3702 e2termConn1.SendSubsResp(t, crereq, cremsg)
3703 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3704
3705 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3706
3707 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3708
3709 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3710 //Wait that subs is cleaned
3711 waitSubsCleanup(t, e2SubsId, 10)
3712
3713 mainCtrl.VerifyCounterValues(t)
3714
3715}
3716
3717//-----------------------------------------------------------------------------
3718// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3719//
3720// stub stub
3721// +-------+ +---------+ +---------+
3722// | xapp | | submgr | | e2term |
3723// +-------+ +---------+ +---------+
3724// | | |
3725// | RESTSubReq | |
3726// |---------------->| |
3727// | | |
3728// | RESTSubResp | |
3729// |<----------------| |
3730// | | SubReq |
3731// | |------------->|
3732// | | |
3733// | | |
3734// | | SubReq |
3735// | |------------->|
3736// | | |
3737// | | SubDelReq |
3738// | |------------->|
3739// | | |
3740// | | |
3741// | | SubDelReq |
3742// | |------------->|
3743// | | |
3744// | | |
3745// | | SubDelResp |
3746// | |<-------------|
3747// | RESTNotif | |
3748// | unsuccess | |
3749// |<----------------| |
3750// | | |
3751// | [SUBS DELETE] |
3752// | | |
3753//
3754//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003755
archaggeafbf95f2021-04-14 08:54:05 +03003756func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3757 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3758
3759 // Init counter check
3760 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003761 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003762 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003763 Counter{cSubReqToE2, 1},
3764 Counter{cSubReReqToE2, 1},
3765 Counter{cSubReqTimerExpiry, 2},
3766 Counter{cSubDelReqToE2, 1},
3767 Counter{cSubDelRespFromE2, 1},
3768 })
3769
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003770 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003771 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003772 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003773
3774 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003775 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003776
3777 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003778 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003779
3780 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003781 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003782 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003783 xappConn1.WaitRESTNotification(t, restSubId)
3784
3785 // Wait that subs is cleaned
3786 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
3787
3788 mainCtrl.VerifyCounterValues(t)
3789}
3790
3791func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3792 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3793
3794 // Init counter check
3795 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003796 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003797 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003798 Counter{cSubReqToE2, 1},
3799 Counter{cSubReReqToE2, 1},
3800 Counter{cSubReqTimerExpiry, 2},
3801 Counter{cSubDelReqToE2, 1},
3802 Counter{cSubDelReqTimerExpiry, 2},
3803 })
3804
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003805 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003806 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003807 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003808
3809 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003810 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003811
3812 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003813 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003814
3815 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003816 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003817
Markku Virtanen55d2a282021-06-04 14:46:56 +03003818 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003819 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003820 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003821
3822 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3823
3824 waitSubsCleanup(t, e2SubsId, 10)
3825
3826 mainCtrl.VerifyCounterValues(t)
3827
3828}
3829
3830//-----------------------------------------------------------------------------
3831// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3832//
3833// stub stub
3834// +-------+ +---------+ +---------+
3835// | xapp | | submgr | | e2term |
3836// +-------+ +---------+ +---------+
3837// | | |
3838// | RESTSubReq | |
3839// |---------------->| |
3840// | | |
3841// | RESTSubResp | |
3842// |<----------------| |
3843// | | SubReq |
3844// | |------------->|
3845// | | |
3846// | | |
3847// | | SubReq |
3848// | |------------->|
3849// | | |
3850// | | SubDelReq |
3851// | |------------->|
3852// | | |
3853// | | |
3854// | | SubDelReq |
3855// | |------------->|
3856// | | |
3857// | | |
3858// | | SubDelResp |
3859// | |<-------------|
3860// | RESTNotif | |
3861// | unsuccess | |
3862// |<----------------| |
3863// | | |
3864// | [SUBS DELETE] |
3865// | | |
3866//
3867//-----------------------------------------------------------------------------
3868func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3869 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3870
3871 // Init counter check
3872 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003873 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003874 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003875 Counter{cSubReqToE2, 1},
3876 Counter{cSubReReqToE2, 1},
3877 Counter{cSubReqTimerExpiry, 2},
3878 Counter{cSubDelReqToE2, 1},
3879 Counter{cSubDelReReqToE2, 1},
3880 Counter{cSubDelReqTimerExpiry, 2},
3881 })
3882
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003883 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003884 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003885 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003886
3887 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003888 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003889
3890 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003891 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003892
3893 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003894 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003895
Markku Virtanen55d2a282021-06-04 14:46:56 +03003896 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003897 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003898 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003899
3900 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3901
3902 waitSubsCleanup(t, e2SubsId, 10)
3903
3904 mainCtrl.VerifyCounterValues(t)
3905}
3906
3907//-----------------------------------------------------------------------------
3908// TestRESTSubReqSubFailRespInSubmgr
3909//
3910// stub stub
3911// +-------+ +---------+ +---------+
3912// | xapp | | submgr | | e2term |
3913// +-------+ +---------+ +---------+
3914// | | |
3915// | RESTSubReq | |
3916// |---------------->| |
3917// | | |
3918// | RESTSubResp | |
3919// |<----------------| |
3920// | | SubReq |
3921// | |------------->|
3922// | | |
3923// | | SubFail |
3924// | |<-------------|
3925// | | |
3926// | | SubDelReq |
3927// | |------------->|
3928// | | |
3929// | | SubDelResp |
3930// | |<-------------|
3931// | | |
3932// | RESTNotif | |
3933// | unsuccess | |
3934// |<----------------| |
3935// | | |
3936// | [SUBS DELETE] |
3937// | | |
3938//
3939//-----------------------------------------------------------------------------
3940func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3941 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3942
3943 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003944 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003945 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003946 Counter{cSubReqToE2, 1},
3947 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003948 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003949 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003950 })
3951
3952 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003953 const e2Timeout int64 = 2
3954 const e2RetryCount int64 = 1
3955 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03003956
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003957 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003958 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03003959 restSubId := xappConn1.SendRESTSubsReq(t, params)
3960
3961 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3962 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3963 fparams1.Set(crereq1)
3964 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3965
3966 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003967 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003968 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3969 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003970 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003971
3972 // REST subscription sill there to be deleted
3973 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3974
3975 // Wait that subs is cleaned
3976 waitSubsCleanup(t, e2SubsId, 10)
3977
3978 mainCtrl.VerifyCounterValues(t)
3979
3980}
3981
3982//-----------------------------------------------------------------------------
3983// TestRESTSubDelReqRetryInSubmgr
3984//
3985// stub stub
3986// +-------+ +---------+ +---------+
3987// | xapp | | submgr | | e2term |
3988// +-------+ +---------+ +---------+
3989// | | |
3990// | [SUBS CREATE] |
3991// | | |
3992// | | |
3993// | RESTSubDelReq | |
3994// |---------------->| |
3995// | | |
3996// | RESTSubDelResp | |
3997// |<----------------| |
3998// | | SubDelReq |
3999// | |------------->|
4000// | | |
4001// | | SubDelReq |
4002// | |------------->|
4003// | | |
4004// | | SubDelResp |
4005// | |<-------------|
4006// | | |
4007//
4008//-----------------------------------------------------------------------------
4009func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
4010 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
4011
4012 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004013 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004014 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004015 Counter{cSubReqToE2, 1},
4016 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004017 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004018 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004019 Counter{cSubDelReqToE2, 1},
4020 Counter{cSubDelReReqToE2, 1},
4021 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004022 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004023 })
4024 // Req
4025 var params *teststube2ap.RESTSubsReqParams = nil
4026 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4027
4028 // Del
4029 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4030
4031 // E2t: Receive 1st SubsDelReq
4032 e2termConn1.RecvSubsDelReq(t)
4033
4034 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4035 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4036 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4037
4038 //Wait that subs is cleaned
4039 waitSubsCleanup(t, e2SubsId, 10)
4040
4041 mainCtrl.VerifyCounterValues(t)
4042}
4043
4044//-----------------------------------------------------------------------------
4045// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4046//
4047// stub stub
4048// +-------+ +---------+ +---------+
4049// | xapp | | submgr | | e2term |
4050// +-------+ +---------+ +---------+
4051// | | |
4052// | [SUBS CREATE] |
4053// | | |
4054// | | |
4055// | RESTSubDelReq | |
4056// |---------------->| |
4057// | | |
4058// | RESTSubDelResp | |
4059// |<----------------| |
4060// | | SubDelReq |
4061// | |------------->|
4062// | | |
4063// | | SubDelReq |
4064// | |------------->|
4065// | | |
4066// | | |
4067//
4068//-----------------------------------------------------------------------------
4069func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
4070 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
4071
4072 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004073 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004074 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004075 Counter{cSubReqToE2, 1},
4076 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004077 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004078 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004079 Counter{cSubDelReqToE2, 1},
4080 Counter{cSubDelReReqToE2, 1},
4081 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004082 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004083 })
4084
4085 // Req
4086 var params *teststube2ap.RESTSubsReqParams = nil
4087 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4088
4089 // Del
4090 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4091
4092 // E2t: Receive 1st SubsDelReq
4093 e2termConn1.RecvSubsDelReq(t)
4094
4095 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4096 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4097 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4098
4099 //Wait that subs is cleaned
4100 waitSubsCleanup(t, e2SubsId, 10)
4101
4102 mainCtrl.VerifyCounterValues(t)
4103}
4104
4105//-----------------------------------------------------------------------------
4106// TestRESTSubDelReqSubDelFailRespInSubmgr
4107//
4108// stub stub
4109// +-------+ +---------+ +---------+
4110// | xapp | | submgr | | e2term |
4111// +-------+ +---------+ +---------+
4112// | | |
4113// | [SUBS CREATE] |
4114// | | |
4115// | | |
4116// | RESTSubDelReq | |
4117// |---------------->| |
4118// | | |
4119// | RESTSubDelResp | |
4120// |<----------------| |
4121// | | SubDelReq |
4122// | |------------->|
4123// | | |
4124// | | SubDelFail |
4125// | |<-------------|
4126// | | |
4127//
4128//-----------------------------------------------------------------------------
4129func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
4130 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
4131
4132 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004133 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004134 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004135 Counter{cSubReqToE2, 1},
4136 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004137 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004138 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004139 Counter{cSubDelReqToE2, 1},
4140 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004141 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004142 })
4143
4144 // Req
4145 var params *teststube2ap.RESTSubsReqParams = nil
4146 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4147
4148 // Del
4149 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4150
4151 // E2t: Send receive SubsDelReq and send SubsDelFail
4152 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4153 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4154
4155 //Wait that subs is cleaned
4156 waitSubsCleanup(t, e2SubsId, 10)
4157
4158 mainCtrl.VerifyCounterValues(t)
4159}
4160
4161//-----------------------------------------------------------------------------
4162// TestRESTSubReqAndSubDelOkSameAction
4163//
4164// stub stub
4165// +-------+ +-------+ +---------+ +---------+
4166// | xapp2 | | xapp1 | | submgr | | e2term |
4167// +-------+ +-------+ +---------+ +---------+
4168// | | | |
4169// | | RESTSubReq1 | |
4170// | |---------------->| |
4171// | | | |
4172// | | RESTSubResp1 | |
4173// | |<----------------| |
4174// | | | |
4175// | | | SubReq1 |
4176// | | |------------->|
4177// | | | SubResp1 |
4178// | | |<-------------|
4179// | | RESTNotif1 | |
4180// | |<----------------| |
4181// | | | |
4182// | RESTSubReq2 | |
4183// |------------------------------>| |
4184// | | | |
4185// | RESTSubResp2 | |
4186// |<------------------------------| |
4187// | | | |
4188// | | RESTNotif2 | |
4189// |<------------------------------| |
4190// | | | |
4191// | | RESTSubDelReq1 | |
4192// | |---------------->| |
4193// | | | |
4194// | | RESTSubDelResp1 | |
4195// | |<----------------| |
4196// | | | |
4197// | RESTSubDelReq2 | |
4198// |------------------------------>| |
4199// | | | |
4200// | RESTSubDelResp2 | |
4201// |<------------------------------| |
4202// | | | |
4203// | | | SubDelReq2 |
4204// | | |------------->|
4205// | | | |
4206// | | | SubDelResp2 |
4207// | | |<-------------|
4208// | | | |
4209//
4210//-----------------------------------------------------------------------------
4211func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
4212 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
4213
4214 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004215 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004216 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004217 Counter{cSubReqToE2, 1},
4218 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004219 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004220 Counter{cMergedSubscriptions, 1},
4221 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004222 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004223 Counter{cSubDelReqToE2, 1},
4224 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004225 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004226 })
4227
4228 // Req1
4229 var params *teststube2ap.RESTSubsReqParams = nil
4230
4231 //Subs Create
4232 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4233 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4234
4235 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004236 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004237 params.SetMeid("RAN_NAME_1")
4238
4239 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004240 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004241 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004242 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004243 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004244 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004245 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004246 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004247
4248 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4249
4250 // Del1
4251 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4252
4253 // Del2
4254 deleteXapp2Subscription(t, &restSubId2)
4255
4256 //Wait that subs is cleaned
4257 waitSubsCleanup(t, e2SubsId2, 10)
4258
4259 mainCtrl.VerifyCounterValues(t)
4260}
4261
4262//-----------------------------------------------------------------------------
4263// TestSubReqAndSubDelOkSameActionParallel
4264//
4265// stub stub stub
4266// +-------+ +-------+ +---------+ +---------+
4267// | xapp2 | | xapp1 | | submgr | | e2term |
4268// +-------+ +-------+ +---------+ +---------+
4269// | | | |
4270// | | | |
4271// | | | |
4272// | | SubReq1 | |
4273// | |------------->| |
4274// | | | |
4275// | | | SubReq1 |
4276// | | |------------->|
4277// | SubReq2 | |
4278// |--------------------------->| |
4279// | | | SubResp1 |
4280// | | |<-------------|
4281// | | SubResp1 | |
4282// | |<-------------| |
4283// | | | SubReq2 |
4284// | | |------------->|
4285// | | | |
4286// | | | SubResp2 |
4287// | | |<-------------|
4288// | SubResp2 | |
4289// |<---------------------------| |
4290// | | | |
4291// | | SubDelReq 1 | |
4292// | |------------->| |
4293// | | | |
4294// | | SubDelResp 1 | |
4295// | |<-------------| |
4296// | | | |
4297// | SubDelReq 2 | |
4298// |--------------------------->| |
4299// | | | |
4300// | | | SubDelReq 2 |
4301// | | |------------->|
4302// | | | |
4303// | | | SubDelReq 2 |
4304// | | |------------->|
4305// | | | |
4306// | SubDelResp 2 | |
4307// |<---------------------------| |
4308//
4309func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4310 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4311
4312 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004313 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004314 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004315 Counter{cSubReqToE2, 2},
4316 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004317 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004318 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004319 Counter{cSubDelReqToE2, 2},
4320 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004321 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004322 })
4323
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004324 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004325 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4326 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4327
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004328 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004329 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4330
4331 xappConn1.ExpectRESTNotification(t, restSubId1)
4332 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4333 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4334
4335 xappConn2.ExpectRESTNotification(t, restSubId2)
4336 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4337 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4338 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4339
4340 // Del1
4341 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4342 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4343 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4344 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4345
4346 // Del2
4347 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4348 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4349 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4350
4351 waitSubsCleanup(t, e2SubsId2, 10)
4352
4353 mainCtrl.VerifyCounterValues(t)
4354}
4355
4356//-----------------------------------------------------------------------------
4357// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4358//
4359// stub stub stub
4360// +-------+ +-------+ +---------+ +---------+
4361// | xapp2 | | xapp1 | | submgr | | e2term |
4362// +-------+ +-------+ +---------+ +---------+
4363// | | | |
4364// | | | |
4365// | | | |
4366// | | RESTSubReq1 | |
4367// | |---------------->| |
4368// | | | |
4369// | | RESTSubResp1 | |
4370// | |<----------------| |
4371// | | | SubReq1 |
4372// | | |------------->|
4373// | RESTSubReq2 | |
4374// |------------------------------>| |
4375// | | | |
4376// | RESTSubDelResp2 | |
4377// |<------------------------------| |
4378// | | | SubReq1 |
4379// | | |------------->|
4380// | | | |
4381// | | | |
4382// | | | SubDelReq |
4383// | | |------------->|
4384// | | | |
4385// | | | SubDelResp |
4386// | | |<-------------|
4387// | | RESTNotif1 | |
4388// | | unsuccess | |
4389// | |<----------------| |
4390// | RESTNotif2 | |
4391// | | unsuccess | |
4392// |<------------------------------| |
4393// | | | |
4394// | | RESTSubDelReq1 | |
4395// | |---------------->| |
4396// | | | |
4397// | | RESTSubDelResp1 | |
4398// | |<----------------| |
4399// | | | |
4400// | RESTSubDelReq2 | |
4401// |------------------------------>| |
4402// | | | |
4403// | RESTSubDelResp2 | |
4404// |<------------------------------| |
4405//
4406//-----------------------------------------------------------------------------
4407func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4408 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4409
4410 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004411 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004412 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004413 Counter{cSubReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004414 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004415 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004416 Counter{cSubDelReqToE2, 1},
4417 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004418 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004419 })
4420
4421 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004422
4423 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004424 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004425 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4426 crereq1, _ := e2termConn1.RecvSubsReq(t)
4427
4428 // Req2
4429 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004430 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004431 params2.SetMeid("RAN_NAME_1")
4432 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4433 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4434
4435 //Req1 (retransmitted)
4436 e2termConn1.RecvSubsReq(t)
4437
4438 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004439
4440 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004441 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4442
Markku Virtanenda34eec2021-05-20 08:22:04 +00004443 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004444 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004445 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004446 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004447
4448 // Del1
4449 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4450
4451 // Del2
4452 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4453
Markku Virtanenda34eec2021-05-20 08:22:04 +00004454 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4455
archaggeafbf95f2021-04-14 08:54:05 +03004456 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004457 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004458
4459 mainCtrl.VerifyCounterValues(t)
4460}
4461
4462//-----------------------------------------------------------------------------
4463// TestRESTSubReqAndSubDelNokSameActionParallel
4464//
4465// stub stub stub
4466// +-------+ +-------+ +---------+ +---------+
4467// | xapp2 | | xapp1 | | submgr | | e2term |
4468// +-------+ +-------+ +---------+ +---------+
4469// | | | |
4470// | | | |
4471// | | | |
4472// | | RESTSubReq1 | |
4473// | |---------------->| |
4474// | | | |
4475// | | RESTSubResp1 | |
4476// | |<----------------| |
4477// | | | SubReq1 |
4478// | | |------------->|
4479// | RESTSubReq2 | |
4480// |------------------------------>| |
4481// | | | |
4482// | RESTSubDelResp2 | |
4483// |<------------------------------| |
4484// | | | SubFail1 |
4485// | | |<-------------|
4486// | | | |
4487// | | RESTNotif1 | |
4488// | | unsuccess | |
4489// | |<----------------| |
4490// | RESTNotif2 | |
4491// | | unsuccess | |
4492// |<------------------------------| |
4493// | | | SubDelReq |
4494// | | |------------->|
4495// | | | SubDelResp |
4496// | | |<-------------|
4497// | | | |
4498// | | RESTSubDelReq1 | |
4499// | |---------------->| |
4500// | | | |
4501// | | RESTSubDelResp1 | |
4502// | |<----------------| |
4503// | | | |
4504// | RESTSubDelReq2 | |
4505// |------------------------------>| |
4506// | | | |
4507// | RESTSubDelResp2 | |
4508// |<------------------------------| |
4509//
4510//-----------------------------------------------------------------------------
4511func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4512 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4513
4514 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004515 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004516 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004517 Counter{cSubReqToE2, 1},
4518 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004519 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004520 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004521 Counter{cSubDelReqToE2, 1},
4522 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004523 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004524 })
4525
4526 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004527
4528 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004529 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004530 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4531 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4532
4533 // Req2
4534 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004535 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004536 params2.SetMeid("RAN_NAME_1")
4537 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4538 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4539
4540 // E2t: send SubsFail (first)
4541 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4542 fparams1.Set(crereq1)
4543 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4544
4545 // E2t: internal delete
4546 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4547 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4548 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4549
4550 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004551 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004552 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004553 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004554
4555 // Del1
4556 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4557
4558 // Del2
4559 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4560
4561 //Wait that subs is cleaned
4562 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4563 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4564
4565 mainCtrl.VerifyCounterValues(t)
4566}
4567
4568func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4569 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4570
4571 // Init counter check
4572 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004573 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004574 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004575 Counter{cSubReqToE2, 1},
4576 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004577 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004578 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004579 Counter{cSubDelReqToE2, 1},
4580 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004581 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004582 })
4583
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004584 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004585 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004586 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004587
4588 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4589 xappConn1.ExpectRESTNotification(t, restSubId)
4590 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4591 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004592 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004593
4594 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4595 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4596 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4597
4598 // Wait that subs is cleaned
4599 waitSubsCleanup(t, e2SubsId, 10)
4600 mainCtrl.VerifyCounterValues(t)
4601}
4602
4603//-----------------------------------------------------------------------------
4604// TestRESTSubReqPolicyChangeAndSubDelOk
4605//
4606// stub stub
4607// +-------+ +---------+ +---------+
4608// | xapp | | submgr | | e2term |
4609// +-------+ +---------+ +---------+
4610// | | |
4611// | RESTSubReq | |
4612// |---------------->| |
4613// | | |
4614// | RESTSubResp | |
4615// |<----------------| |
4616// | | SubReq |
4617// | |------------->|
4618// | | |
4619// | | SubResp |
4620// | |<-------------|
4621// | | |
4622// | RESTNotif | |
4623// |<----------------| |
4624// | | |
4625// | RESTSubReq | |
4626// |---------------->| |
4627// | | |
4628// | RESTSubResp | |
4629// |<----------------| |
4630// | | SubReq |
4631// | |------------->|
4632// | | |
4633// | | SubResp |
4634// | |<-------------|
4635// | | |
4636// | RESTNotif | |
4637// |<----------------| |
4638// | | |
4639// | RESTSubDelReq | |
4640// |---------------->| |
4641// | | |
4642// | | SubDelReq |
4643// | |------------->|
4644// | | |
4645// | | SubDelResp |
4646// | |<-------------|
4647// | | |
4648// | RESTSubDelResp | |
4649// |<----------------| |
4650//
4651//-----------------------------------------------------------------------------
4652func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4653 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4654
4655 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004656 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004657 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004658 Counter{cSubReqToE2, 2},
4659 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004660 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004661 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004662 Counter{cSubDelReqToE2, 1},
4663 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004664 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004665 })
4666
4667 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004668 const e2Timeout int64 = 1
4669 const e2RetryCount int64 = 0
4670 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004671
4672 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004673 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004674 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004675 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4676
4677 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004678 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004679
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004680 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004681 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004682 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004683 params.SetTimeToWait("w200ms")
4684 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4685
4686 // Del
4687 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4688
4689 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4690 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4691
4692 // Wait that subs is cleaned
4693 waitSubsCleanup(t, e2SubsId, 10)
4694 mainCtrl.VerifyCounterValues(t)
4695}
4696
4697//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004698// TestRESTSubReqPolicyChangeNOk
4699//
4700// stub stub
4701// +-------+ +---------+ +---------+
4702// | xapp | | submgr | | e2term |
4703// +-------+ +---------+ +---------+
4704// | | |
4705// | RESTSubReq | |
4706// |---------------->| |
4707// | | |
4708// | RESTSubResp | |
4709// |<----------------| |
4710// | | SubReq |
4711// | |------------->|
4712// | | |
4713// | | SubResp |
4714// | |<-------------|
4715// | | |
4716// | RESTNotif | |
4717// |<----------------| |
4718// | | |
4719// | RESTSubReq | |
4720// |---------------->| |
4721// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004722// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004723// | | |
4724// | RESTSubDelReq | |
4725// |---------------->| |
4726// | | |
4727// | | SubDelReq |
4728// | |------------->|
4729// | | |
4730// | | SubDelResp |
4731// | |<-------------|
4732// | | |
4733// | RESTSubDelResp | |
4734// |<----------------| |
4735//
4736//-----------------------------------------------------------------------------
4737func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4738 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4739
4740 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4741 Counter{cRestSubReqFromXapp, 2},
4742 Counter{cRestSubRespToXapp, 1},
4743 Counter{cSubReqToE2, 1},
4744 Counter{cSubRespFromE2, 1},
4745 Counter{cRestSubNotifToXapp, 1},
4746 Counter{cRestSubFailToXapp, 1},
4747 Counter{cRestSubDelReqFromXapp, 1},
4748 Counter{cSubDelReqToE2, 1},
4749 Counter{cSubDelRespFromE2, 1},
4750 Counter{cRestSubDelRespToXapp, 1},
4751 })
4752
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004753 // Req
4754 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4755 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4756
4757 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004758 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4759
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004760 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004761 params.SetSubscriptionID(&restSubIdUpd)
4762 params.SetTimeToWait("w200ms")
4763
4764 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4765 assert.Equal(t, restSubId2, "")
4766
4767 // Del
4768 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4769
4770 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4771 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4772
4773 // Wait that subs is cleaned
4774 waitSubsCleanup(t, e2SubsId, 10)
4775 mainCtrl.VerifyCounterValues(t)
4776}
4777
4778//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004779// TestRESTSubReqAndSubDelOkTwoE2termParallel
4780//
4781// stub stub stub
4782// +-------+ +---------+ +---------+ +---------+
4783// | xapp | | submgr | | e2term1 | | e2term2 |
4784// +-------+ +---------+ +---------+ +---------+
4785// | | | |
4786// | | | |
4787// | | | |
4788// | RESTSubReq1 | | |
4789// |---------------->| | |
4790// | | | |
4791// | RESTSubResp1 | | |
4792// |<----------------| | |
4793// | | SubReq1 | |
4794// | |------------->| |
4795// | | | |
4796// | RESTSubReq2 | | |
4797// |---------------->| | |
4798// | | | |
4799// | RESTSubResp2 | | |
4800// |<----------------| | |
4801// | | SubReq2 | |
4802// | |---------------------------->|
4803// | | | |
4804// | | SubResp1 | |
4805// | |<-------------| |
4806// | RESTNotif1 | | |
4807// |<----------------| | |
4808// | | SubResp2 | |
4809// | |<----------------------------|
4810// | RESTNotif2 | | |
4811// |<----------------| | |
4812// | | | |
4813// | [SUBS 1 DELETE] | |
4814// | | | |
4815// | [SUBS 2 DELETE] | |
4816// | | | |
4817//
4818//-----------------------------------------------------------------------------
4819func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4820 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4821
4822 // Init counter check
4823 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004824 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004825 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004826 Counter{cSubReqToE2, 2},
4827 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004828 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004829 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004830 Counter{cSubDelReqToE2, 2},
4831 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004832 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004833 })
4834
4835 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004836
4837 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004838 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004839 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4840 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4841
4842 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004843 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004844 params.SetMeid("RAN_NAME_11")
4845 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4846 // would not work as notification would not be received
4847 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4848 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4849
4850 // Resp1
4851 xappConn1.ExpectRESTNotification(t, restSubId1)
4852 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4853 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004854 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004855
4856 // Resp2
4857 xappConn2.ExpectRESTNotification(t, restSubId2)
4858 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4859 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004860 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004861
4862 // Delete1
4863 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4864 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4865 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4866
4867 // Wait that subs is cleaned
4868 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4869
4870 // Delete2
4871 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4872 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4873 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4874
4875 // Wait that subs is cleaned
4876 waitSubsCleanup(t, e2SubsId2, 10)
4877
4878 mainCtrl.VerifyCounterValues(t)
4879}
4880
4881//-----------------------------------------------------------------------------
4882// TestRESTSubReqAsn1EncodeFail
4883//
4884// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4885// stub stub
4886// +-------+ +---------+ +---------+
4887// | xapp | | submgr | | e2term |
4888// +-------+ +---------+ +---------+
4889// | | |
4890// | RESTSubReq | |
4891// |---------------->| |
4892// | | |
4893// | RESTSubResp | |
4894// |<----------------| |
4895// | RESTSubDelReq | |
4896// |---------------->| |
4897// | RESTSubDelResp | |
4898// | unsuccess | |
4899// |<----------------| |
4900// | | |
4901//
4902//-----------------------------------------------------------------------------
4903func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4904 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4905
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004906 xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
archaggeafbf95f2021-04-14 08:54:05 +03004907
4908}
4909
4910//-----------------------------------------------------------------------------
4911// TestRESTSubReqInsertAndSubDelOk
4912//
4913// stub stub
4914// +-------+ +---------+ +---------+
4915// | xapp | | submgr | | e2term |
4916// +-------+ +---------+ +---------+
4917// | | |
4918// | RestSubReq | |
4919// |---------------->| |
4920// | | |
4921// | RESTSubResp | |
4922// |<----------------| |
4923// | | |
4924// | | SubReq |
4925// | |------------->|
4926// | | |
4927// | | SubResp |
4928// | |<-------------|
4929// | RESTNotif | |
4930// |<----------------| |
4931// | ... | ... |
4932// | | |
4933// | RESTSubDelReq | |
4934// |---------------->| |
4935// | | |
4936// | | SubDelReq |
4937// | |------------->|
4938// | | |
4939// | | SubDelResp |
4940// | |<-------------|
4941// | | |
4942// | RESTSubDelResp| |
4943// |<----------------| |
4944//
4945//-----------------------------------------------------------------------------
4946func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4947 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4948
4949 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004950 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004951 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004952 Counter{cSubReqToE2, 1},
4953 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004954 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004955 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004956 Counter{cSubDelReqToE2, 1},
4957 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004958 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004959 })
4960
4961 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004962
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004963 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004964 params.SetSubActionTypes("insert")
4965
4966 // Req
4967 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4968
4969 // Del
4970 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4971
4972 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4973 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4974
4975 // Wait that subs is cleaned
4976 waitSubsCleanup(t, e2SubsId, 10)
4977 mainCtrl.VerifyCounterValues(t)
4978}
4979
4980//-----------------------------------------------------------------------------
4981// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4982//
4983// stub stub
4984// +-------+ +---------+ +---------+
4985// | xapp | | submgr | | e2term |
4986// +-------+ +---------+ +---------+
4987// | | |
4988// | RESTSubReq | |
4989// |------------->| |
4990// | | |
4991// | | SubReq |
4992// | |------------->|
4993// | | |
4994// | | SubResp |
4995// | <----|
4996// | |
4997// | Submgr restart |
4998// | |
4999// | | |
5000// | | SubDelReq |
5001// | |------------->|
5002// | | |
5003// | | SubDelResp |
5004// | |<-------------|
5005// | | |
5006//
5007//-----------------------------------------------------------------------------
5008func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
5009 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
5010
5011 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005012 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005013 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005014 Counter{cSubReqToE2, 1},
5015 Counter{cSubDelReqFromXapp, 1},
5016 Counter{cSubDelReqToE2, 1},
5017 Counter{cSubDelRespFromE2, 1},
5018 })
5019
5020 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005021
5022 // Remove possible existing subscription
5023 mainCtrl.removeExistingSubscriptions(t)
5024
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005025 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005026
5027 //Req
5028 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5029 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005030 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005031
5032 e2termConn1.RecvSubsReq(t)
5033
5034 mainCtrl.SetResetTestFlag(t, false)
5035
5036 mainCtrl.SimulateRestart(t)
5037 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5038
5039 //Del
5040 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5041 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5042
5043 xappConn1.TestMsgChanEmpty(t)
5044 xappConn2.TestMsgChanEmpty(t)
5045 e2termConn1.TestMsgChanEmpty(t)
5046 mainCtrl.wait_registry_empty(t, 10)
5047
5048 mainCtrl.VerifyCounterValues(t)
5049}
5050
5051//-----------------------------------------------------------------------------
5052// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5053//
5054// stub stub
5055// +-------+ +---------+ +---------+
5056// | xapp | | submgr | | e2term |
5057// +-------+ +---------+ +---------+
5058// | | |
5059// | RESTSubReq | |
5060// |---------------->| |
5061// | | |
5062// | RESTSubResp | |
5063// |<----------------| |
5064// | | SubReq |
5065// | |------------->|
5066// | | |
5067// | | SubResp |
5068// | |<-------------|
5069// | | |
5070// | RESTNotif | |
5071// |<----------------| |
5072// | | |
5073// | |
5074// | Submgr restart |
5075// | | |
5076// | RESTSubDelReq | |
5077// |---------------->| |
5078// | | |
5079// | | SubDelReq |
5080// | |------------->|
5081// | | |
5082// | | SubDelResp |
5083// | |<-------------|
5084// | | |
5085// | RESTSubDelResp | |
5086// |<----------------| |
5087//
5088//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005089
archaggeafbf95f2021-04-14 08:54:05 +03005090func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
5091 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
5092
5093 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005094 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005095 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005096 Counter{cSubReqToE2, 1},
5097 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005098 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005099 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005100 Counter{cSubDelReqToE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005101 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005102 })
5103
5104 // Remove possible existing subscription
5105 mainCtrl.removeExistingSubscriptions(t)
5106
5107 var params *teststube2ap.RESTSubsReqParams = nil
5108
5109 // Create subscription
5110 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005111 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005112
5113 // Check subscription
5114 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5115
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005116 mainCtrl.SimulateRestart(t)
5117 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005118
5119 // Check subscription
5120 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5121
5122 // Delete subscription
5123 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5124
5125 //Wait that subs is cleaned
5126 waitSubsCleanup(t, e2SubsId, 10)
5127
5128 mainCtrl.VerifyCounterValues(t)
5129}
5130
5131//-----------------------------------------------------------------------------
5132// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5133//
5134// stub stub
5135// +-------+ +-------+ +---------+ +---------+
5136// | xapp2 | | xapp1 | | submgr | | e2term |
5137// +-------+ +-------+ +---------+ +---------+
5138// | | | |
5139// | | RESTSubReq1 | |
5140// | |---------------->| |
5141// | | | |
5142// | | RESTSubResp1 | |
5143// | |<----------------| |
5144// | | | |
5145// | | | SubReq1 |
5146// | | |------------->|
5147// | | | SubResp1 |
5148// | | |<-------------|
5149// | | RESTNotif1 | |
5150// | |<----------------| |
5151// | | | |
5152// | RESTSubReq2 | |
5153// |------------------------------>| |
5154// | | | |
5155// | RESTSubResp2 | |
5156// |<------------------------------| |
5157// | | | |
5158// | | RESTNotif2 | |
5159// |<------------------------------| |
5160// | | | |
5161// | | Submgr restart |
5162// | | | |
5163// | | RESTSubDelReq1 | |
5164// | |---------------->| |
5165// | | | |
5166// | | RESTSubDelResp1 | |
5167// | |<----------------| |
5168// | | | |
5169// | | Submgr restart |
5170// | | | |
5171// | RESTSubDelReq2 | |
5172// |------------------------------>| |
5173// | | | |
5174// | RESTSubDelResp2 | |
5175// |<------------------------------| |
5176// | | | |
5177// | | | SubDelReq2 |
5178// | | |------------->|
5179// | | | |
5180// | | | SubDelResp2 |
5181// | | |<-------------|
5182// | | | |
5183//
5184//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005185
archaggeafbf95f2021-04-14 08:54:05 +03005186func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
5187 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
5188
5189 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005190 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005191 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005192 Counter{cSubReqToE2, 1},
5193 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005194 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005195 Counter{cMergedSubscriptions, 1},
5196 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005197 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005198 Counter{cSubDelReqToE2, 1},
5199 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005200 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005201 })
5202
5203 // Remove possible existing subscription
5204 mainCtrl.removeExistingSubscriptions(t)
5205
5206 var params *teststube2ap.RESTSubsReqParams = nil
5207
5208 // Create subscription 1
5209 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005210 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005211
5212 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005213 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005214 params.SetMeid("RAN_NAME_1")
5215 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005216 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005217 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005218 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005219 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005220 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005221
5222 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5223
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005224 mainCtrl.SimulateRestart(t)
5225 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005226
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005227 // Delete subscription 1, and wait until it has removed the first endpoint
5228 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005229 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005230 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005231
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005232 mainCtrl.SimulateRestart(t)
5233 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005234 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5235
5236 // Delete subscription 2
5237 deleteXapp2Subscription(t, &restSubId2)
5238
5239 //Wait that subs is cleaned
5240 waitSubsCleanup(t, e2SubsId2, 10)
5241
5242 mainCtrl.VerifyCounterValues(t)
5243}
5244
5245//-----------------------------------------------------------------------------
5246// TestRESTReportSubReqAndSubDelOk
5247//
5248// stub stub
5249// +-------+ +---------+ +---------+
5250// | xapp | | submgr | | e2term |
5251// +-------+ +---------+ +---------+
5252// | | |
5253// | RestSubReq | |
5254// |---------------->| |
5255// | | |
5256// | RESTSubResp | |
5257// |<----------------| |
5258// | | |
5259// | | SubReq |
5260// | |------------->|
5261// | | |
5262// | | SubResp |
5263// | |<-------------|
5264// | RESTNotif | |
5265// |<----------------| |
5266// | | SubReq |
5267// | |------------->|
5268// | | |
5269// | | SubResp |
5270// | |<-------------|
5271// | RESTNotif | |
5272// |<----------------| |
5273// | ... | ... |
5274// | | |
5275// | | |
5276// | RESTSubDelReq | |
5277// |---------------->| |
5278// | | |
5279// | | SubDelReq |
5280// | |------------->|
5281// | | |
5282// | | SubDelResp |
5283// | |<-------------|
5284// | | |
5285// | RESTSubDelResp| |
5286// |<----------------| |
5287//
5288//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005289
archaggeafbf95f2021-04-14 08:54:05 +03005290func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5291 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005292 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005293 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005294 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005295}
5296
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005297func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005298 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005299
5300 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005301 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005302 restSubId := xappConn1.SendRESTSubsReq(t, params)
5303
5304 var e2SubsId []uint32
5305 for i := 0; i < subReqCount; i++ {
5306 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5307 xappConn1.ExpectRESTNotification(t, restSubId)
5308
5309 e2termConn1.SendSubsResp(t, crereq, cremsg)
5310 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005311 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005312 e2SubsId = append(e2SubsId, instanceId)
5313 resp, _ := xapp.Subscription.QuerySubscriptions()
5314 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5315 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5316 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5317
5318 }
5319
5320 // Del
5321 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5322
5323 for i := 0; i < subReqCount; i++ {
5324 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5325 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5326 }
5327
5328 // Wait that subs is cleaned
5329 for i := 0; i < subReqCount; i++ {
5330 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5331 }
5332
5333 xappConn1.TestMsgChanEmpty(t)
5334 e2termConn1.TestMsgChanEmpty(t)
5335 mainCtrl.wait_registry_empty(t, 10)
5336}
5337
5338/*
5339func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
5340 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5341
5342 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005343 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005344 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005345
5346 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005347 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005348 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005349}
5350*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005351func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005352 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005353
5354 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005355 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005356 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005357
5358 var e2SubsId []uint32
5359 for i := 0; i < subReqCount; i++ {
5360 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5361 xappConn1.ExpectRESTNotification(t, restSubId)
5362 e2termConn1.SendSubsResp(t, crereq, cremsg)
5363 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005364 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005365 e2SubsId = append(e2SubsId, instanceId)
5366 }
5367
5368 // Del
5369 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5370
5371 for i := 0; i < subReqCount; i++ {
5372 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5373 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5374 }
5375
5376 // Wait that subs is cleaned
5377 for i := 0; i < subReqCount; i++ {
5378 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5379 }
5380 xappConn1.TestMsgChanEmpty(t)
5381 e2termConn1.TestMsgChanEmpty(t)
5382 mainCtrl.wait_registry_empty(t, 10)
5383}
5384
archaggeafbf95f2021-04-14 08:54:05 +03005385func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5386
archaggeafbf95f2021-04-14 08:54:05 +03005387 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005388 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005389 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005390 Counter{cSubReqToE2, 2},
5391 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005392 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005393 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005394 Counter{cSubDelReqToE2, 2},
5395 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005396 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005397 })
5398
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005399 const subReqCount int = 2
5400
archaggeafbf95f2021-04-14 08:54:05 +03005401 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005402 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005403 restSubId := xappConn1.SendRESTSubsReq(t, params)
5404 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5405
5406 assert.Equal(t, len(e2SubsIds), 2)
5407
5408 // Del
5409 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5410 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5411
5412 xappConn1.TestMsgChanEmpty(t)
5413 e2termConn1.TestMsgChanEmpty(t)
5414 mainCtrl.wait_registry_empty(t, 10)
5415
5416 mainCtrl.VerifyCounterValues(t)
5417}
archaggeafbf95f2021-04-14 08:54:05 +03005418func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5419
archaggeafbf95f2021-04-14 08:54:05 +03005420 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005421 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005422 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005423 Counter{cSubReqToE2, 19},
5424 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005425 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005426 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005427 Counter{cSubDelReqToE2, 19},
5428 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005429 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005430 })
5431
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005432 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005433 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005434 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005435 restSubId := xappConn1.SendRESTSubsReq(t, params)
5436 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5437
5438 assert.Equal(t, len(e2SubsIds), 19)
5439
5440 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5441 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5442
5443 xappConn1.TestMsgChanEmpty(t)
5444 e2termConn1.TestMsgChanEmpty(t)
5445 mainCtrl.wait_registry_empty(t, 10)
5446
5447 mainCtrl.VerifyCounterValues(t)
5448}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005449
archaggeafbf95f2021-04-14 08:54:05 +03005450func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5451
5452 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005453
5454 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005455 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005456 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005457 Counter{cSubReqToE2, uint64(subReqCount)},
5458 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005459 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005460 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005461 Counter{cSubDelReqToE2, uint64(subReqCount)},
5462 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005463 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005464 })
5465
5466 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005467 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005468 restSubId := xappConn1.SendRESTSubsReq(t, params)
5469 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5470
5471 assert.Equal(t, len(e2SubsIds), subReqCount)
5472
5473 // Del
5474 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5475 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5476
5477 xappConn1.TestMsgChanEmpty(t)
5478 e2termConn1.TestMsgChanEmpty(t)
5479 mainCtrl.wait_registry_empty(t, 10)
5480
5481 mainCtrl.VerifyCounterValues(t)
5482}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005483
archaggeafbf95f2021-04-14 08:54:05 +03005484func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5485
5486 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005487
5488 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005489 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005490 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005491 Counter{cSubReqToE2, uint64(subReqCount)},
5492 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005493 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005494 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005495 Counter{cSubDelReqToE2, uint64(subReqCount)},
5496 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005497 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005498 })
5499
5500 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005501 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005502 restSubId := xappConn1.SendRESTSubsReq(t, params)
5503 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5504
5505 assert.Equal(t, len(e2SubsIds), subReqCount)
5506
5507 // Del
5508 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5509 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5510
5511 xappConn1.TestMsgChanEmpty(t)
5512 e2termConn1.TestMsgChanEmpty(t)
5513 mainCtrl.wait_registry_empty(t, 10)
5514
5515 mainCtrl.VerifyCounterValues(t)
5516}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005517
archaggeafbf95f2021-04-14 08:54:05 +03005518func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5519
5520 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005521
5522 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005523 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005524 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005525 Counter{cSubReqToE2, uint64(subReqCount)},
5526 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005527 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005528 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005529 Counter{cSubDelReqToE2, uint64(subReqCount)},
5530 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005531 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005532 })
5533
5534 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005535 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005536 restSubId := xappConn1.SendRESTSubsReq(t, params)
5537 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5538
5539 assert.Equal(t, len(e2SubsIds), subReqCount)
5540
5541 // Del
5542 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5543 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5544
5545 xappConn1.TestMsgChanEmpty(t)
5546 e2termConn1.TestMsgChanEmpty(t)
5547 mainCtrl.wait_registry_empty(t, 10)
5548
5549 mainCtrl.VerifyCounterValues(t)
5550}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005551
5552func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5553 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5554
5555 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005556 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005557 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005558 Counter{cSubReqToE2, 2},
5559 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005560 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005561 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005562 Counter{cSubDelReqToE2, 2},
5563 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005564 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005565 })
5566
5567 // Req1
5568 var params *teststube2ap.RESTSubsReqParams = nil
5569
5570 //Subs Create
5571 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005572 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005573
5574 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5575
5576 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005577 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005578 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005579 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005580 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5581
5582 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005583 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005584 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5585 xappConn2.ExpectRESTNotification(t, restSubId2)
5586 e2termConn1.SendSubsResp(t, crereq, cremsg)
5587 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5588
5589 deleteXapp1Subscription(t, &restSubId1)
5590 deleteXapp2Subscription(t, &restSubId2)
5591
5592 waitSubsCleanup(t, e2SubsId1, 10)
5593 waitSubsCleanup(t, e2SubsId2, 10)
5594
5595 mainCtrl.VerifyCounterValues(t)
5596
5597}
5598
5599func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5600 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5601
5602 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005603 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005604 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005605 Counter{cSubReqToE2, 2},
5606 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005607 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005608 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005609 Counter{cSubDelReqToE2, 2},
5610 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005611 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005612 })
5613
5614 // Req1
5615 var params *teststube2ap.RESTSubsReqParams = nil
5616
5617 //Subs Create
5618 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005619 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005620
5621 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5622
5623 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005624 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005625 params.SetMeid("RAN_NAME_1")
5626
5627 actionId := int64(1)
5628 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005629 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005630 subsequestActionType := "continue"
5631 timeToWait := "w10ms"
5632 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5633
5634 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005635 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005636 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5637 xappConn2.ExpectRESTNotification(t, restSubId2)
5638 e2termConn1.SendSubsResp(t, crereq, cremsg)
5639 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5640
5641 deleteXapp1Subscription(t, &restSubId1)
5642 deleteXapp2Subscription(t, &restSubId2)
5643
5644 waitSubsCleanup(t, e2SubsId1, 10)
5645 waitSubsCleanup(t, e2SubsId2, 10)
5646
5647 mainCtrl.VerifyCounterValues(t)
5648
5649}
5650
5651func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5652 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5653
5654 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005655 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005656 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005657 Counter{cSubReqToE2, 2},
5658 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005659 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005660 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005661 Counter{cSubDelReqToE2, 2},
5662 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005663 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005664 })
5665
5666 // Req1
5667 var params *teststube2ap.RESTSubsReqParams = nil
5668
5669 //Subs Create
5670 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005671 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005672
5673 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5674
5675 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005676 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005677 params.SetMeid("RAN_NAME_1")
5678 params.SetSubActionIDs(int64(2))
5679
5680 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005681 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005682 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5683 xappConn2.ExpectRESTNotification(t, restSubId2)
5684 e2termConn1.SendSubsResp(t, crereq, cremsg)
5685 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5686
5687 deleteXapp1Subscription(t, &restSubId1)
5688 deleteXapp2Subscription(t, &restSubId2)
5689
5690 waitSubsCleanup(t, e2SubsId1, 10)
5691 waitSubsCleanup(t, e2SubsId2, 10)
5692
5693 mainCtrl.VerifyCounterValues(t)
5694
5695}
5696
5697func TestRESTSubReqDiffActionType(t *testing.T) {
5698 CaseBegin("TestRESTSubReqDiffActionType")
5699
5700 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005701 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005702 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005703 Counter{cSubReqToE2, 2},
5704 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005705 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005706 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005707 Counter{cSubDelReqToE2, 2},
5708 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005709 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005710 })
5711
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005712 const e2Timeout int64 = 2
5713 const e2RetryCount int64 = 2
5714 const routingNeeded bool = true
5715
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005716 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005717 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005718 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005719
5720 //Subs Create
5721 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005722 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005723
5724 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5725
5726 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005727 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005728 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005729 params.SetMeid("RAN_NAME_1")
5730
5731 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005732 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005733 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5734 xappConn2.ExpectRESTNotification(t, restSubId2)
5735 e2termConn1.SendSubsResp(t, crereq, cremsg)
5736 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5737
5738 deleteXapp1Subscription(t, &restSubId1)
5739 deleteXapp2Subscription(t, &restSubId2)
5740
5741 waitSubsCleanup(t, e2SubsId1, 10)
5742 waitSubsCleanup(t, e2SubsId2, 10)
5743
5744 mainCtrl.VerifyCounterValues(t)
5745
5746}
5747
5748func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5749 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5750
5751 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005752 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005753 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005754 Counter{cSubReqToE2, 2},
5755 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005756 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005757 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005758 Counter{cSubDelReqToE2, 2},
5759 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005760 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005761 })
5762
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005763 const e2Timeout int64 = 2
5764 const e2RetryCount int64 = 2
5765 const routingNeeded bool = true
5766
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005767 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005768 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005769 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005770
5771 //Subs Create
5772 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005773 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005774
5775 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5776
5777 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005778 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005779 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005780 params.SetMeid("RAN_NAME_1")
5781
5782 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005783 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005784 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5785 xappConn2.ExpectRESTNotification(t, restSubId2)
5786 e2termConn1.SendSubsResp(t, crereq, cremsg)
5787 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5788
5789 deleteXapp1Subscription(t, &restSubId1)
5790 deleteXapp2Subscription(t, &restSubId2)
5791
5792 waitSubsCleanup(t, e2SubsId1, 10)
5793 waitSubsCleanup(t, e2SubsId2, 10)
5794
5795 mainCtrl.VerifyCounterValues(t)
5796
5797}
5798
5799func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5800 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5801
5802 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005803 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005804 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005805 Counter{cSubReqToE2, 2},
5806 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005807 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005808 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005809 Counter{cSubDelReqToE2, 2},
5810 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005811 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005812 })
5813
5814 // Req1
5815 var params *teststube2ap.RESTSubsReqParams = nil
5816
5817 //Subs Create
5818 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005819 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005820
5821 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5822
5823 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005824 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005825 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005826 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005827 params.SetSubActionDefinition(actionDefinition)
5828
5829 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005830 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005831 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5832 xappConn2.ExpectRESTNotification(t, restSubId2)
5833 e2termConn1.SendSubsResp(t, crereq, cremsg)
5834 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5835
5836 deleteXapp1Subscription(t, &restSubId1)
5837 deleteXapp2Subscription(t, &restSubId2)
5838
5839 waitSubsCleanup(t, e2SubsId1, 10)
5840 waitSubsCleanup(t, e2SubsId2, 10)
5841
5842 mainCtrl.VerifyCounterValues(t)
5843
5844}
5845
5846func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5847 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5848
5849 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005850 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005851 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005852 Counter{cSubReqToE2, 2},
5853 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005854 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005855 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005856 Counter{cSubDelReqToE2, 2},
5857 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005858 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005859 })
5860
5861 // Req1
5862 var params *teststube2ap.RESTSubsReqParams = nil
5863
5864 //Subs Create
5865 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005866 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005867
5868 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5869
5870 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005871 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005872 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005873 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005874 params.SetSubActionDefinition(actionDefinition)
5875
5876 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005877 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005878 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5879 xappConn2.ExpectRESTNotification(t, restSubId2)
5880 e2termConn1.SendSubsResp(t, crereq, cremsg)
5881 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5882
5883 deleteXapp1Subscription(t, &restSubId1)
5884 deleteXapp2Subscription(t, &restSubId2)
5885
5886 waitSubsCleanup(t, e2SubsId1, 10)
5887 waitSubsCleanup(t, e2SubsId2, 10)
5888
5889 mainCtrl.VerifyCounterValues(t)
5890
5891}
5892
5893func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5894 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5895
5896 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005897 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005898 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005899 Counter{cSubReqToE2, 2},
5900 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005901 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005902 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005903 Counter{cSubDelReqToE2, 2},
5904 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005905 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005906 })
5907
5908 // Req1
5909 var params *teststube2ap.RESTSubsReqParams = nil
5910
5911 //Subs Create
5912 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005913 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005914
5915 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5916
5917 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005918 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005919 params.SetMeid("RAN_NAME_1")
5920 params.SetTimeToWait("w200ms")
5921 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005922 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005923 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5924 xappConn2.ExpectRESTNotification(t, restSubId2)
5925 e2termConn1.SendSubsResp(t, crereq, cremsg)
5926 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5927
5928 deleteXapp1Subscription(t, &restSubId1)
5929 deleteXapp2Subscription(t, &restSubId2)
5930
5931 waitSubsCleanup(t, e2SubsId1, 10)
5932 waitSubsCleanup(t, e2SubsId2, 10)
5933
5934 mainCtrl.VerifyCounterValues(t)
5935
5936}
5937
Anssi Mannila51122392021-05-25 11:51:31 +03005938//-----------------------------------------------------------------------------
5939// TestRESTUnpackSubscriptionResponseDecodeFail
5940//
5941// stub stub
5942// +-------+ +---------+ +---------+
5943// | xapp | | submgr | | e2term |
5944// +-------+ +---------+ +---------+
5945// | | |
5946// | RestSubReq | |
5947// |---------------->| |
5948// | | |
5949// | RESTSubResp | |
5950// |<----------------| |
5951// | | |
5952// | | SubReq |
5953// | |------------->|
5954// | | |
5955// | | SubResp | ASN.1 decode fails
5956// | |<-------------|
5957// | | |
5958// | | SubReq |
5959// | |------------->|
5960// | | |
5961// | | SubFail | Duplicated action
5962// | |<-------------|
5963// | RESTNotif (fail)| |
5964// |<----------------| |
5965// | | SubDelReq |
5966// | |------------->|
5967// | | |
5968// | | SubDelResp |
5969// | |<-------------|
5970//
5971//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005972
Anssi Mannila51122392021-05-25 11:51:31 +03005973func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005974 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5975 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03005976
5977 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005978 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005979 restSubId := xappConn1.SendRESTSubsReq(t, params)
5980
5981 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5982 // Decode of this response fails which will result resending original request
5983 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5984
5985 _, cremsg = e2termConn1.RecvSubsReq(t)
5986
Markku Virtanen55d2a282021-06-04 14:46:56 +03005987 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005988
5989 // Subscription already created in E2 Node.
5990 fparams := &teststube2ap.E2StubSubsFailParams{}
5991 fparams.Set(crereq)
5992 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5993 e2termConn1.SendSubsFail(t, fparams, cremsg)
5994
5995 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5996 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5997
5998 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005999 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006000
6001 // Wait that subs is cleaned
6002 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6003
6004 xappConn1.TestMsgChanEmpty(t)
6005 e2termConn1.TestMsgChanEmpty(t)
6006 mainCtrl.wait_registry_empty(t, 10)
6007}
6008
6009//-----------------------------------------------------------------------------
6010// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6011//
6012// stub stub
6013// +-------+ +---------+ +---------+
6014// | xapp | | submgr | | e2term |
6015// +-------+ +---------+ +---------+
6016// | | |
6017// | RestSubReq | |
6018// |---------------->| |
6019// | | |
6020// | RESTSubResp | |
6021// |<----------------| |
6022// | | |
6023// | | SubReq |
6024// | |------------->|
6025// | | |
6026// | | SubResp | Unknown instanceId
6027// | |<-------------|
6028// | | |
6029// | | SubReq |
6030// | |------------->|
6031// | | |
6032// | | SubFail | Duplicated action
6033// | |<-------------|
6034// | RESTNotif (fail)| |
6035// |<----------------| |
6036// | | SubDelReq |
6037// | |------------->|
6038// | | |
6039// | | SubDelResp |
6040// | |<-------------|
6041//
6042//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006043
Anssi Mannila51122392021-05-25 11:51:31 +03006044func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006045 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
6046 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006047
6048 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006049 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006050 restSubId := xappConn1.SendRESTSubsReq(t, params)
6051
6052 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6053
6054 // Unknown instanceId in this response which will result resending original request
6055 orgInstanceId := crereq.RequestId.InstanceId
6056 crereq.RequestId.InstanceId = 0
6057 e2termConn1.SendSubsResp(t, crereq, cremsg)
6058
6059 _, cremsg = e2termConn1.RecvSubsReq(t)
6060
Markku Virtanen55d2a282021-06-04 14:46:56 +03006061 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006062
6063 // Subscription already created in E2 Node.
6064 fparams := &teststube2ap.E2StubSubsFailParams{}
6065 fparams.Set(crereq)
6066 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6067 e2termConn1.SendSubsFail(t, fparams, cremsg)
6068
6069 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6070 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6071
6072 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006073 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006074
6075 // Wait that subs is cleaned
6076 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6077
6078 xappConn1.TestMsgChanEmpty(t)
6079 e2termConn1.TestMsgChanEmpty(t)
6080 mainCtrl.wait_registry_empty(t, 10)
6081}
6082
6083//-----------------------------------------------------------------------------
6084// TestRESTUnpackSubscriptionResponseNoTransaction
6085//
6086// stub stub
6087// +-------+ +---------+ +---------+
6088// | xapp | | submgr | | e2term |
6089// +-------+ +---------+ +---------+
6090// | | |
6091// | RestSubReq | |
6092// |---------------->| |
6093// | | |
6094// | RESTSubResp | |
6095// |<----------------| |
6096// | | |
6097// | | SubReq |
6098// | |------------->|
6099// | | |
6100// | | SubResp | No transaction for the response
6101// | |<-------------|
6102// | | |
6103// | | SubReq |
6104// | |------------->|
6105// | | |
6106// | | SubFail | Duplicated action
6107// | |<-------------|
6108// | RESTNotif (fail)| |
6109// |<----------------| |
6110// | | SubDelReq |
6111// | |------------->|
6112// | | |
6113// | | SubDelResp |
6114// | |<-------------|
6115// | | |
6116// | | SubDelReq |
6117// | |------------->|
6118// | | |
6119// | | SubDelResp |
6120// | |<-------------|
6121//
6122//-----------------------------------------------------------------------------
6123func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006124 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
6125 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006126
6127 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006128 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006129 restSubId := xappConn1.SendRESTSubsReq(t, params)
6130
6131 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6132
6133 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6134 // No transaction exist for this response which will result resending original request
6135 e2termConn1.SendSubsResp(t, crereq, cremsg)
6136
6137 _, cremsg = e2termConn1.RecvSubsReq(t)
6138
Markku Virtanen55d2a282021-06-04 14:46:56 +03006139 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006140
6141 // Subscription already created in E2 Node.
6142 fparams := &teststube2ap.E2StubSubsFailParams{}
6143 fparams.Set(crereq)
6144 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6145 e2termConn1.SendSubsFail(t, fparams, cremsg)
6146
6147 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6148 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6149
6150 // Resending happens because there no transaction
6151 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6152 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6153
6154 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006155 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006156
6157 // Wait that subs is cleaned
6158 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6159
6160 xappConn1.TestMsgChanEmpty(t)
6161 e2termConn1.TestMsgChanEmpty(t)
6162 mainCtrl.wait_registry_empty(t, 10)
6163
6164}
6165
6166//-----------------------------------------------------------------------------
6167// TestRESTUnpackSubscriptionFailureDecodeFail
6168//
6169// stub stub
6170// +-------+ +---------+ +---------+
6171// | xapp | | submgr | | e2term |
6172// +-------+ +---------+ +---------+
6173// | | |
6174// | RestSubReq | |
6175// |---------------->| |
6176// | | |
6177// | RESTSubResp | |
6178// |<----------------| |
6179// | | |
6180// | | SubReq |
6181// | |------------->|
6182// | | |
6183// | | SubFail | ASN.1 decode fails
6184// | |<-------------|
6185// | | |
6186// | | SubReq |
6187// | |------------->|
6188// | | |
6189// | | SubFail | Duplicated action
6190// | |<-------------|
6191// | RESTNotif (fail)| |
6192// |<----------------| |
6193// | | SubDelReq |
6194// | |------------->|
6195// | | |
6196// | | SubDelResp |
6197// | |<-------------|
6198//
6199//-----------------------------------------------------------------------------
6200func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006201 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
6202 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006203
6204 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006205 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006206 restSubId := xappConn1.SendRESTSubsReq(t, params)
6207
6208 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6209
6210 // Decode of this response fails which will result resending original request
6211 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
6212
6213 _, cremsg = e2termConn1.RecvSubsReq(t)
6214
Markku Virtanen55d2a282021-06-04 14:46:56 +03006215 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006216
6217 // Subscription already created in E2 Node.
6218 fparams := &teststube2ap.E2StubSubsFailParams{}
6219 fparams.Set(crereq)
6220 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6221 e2termConn1.SendSubsFail(t, fparams, cremsg)
6222
6223 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6224 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6225
6226 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006227 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006228
6229 // Wait that subs is cleaned
6230 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6231
6232 xappConn1.TestMsgChanEmpty(t)
6233 e2termConn1.TestMsgChanEmpty(t)
6234 mainCtrl.wait_registry_empty(t, 10)
6235}
6236
6237//-----------------------------------------------------------------------------
6238// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6239//
6240// stub stub
6241// +-------+ +---------+ +---------+
6242// | xapp | | submgr | | e2term |
6243// +-------+ +---------+ +---------+
6244// | | |
6245// | RestSubReq | |
6246// |---------------->| |
6247// | | |
6248// | RESTSubResp | |
6249// |<----------------| |
6250// | | |
6251// | | SubReq |
6252// | |------------->|
6253// | | |
6254// | | SubFail | Unknown instanceId
6255// | |<-------------|
6256// | | |
6257// | | SubReq |
6258// | |------------->|
6259// | | |
6260// | | SubFail | Duplicated action
6261// | |<-------------|
6262// | RESTNotif (fail)| |
6263// |<----------------| |
6264// | | SubDelReq |
6265// | |------------->|
6266// | | |
6267// | | SubDelResp |
6268// | |<-------------|
6269//
6270//-----------------------------------------------------------------------------
6271func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006272 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6273 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006274
6275 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006276 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006277 restSubId := xappConn1.SendRESTSubsReq(t, params)
6278
6279 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6280
6281 // Unknown instanceId in this response which will result resending original request
6282 fparams := &teststube2ap.E2StubSubsFailParams{}
6283 fparams.Set(crereq)
6284 fparams.Fail.RequestId.InstanceId = 0
6285 e2termConn1.SendSubsFail(t, fparams, cremsg)
6286
6287 _, cremsg = e2termConn1.RecvSubsReq(t)
6288
Markku Virtanen55d2a282021-06-04 14:46:56 +03006289 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006290
6291 // Subscription already created in E2 Node.
6292 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6293 e2termConn1.SendSubsFail(t, fparams, cremsg)
6294
6295 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6296 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6297
6298 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006299 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006300
6301 // Wait that subs is cleaned
6302 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6303
6304 xappConn1.TestMsgChanEmpty(t)
6305 e2termConn1.TestMsgChanEmpty(t)
6306 mainCtrl.wait_registry_empty(t, 10)
6307}
6308
6309//-----------------------------------------------------------------------------
6310// TestRESTUnpackSubscriptionFailureNoTransaction
6311//
6312// stub stub
6313// +-------+ +---------+ +---------+
6314// | xapp | | submgr | | e2term |
6315// +-------+ +---------+ +---------+
6316// | | |
6317// | RestSubReq | |
6318// |---------------->| |
6319// | | |
6320// | RESTSubResp | |
6321// |<----------------| |
6322// | | |
6323// | | SubReq |
6324// | |------------->|
6325// | | |
6326// | | SubFail | No transaction for the response
6327// | |<-------------|
6328// | | |
6329// | | SubReq |
6330// | |------------->|
6331// | | |
6332// | | SubFail | Duplicated action
6333// | |<-------------|
6334// | RESTNotif (fail)| |
6335// |<----------------| |
6336// | | SubDelReq |
6337// | |------------->|
6338// | | |
6339// | | SubDelResp |
6340// | |<-------------|
6341//
6342//-----------------------------------------------------------------------------
6343func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006344 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6345 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006346
6347 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006348 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006349 restSubId := xappConn1.SendRESTSubsReq(t, params)
6350
6351 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6352
6353 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6354
6355 // No transaction exist for this response which will result resending original request
6356 fparams := &teststube2ap.E2StubSubsFailParams{}
6357 fparams.Set(crereq)
6358 e2termConn1.SendSubsFail(t, fparams, cremsg)
6359
6360 _, cremsg = e2termConn1.RecvSubsReq(t)
6361
Markku Virtanen55d2a282021-06-04 14:46:56 +03006362 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006363
6364 // Subscription already created in E2 Node.
6365 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6366 e2termConn1.SendSubsFail(t, fparams, cremsg)
6367
6368 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6369 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6370
6371 // Resending happens because there no transaction
6372 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6373 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6374
6375 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006376 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006377
6378 // Wait that subs is cleaned
6379 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6380
6381 xappConn1.TestMsgChanEmpty(t)
6382 e2termConn1.TestMsgChanEmpty(t)
6383 mainCtrl.wait_registry_empty(t, 10)
6384}
6385
6386//-----------------------------------------------------------------------------
6387// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6388//
6389// stub stub
6390// +-------+ +---------+ +---------+
6391// | xapp | | submgr | | e2term |
6392// +-------+ +---------+ +---------+
6393// | | |
6394// | [SUBS CREATE] |
6395// | | |
6396// | | |
6397// | RESTSubDelReq | |
6398// |---------------->| |
6399// | | |
6400// | RESTSubDelResp | |
6401// |<----------------| |
6402// | | |
6403// | | SubDelReq |
6404// | |------------->|
6405// | | |
6406// | | SubDelResp | ASN.1 decode fails
6407// | |<-------------|
6408// | | |
6409// | | SubDelReq |
6410// | |------------->|
6411// | | |
6412// | | SubDelFail | Subscription does exist any more
6413// | |<-------------|
6414// | | |
6415//
6416//-----------------------------------------------------------------------------
6417func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006418 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006419
6420 // Req
6421 var params *teststube2ap.RESTSubsReqParams = nil
6422 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6423
6424 // Del
6425 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6426
6427 // E2t: Receive 1st SubsDelReq
6428 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6429
6430 // Decode of this response fails which will result resending original request
6431 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6432
6433 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6434 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6435
6436 // Subscription does not exist in in E2 Node.
6437 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6438
6439 // Wait that subs is cleaned
6440 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6441
6442 xappConn1.TestMsgChanEmpty(t)
6443 e2termConn1.TestMsgChanEmpty(t)
6444 mainCtrl.wait_registry_empty(t, 10)
6445}
6446
6447//-----------------------------------------------------------------------------
6448// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6449//
6450// stub stub
6451// +-------+ +---------+ +---------+
6452// | xapp | | submgr | | e2term |
6453// +-------+ +---------+ +---------+
6454// | | |
6455// | [SUBS CREATE] |
6456// | | |
6457// | | |
6458// | RESTSubDelReq | |
6459// |---------------->| |
6460// | | |
6461// | RESTSubDelResp | |
6462// |<----------------| |
6463// | | |
6464// | | SubDelReq |
6465// | |------------->|
6466// | | |
6467// | | SubDelResp | Unknown instanceId
6468// | |<-------------|
6469// | | |
6470// | | SubDelReq |
6471// | |------------->|
6472// | | |
6473// | | SubDelFail | Subscription does exist any more
6474// | |<-------------|
6475//
6476//-----------------------------------------------------------------------------
6477func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006478 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006479
6480 // Req
6481 var params *teststube2ap.RESTSubsReqParams = nil
6482 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6483
6484 // Del
6485 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6486
6487 // E2t: Receive 1st SubsDelReq
6488 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6489
6490 // Unknown instanceId in this response which will result resending original request
6491 delreq.RequestId.InstanceId = 0
6492 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6493
6494 // E2t: Receive 2nd SubsDelReq
6495 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6496
6497 // Subscription does not exist in in E2 Node.
6498 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6499
6500 // Wait that subs is cleaned
6501 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6502
6503 xappConn1.TestMsgChanEmpty(t)
6504 e2termConn1.TestMsgChanEmpty(t)
6505 mainCtrl.wait_registry_empty(t, 10)
6506}
6507
6508//-----------------------------------------------------------------------------
6509// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6510//
6511// stub stub
6512// +-------+ +---------+ +---------+
6513// | xapp | | submgr | | e2term |
6514// +-------+ +---------+ +---------+
6515// | | |
6516// | [SUBS CREATE] |
6517// | | |
6518// | | |
6519// | RESTSubDelReq | |
6520// |---------------->| |
6521// | | |
6522// | RESTSubDelResp | |
6523// |<----------------| |
6524// | | |
6525// | | SubDelReq |
6526// | |------------->|
6527// | | |
6528// | | SubDelResp | No transaction for the response
6529// | |<-------------|
6530// | | |
6531// | | SubDelReq |
6532// | |------------->|
6533// | | |
6534// | | SubDelFail | Subscription does exist any more
6535// | |<-------------|
6536//
6537//-----------------------------------------------------------------------------
6538func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006539 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006540
6541 // Req
6542 var params *teststube2ap.RESTSubsReqParams = nil
6543 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6544
6545 // Del
6546 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6547
6548 // E2t: Receive 1st SubsDelReq
6549 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6550
6551 mainCtrl.MakeTransactionNil(t, e2SubsId)
6552
6553 // No transaction exist for this response which will result resending original request
6554 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6555
6556 // E2t: Receive 2nd SubsDelReq
6557 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6558
6559 // Subscription does not exist in in E2 Node.
6560 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6561
6562 // Wait that subs is cleaned
6563 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6564
6565 xappConn1.TestMsgChanEmpty(t)
6566 e2termConn1.TestMsgChanEmpty(t)
6567 mainCtrl.wait_registry_empty(t, 10)
6568}
6569
6570//-----------------------------------------------------------------------------
6571// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6572//
6573// stub stub
6574// +-------+ +---------+ +---------+
6575// | xapp | | submgr | | e2term |
6576// +-------+ +---------+ +---------+
6577// | | |
6578// | [SUBS CREATE] |
6579// | | |
6580// | | |
6581// | RESTSubDelReq | |
6582// |---------------->| |
6583// | | |
6584// | RESTSubDelResp | |
6585// |<----------------| |
6586// | | |
6587// | | SubDelReq |
6588// | |------------->|
6589// | | |
6590// | | SubDelFail | ASN.1 decode fails
6591// | |<-------------|
6592// | | |
6593// | | SubDelReq |
6594// | |------------->|
6595// | | |
6596// | | SubDelFail | Subscription does exist any more
6597// | |<-------------|
6598//
6599//-----------------------------------------------------------------------------
6600func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006601 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006602
6603 // Req
6604 var params *teststube2ap.RESTSubsReqParams = nil
6605 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6606
6607 // Del
6608 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6609
6610 // E2t: Receive 1st SubsDelReq
6611 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6612
6613 // Decode of this response fails which will result resending original request
6614 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6615
6616 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6617 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6618
6619 // Subscription does not exist in in E2 Node.
6620 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6621
6622 // Wait that subs is cleaned
6623 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6624
6625 xappConn1.TestMsgChanEmpty(t)
6626 e2termConn1.TestMsgChanEmpty(t)
6627 mainCtrl.wait_registry_empty(t, 10)
6628}
6629
6630//-----------------------------------------------------------------------------
6631// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6632//
6633// stub stub
6634// +-------+ +---------+ +---------+
6635// | xapp | | submgr | | e2term |
6636// +-------+ +---------+ +---------+
6637// | | |
6638// | [SUBS CREATE] |
6639// | | |
6640// | | |
6641// | RESTSubDelReq | |
6642// |---------------->| |
6643// | | |
6644// | RESTSubDelResp | |
6645// |<----------------| |
6646// | | |
6647// | | SubDelReq |
6648// | |------------->|
6649// | | |
6650// | | SubDelFail | Unknown instanceId
6651// | |<-------------|
6652// | | |
6653// | | SubDelReq |
6654// | |------------->|
6655// | | |
6656// | | SubDelFail | Subscription does exist any more
6657// | |<-------------|
6658//
6659//-----------------------------------------------------------------------------
6660func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006661 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006662
6663 // Req
6664 var params *teststube2ap.RESTSubsReqParams = nil
6665 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6666
6667 // Del
6668 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6669
6670 // E2t: Receive 1st SubsDelReq
6671 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6672
6673 // Unknown instanceId in this response which will result resending original request
6674 delreq.RequestId.InstanceId = 0
6675 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6676
6677 // E2t: Receive 2nd SubsDelReq
6678 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6679
6680 // Subscription does not exist in in E2 Node.
6681 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6682
6683 // Wait that subs is cleaned
6684 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6685
6686 xappConn1.TestMsgChanEmpty(t)
6687 e2termConn1.TestMsgChanEmpty(t)
6688 mainCtrl.wait_registry_empty(t, 10)
6689}
6690
6691//-----------------------------------------------------------------------------
6692// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6693//
6694// stub stub
6695// +-------+ +---------+ +---------+
6696// | xapp | | submgr | | e2term |
6697// +-------+ +---------+ +---------+
6698// | | |
6699// | [SUBS CREATE] |
6700// | | |
6701// | | |
6702// | RESTSubDelReq | |
6703// |---------------->| |
6704// | | |
6705// | RESTSubDelResp | |
6706// |<----------------| |
6707// | | |
6708// | | SubDelReq |
6709// | |------------->|
6710// | | |
6711// | | SubDelFail | No transaction for the response
6712// | |<-------------|
6713// | | |
6714// | | SubDelReq |
6715// | |------------->|
6716// | | |
6717// | | SubDelFail | Subscription does exist any more
6718// | |<-------------|
6719//
6720//-----------------------------------------------------------------------------
6721func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006722 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006723
6724 // Req
6725 var params *teststube2ap.RESTSubsReqParams = nil
6726 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6727
6728 // Del
6729 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6730
6731 // E2t: Receive 1st SubsDelReq
6732 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6733
6734 mainCtrl.MakeTransactionNil(t, e2SubsId)
6735
6736 // No transaction exist for this response which will result resending original request
6737 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6738
6739 // E2t: Receive 2nd SubsDelReq
6740 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6741
6742 // Subscription does not exist in in E2 Node.
6743 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6744
6745 // Wait that subs is cleaned
6746 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6747
6748 xappConn1.TestMsgChanEmpty(t)
6749 e2termConn1.TestMsgChanEmpty(t)
6750 mainCtrl.wait_registry_empty(t, 10)
6751}
6752
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006753//-----------------------------------------------------------------------------
6754// TestRESTSubReqFailAsn1PackSubReqError
6755//
6756// stub stub
6757// +-------+ +---------+ +---------+
6758// | xapp | | submgr | | e2term |
6759// +-------+ +---------+ +---------+
6760// | | |
6761// | RESTSubReq | |
6762// |---------------->| |
6763// | | |
6764// | RESTSubResp | |
6765// |<----------------| |
6766// | | |
6767// | ASN.1 encode fails |
6768// | | |
6769// | | SubDelReq |
6770// | |------------->|
6771// | | |
6772// | | SubDelFail |
6773// | |<-------------|
6774// | | |
6775// | RESTNotif | |
6776// | unsuccess | |
6777// |<----------------| |
6778// | | |
6779// | [SUBS DELETE] |
6780// | | |
6781//
6782//-----------------------------------------------------------------------------
6783func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6784
6785 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006786 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006787 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006788 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006789 })
6790
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006791 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006792
6793 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006794 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006795 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6796
6797 // Req
6798 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006799 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006800
6801 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03006802 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006803
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006804 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006805 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006806
6807 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
6808 // Wait that subs is cleaned
6809 waitSubsCleanup(t, e2SubsId, 10)
6810 mainCtrl.VerifyCounterValues(t)
6811}
6812
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006813func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
6814 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
6815
6816 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6817 Counter{cRestSubReqFromXapp, 2},
6818 Counter{cRestSubRespToXapp, 2},
6819 Counter{cSubReqToE2, 2},
6820 Counter{cSubRespFromE2, 1},
6821 Counter{cRestSubNotifToXapp, 1},
6822 Counter{cRestSubFailNotifToXapp, 1},
6823 Counter{cRestSubDelReqFromXapp, 1},
6824 Counter{cSubDelReqToE2, 1},
6825 Counter{cSubDelRespFromE2, 1},
6826 Counter{cRestSubDelRespToXapp, 1},
6827 })
6828
6829 const e2Timeout int64 = 1
6830 const e2RetryCount int64 = 0
6831 const routingNeeded bool = false
6832
6833 // Req1
6834 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6835 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6836
6837 // Subs Create
6838 restSubId := xappConn1.SendRESTSubsReq(t, params)
6839 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6840
6841 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6842 xappConn1.ExpectRESTNotification(t, restSubId)
6843 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6844 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6845 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6846
6847 // Policy change
6848 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6849 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6850 params.SetSubscriptionID(&restSubId)
6851 params.SetTimeToWait("w200ms")
6852 restSubId = xappConn1.SendRESTSubsReq(t, params)
6853 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6854
6855 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6856 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03006857 // SubsResp is missing, e2SubsId will be 0
6858 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6859 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006860
6861 // Del
6862 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6863 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6864 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6865
6866 waitSubsCleanup(t, e2SubsId, 10)
6867
6868 mainCtrl.VerifyCounterValues(t)
6869}
6870
6871//-----------------------------------------------------------------------------
6872// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
6873//
6874// stub stub
6875// +-------+ +---------+ +---------+
6876// | xapp | | submgr | | e2term |
6877// +-------+ +---------+ +---------+
6878// | | |
6879// | RESTSubReq | |
6880// |---------------->| |
6881// | | |
6882// | RESTSubResp | |
6883// |<----------------| |
6884// | | SubReq |
6885// | |------------->|
6886// | | |
6887// | | SubResp |
6888// | |<-------------|
6889// | | |
6890// | RESTNotif | |
6891// |<----------------| |
6892// | | |
6893// | RESTSubReq | |
6894// |---------------->| |
6895// | | |
6896// | RESTSubResp | |
6897// |<----------------| |
6898// | | SubReq |
6899// | |------------->|
6900// | |
6901// | Submgr restart |
6902// | | |
6903// | RESTSubDelReq | |
6904// |---------------->| |
6905// | | |
6906// | | SubDelReq |
6907// | |------------->|
6908// | | |
6909// | | SubDelResp |
6910// | |<-------------|
6911// | | |
6912// | RESTSubDelResp | |
6913// |<----------------| |
6914//
6915//-----------------------------------------------------------------------------
6916
6917func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
6918 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
6919
6920 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6921 Counter{cRestSubReqFromXapp, 2},
6922 Counter{cRestSubRespToXapp, 2},
6923 Counter{cSubReqToE2, 2},
6924 Counter{cSubRespFromE2, 1},
6925 Counter{cRestSubNotifToXapp, 1},
6926 Counter{cRestSubNotifToXapp, 1},
6927 Counter{cRestSubDelReqFromXapp, 1},
6928 Counter{cSubDelReqToE2, 1},
6929 Counter{cRestSubDelRespToXapp, 1},
6930 })
6931
6932 // Remove possible existing subscription
6933 mainCtrl.removeExistingSubscriptions(t)
6934
6935 const e2Timeout int64 = 1
6936 const e2RetryCount int64 = 0
6937 const routingNeeded bool = false
6938
6939 // Req1
6940 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6941 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6942 // Create subscription
6943 restSubId := xappConn1.SendRESTSubsReq(t, params)
6944 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6945
6946 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6947 xappConn1.ExpectRESTNotification(t, restSubId)
6948 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6949 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6950 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6951
6952 // Check subscription
6953 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6954
6955 // Policy change
6956 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6957 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6958 params.SetSubscriptionID(&restSubId)
6959 params.SetTimeToWait("w200ms")
6960 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
6961 restSubId = xappConn1.SendRESTSubsReq(t, params)
6962 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6963
6964 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6965 mainCtrl.SetResetTestFlag(t, false)
6966
6967 // SubsResp is missing due to submgr restart
6968
6969 mainCtrl.SimulateRestart(t)
6970 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
6971
6972 // Check subscription
6973 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6974
6975 xapp.Logger.Debug("Here 1")
6976 //<-time.After(3 * time.Second)
6977 xapp.Logger.Debug("Here 2")
6978
6979 // Delete subscription
6980 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6981 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6982 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6983
6984 //Wait that subs is cleaned
6985 waitSubsCleanup(t, e2SubsId, 10)
6986
6987 mainCtrl.VerifyCounterValues(t)
6988}
6989
archaggeafbf95f2021-04-14 08:54:05 +03006990////////////////////////////////////////////////////////////////////////////////////
6991// Services for UT cases
6992////////////////////////////////////////////////////////////////////////////////////
6993const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006994const host string = "localhost"
6995
6996func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
6997 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006998 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006999 }
7000 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007001 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007002
7003 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
7004 fromXappConn.ExpectRESTNotification(t, restSubId)
7005 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
7006 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007007 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007008
7009 return restSubId, e2SubsId
7010}
7011
7012func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
7013
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007014 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007015 if meid != "" {
7016 params.SetMeid(meid)
7017 }
7018 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
7019 restSubId := xappConn2.SendRESTSubsReq(t, params)
7020 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007021 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007022 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007023 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007024
7025 return restSubId, e2SubsId
7026}
7027
7028func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007029
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007030 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007031 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007032 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03007033
7034 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7035 xappConn1.ExpectRESTNotification(t, restSubId)
7036 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
7037 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007038 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007039
7040 return restSubId, e2SubsId
7041}
7042
7043func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007044 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007045 restSubId := xappConn1.SendRESTSubsReq(t, params)
7046
7047 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7048 fparams1 := &teststube2ap.E2StubSubsFailParams{}
7049 fparams1.Set(crereq1)
7050 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
7051
7052 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
7053 xappConn1.ExpectRESTNotification(t, restSubId)
7054 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
7055 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007056 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007057
7058 return restSubId, e2SubsId
7059}
7060
7061func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
7062 fromXappConn.SendRESTSubsDelReq(t, restSubId)
7063 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7064 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7065}
7066
7067func deleteXapp1Subscription(t *testing.T, restSubId *string) {
7068 xappConn1.SendRESTSubsDelReq(t, restSubId)
7069 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7070 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7071}
7072
7073func deleteXapp2Subscription(t *testing.T, restSubId *string) {
7074 xappConn2.SendRESTSubsDelReq(t, restSubId)
7075 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7076 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7077}
7078
7079func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
7080 resp, _ := xapp.Subscription.QuerySubscriptions()
7081 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
7082 assert.Equal(t, resp[0].Meid, meid)
7083 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
7084}
7085
7086func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
7087 //Wait that subs is cleaned
7088 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
7089
7090 xappConn1.TestMsgChanEmpty(t)
7091 xappConn2.TestMsgChanEmpty(t)
7092 e2termConn1.TestMsgChanEmpty(t)
7093 mainCtrl.wait_registry_empty(t, timeout)
7094}
7095
7096func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
7097
7098 var e2SubsId []uint32
7099
7100 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007101 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007102 crereq, cremsg := toE2termConn.RecvSubsReq(t)
7103 fromXappConn.ExpectRESTNotification(t, restSubId)
7104 toE2termConn.SendSubsResp(t, crereq, cremsg)
7105 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
7106 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007107 xapp.Logger.Debug("TEST: %v", e2SubsId)
7108 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007109 <-time.After(100 * time.Millisecond)
7110 }
7111 return e2SubsId
7112}
7113
7114func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
7115
7116 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007117 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007118 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7119 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7120 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007121 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007122 <-time.After(100 * time.Millisecond)
7123 }
7124
7125 // Wait that subs is cleaned
7126 for i := 0; i < len(e2SubsIds); i++ {
7127 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
7128 }
7129
7130}