blob: 19680e802dfa62183cedda97a483c05dcac0c525 [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
Anssi Mannila3d80b722021-11-12 13:17:15 +020042 mainCtrl.InitAllCounterMap()
Markku Virtanenfa39fed2021-05-25 08:18:43 +000043 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Anssi Mannila3cdd2e02021-10-14 12:35:41 +030044 mainCtrl.c.restDuplicateCtrl.Init()
Markku Virtanenb642a192021-06-09 09:08:14 +000045
Markku Virtanenac8bde42021-05-25 09:54:42 +000046}
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030047func TestRanStatusChangeViaSDLNotification(t *testing.T) {
48
49 // Current UT test cases use these ran names
50 xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
51 xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
52 xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
53
54 mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
55 mainCtrl.c.e2IfState.SubscribeChannels()
56
57 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
58 mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
59 mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
60}
61
62//-----------------------------------------------------------------------------
63// TestRESTSubReqAfterE2ConnBreak
64//
65// stub stub
66// +-------+ +---------+ +---------+
67// | xapp | | submgr | | e2term |
68// +-------+ +---------+ +---------+
69// | | |
70// | [E2 Conn. DOWN] |
71// | | |
72// | RESTSubReq | |
73// |---------------->| |
74// | RESTSubFail | |
75// |<----------------| |
76// | | |
77//
78//-----------------------------------------------------------------------------
79
80func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
81 CaseBegin("TestRESTSubReqAfterE2ConnBreak")
82
83 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
84 Counter{cRestSubReqFromXapp, 1},
85 Counter{cRestReqRejDueE2Down, 1},
86 })
87
88 // E2 disconnect after E2term has received response
89 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
90 // Req
91 const subReqCount int = 1
92 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
93 xappConn1.SendRESTSubsReq(t, params)
94
95 // Restore E2 connection for following test cases
96 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
97
98 mainCtrl.VerifyCounterValues(t)
Anssi Mannila3d80b722021-11-12 13:17:15 +020099 //os.Exit(1)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300100}
101
102//-----------------------------------------------------------------------------
103// TestRESTSubReqE2ConnBreak
104//
105// stub stub
106// +-------+ +---------+ +---------+
107// | xapp | | submgr | | e2term |
108// +-------+ +---------+ +---------+
109// | | |
110// | RESTSubReq | |
111// |---------------->| |
112// | RESTSubResp | |
113// |<----------------| |
114// | | SubReq |
115// | |------------->|
116// | | SubResp |
117// | |<-------------|
118// | | |
119// | [E2 Conn. DOWN] |
120// | [Int. SUBS DELETE] |
121// | | |
122// | RESTNotif(unsuccessful) |
123// |<----------------| |
124// | | |
125// | | |
126//
127//-----------------------------------------------------------------------------
128func TestRESTSubReqE2ConnBreak(t *testing.T) {
129 CaseBegin("TestRESTSubReqE2ConnBreak")
130
131 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
132 Counter{cRestSubReqFromXapp, 1},
133 Counter{cRestSubRespToXapp, 1},
134 Counter{cSubReqToE2, 1},
135 Counter{cSubRespFromE2, 1},
136 Counter{cRestSubFailNotifToXapp, 1},
137 })
138
139 // Req
140 const subReqCount int = 1
141 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
142 restSubId := xappConn1.SendRESTSubsReq(t, params)
143
144 crereq, cremsg := e2termConn1.RecvSubsReq(t)
145 xappConn1.ExpectRESTNotification(t, restSubId)
146
147 // E2 disconnect after E2term has received response
148 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
149
150 e2termConn1.SendSubsResp(t, crereq, cremsg)
151 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
152
153 <-time.After(time.Second * 1)
154 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
155 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
156
157 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
158 if err != nil {
159 xapp.Logger.Error("%v", err)
160 } else {
161 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
162 assert.Equal(t, 0, len(register))
163 }
164
165 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
166 if err != nil {
167 xapp.Logger.Error("%v", err)
168 } else {
169 assert.Equal(t, 0, len(restSubscriptions))
170 }
171
172 // Restore E2 connection for following test cases
173 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
174
175 // Wait that subs is cleaned
176 waitSubsCleanup(t, e2SubsId, 10)
177 mainCtrl.VerifyCounterValues(t)
178}
179
180//-----------------------------------------------------------------------------
181// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
182//
183// stub stub
184// +-------+ +---------+ +---------+
185// | xapp | | submgr | | e2term |
186// +-------+ +---------+ +---------+
187// | | |
188// | [SUBS CREATE] |
189// | | |
190// | [E2 Conn. DOWN] |
191// | | |
192// | RESTSubDelReq | |
193// |---------------->| |
194// | | |
195// | RESTSubDelResp | |
196// |<----------------| |
197// | | |
198// | [No valid subscription found] |
199// | | |
200//
201//-----------------------------------------------------------------------------
202func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
203 xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak")
204
205 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
206 Counter{cRestSubReqFromXapp, 1},
207 Counter{cRestSubRespToXapp, 1},
208 Counter{cSubReqToE2, 1},
209 Counter{cSubRespFromE2, 1},
210 Counter{cRestSubNotifToXapp, 1},
211 Counter{cRestSubDelReqFromXapp, 1},
212 Counter{cRestSubDelRespToXapp, 1},
213 })
214
215 // Req
216 var params *teststube2ap.RESTSubsReqParams = nil
217 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
218
219 // E2 disconnect after E2term has received response
220 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
221
222 // Del
223 xappConn1.SendRESTSubsDelReq(t, &restSubId)
224
225 <-time.After(time.Second * 1)
226 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
227 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
228
229 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
230 if err != nil {
231 xapp.Logger.Error("%v", err)
232 } else {
233 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
234 assert.Equal(t, 0, len(register))
235 }
236
237 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
238 if err != nil {
239 xapp.Logger.Error("%v", err)
240 } else {
241 assert.Equal(t, 0, len(restSubscriptions))
242 }
243
244 // Restore E2 connection for following test cases
245 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
246
247 // Wait that subs is cleaned
248 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
249
250 xappConn1.TestMsgChanEmpty(t)
251 e2termConn1.TestMsgChanEmpty(t)
252 mainCtrl.wait_registry_empty(t, 10)
253 mainCtrl.VerifyCounterValues(t)
254}
255
256//-----------------------------------------------------------------------------
257// TestRESTOtherE2ConnectionChanges
258//
259
260// stub stub
261// +-------+ +---------+ +---------+
262// | xapp | | submgr | | e2term |
263// +-------+ +---------+ +---------+
264// | | |
265// | [SUBS CREATE] |
266// | | |
267// | [E2 CONNECTED_SETUP_FAILED] |
268// | [E2 CONNECTING] |
269// | [E2 SHUTTING_DOWN] |
270// | [E2 SHUT_DOWN] |
271// | | |
272// | [SUBS DELETE] |
273// | | |
274//
275//-----------------------------------------------------------------------------
276func TestRESTOtherE2ConnectionChanges(t *testing.T) {
277 xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges")
278
279 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
280 Counter{cRestSubReqFromXapp, 1},
281 Counter{cRestSubRespToXapp, 1},
282 Counter{cSubReqToE2, 1},
283 Counter{cSubRespFromE2, 1},
284 Counter{cRestSubNotifToXapp, 1},
285 Counter{cRestSubDelReqFromXapp, 1},
286 Counter{cSubDelReqToE2, 1},
287 Counter{cSubDelRespFromE2, 1},
288 Counter{cRestSubDelRespToXapp, 1},
289 })
290
291 // Req
292 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
293 restSubId := xappConn1.SendRESTSubsReq(t, params)
294
295 crereq, cremsg := e2termConn1.RecvSubsReq(t)
296 xappConn1.ExpectRESTNotification(t, restSubId)
297 e2termConn1.SendSubsResp(t, crereq, cremsg)
298 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
299
300 // Submgr should not react any other connection state changes than CONNECTED and DISCONNECTED
301 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
302 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
303 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
304 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
305
306 // Del
307 xappConn1.SendRESTSubsDelReq(t, &restSubId)
308 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
309 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
310
311 // Restore E2 connection for following test cases
312 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
313
314 // Wait that subs is cleaned
315 waitSubsCleanup(t, e2SubsId, 10)
316 mainCtrl.VerifyCounterValues(t)
317}
Markku Virtanenac8bde42021-05-25 09:54:42 +0000318
319//-----------------------------------------------------------------------------
320// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
321//
322// stub stub stub
323// +-------+ +---------+ +---------+ +---------+
324// | xapp | | submgr | | e2term | | rtmgr |
325// +-------+ +---------+ +---------+ +---------+
326// | | | |
327// | RESTSubReq | | |
328// |---------------->| | |
329// | | RouteCreate | |
330// | |--------------------------->| // The order of these events may vary
331// | | | |
332// | RESTSubResp | | | // The order of these events may vary
333// |<----------------| | |
334// | | RouteResponse| |
335// | |<---------------------------| // The order of these events may vary
336// | | | |
337// | | SubReq | |
338// | |------------->| | // The order of these events may vary
339// | | | |
340// | | SubResp | |
341// | |<-------------| |
342// | RESTNotif1 | | |
343// |<----------------| | |
344// | | | |
345// | RESTSubDelReq | | |
346// |---------------->| | |
347// | | SubDelReq | |
348// | |------------->| |
349// | | | |
350// | RESTSubDelResp| | |
351// |<----------------| | |
352// | | | |
353// | | SubDelResp | |
354// | |<-------------| |
355// | | | |
356// | | | |
357//
358//-----------------------------------------------------------------------------
359func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000360
361 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
362
363 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
364
365 waitSubsCleanup(t, e2SubsId, 10)
366}
367
Juha Hyttinenfa015662020-01-24 10:05:18 +0200368//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +0000369// TestRESTSubReqAndE1apDeleteReqPackingError
370//
371// stub stub stub
372// +-------+ +---------+ +---------+ +---------+
373// | xapp | | submgr | | e2term | | rtmgr |
374// +-------+ +---------+ +---------+ +---------+
375// | | | |
376// | RESTSubReq | | |
377// |---------------->| | |
378// | | RouteCreate | |
379// | |--------------------------->| // The order of these events may vary
380// | | | |
381// | RESTSubResp | | | // The order of these events may vary
382// |<----------------| | |
383// | | RouteResponse| |
384// | |<---------------------------| // The order of these events may vary
385// | | | |
386// | | SubReq | |
387// | |------------->| | // The order of these events may vary
388// | | | |
389// | | SubResp | |
390// | |<-------------| |
391// | RESTNotif1 | | |
392// |<----------------| | |
393// | | | |
394// | RESTSubDelReq | | |
395// |---------------->| | |
396// | | | |
397// | RESTSubDelResp| | |
398// |<----------------| | |
399// | | | |
400// | | | |
401//
402//-----------------------------------------------------------------------------
403func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
404
405 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
406
407 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
408 xappConn1.SendRESTSubsDelReq(t, &restSubId)
409 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
410
411 waitSubsCleanup(t, e2SubsId, 10)
412}
413
414//-----------------------------------------------------------------------------
415// TestRESTSubReqAndE1apDeleteRespUnpackingError
416//
417// stub stub stub
418// +-------+ +---------+ +---------+ +---------+
419// | xapp | | submgr | | e2term | | rtmgr |
420// +-------+ +---------+ +---------+ +---------+
421// | | | |
422// | RESTSubReq | | |
423// |---------------->| | |
424// | | RouteCreate | |
425// | |--------------------------->| // The order of these events may vary
426// | | | |
427// | RESTSubResp | | | // The order of these events may vary
428// |<----------------| | |
429// | | RouteResponse| |
430// | |<---------------------------| // The order of these events may vary
431// | | | |
432// | | SubReq | |
433// | |------------->| | // The order of these events may vary
434// | | | |
435// | | SubResp | |
436// | |<-------------| |
437// | RESTNotif1 | | |
438// |<----------------| | |
439// | | | |
440// | RESTSubDelReq | | |
441// |---------------->| | |
442// | | SubDelReq | |
443// | |------------->| |
444// | | | |
445// | RESTSubDelResp| | |
446// |<----------------| | | // The order of these events may vary
447// | | | |
448// | | SubDelResp | |
449// | |<-------------| | // 1.st NOK
450// | | | |
451// | | SubDelReq | |
452// | |------------->| |
453// | | | |
454// | | SubDelResp | |
455// | |<-------------| | // 2.nd NOK
456//
457//-----------------------------------------------------------------------------
458
459func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
460
461 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
462
463 xappConn1.SendRESTSubsDelReq(t, &restSubId)
464 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
465 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
466 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
467
468 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
469 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
470
471 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
472
473 waitSubsCleanup(t, e2SubsId, 10)
474}
475
476//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200477// TestSubReqAndRouteNok
478//
479// stub stub
480// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200481// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200482// +-------+ +---------+ +---------+
483// | | |
484// | SubReq | |
485// |------------->| |
486// | | |
487// | | RouteCreate |
488// | |------------->|
489// | | |
490// | | RouteCreate |
491// | | status:400 |
492// | |<-------------|
493// | | |
494// | [SUBS INT DELETE] |
495// | | |
496//
497//-----------------------------------------------------------------------------
498
499func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200500 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200501
Anssi Mannila4abf1802021-01-28 13:06:46 +0200502 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200503 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
504 Counter{cSubReqFromXapp, 1},
505 Counter{cRouteCreateFail, 1},
506 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200507
Juha Hyttinenfa015662020-01-24 10:05:18 +0200508 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300509 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200510 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200511 waiter.WaitResult(t)
512
513 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200514 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200515
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200516 xappConn1.TestMsgChanEmpty(t)
517 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200518 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200519 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200520
521 <-time.After(1 * time.Second)
522 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200523}
524
525//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200526// TestSubReqAndRouteUpdateNok
527
528// stub stub
529// +-------+ +-------+ +---------+ +---------+
530// | xapp2 | | xapp1 | | submgr | | rtmgr |
531// +-------+ +-------+ +---------+ +---------+
532// | | | |
533// | [SUBS CREATE] | |
534// | | | |
535// | | | |
536// | | | |
537// | SubReq (mergeable) | |
538// |--------------------------->| | |
539// | | | |
540// | | | RouteUpdate |
541// | | |------------->|
542// | | | |
543// | | | RouteUpdate |
544// | | | status:400 |
545// | | |<-------------|
546// | | | |
547// | [SUBS INT DELETE] | |
548// | | | |
549// | | | |
550// | [SUBS DELETE] | |
551// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300552
Anssi Mannila4abf1802021-01-28 13:06:46 +0200553func TestSubReqAndRouteUpdateNok(t *testing.T) {
554 CaseBegin("TestSubReqAndRouteUpdateNok")
555
556 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200557 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
558 Counter{cSubReqFromXapp, 2},
559 Counter{cSubReqToE2, 1},
560 Counter{cSubRespFromE2, 1},
561 Counter{cSubRespToXapp, 1},
562 Counter{cRouteCreateUpdateFail, 1},
563 Counter{cSubDelReqFromXapp, 1},
564 Counter{cSubDelReqToE2, 1},
565 Counter{cSubDelRespFromE2, 1},
566 Counter{cSubDelRespToXapp, 1},
567 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200568
569 cretrans := xappConn1.SendSubsReq(t, nil, nil)
570 crereq, cremsg := e2termConn1.RecvSubsReq(t)
571 e2termConn1.SendSubsResp(t, crereq, cremsg)
572 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
573
574 resp, _ := xapp.Subscription.QuerySubscriptions()
575 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
576 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300577 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200578
579 waiter := rtmgrHttp.AllocNextEvent(false)
580 newSubsId := mainCtrl.get_registry_next_subid(t)
581 xappConn2.SendSubsReq(t, nil, nil)
582 waiter.WaitResult(t)
583
584 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
585 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
586
587 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
588 xappConn1.RecvSubsDelResp(t, deltrans)
589
590 //Wait that subs is cleaned
591 mainCtrl.wait_subs_clean(t, newSubsId, 10)
592 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
593
594 xappConn1.TestMsgChanEmpty(t)
595 xappConn2.TestMsgChanEmpty(t)
596 e2termConn1.TestMsgChanEmpty(t)
597 mainCtrl.wait_registry_empty(t, 10)
598
599 mainCtrl.VerifyCounterValues(t)
600}
601
602//-----------------------------------------------------------------------------
603// TestSubDelReqAndRouteDeleteNok
604//
605// stub stub
606// +-------+ +---------+ +---------+ +---------+
607// | xapp | | submgr | | e2term | | rtmgr |
608// +-------+ +---------+ +---------+ +---------+
609// | | | |
610// | [SUBS CREATE] | |
611// | | | |
612// | | | |
613// | | | |
614// | SubDelReq | | |
615// |------------->| | |
616// | | SubDelReq | |
617// | |------------->| |
618// | | SubDelRsp | |
619// | |<-------------| |
620// | SubDelRsp | | |
621// |<-------------| | |
622// | | RouteDelete | |
623// | |---------------------------->|
624// | | | |
625// | | RouteDelete | |
626// | | status:400 | |
627// | |<----------------------------|
628// | | | |
629func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
630 CaseBegin("TestSubDelReqAndRouteDeleteNok")
631
632 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200633 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
634 Counter{cSubReqFromXapp, 1},
635 Counter{cSubReqToE2, 1},
636 Counter{cSubRespFromE2, 1},
637 Counter{cSubRespToXapp, 1},
638 Counter{cSubDelReqFromXapp, 1},
639 Counter{cRouteDeleteFail, 1},
640 Counter{cSubDelReqToE2, 1},
641 Counter{cSubDelRespFromE2, 1},
642 Counter{cSubDelRespToXapp, 1},
643 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200644
645 cretrans := xappConn1.SendSubsReq(t, nil, nil)
646 crereq, cremsg := e2termConn1.RecvSubsReq(t)
647 e2termConn1.SendSubsResp(t, crereq, cremsg)
648 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
649
650 resp, _ := xapp.Subscription.QuerySubscriptions()
651 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
652 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300653 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200654
655 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
656 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
657
658 waiter := rtmgrHttp.AllocNextEvent(false)
659 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
660 waiter.WaitResult(t)
661
662 xappConn1.RecvSubsDelResp(t, deltrans)
663
664 //Wait that subs is cleaned
665 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
666
667 xappConn1.TestMsgChanEmpty(t)
668 xappConn2.TestMsgChanEmpty(t)
669 e2termConn1.TestMsgChanEmpty(t)
670 mainCtrl.wait_registry_empty(t, 10)
671
672 mainCtrl.VerifyCounterValues(t)
673}
674
675//-----------------------------------------------------------------------------
676// TestSubMergeDelAndRouteUpdateNok
677// stub stub
678// +-------+ +-------+ +---------+ +---------+
679// | xapp2 | | xapp1 | | submgr | | e2term |
680// +-------+ +-------+ +---------+ +---------+
681// | | | |
682// | | | |
683// | | | |
684// | | SubReq1 | |
685// | |------------->| |
686// | | | |
687// | | | SubReq1 |
688// | | |------------->|
689// | | | SubResp1 |
690// | | |<-------------|
691// | | SubResp1 | |
692// | |<-------------| |
693// | | | |
694// | SubReq2 | |
695// |--------------------------->| |
696// | | | |
697// | SubResp2 | |
698// |<---------------------------| |
699// | | | |
700// | | SubDelReq 1 | |
701// | |------------->| |
702// | | | RouteUpdate |
703// | | |-----> rtmgr |
704// | | | |
705// | | | RouteUpdate |
706// | | | status:400 |
707// | | |<----- rtmgr |
708// | | | |
709// | | SubDelResp 1 | |
710// | |<-------------| |
711// | | | |
712// | SubDelReq 2 | |
713// |--------------------------->| |
714// | | | |
715// | | | SubDelReq 2 |
716// | | |------------->|
717// | | | |
718// | | | SubDelReq 2 |
719// | | |------------->|
720// | | | |
721// | SubDelResp 2 | |
722// |<---------------------------| |
723//
724//-----------------------------------------------------------------------------
725func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
726 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
727
728 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200729 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
730 Counter{cSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200731 Counter{cMergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200732 Counter{cSubReqToE2, 1},
733 Counter{cSubRespFromE2, 1},
734 Counter{cSubRespToXapp, 2},
735 Counter{cSubDelReqFromXapp, 2},
736 Counter{cRouteDeleteUpdateFail, 1},
737 Counter{cSubDelReqToE2, 1},
738 Counter{cSubDelRespFromE2, 1},
739 Counter{cSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200740 Counter{cUnmergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200741 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200742
743 //Req1
744 rparams1 := &teststube2ap.E2StubSubsReqParams{}
745 rparams1.Init()
746 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
747 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
748 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
749 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
750
751 //Req2
752 rparams2 := &teststube2ap.E2StubSubsReqParams{}
753 rparams2.Init()
754 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
755 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
756
757 resp, _ := xapp.Subscription.QuerySubscriptions()
758 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
759 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300760 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200761
762 //Del1
763 waiter := rtmgrHttp.AllocNextEvent(false)
764 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
765 waiter.WaitResult(t)
766
767 xappConn1.RecvSubsDelResp(t, deltrans1)
768
769 //Del2
770 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
771 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
772 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
773 xappConn2.RecvSubsDelResp(t, deltrans2)
774 //Wait that subs is cleaned
775 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
776
777 xappConn1.TestMsgChanEmpty(t)
778 xappConn2.TestMsgChanEmpty(t)
779 e2termConn1.TestMsgChanEmpty(t)
780 mainCtrl.wait_registry_empty(t, 10)
781
782 mainCtrl.VerifyCounterValues(t)
783}
784
785//-----------------------------------------------------------------------------
786
787//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200788// TestSubReqAndSubDelOk
789//
790// stub stub
791// +-------+ +---------+ +---------+
792// | xapp | | submgr | | e2term |
793// +-------+ +---------+ +---------+
794// | | |
795// | SubReq | |
796// |------------->| |
797// | | |
798// | | SubReq |
799// | |------------->|
800// | | |
801// | | SubResp |
802// | |<-------------|
803// | | |
804// | SubResp | |
805// |<-------------| |
806// | | |
807// | | |
808// | SubDelReq | |
809// |------------->| |
810// | | |
811// | | SubDelReq |
812// | |------------->|
813// | | |
814// | | SubDelResp |
815// | |<-------------|
816// | | |
817// | SubDelResp | |
818// |<-------------| |
819//
820//-----------------------------------------------------------------------------
821func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200822 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200823
Anssi Mannila4abf1802021-01-28 13:06:46 +0200824 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200825 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
826 Counter{cSubReqFromXapp, 1},
827 Counter{cSubReqToE2, 1},
828 Counter{cSubRespFromE2, 1},
829 Counter{cSubRespToXapp, 1},
830 Counter{cSubDelReqFromXapp, 1},
831 Counter{cSubDelReqToE2, 1},
832 Counter{cSubDelRespFromE2, 1},
833 Counter{cSubDelRespToXapp, 1},
834 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200835
836 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200837 crereq, cremsg := e2termConn1.RecvSubsReq(t)
838 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200839 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200840
841 resp, _ := xapp.Subscription.QuerySubscriptions()
842 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
843 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300844 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200845
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200846 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200847 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200848
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200849 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200850 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200851
852 //Wait that subs is cleaned
853 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
854
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200855 xappConn1.TestMsgChanEmpty(t)
856 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200857 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200858 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200859
860 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200861}
862
863//-----------------------------------------------------------------------------
864// TestSubReqRetransmission
865//
866// stub stub
867// +-------+ +---------+ +---------+
868// | xapp | | submgr | | e2term |
869// +-------+ +---------+ +---------+
870// | | |
871// | SubReq | |
872// |------------->| |
873// | | |
874// | | SubReq |
875// | |------------->|
876// | | |
877// | SubReq | |
878// | (retrans) | |
879// |------------->| |
880// | | |
881// | | SubResp |
882// | |<-------------|
883// | | |
884// | SubResp | |
885// |<-------------| |
886// | | |
887// | [SUBS DELETE] |
888// | | |
889//
890//-----------------------------------------------------------------------------
891func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200892 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200893
894 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200895 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200896 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200897
898 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200899 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200900 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
901
Juha Hyttinen1683f912020-04-17 10:39:57 +0300902 // hack as there is no real way to see has message be handled.
903 // Previuos counter check just tells that is has been received by submgr
904 // --> artificial delay
905 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200906 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200907 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200908
909 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200910 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200911 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
912 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200913 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200914
915 //Wait that subs is cleaned
916 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
917
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200918 xappConn1.TestMsgChanEmpty(t)
919 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200920 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200921 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200922}
923
924//-----------------------------------------------------------------------------
925// TestSubDelReqRetransmission
926//
927// stub stub
928// +-------+ +---------+ +---------+
929// | xapp | | submgr | | e2term |
930// +-------+ +---------+ +---------+
931// | | |
932// | [SUBS CREATE] |
933// | | |
934// | | |
935// | SubDelReq | |
936// |------------->| |
937// | | |
938// | | SubDelReq |
939// | |------------->|
940// | | |
941// | SubDelReq | |
942// | (same sub) | |
943// | (same xid) | |
944// |------------->| |
945// | | |
946// | | SubDelResp |
947// | |<-------------|
948// | | |
949// | SubDelResp | |
950// |<-------------| |
951//
952//-----------------------------------------------------------------------------
953func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200954 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200955
956 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200957 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200958 crereq, cremsg := e2termConn1.RecvSubsReq(t)
959 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200960 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200961
962 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200963 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200964 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200965
966 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200967 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200968 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
969
Juha Hyttinen1683f912020-04-17 10:39:57 +0300970 // hack as there is no real way to see has message be handled.
971 // Previuos counter check just tells that is has been received by submgr
972 // --> artificial delay
973 <-time.After(1 * time.Second)
974
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200975 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200976 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200977
978 //Wait that subs is cleaned
979 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
980
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200981 xappConn1.TestMsgChanEmpty(t)
982 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200983 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200984 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200985}
986
987//-----------------------------------------------------------------------------
988// TestSubDelReqCollision
989//
990// stub stub
991// +-------+ +---------+ +---------+
992// | xapp | | submgr | | e2term |
993// +-------+ +---------+ +---------+
994// | | |
995// | [SUBS CREATE] |
996// | | |
997// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200998// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200999// |------------->| |
1000// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001001// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001002// | |------------->|
1003// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001004// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001005// | (same sub) | |
1006// | (diff xid) | |
1007// |------------->| |
1008// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001009// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001010// | |<-------------|
1011// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001012// | SubDelResp 1 | |
1013// |<-------------| |
1014// | | |
1015// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001016// |<-------------| |
1017//
1018//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001019
Juha Hyttinenfa015662020-01-24 10:05:18 +02001020func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001021 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001022
1023 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001024 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001025 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1026 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001027 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001028
1029 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001030 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001031 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001032
Juha Hyttinen3944a222020-01-24 11:51:46 +02001033 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001034 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001035 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1036 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001037 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1038
Juha Hyttinen1683f912020-04-17 10:39:57 +03001039 // hack as there is no real way to see has message be handled.
1040 // Previuos counter check just tells that is has been received by submgr
1041 // --> artificial delay
1042 <-time.After(1 * time.Second)
1043
Juha Hyttinen3944a222020-01-24 11:51:46 +02001044 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001045 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001046
1047 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001048 xappConn1.RecvSubsDelResp(t, nil)
1049 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001050
1051 //Wait that subs is cleaned
1052 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1053
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001054 xappConn1.TestMsgChanEmpty(t)
1055 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001056 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001057 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001058}
1059
1060//-----------------------------------------------------------------------------
1061// TestSubReqAndSubDelOkTwoParallel
1062//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001063// stub stub stub
1064// +-------+ +-------+ +---------+ +---------+
1065// | xapp | | xapp | | submgr | | e2term |
1066// +-------+ +-------+ +---------+ +---------+
1067// | | | |
1068// | | | |
1069// | | | |
1070// | | SubReq1 | |
1071// | |------------->| |
1072// | | | |
1073// | | | SubReq1 |
1074// | | |------------->|
1075// | | | |
1076// | SubReq2 | |
1077// |------------------------>| |
1078// | | | |
1079// | | | SubReq2 |
1080// | | |------------->|
1081// | | | |
1082// | | | SubResp1 |
1083// | | |<-------------|
1084// | | SubResp1 | |
1085// | |<-------------| |
1086// | | | |
1087// | | | SubResp2 |
1088// | | |<-------------|
1089// | SubResp2 | |
1090// |<------------------------| |
1091// | | | |
1092// | | [SUBS 1 DELETE] |
1093// | | | |
1094// | | [SUBS 2 DELETE] |
1095// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001096//
1097//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001098
Juha Hyttinenfa015662020-01-24 10:05:18 +02001099func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001100 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001101
1102 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001103 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001104 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001105 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001106 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001107
1108 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001109 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001110 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001111
1112 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1113 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1114 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1115
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001116 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001117 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001118
1119 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001120 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001121 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001122
1123 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001124 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001125 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001126
1127 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001128 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001129 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1130 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001131 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001132 //Wait that subs is cleaned
1133 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1134
1135 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001136 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001137 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1138 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001139 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001140 //Wait that subs is cleaned
1141 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1142
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001143 xappConn1.TestMsgChanEmpty(t)
1144 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001145 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001146 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001147}
1148
1149//-----------------------------------------------------------------------------
1150// TestSameSubsDiffRan
1151// Same subscription to different RANs
1152//
1153// stub stub
1154// +-------+ +---------+ +---------+
1155// | xapp | | submgr | | e2term |
1156// +-------+ +---------+ +---------+
1157// | | |
1158// | | |
1159// | | |
1160// | SubReq(r1) | |
1161// |------------->| |
1162// | | |
1163// | | SubReq(r1) |
1164// | |------------->|
1165// | | |
1166// | | SubResp(r1) |
1167// | |<-------------|
1168// | | |
1169// | SubResp(r1) | |
1170// |<-------------| |
1171// | | |
1172// | SubReq(r2) | |
1173// |------------->| |
1174// | | |
1175// | | SubReq(r2) |
1176// | |------------->|
1177// | | |
1178// | | SubResp(r2) |
1179// | |<-------------|
1180// | | |
1181// | SubResp(r2) | |
1182// |<-------------| |
1183// | | |
1184// | [SUBS r1 DELETE] |
1185// | | |
1186// | [SUBS r2 DELETE] |
1187// | | |
1188//
1189//-----------------------------------------------------------------------------
1190func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001191 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001192
1193 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001194 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1195 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001196 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1197 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001198 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001199
1200 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001201 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1202 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001203 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1204 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001205 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001206
1207 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001208 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1209 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001210 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1211 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001212 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001213 //Wait that subs is cleaned
1214 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1215
1216 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001217 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1218 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001219 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1220 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001221 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001222 //Wait that subs is cleaned
1223 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1224
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001225 xappConn1.TestMsgChanEmpty(t)
1226 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001227 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001228 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001229}
1230
1231//-----------------------------------------------------------------------------
1232// TestSubReqRetryInSubmgr
1233//
1234// stub stub
1235// +-------+ +---------+ +---------+
1236// | xapp | | submgr | | e2term |
1237// +-------+ +---------+ +---------+
1238// | | |
1239// | SubReq | |
1240// |------------->| |
1241// | | |
1242// | | SubReq |
1243// | |------------->|
1244// | | |
1245// | | |
1246// | | SubReq |
1247// | |------------->|
1248// | | |
1249// | | SubResp |
1250// | |<-------------|
1251// | | |
1252// | SubResp | |
1253// |<-------------| |
1254// | | |
1255// | [SUBS DELETE] |
1256// | | |
1257//
1258//-----------------------------------------------------------------------------
1259
1260func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001261 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001262
1263 // Init counter check
1264 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1265 Counter{cSubReqFromXapp, 1},
1266 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001267 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001268 Counter{cSubReReqToE2, 1},
1269 Counter{cSubRespFromE2, 1},
1270 Counter{cSubRespToXapp, 1},
1271 Counter{cSubDelReqFromXapp, 1},
1272 Counter{cSubDelReqToE2, 1},
1273 Counter{cSubDelRespFromE2, 1},
1274 Counter{cSubDelRespToXapp, 1},
1275 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001276
1277 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001278 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001279
1280 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001281 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001282
1283 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001284 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1285 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001286
1287 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001288 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001289
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001290 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001291 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1292 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001293 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001294
1295 // Wait that subs is cleaned
1296 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1297
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001298 xappConn1.TestMsgChanEmpty(t)
1299 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001300 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001301 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001302
1303 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001304}
1305
1306//-----------------------------------------------------------------------------
1307// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1308//
1309// stub stub
1310// +-------+ +---------+ +---------+
1311// | xapp | | submgr | | e2term |
1312// +-------+ +---------+ +---------+
1313// | | |
1314// | SubReq | |
1315// |------------->| |
1316// | | |
1317// | | SubReq |
1318// | |------------->|
1319// | | |
1320// | | |
1321// | | SubReq |
1322// | |------------->|
1323// | | |
1324// | | SubDelReq |
1325// | |------------->|
1326// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001327// | | SubDelResp |
1328// | |<-------------|
1329// | | |
1330//
1331//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001332func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001333 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001334
1335 // Init counter check
1336 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1337 Counter{cSubReqFromXapp, 1},
1338 Counter{cSubReqToE2, 1},
1339 Counter{cSubReReqToE2, 1},
1340 Counter{cSubReqTimerExpiry, 2},
1341 Counter{cSubDelReqToE2, 1},
1342 Counter{cSubDelRespFromE2, 1},
1343 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001344
1345 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001346 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001347
1348 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001349 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001350
1351 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001352 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001353
1354 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001355 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1356 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001357
1358 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001359 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001360
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001361 xappConn1.TestMsgChanEmpty(t)
1362 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001363 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001364 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001365
1366 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001367}
1368
1369//-----------------------------------------------------------------------------
1370// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1371//
1372// stub stub
1373// +-------+ +---------+ +---------+
1374// | xapp | | submgr | | e2term |
1375// +-------+ +---------+ +---------+
1376// | | |
1377// | SubReq | |
1378// |------------->| |
1379// | | |
1380// | | SubReq |
1381// | |------------->|
1382// | | |
1383// | | |
1384// | | SubReq |
1385// | |------------->|
1386// | | |
1387// | | SubDelReq |
1388// | |------------->|
1389// | | |
1390// | | |
1391// | | SubDelReq |
1392// | |------------->|
1393// | | |
1394// | | |
1395//
1396//-----------------------------------------------------------------------------
1397
1398func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001399 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001400
1401 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1402 Counter{cSubReqFromXapp, 1},
1403 Counter{cSubReqToE2, 1},
1404 Counter{cSubReReqToE2, 1},
1405 Counter{cSubReqTimerExpiry, 2},
1406 Counter{cSubDelReqToE2, 1},
1407 Counter{cSubDelReReqToE2, 1},
1408 Counter{cSubDelReqTimerExpiry, 2},
1409 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001410
1411 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001412 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001413
1414 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001415 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001416
1417 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001418 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001419
1420 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001421 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001422
1423 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001424 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001425
1426 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001427 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001428
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001429 xappConn1.TestMsgChanEmpty(t)
1430 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001431 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001432 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001433
1434 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001435}
1436
1437//-----------------------------------------------------------------------------
1438// TestSubReqSubFailRespInSubmgr
1439//
1440// stub stub
1441// +-------+ +---------+ +---------+
1442// | xapp | | submgr | | e2term |
1443// +-------+ +---------+ +---------+
1444// | | |
1445// | SubReq | |
1446// |------------->| |
1447// | | |
1448// | | SubReq |
1449// | |------------->|
1450// | | |
1451// | | SubFail |
1452// | |<-------------|
1453// | | |
1454// | SubFail | |
1455// |<-------------| |
1456// | | |
1457//
1458//-----------------------------------------------------------------------------
1459
1460func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001461 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001462
1463 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1464 Counter{cSubReqFromXapp, 1},
1465 Counter{cSubReqToE2, 1},
1466 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001467 Counter{cSubFailToXapp, 1},
1468 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001469
1470 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001471 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001472
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001473 // E2t: Receive SubsReq and send SubsFail (first)
1474 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1475 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1476 fparams1.Set(crereq1)
1477 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1478
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001479 // Xapp: Receive SubsFail
1480 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1481
1482 // Wait that subs is cleaned
1483 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1484
1485 xappConn1.TestMsgChanEmpty(t)
1486 xappConn2.TestMsgChanEmpty(t)
1487 e2termConn1.TestMsgChanEmpty(t)
1488 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001489
1490 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001491}
1492
1493//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001494// TestSubDelReqRetryInSubmgr
1495//
1496// stub stub
1497// +-------+ +---------+ +---------+
1498// | xapp | | submgr | | e2term |
1499// +-------+ +---------+ +---------+
1500// | | |
1501// | [SUBS CREATE] |
1502// | | |
1503// | | |
1504// | SubDelReq | |
1505// |------------->| |
1506// | | |
1507// | | SubDelReq |
1508// | |------------->|
1509// | | |
1510// | | SubDelReq |
1511// | |------------->|
1512// | | |
1513// | | SubDelResp |
1514// | |<-------------|
1515// | | |
1516// | SubDelResp | |
1517// |<-------------| |
1518//
1519//-----------------------------------------------------------------------------
1520
1521func TestSubDelReqRetryInSubmgr(t *testing.T) {
1522
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001523 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001524
1525 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001526 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001527 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1528 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001529 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001530
1531 // Subs Delete
1532 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001533 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001534
1535 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001536 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001537
1538 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001539 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1540 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001541
1542 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001543 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001544
1545 // Wait that subs is cleaned
1546 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1547
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001548 xappConn1.TestMsgChanEmpty(t)
1549 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001550 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001551 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001552}
1553
1554//-----------------------------------------------------------------------------
1555// TestSubDelReqTwoRetriesNoRespInSubmgr
1556//
1557// stub stub
1558// +-------+ +---------+ +---------+
1559// | xapp | | submgr | | e2term |
1560// +-------+ +---------+ +---------+
1561// | | |
1562// | [SUBS CREATE] |
1563// | | |
1564// | | |
1565// | SubDelReq | |
1566// |------------->| |
1567// | | |
1568// | | SubDelReq |
1569// | |------------->|
1570// | | |
1571// | | SubDelReq |
1572// | |------------->|
1573// | | |
1574// | | |
1575// | SubDelResp | |
1576// |<-------------| |
1577//
1578//-----------------------------------------------------------------------------
1579
1580func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1581
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001582 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001583
1584 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001585 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001586 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1587 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001588 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001589
1590 // Subs Delete
1591 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001592 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001593
1594 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001595 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001596
1597 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001598 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001599
1600 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001601 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001602
1603 // Wait that subs is cleaned
1604 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1605
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001606 xappConn1.TestMsgChanEmpty(t)
1607 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001608 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001609 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001610}
1611
1612//-----------------------------------------------------------------------------
1613// TestSubDelReqSubDelFailRespInSubmgr
1614//
1615// stub stub
1616// +-------+ +---------+ +---------+
1617// | xapp | | submgr | | e2term |
1618// +-------+ +---------+ +---------+
1619// | | |
1620// | [SUBS CREATE] |
1621// | | |
1622// | | |
1623// | SubDelReq | |
1624// |------------->| |
1625// | | |
1626// | | SubDelReq |
1627// | |------------->|
1628// | | |
1629// | | SubDelFail |
1630// | |<-------------|
1631// | | |
1632// | SubDelResp | |
1633// |<-------------| |
1634// | | |
1635//
1636//-----------------------------------------------------------------------------
1637
1638func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001639 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001640
1641 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1642 Counter{cSubReqFromXapp, 1},
1643 Counter{cSubReqToE2, 1},
1644 Counter{cSubRespFromE2, 1},
1645 Counter{cSubRespToXapp, 1},
1646 Counter{cSubDelReqFromXapp, 1},
1647 Counter{cSubDelReqToE2, 1},
1648 Counter{cSubDelFailFromE2, 1},
1649 Counter{cSubDelRespToXapp, 1},
1650 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001651
1652 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001653 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001654 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1655 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001656 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001657
1658 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001659 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001660
1661 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001662 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1663 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001664
1665 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001666 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001667
1668 // Wait that subs is cleaned
1669 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1670
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001671 xappConn1.TestMsgChanEmpty(t)
1672 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001673 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001674 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001675
1676 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001677}
1678
1679//-----------------------------------------------------------------------------
1680// TestSubReqAndSubDelOkSameAction
1681//
1682// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001683// +-------+ +-------+ +---------+ +---------+
1684// | xapp2 | | xapp1 | | submgr | | e2term |
1685// +-------+ +-------+ +---------+ +---------+
1686// | | | |
1687// | | | |
1688// | | | |
1689// | | SubReq1 | |
1690// | |------------->| |
1691// | | | |
1692// | | | SubReq1 |
1693// | | |------------->|
1694// | | | SubResp1 |
1695// | | |<-------------|
1696// | | SubResp1 | |
1697// | |<-------------| |
1698// | | | |
1699// | SubReq2 | |
1700// |--------------------------->| |
1701// | | | |
1702// | SubResp2 | |
1703// |<---------------------------| |
1704// | | | |
1705// | | SubDelReq 1 | |
1706// | |------------->| |
1707// | | | |
1708// | | SubDelResp 1 | |
1709// | |<-------------| |
1710// | | | |
1711// | SubDelReq 2 | |
1712// |--------------------------->| |
1713// | | | |
1714// | | | SubDelReq 2 |
1715// | | |------------->|
1716// | | | |
1717// | | | SubDelReq 2 |
1718// | | |------------->|
1719// | | | |
1720// | SubDelResp 2 | |
1721// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001722//
1723//-----------------------------------------------------------------------------
1724func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001725 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001726
Anssi Mannila4abf1802021-01-28 13:06:46 +02001727 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001728 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1729 Counter{cSubReqFromXapp, 2},
1730 Counter{cSubReqToE2, 1},
1731 Counter{cSubRespFromE2, 1},
1732 Counter{cSubRespToXapp, 2},
1733 Counter{cMergedSubscriptions, 1},
1734 Counter{cUnmergedSubscriptions, 1},
1735 Counter{cSubDelReqFromXapp, 2},
1736 Counter{cSubDelReqToE2, 1},
1737 Counter{cSubDelRespFromE2, 1},
1738 Counter{cSubDelRespToXapp, 2},
1739 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001740
Juha Hyttinen3944a222020-01-24 11:51:46 +02001741 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001742 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001743 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001744 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001745 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1746 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001747 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001748
1749 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001750 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001751 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001752 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001753 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001754
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001755 resp, _ := xapp.Subscription.QuerySubscriptions()
1756 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1757 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001758 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001759
Juha Hyttinen3944a222020-01-24 11:51:46 +02001760 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001761 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001762 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001763
1764 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001765 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001766 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1767 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001768 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001769 //Wait that subs is cleaned
1770 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1771
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001772 xappConn1.TestMsgChanEmpty(t)
1773 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001774 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001775 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001776
1777 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001778}
1779
1780//-----------------------------------------------------------------------------
1781// TestSubReqAndSubDelOkSameActionParallel
1782//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001783// stub stub stub
1784// +-------+ +-------+ +---------+ +---------+
1785// | xapp2 | | xapp1 | | submgr | | e2term |
1786// +-------+ +-------+ +---------+ +---------+
1787// | | | |
1788// | | | |
1789// | | | |
1790// | | SubReq1 | |
1791// | |------------->| |
1792// | | | |
1793// | | | SubReq1 |
1794// | | |------------->|
1795// | SubReq2 | |
1796// |--------------------------->| |
1797// | | | SubResp1 |
1798// | | |<-------------|
1799// | | SubResp1 | |
1800// | |<-------------| |
1801// | | | |
1802// | SubResp2 | |
1803// |<---------------------------| |
1804// | | | |
1805// | | SubDelReq 1 | |
1806// | |------------->| |
1807// | | | |
1808// | | SubDelResp 1 | |
1809// | |<-------------| |
1810// | | | |
1811// | SubDelReq 2 | |
1812// |--------------------------->| |
1813// | | | |
1814// | | | SubDelReq 2 |
1815// | | |------------->|
1816// | | | |
1817// | | | SubDelReq 2 |
1818// | | |------------->|
1819// | | | |
1820// | SubDelResp 2 | |
1821// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001822//
1823//-----------------------------------------------------------------------------
1824func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001825 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001826
1827 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001828 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001829 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001830 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001831 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001832
1833 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001834 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001835 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001836 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001837
1838 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001839 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001840 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001841
1842 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001843 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001844
1845 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001846 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1847 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001848
1849 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001850 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001851 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1852 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001853 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001854
1855 //Wait that subs is cleaned
1856 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1857
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001858 xappConn1.TestMsgChanEmpty(t)
1859 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001860 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001861 mainCtrl.wait_registry_empty(t, 10)
1862}
1863
1864//-----------------------------------------------------------------------------
1865// TestSubReqAndSubDelNokSameActionParallel
1866//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001867// stub stub stub
1868// +-------+ +-------+ +---------+ +---------+
1869// | xapp2 | | xapp1 | | submgr | | e2term |
1870// +-------+ +-------+ +---------+ +---------+
1871// | | | |
1872// | | | |
1873// | | | |
1874// | | SubReq1 | |
1875// | |------------->| |
1876// | | | |
1877// | | | SubReq1 |
1878// | | |------------->|
1879// | SubReq2 | |
1880// |--------------------------->| |
1881// | | | SubFail1 |
1882// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001883// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001884// | | SubFail1 | |
1885// | |<-------------| |
1886// | | | |
1887// | SubFail2 | |
1888// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001889//
1890//-----------------------------------------------------------------------------
1891func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001892 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001893
1894 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001895 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001896 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001897 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001898
1899 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001900 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001901
1902 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001903 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001904 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001905 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001906 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001907 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001908
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001909 // E2t: send SubsFail (first)
1910 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1911 fparams1.Set(crereq1)
1912 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1913
Juha Hyttinen3944a222020-01-24 11:51:46 +02001914 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001915 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001916 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001917 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001918
1919 //Wait that subs is cleaned
1920 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1921
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001922 xappConn1.TestMsgChanEmpty(t)
1923 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001924 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001925 mainCtrl.wait_registry_empty(t, 10)
1926}
1927
1928//-----------------------------------------------------------------------------
1929// TestSubReqAndSubDelNoAnswerSameActionParallel
1930//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001931// stub stub stub
1932// +-------+ +-------+ +---------+ +---------+
1933// | xapp2 | | xapp1 | | submgr | | e2term |
1934// +-------+ +-------+ +---------+ +---------+
1935// | | | |
1936// | | | |
1937// | | | |
1938// | | SubReq1 | |
1939// | |------------->| |
1940// | | | |
1941// | | | SubReq1 |
1942// | | |------------->|
1943// | | SubReq2 | |
1944// |--------------------------->| |
1945// | | | |
1946// | | | SubReq1 |
1947// | | |------------->|
1948// | | | |
1949// | | | |
1950// | | | SubDelReq |
1951// | | |------------->|
1952// | | | |
1953// | | | SubDelResp |
1954// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001955//
1956//-----------------------------------------------------------------------------
1957func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001958 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001959
1960 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001961 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001962 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001963 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001964
Juha Hyttinen1683f912020-04-17 10:39:57 +03001965 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001966
1967 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001968 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001969 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001970 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001971 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001972 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001973
1974 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001975 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001976
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001977 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1978 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001979
1980 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001981 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001982
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001983 xappConn1.TestMsgChanEmpty(t)
1984 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001985 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001986 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001987}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001988
1989//----------------------------- Policy cases ---------------------------------
1990//-----------------------------------------------------------------------------
1991// TestSubReqPolicyAndSubDelOk
1992//
1993// stub stub
1994// +-------+ +---------+ +---------+
1995// | xapp | | submgr | | e2term |
1996// +-------+ +---------+ +---------+
1997// | | |
1998// | SubReq | |
1999// |------------->| |
2000// | | |
2001// | | SubReq |
2002// | |------------->|
2003// | | |
2004// | | SubResp |
2005// | |<-------------|
2006// | | |
2007// | SubResp | |
2008// |<-------------| |
2009// | | |
2010// | | |
2011// | SubDelReq | |
2012// |------------->| |
2013// | | |
2014// | | SubDelReq |
2015// | |------------->|
2016// | | |
2017// | | SubDelResp |
2018// | |<-------------|
2019// | | |
2020// | SubDelResp | |
2021// |<-------------| |
2022//
2023//-----------------------------------------------------------------------------
2024func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2025 CaseBegin("TestSubReqAndSubDelOk")
2026
2027 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2028 rparams1.Init()
2029 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2030 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2031
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002032 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2033 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002034 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2035 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002036 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002037
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002038 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002039 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002040
2041 //Wait that subs is cleaned
2042 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2043
2044 xappConn1.TestMsgChanEmpty(t)
2045 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002046 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002047 mainCtrl.wait_registry_empty(t, 10)
2048}
2049
2050//-----------------------------------------------------------------------------
2051// TestSubReqPolicyChangeAndSubDelOk
2052//
2053// stub stub
2054// +-------+ +---------+ +---------+
2055// | xapp | | submgr | | e2term |
2056// +-------+ +---------+ +---------+
2057// | | |
2058// | SubReq | |
2059// |------------->| |
2060// | | |
2061// | | SubReq |
2062// | |------------->|
2063// | | |
2064// | | SubResp |
2065// | |<-------------|
2066// | | |
2067// | SubResp | |
2068// |<-------------| |
2069// | | |
2070// | SubReq | |
2071// |------------->| |
2072// | | |
2073// | | SubReq |
2074// | |------------->|
2075// | | |
2076// | | SubResp |
2077// | |<-------------|
2078// | | |
2079// | SubResp | |
2080// |<-------------| |
2081// | | |
2082// | SubDelReq | |
2083// |------------->| |
2084// | | |
2085// | | SubDelReq |
2086// | |------------->|
2087// | | |
2088// | | SubDelResp |
2089// | |<-------------|
2090// | | |
2091// | SubDelResp | |
2092// |<-------------| |
2093//
2094//-----------------------------------------------------------------------------
2095
2096func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2097 CaseBegin("TestSubReqAndSubDelOk")
2098
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002099 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2100 rparams1.Init()
2101 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2102 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002103
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002104 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2105 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002106 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2107
2108 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002109 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002110 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2111 xappConn1.SendSubsReq(t, rparams1, cretrans)
2112
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002113 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2114 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002115 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2116 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002117 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002118
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002119 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002120 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002121
2122 //Wait that subs is cleaned
2123 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2124
2125 xappConn1.TestMsgChanEmpty(t)
2126 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002127 e2termConn1.TestMsgChanEmpty(t)
2128 mainCtrl.wait_registry_empty(t, 10)
2129}
2130
2131//-----------------------------------------------------------------------------
2132// TestSubReqAndSubDelOkTwoE2termParallel
2133//
2134// stub stub stub
2135// +-------+ +---------+ +---------+ +---------+
2136// | xapp | | submgr | | e2term1 | | e2term2 |
2137// +-------+ +---------+ +---------+ +---------+
2138// | | | |
2139// | | | |
2140// | | | |
2141// | SubReq1 | | |
2142// |------------->| | |
2143// | | | |
2144// | | SubReq1 | |
2145// | |------------->| |
2146// | | | |
2147// | SubReq2 | | |
2148// |------------->| | |
2149// | | | |
2150// | | SubReq2 | |
2151// | |---------------------------->|
2152// | | | |
2153// | | SubResp1 | |
2154// | |<-------------| |
2155// | SubResp1 | | |
2156// |<-------------| | |
2157// | | SubResp2 | |
2158// | |<----------------------------|
2159// | SubResp2 | | |
2160// |<-------------| | |
2161// | | | |
2162// | [SUBS 1 DELETE] | |
2163// | | | |
2164// | [SUBS 2 DELETE] | |
2165// | | | |
2166//
2167//-----------------------------------------------------------------------------
2168func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2169 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2170
2171 //Req1
2172 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2173 xappConn1.SendSubsReq(t, nil, cretrans1)
2174 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2175
2176 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2177 xappConn1.SendSubsReq(t, nil, cretrans2)
2178 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2179
2180 //Resp1
2181 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2182 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2183
2184 //Resp2
2185 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2186 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2187
2188 //Del1
2189 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2190 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2191 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2192 xappConn1.RecvSubsDelResp(t, deltrans1)
2193 //Wait that subs is cleaned
2194 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2195
2196 //Del2
2197 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2198 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2199 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2200 xappConn1.RecvSubsDelResp(t, deltrans2)
2201 //Wait that subs is cleaned
2202 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2203
2204 xappConn1.TestMsgChanEmpty(t)
2205 xappConn2.TestMsgChanEmpty(t)
2206 e2termConn1.TestMsgChanEmpty(t)
2207 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002208 mainCtrl.wait_registry_empty(t, 10)
2209}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002210
2211//-----------------------------------------------------------------------------
2212// TestSubReqInsertAndSubDelOk
2213//
2214// stub stub
2215// +-------+ +---------+ +---------+
2216// | xapp | | submgr | | e2term |
2217// +-------+ +---------+ +---------+
2218// | | |
2219// | SubReq | |
2220// |------------->| |
2221// | | |
2222// | | SubReq |
2223// | |------------->|
2224// | | |
2225// | | SubResp |
2226// | |<-------------|
2227// | | |
2228// | SubResp | |
2229// |<-------------| |
2230// | | |
2231// | | |
2232// | SubDelReq | |
2233// |------------->| |
2234// | | |
2235// | | SubDelReq |
2236// | |------------->|
2237// | | |
2238// | | SubDelResp |
2239// | |<-------------|
2240// | | |
2241// | SubDelResp | |
2242// |<-------------| |
2243//
2244//-----------------------------------------------------------------------------
2245func TestSubReqInsertAndSubDelOk(t *testing.T) {
2246 CaseBegin("TestInsertSubReqAndSubDelOk")
2247
2248 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2249 rparams1.Init()
2250 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2251 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2252
2253 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2254 e2termConn1.SendSubsResp(t, crereq, cremsg)
2255 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2256 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2257 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2258
2259 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2260 xappConn1.RecvSubsDelResp(t, deltrans)
2261
2262 //Wait that subs is cleaned
2263 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2264
2265 xappConn1.TestMsgChanEmpty(t)
2266 xappConn2.TestMsgChanEmpty(t)
2267 e2termConn1.TestMsgChanEmpty(t)
2268 mainCtrl.wait_registry_empty(t, 10)
2269}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002270
2271//-----------------------------------------------------------------------------
2272// TestSubReqRetransmissionWithSameSubIdDiffXid
2273//
2274// This case simulates case where xApp restarts and starts sending same
2275// subscription requests which have already subscribed successfully
2276
2277// stub stub
2278// +-------+ +---------+ +---------+
2279// | xapp | | submgr | | e2term |
2280// +-------+ +---------+ +---------+
2281// | | |
2282// | SubReq | |
2283// |------------->| |
2284// | | |
2285// | | SubReq |
2286// | |------------->|
2287// | | |
2288// | | SubResp |
2289// | |<-------------|
2290// | | |
2291// | SubResp | |
2292// |<-------------| |
2293// | | |
2294// | xApp restart | |
2295// | | |
2296// | SubReq | |
2297// | (retrans with same xApp generated subid but diff xid)
2298// |------------->| |
2299// | | |
2300// | SubResp | |
2301// |<-------------| |
2302// | | |
2303// | [SUBS DELETE] |
2304// | | |
2305//
2306//-----------------------------------------------------------------------------
2307func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2308 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2309
2310 //Subs Create
2311 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2312 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2313 e2termConn1.SendSubsResp(t, crereq, cremsg)
2314 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2315
2316 // xApp restart here
2317 // --> artificial delay
2318 <-time.After(1 * time.Second)
2319
2320 //Subs Create
2321 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2322 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2323
2324 //Subs Delete
2325 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2326 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2327 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2328 xappConn1.RecvSubsDelResp(t, deltrans)
2329
2330 //Wait that subs is cleaned
2331 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2332
2333 xappConn1.TestMsgChanEmpty(t)
2334 xappConn2.TestMsgChanEmpty(t)
2335 e2termConn1.TestMsgChanEmpty(t)
2336 mainCtrl.wait_registry_empty(t, 10)
2337}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002338
2339//-----------------------------------------------------------------------------
2340// TestSubReqNokAndSubDelOkWithRestartInMiddle
2341//
2342// stub stub
2343// +-------+ +---------+ +---------+
2344// | xapp | | submgr | | e2term |
2345// +-------+ +---------+ +---------+
2346// | | |
2347// | SubReq | |
2348// |------------->| |
2349// | | |
2350// | | SubReq |
2351// | |------------->|
2352// | | |
2353// | | SubResp |
2354// | <----|
2355// | |
2356// | Submgr restart |
2357// | |
2358// | | |
2359// | | SubDelReq |
2360// | |------------->|
2361// | | |
2362// | | SubDelResp |
2363// | |<-------------|
2364// | | |
2365//
2366//-----------------------------------------------------------------------------
2367
2368func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2369 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2370
2371 // Remove possible existing subscrition
2372 mainCtrl.removeExistingSubscriptions(t)
2373
2374 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2375 xappConn1.SendSubsReq(t, nil, nil)
2376 e2termConn1.RecvSubsReq(t)
2377 mainCtrl.SetResetTestFlag(t, false)
2378
2379 resp, _ := xapp.Subscription.QuerySubscriptions()
2380 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002381 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002382 e2SubsId := uint32(resp[0].SubscriptionID)
2383 t.Logf("e2SubsId = %v", e2SubsId)
2384
archaggeafbf95f2021-04-14 08:54:05 +03002385 mainCtrl.SimulateRestart(t)
2386 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002387
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002388 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002389 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2390 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2391
2392 // Wait that subs is cleaned
2393 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2394
2395 xappConn1.TestMsgChanEmpty(t)
2396 xappConn2.TestMsgChanEmpty(t)
2397 e2termConn1.TestMsgChanEmpty(t)
2398 mainCtrl.wait_registry_empty(t, 10)
2399}
2400
2401//-----------------------------------------------------------------------------
2402// TestSubReqAndSubDelOkWithRestartInMiddle
2403//
2404// stub stub
2405// +-------+ +---------+ +---------+
2406// | xapp | | submgr | | e2term |
2407// +-------+ +---------+ +---------+
2408// | | |
2409// | SubReq | |
2410// |------------->| |
2411// | | |
2412// | | SubReq |
2413// | |------------->|
2414// | | |
2415// | | SubResp |
2416// | |<-------------|
2417// | | |
2418// | SubResp | |
2419// |<-------------| |
2420// | | |
2421// | |
2422// | Submgr restart |
2423// | |
2424// | SubDelReq | |
2425// |------------->| |
2426// | | |
2427// | | SubDelReq |
2428// | |------------->|
2429// | | |
2430// | | SubDelResp |
2431// | |<-------------|
2432// | | |
2433// | SubDelResp | |
2434// |<-------------| |
2435//
2436//-----------------------------------------------------------------------------
2437
2438func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2439 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2440
2441 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2442 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2443 e2termConn1.SendSubsResp(t, crereq, cremsg)
2444 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2445
2446 // Check subscription
2447 resp, _ := xapp.Subscription.QuerySubscriptions()
2448 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2449 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002450 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002451
2452 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002453 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002454
2455 // Check that subscription is restored correctly after restart
2456 resp, _ = xapp.Subscription.QuerySubscriptions()
2457 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2458 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002459 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002460
2461 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2462 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2463 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2464 xappConn1.RecvSubsDelResp(t, deltrans)
2465
2466 //Wait that subs is cleaned
2467 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2468
2469 xappConn1.TestMsgChanEmpty(t)
2470 xappConn2.TestMsgChanEmpty(t)
2471 e2termConn1.TestMsgChanEmpty(t)
2472 mainCtrl.wait_registry_empty(t, 10)
2473}
2474
2475//-----------------------------------------------------------------------------
2476// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2477//
2478// stub stub
2479// +-------+ +-------+ +---------+ +---------+
2480// | xapp2 | | xapp1 | | submgr | | e2term |
2481// +-------+ +-------+ +---------+ +---------+
2482// | | | |
2483// | | | |
2484// | | | |
2485// | | SubReq1 | |
2486// | |------------->| |
2487// | | | |
2488// | | | SubReq1 |
2489// | | |------------->|
2490// | | | SubResp1 |
2491// | | |<-------------|
2492// | | SubResp1 | |
2493// | |<-------------| |
2494// | | | |
2495// | |
2496// | submgr restart |
2497// | |
2498// | | | |
2499// | | | |
2500// | SubReq2 | |
2501// |--------------------------->| |
2502// | | | |
2503// | SubResp2 | |
2504// |<---------------------------| |
2505// | | | |
2506// | | SubDelReq 1 | |
2507// | |------------->| |
2508// | | | |
2509// | | SubDelResp 1 | |
2510// | |<-------------| |
2511// | | | |
2512// | | | |
2513// | |
2514// | submgr restart |
2515// | |
2516// | | | |
2517// | SubDelReq 2 | |
2518// |--------------------------->| |
2519// | | | |
2520// | | | SubDelReq 2 |
2521// | | |------------->|
2522// | | | |
2523// | | | SubDelReq 2 |
2524// | | |------------->|
2525// | | | |
2526// | SubDelResp 2 | |
2527// |<---------------------------| |
2528//
2529//-----------------------------------------------------------------------------
2530
2531func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2532 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2533
2534 //Req1
2535 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2536 rparams1.Init()
2537 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2538 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2539 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2540 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2541
2542 //Req2
2543 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2544 rparams2.Init()
2545 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2546 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2547
2548 // Check subscription
2549 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2550 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2551 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002552 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002553
2554 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002555 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002556
2557 // Check that subscription is restored correctly after restart
2558 resp, _ = xapp.Subscription.QuerySubscriptions()
2559 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2560 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002561 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002562
2563 //Del1
2564 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2565 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2566 xappConn1.RecvSubsDelResp(t, deltrans1)
2567 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2568
2569 mainCtrl.SimulateRestart(t)
2570 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2571
2572 //Del2
2573 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2574 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2575
2576 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2577 xappConn2.RecvSubsDelResp(t, deltrans2)
2578
2579 //Wait that subs is cleaned
2580 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2581
2582 xappConn1.TestMsgChanEmpty(t)
2583 xappConn2.TestMsgChanEmpty(t)
2584 e2termConn1.TestMsgChanEmpty(t)
2585 mainCtrl.wait_registry_empty(t, 10)
2586}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002587
archaggeafbf95f2021-04-14 08:54:05 +03002588//*****************************************************************************
2589// REST interface test cases
2590//*****************************************************************************
2591
Anssi Mannila47518ae2021-04-16 09:27:07 +03002592//-----------------------------------------------------------------------------
2593// Test debug GET and POST requests
2594//
2595// curl
2596// +-------+ +---------+
2597// | user | | submgr |
2598// +-------+ +---------+
2599// | |
2600// | GET/POST Req |
2601// |------------->|
2602// | Resp |
2603// |<-------------|
2604// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002605func TestGetSubscriptions(t *testing.T) {
2606
2607 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2608}
2609
2610func TestGetSymptomData(t *testing.T) {
2611
2612 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2613}
2614
2615func TestPostdeleteSubId(t *testing.T) {
2616
2617 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2618}
2619
2620func TestPostEmptyDb(t *testing.T) {
2621
2622 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2623}
archaggeafbf95f2021-04-14 08:54:05 +03002624
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002625func TestGetRestSubscriptions(t *testing.T) {
2626
2627 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2628}
2629
archaggeafbf95f2021-04-14 08:54:05 +03002630//-----------------------------------------------------------------------------
2631// TestRESTSubReqAndRouteNok
2632//
2633// stub stub
2634// +-------+ +---------+ +---------+
2635// | xapp | | submgr | | rtmgr |
2636// +-------+ +---------+ +---------+
2637// | | |
2638// | RESTSubReq | |
2639// |---------------->| |
2640// | | |
2641// | RESTSubResp | |
2642// |<----------------| |
2643// | | RouteCreate |
2644// | |------------->|
2645// | | |
2646// | | RouteCreate |
2647// | | status:400 |
2648// | |(Bad request) |
2649// | |<-------------|
2650// | RESTNotif | |
2651// |<----------------| |
2652// | | |
2653// | [SUBS INT DELETE] |
2654// | | |
2655// | RESTSubDelReq | |
2656// |---------------->| |
2657// | RESTSubDelResp | |
2658// |<----------------| |
2659//
2660//-----------------------------------------------------------------------------
2661func TestRESTSubReqAndRouteNok(t *testing.T) {
2662 CaseBegin("TestRESTSubReqAndRouteNok")
2663
2664 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002665 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002666 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002667 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002668 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002669 Counter{cRestSubDelReqFromXapp, 1},
2670 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002671 })
2672
2673 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002674
Markku Virtanenda34eec2021-05-20 08:22:04 +00002675 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2676 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002677 newSubsId := mainCtrl.get_registry_next_subid(t)
2678
2679 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002680 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002681 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002682 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002683 waiter.WaitResult(t)
2684
archaggeafbf95f2021-04-14 08:54:05 +03002685 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002686 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03002687
2688 // Del
2689 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2690
2691 // Wait that subs is cleaned
2692 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2693 waitSubsCleanup(t, e2SubsId, 10)
2694 mainCtrl.VerifyCounterValues(t)
2695}
2696
2697func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2698 CaseBegin("TestSubReqAndRouteUpdateNok")
2699
2700 //Init counter check
2701 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002702 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002703 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002704 Counter{cSubReqToE2, 1},
2705 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002706 Counter{cRestSubNotifToXapp, 1},
2707 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002708 Counter{cRouteCreateUpdateFail, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002709 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002710 Counter{cSubDelReqToE2, 1},
2711 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002712 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002713 })
2714
2715 var params *teststube2ap.RESTSubsReqParams = nil
2716
2717 //Subs Create
2718 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2719
2720 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2721
2722 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2723 waiter := rtmgrHttp.AllocNextEvent(false)
2724 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002725 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002726 params.SetMeid("RAN_NAME_1")
2727 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002728 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002729 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03002730 waiter.WaitResult(t)
2731 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2732 xappConn2.WaitRESTNotification(t, restSubId2)
2733
2734 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2735
2736 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2737
2738 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2739 //Wait that subs is cleaned
2740 waitSubsCleanup(t, e2SubsId, 10)
2741
2742 mainCtrl.VerifyCounterValues(t)
2743}
2744
2745func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2746 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2747
2748 // Init counter check
2749 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002750 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002751 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002752 Counter{cSubReqToE2, 1},
2753 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002754 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002755 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002756 Counter{cRouteDeleteFail, 1},
2757 Counter{cSubDelReqToE2, 1},
2758 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002759 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002760 })
2761
2762 var params *teststube2ap.RESTSubsReqParams = nil
2763
2764 //Subs Create
2765 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2766
2767 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2768
2769 waiter := rtmgrHttp.AllocNextEvent(false)
2770 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2771 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2772 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2773 waiter.WaitResult(t)
2774
2775 waitSubsCleanup(t, e2SubsId, 10)
2776
2777 mainCtrl.VerifyCounterValues(t)
2778}
2779
2780func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2781 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2782
2783 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002784 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002785 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002786 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002787 Counter{cSubReqToE2, 1},
2788 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002789 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002790 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03002791 Counter{cRouteDeleteUpdateFail, 1},
2792 Counter{cSubDelReqToE2, 1},
2793 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002794 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002795 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002796 })
2797
2798 var params *teststube2ap.RESTSubsReqParams = nil
2799
2800 //Subs Create
2801 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2802
2803 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2804 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2805
2806 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2807
2808 //Del1, this shall fail on rtmgr side
2809 waiter := rtmgrHttp.AllocNextEvent(false)
2810 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2811 waiter.WaitResult(t)
2812
2813 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2814
2815 //Del2
2816 deleteXapp2Subscription(t, &restSubId2)
2817
2818 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002819 mainCtrl.VerifyCounterValues(t)
2820}
2821
2822//-----------------------------------------------------------------------------
2823// TestRESTSubReqRetransmission
2824//
2825// stub stub
2826// +-------+ +---------+ +---------+
2827// | xapp | | submgr | | e2term |
2828// +-------+ +---------+ +---------+
2829// | | |
2830// | RESTSubReq1 | |
2831// |---------------->| |
2832// | | |
2833// | RESTSubResp | |
2834// |<----------------| |
2835// | | SubReq1 |
2836// | |------------->|
2837// | | |
2838// | RESTSubReq2 | |
2839// | (retrans) | |
2840// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002841// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03002842// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00002843// | | |
archaggeafbf95f2021-04-14 08:54:05 +03002844// | | SubResp1 |
2845// | |<-------------|
2846// | RESTNotif1 | |
2847// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03002848// | | |
2849// | [SUBS DELETE] |
2850// | | |
2851//
2852//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002853
archaggeafbf95f2021-04-14 08:54:05 +03002854func TestRESTSubReqRetransmission(t *testing.T) {
2855 CaseBegin("TestRESTSubReqRetransmission")
2856
2857 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002858 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002859 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00002860 Counter{cSubReqToE2, 1},
2861 Counter{cSubRespFromE2, 1},
2862 Counter{cRestSubNotifToXapp, 1},
2863 Counter{cRestSubDelReqFromXapp, 1},
2864 Counter{cSubDelReqToE2, 1},
2865 Counter{cSubDelRespFromE2, 1},
2866 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002867 })
Markku Virtanen42723e22021-06-15 10:09:23 +03002868 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03002869 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2870 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2871
2872 // Subs Create
2873 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03002874
2875 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2876 // gets into execution before the rtmgrg responds for the first one.
2877 waiter := rtmgrHttp.AllocNextSleep(10, true)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002878 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002879 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenb642a192021-06-09 09:08:14 +00002880 xappConn2.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03002881
2882 waiter.WaitResult(t)
2883
Markku Virtanenb642a192021-06-09 09:08:14 +00002884 xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
archaggeafbf95f2021-04-14 08:54:05 +03002885
2886 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2887 // the order is not significant he6re.
2888 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2889 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03002890
2891 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002892 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03002893
2894 // Del1
2895 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2896 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2897 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2898
Markku Virtanenb642a192021-06-09 09:08:14 +00002899 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03002900
2901 mainCtrl.VerifyCounterValues(t)
2902}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002903
Markku Virtanen42723e22021-06-15 10:09:23 +03002904//-----------------------------------------------------------------------------
2905// stub stub stub
2906// +-------+ +---------+ +---------+ +---------+
2907// | xapp | | submgr | | e2term | | rtmgr |
2908// +-------+ +---------+ +---------+ +---------+
2909// | | | |
2910// | RESTSubReq | | |
2911// |---------------->| | |
2912// | RESTSubResp | | |
2913// |<----------------| | |
2914// | | RouteCreate | |
2915// | |--------------------------->|
2916// | | RouteResponse| |
2917// | |<---------------------------| // The order of these events may vary
2918// | | SubReq | |
2919// | |------------->| | // The order of these events may vary
2920// | | SubResp | |
2921// | |<-------------| |
2922// | RESTNotif1 | | |
2923// |<----------------| | |
2924// | RESTSubReq | | |
2925// | [RETRANS1] | | |
2926// |---------------->| | |
2927// | RESTNotif1 | | |
2928// |<----------------| | |
2929// | RESTSubReq | | |
2930// | [RETRANS2] | | |
2931// |---------------->| | |
2932// | RESTNotif1 | | |
2933// |<----------------| | |
2934// | RESTSubDelReq | | |
2935// |---------------->| | |
2936// | | SubDelReq | |
2937// | |------------->| |
2938// | RESTSubDelResp| | |
2939// |<----------------| | |
2940// | | SubDelResp | |
2941// | |<-------------| |
2942// | | | |
2943//
2944//-----------------------------------------------------------------------------
2945
2946func TestRESTSubReqRetransmissionV2(t *testing.T) {
2947 CaseBegin("TestRESTSubReqRetransmissionV2")
2948
2949 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2950 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02002951 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03002952 Counter{cRestSubRespToXapp, 3},
2953 Counter{cSubReqToE2, 1},
2954 Counter{cSubRespFromE2, 1},
2955 Counter{cRestSubNotifToXapp, 3},
2956 Counter{cRestSubDelReqFromXapp, 1},
2957 Counter{cSubDelReqToE2, 1},
2958 Counter{cSubDelRespFromE2, 1},
2959 Counter{cRestSubDelRespToXapp, 1},
2960 })
2961
2962 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2963
2964 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2965
2966 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2967
2968 //1.st resend
2969 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
2970
2971 assert.Equal(t, restSubId_resend, restSubId)
2972
2973 <-time.After(100 * time.Millisecond)
2974
2975 //2.nd resend
2976 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
2977
2978 assert.Equal(t, restSubId_resend2, restSubId)
2979
2980 <-time.After(100 * time.Millisecond)
2981
2982 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2983
2984 waitSubsCleanup(t, e2SubsId, 10)
2985
2986 //Wait that subs is cleaned
2987 mainCtrl.VerifyCounterValues(t)
2988}
2989
2990//-----------------------------------------------------------------------------
2991// stub stub stub
2992// +-------+ +---------+ +---------+ +---------+
2993// | xapp | | submgr | | e2term | | rtmgr |
2994// +-------+ +---------+ +---------+ +---------+
2995// | | | |
2996// | RESTSubReq | | |
2997// |---------------->| | |
2998// | RESTSubResp | | |
2999// |<----------------| | |
3000// | | RouteCreate | |
3001// | |--------------------------->|
3002// | | RouteResponse| |
3003// | |<---------------------------| // The order of these events may vary
3004// | | SubReq | |
3005// | |------------->| | // The order of these events may vary
3006// | | SubResp | |
3007// | |<-------------| |
3008// | RESTNotif1 | | |
3009// |<----------------| | |
3010// | RESTSubReq | | |
3011// | [RETRANS, with RESTsubsId] | |
3012// |---------------->| | |
3013// | RESTNotif1 | | |
3014// |<----------------| | |
3015// | RESTSubReq | | |
3016// | [RETRANS, without RESTsubsId] | |
3017// |---------------->| | |
3018// | RESTNotif1 | | |
3019// |<----------------| | |
3020// | RESTSubDelReq | | |
3021// |---------------->| | |
3022// | | SubDelReq | |
3023// | |------------->| |
3024// | RESTSubDelResp| | |
3025// |<----------------| | |
3026// | | SubDelResp | |
3027// | |<-------------| |
3028// | | | |
3029//
3030//-----------------------------------------------------------------------------
3031func TestRESTSubReqRetransmissionV3(t *testing.T) {
3032 CaseBegin("TestRESTSubReqRetransmissionV3")
3033
3034 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3035 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003036 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003037 Counter{cRestSubRespToXapp, 3},
3038 Counter{cSubReqToE2, 1},
3039 Counter{cSubRespFromE2, 1},
3040 Counter{cRestSubNotifToXapp, 3},
3041 Counter{cRestSubDelReqFromXapp, 1},
3042 Counter{cSubDelReqToE2, 1},
3043 Counter{cSubDelRespFromE2, 1},
3044 Counter{cRestSubDelRespToXapp, 1},
3045 })
3046
3047 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3048
3049 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3050
3051 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3052
3053 <-time.After(100 * time.Millisecond)
3054
3055 //1.st resend with subscription ID
3056 params.SetSubscriptionID(&restSubId)
3057 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3058
3059 assert.Equal(t, restSubId_resend, restSubId)
3060
3061 <-time.After(100 * time.Millisecond)
3062
3063 //2.nd resend without subscription ID (faking app restart)
3064 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3065 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3066
3067 assert.Equal(t, restSubId_resend2, restSubId)
3068
3069 <-time.After(100 * time.Millisecond)
3070
3071 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3072
3073 waitSubsCleanup(t, e2SubsId, 10)
3074
3075 //Wait that subs is cleaned
3076 mainCtrl.VerifyCounterValues(t)
3077}
3078
3079//-----------------------------------------------------------------------------
3080// stub stub stub
3081// +-------+ +---------+ +---------+ +---------+
3082// | xapp | | submgr | | e2term | | rtmgr |
3083// +-------+ +---------+ +---------+ +---------+
3084// | | | |
3085// | RESTSubReq | | |
3086// |---------------->| | |
3087// | RESTSubResp | | |
3088// |<----------------| | |
3089// | | RouteCreate | |
3090// | |--------------------------->|
3091// | | RouteResponse| |
3092// | |<---------------------------|
3093// | | SubReq | |
3094// | |------------->| |
3095// | | SubResp | |
3096// | |<-------------| |
3097// | RESTNotif1 | | |
3098// |<----------------| | |
3099// | RESTSubReq | | |
3100// | [with RestSUbsId + one additional e2 subDetail]
3101// |---------------->| | |
3102// | RESTNotif1 | | |
3103// | [for initial e2 subDetail] | |
3104// |<----------------| | |
3105// | | RouteCreate | |
3106// | |--------------------------->|
3107// | | RouteResponse| |
3108// | |<---------------------------|
3109// | | SubReq | |
3110// | |------------->| |
3111// | | SubResp | |
3112// | |<-------------| |
3113// | RESTNotif1 | | |
3114// |<----------------| | |
3115// | RESTSubReq | | |
3116// | [with RESTsubsId initial request] |
3117// |---------------->| | |
3118// | RESTNotif1 | | |
3119// |<----------------| | |
3120// | RESTSubDelReq | | |
3121// |---------------->| | |
3122// | RESTSubDelResp| | |
3123// |<----------------| | |
3124// | | SubDelReq | |
3125// | |------------->| |
3126// | | SubDelResp | |
3127// | |<-------------| |
3128// | | SubDelReq | |
3129// | |------------->| |
3130// | | SubDelResp | |
3131// | |<-------------| |
3132// | | | |
3133//
3134//-----------------------------------------------------------------------------
3135
3136func TestRESTSubReqRetransmissionV4(t *testing.T) {
3137 CaseBegin("TestRESTSubReqRetransmissionV4")
3138
3139 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3140 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003141 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003142 Counter{cRestSubRespToXapp, 3},
3143 Counter{cSubReqToE2, 2},
3144 Counter{cSubRespFromE2, 2},
3145 Counter{cRestSubNotifToXapp, 4},
3146 Counter{cRestSubDelReqFromXapp, 1},
3147 Counter{cSubDelReqToE2, 2},
3148 Counter{cSubDelRespFromE2, 2},
3149 Counter{cRestSubDelRespToXapp, 1},
3150 })
3151
3152 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3153
3154 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3155
3156 <-time.After(100 * time.Millisecond)
3157
3158 // Send modified requst, this time with e2 subscriptions.
3159 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3160 params2.SetSubscriptionID(&restSubId)
3161
3162 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003163 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003164 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3165 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003166 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3167 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003168
3169 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3170
Markku Virtanen2b512b62021-07-30 12:04:00 +00003171 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003172 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3173 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3174 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3175 assert.NotEqual(t, e2SubsId2, 0)
3176
3177 <-time.After(100 * time.Millisecond)
3178
3179 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3180 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3181 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003182 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003183 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3184 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3185 assert.Equal(t, restSubId_resend, restSubId_resend2)
3186
Markku Virtanen2b512b62021-07-30 12:04:00 +00003187 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3188 assert.Equal(t, e2SubsId, e2SubsId1)
3189
Markku Virtanen42723e22021-06-15 10:09:23 +03003190 // Delete both e2 subscriptions
3191 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3192 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3193 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3194
3195 waitSubsCleanup(t, e2SubsId, 10)
3196
3197 //Wait that subs is cleaned
3198 mainCtrl.VerifyCounterValues(t)
3199}
3200
3201//-----------------------------------------------------------------------------
3202// stub stub stub
3203// +-------+ +---------+ +---------+ +---------+
3204// | xapp | | submgr | | e2term | | rtmgr |
3205// +-------+ +---------+ +---------+ +---------+
3206// | | | |
3207// | RESTSubReq | | |
3208// |---------------->| | |
3209// | RESTSubResp | | |
3210// |<----------------| | |
3211// | | RouteCreate | |
3212// | |--------------------------->|
3213// | | RouteResponse| |
3214// | |<---------------------------|
3215// | | SubReq | |
3216// | |------------->| |
3217// | | SubResp | |
3218// | |<-------------| |
3219// | RESTNotif1 | | |
3220// |<----------------| | |
3221// | RESTSubReq | | |
3222// | [with RestSUbsId + one additional e2 subDetail]
3223// |---------------->| | |
3224// | RESTNotif1 | | |
3225// | [for initial e2 subDetail] | |
3226// |<----------------| | |
3227// | | RouteCreate | |
3228// | |--------------------------->|
3229// | | RouteResponse| |
3230// | |<---------------------------|
3231// | | SubReq | |
3232// | |------------->| |
3233// | | SubResp | |
3234// | |<-------------| |
3235// | RESTNotif1 | | |
3236// |<----------------| | |
3237// | RESTSubReq | | |
3238// | [without RESTsubsId initial request] |
3239// |---------------->| | |
3240// | RESTNotif1 | | |
3241// |<----------------| | |
3242// | RESTSubDelReq | | |
3243// |---------------->| | |
3244// | RESTSubDelResp| | |
3245// |<----------------| | |
3246// | | SubDelReq | |
3247// | |------------->| |
3248// | | SubDelResp | |
3249// | |<-------------| |
3250// | | SubDelReq | |
3251// | |------------->| |
3252// | | SubDelResp | |
3253// | |<-------------| |
3254// | | | |
3255//
3256//-----------------------------------------------------------------------------
3257
3258func TestRESTSubReqRetransmissionV5(t *testing.T) {
3259 CaseBegin("TestRESTSubReqRetransmissionV5")
3260
3261 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3262 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003263 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003264 Counter{cRestSubRespToXapp, 3},
3265 Counter{cSubReqToE2, 2},
3266 Counter{cSubRespFromE2, 2},
3267 Counter{cRestSubNotifToXapp, 4},
3268 Counter{cRestSubDelReqFromXapp, 1},
3269 Counter{cSubDelReqToE2, 2},
3270 Counter{cSubDelRespFromE2, 2},
3271 Counter{cRestSubDelRespToXapp, 1},
3272 })
3273
3274 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3275
3276 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3277
3278 <-time.After(100 * time.Millisecond)
3279
3280 // Send modified requst, this time with e2 subscriptions.
3281 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3282 params2.SetSubscriptionID(&restSubId)
3283
3284 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003285 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003286 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3287 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3288
Markku Virtanen2b512b62021-07-30 12:04:00 +00003289 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3290 assert.Equal(t, e2SubsId, e2SubsId1)
3291 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3292 xappConn1.DecrementRequestCount()
3293
Markku Virtanen42723e22021-06-15 10:09:23 +03003294 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3295
3296 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3297 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3298 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3299 assert.NotEqual(t, e2SubsId2, 0)
3300
3301 <-time.After(100 * time.Millisecond)
3302
3303 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3304 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003305 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003306 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3307 // md5sum shall find the original request
3308 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3309 assert.Equal(t, restSubId_resend, restSubId_resend2)
3310
Markku Virtanen2b512b62021-07-30 12:04:00 +00003311 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3312 assert.Equal(t, e2SubsId, e2SubsId1)
3313
Markku Virtanen42723e22021-06-15 10:09:23 +03003314 // Delete both e2 subscriptions
3315 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3316 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3317 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3318
3319 waitSubsCleanup(t, e2SubsId, 10)
3320
3321 //Wait that subs is cleaned
3322 mainCtrl.VerifyCounterValues(t)
3323}
3324
3325//-----------------------------------------------------------------------------
3326// stub stub stub
3327// +-------+ +---------+ +---------+ +---------+
3328// | xapp | | submgr | | e2term | | rtmgr |
3329// +-------+ +---------+ +---------+ +---------+
3330// | | | |
3331// | RESTSubReq | | |
3332// |---------------->| | |
3333// | RESTSubResp | | |
3334// |<----------------| | |
3335// | | RouteCreate | |
3336// | |--------------------------->|
3337// | | RouteResponse| |
3338// | |<---------------------------|
3339// | | SubReq | |
3340// | |------------->| |
3341// | | SubResp | |
3342// | |<-------------| |
3343// | RESTNotif1 | | |
3344// |<----------------| | |
3345// | RESTSubReq | | |
3346// | [with RestSUbsId + one additional e2 subDetail]
3347// |---------------->| | |
3348// | RESTNotif1 | | |
3349// | [for initial e2 subDetail] | |
3350// |<----------------| | |
3351// | | RouteCreate | |
3352// | |--------------------------->|
3353// | | RouteResponse| |
3354// | |<---------------------------|
3355// | | SubReq | |
3356// | |------------->| |
3357// | | SubResp | |
3358// | |<-------------| |
3359// | RESTNotif1 | | |
3360// |<----------------| | |
3361// | RESTSubDelReq | | |
3362// |---------------->| | |
3363// | RESTSubDelResp| | |
3364// |<----------------| | |
3365// | | SubDelReq | |
3366// | |------------->| |
3367// | | SubDelResp | |
3368// | |<-------------| |
3369// | | SubDelReq | |
3370// | |------------->| |
3371// | | SubDelResp | |
3372// | |<-------------| |
3373// | RESTSubReq | | |
3374// | [with RESTsubsId initial request] |
3375// |---------------->| | |
3376// | RESTSubResp | | |
3377// |<----------------| | |
3378// | | RouteCreate | |
3379// | |--------------------------->|
3380// | | RouteResponse| |
3381// | |<---------------------------|
3382// | | SubReq | |
3383// | |------------->| |
3384// | | SubResp | |
3385// | |<-------------| |
3386// | RESTNotif1 | | |
3387// |<----------------| | |
3388// | | | |
3389//
3390//-----------------------------------------------------------------------------
3391func TestRESTSubReqRetransmissionV6(t *testing.T) {
3392 CaseBegin("TestRESTSubReqRetransmissionV6")
3393
3394 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3395 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003396 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003397 Counter{cRestSubRespToXapp, 3},
3398 Counter{cSubReqToE2, 3},
3399 Counter{cSubRespFromE2, 3},
3400 Counter{cRestSubNotifToXapp, 4},
3401 Counter{cRestSubDelReqFromXapp, 2},
3402 Counter{cSubDelReqToE2, 3},
3403 Counter{cSubDelRespFromE2, 3},
3404 Counter{cRestSubDelRespToXapp, 2},
3405 })
3406
3407 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3408
3409 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3410
3411 <-time.After(100 * time.Millisecond)
3412
3413 // Send modified requst, this time with e2 subscriptions.
3414 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3415 params2.SetSubscriptionID(&restSubId)
3416
3417 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003418 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003419 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3420 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3421
Markku Virtanen2b512b62021-07-30 12:04:00 +00003422 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3423 assert.Equal(t, e2SubsId, e2SubsId1)
3424
Markku Virtanen42723e22021-06-15 10:09:23 +03003425 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3426
3427 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3428 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3429 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3430 assert.NotEqual(t, e2SubsId2, 0)
3431
3432 <-time.After(100 * time.Millisecond)
3433
3434 // Delete both e2 subscriptions
3435 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3436 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3437 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3438
3439 waitSubsCleanup(t, e2SubsId, 10)
3440
3441 // Resend the original request, we shall find it's previous md5sum/restsubs
3442 // but the restsubscription has been already removed. This shall trigger a
3443 // fresh create.
3444 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3445
3446 <-time.After(100 * time.Millisecond)
3447
3448 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3449
3450 waitSubsCleanup(t, e2SubsId, 10)
3451
3452 //Wait that subs is cleaned
3453 mainCtrl.VerifyCounterValues(t)
3454}
3455
archaggeafbf95f2021-04-14 08:54:05 +03003456func TestRESTSubDelReqRetransmission(t *testing.T) {
3457 CaseBegin("TestRESTSubDelReqRetransmission")
3458
3459 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003460 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003461 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003462 Counter{cSubReqToE2, 1},
3463 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003464 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003465 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003466 Counter{cSubDelReqToE2, 1},
3467 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003468 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003469 })
3470
3471 var params *teststube2ap.RESTSubsReqParams = nil
3472
3473 //Subs Create
3474 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3475
3476 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3477
3478 //Subs Delete
3479 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3480 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3481
3482 seqBef := mainCtrl.get_msgcounter(t)
3483 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3484 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3485
3486 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3487
3488 waitSubsCleanup(t, e2SubsId, 10)
3489
3490 mainCtrl.VerifyCounterValues(t)
3491}
3492
3493//-----------------------------------------------------------------------------
3494// TestRESTSubReqDelReq
3495//
3496// stub stub
3497// +-------+ +---------+ +---------+
3498// | xapp | | submgr | | e2term |
3499// +-------+ +---------+ +---------+
3500// | | |
3501// | RESTSubReq | |
3502// |---------------->| |
3503// | | |
3504// | RESTSubResp | |
3505// |<----------------| |
3506// | | SubReq |
3507// | |------------->|
3508// | RESTSubDelReq | |
3509// |---------------->| |
3510// | RESTSubDelResp | |
3511// | unsuccess | |
3512// |<----------------| |
3513// | | SubResp |
3514// | |<-------------|
3515// | RESTNotif1 | |
3516// |<----------------| |
3517// | | |
3518// | [SUBS DELETE] |
3519// | | |
3520//
3521//-----------------------------------------------------------------------------
3522func TestRESTSubReqDelReq(t *testing.T) {
3523 CaseBegin("TestRESTSubReqDelReq")
3524
3525 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003526 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003527 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003528 Counter{cSubReqToE2, 1},
3529 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003530 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003531 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003532 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003533 Counter{cSubDelReqToE2, 1},
3534 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003535 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003536 })
3537
3538 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003539
3540 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003541 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003542 restSubId := xappConn1.SendRESTSubsReq(t, params)
3543
3544 // Del. This will fail as processing of the subscription
3545 // is still ongoing in submgr. Deletion is not allowed before
3546 // subscription creation has been completed.
3547 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3548 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3549 xappConn1.ExpectRESTNotification(t, restSubId)
3550 e2termConn1.SendSubsResp(t, crereq, cremsg)
3551 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3552
3553 // Retry del
3554 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3555
3556 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3557 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3558
3559 // Wait that subs is cleaned
3560 waitSubsCleanup(t, e2SubsId, 10)
3561 mainCtrl.VerifyCounterValues(t)
3562
3563}
3564
3565func TestRESTSubDelReqCollision(t *testing.T) {
3566 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
3567}
3568
3569func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
3570 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
3571
3572 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003573 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003574 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003575 Counter{cSubReqToE2, 2},
3576 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003577 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003578 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003579 Counter{cSubDelReqToE2, 2},
3580 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003581 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003582 })
3583
3584 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003585 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003586 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003587 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003588
3589 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003590 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003591 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003592 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003593
3594 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3595 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3596
3597 //XappConn1 receives both of the responses
3598 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3599
3600 //Resp1
3601 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3602 //Resp2
3603 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3604
3605 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003606 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03003607 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003608 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003609
3610 //Del1
3611 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3612 //Del2
3613 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
3614
3615 //Wait that subs is cleaned
3616 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
3617 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3618
3619 mainCtrl.VerifyCounterValues(t)
3620
3621}
3622
3623func TestRESTSameSubsDiffRan(t *testing.T) {
3624 CaseBegin("TestRESTSameSubsDiffRan")
3625
3626 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003627 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003628 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003629 Counter{cSubReqToE2, 2},
3630 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003631 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003632 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003633 Counter{cSubDelReqToE2, 2},
3634 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003635 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003636 })
3637
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003638 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003639 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003640 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03003641
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003642 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003643 params.SetMeid("RAN_NAME_2")
3644 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003645 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003646
3647 //Del1
3648 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
3649 //Del2
3650 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
3651
3652 //Wait that subs is cleaned
3653 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3654 waitSubsCleanup(t, e2SubsId2, 10)
3655
3656 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03003657}
3658
3659func TestRESTSubReqRetryInSubmgr(t *testing.T) {
3660 CaseBegin("TestRESTSubReqRetryInSubmgr start")
3661
3662 // Init counter check
3663 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003664 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003665 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003666 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003667 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003668 Counter{cSubReReqToE2, 1},
3669 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003670 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003671 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003672 Counter{cSubDelReqToE2, 1},
3673 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003674 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003675 })
3676
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003677 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003678 restSubId := xappConn1.SendRESTSubsReq(t, params)
3679
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003680 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003681
3682 // Catch the first message and ignore it
3683 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003684 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003685
3686 // The second request is being handled normally
3687 crereq, cremsg = e2termConn1.RecvSubsReq(t)
3688 xappConn1.ExpectRESTNotification(t, restSubId)
3689 e2termConn1.SendSubsResp(t, crereq, cremsg)
3690 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3691
3692 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3693
3694 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3695
3696 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
3697 //Wait that subs is cleaned
3698 waitSubsCleanup(t, e2SubsId, 10)
3699
3700 mainCtrl.VerifyCounterValues(t)
3701
3702}
3703
3704//-----------------------------------------------------------------------------
3705// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3706//
3707// stub stub
3708// +-------+ +---------+ +---------+
3709// | xapp | | submgr | | e2term |
3710// +-------+ +---------+ +---------+
3711// | | |
3712// | RESTSubReq | |
3713// |---------------->| |
3714// | | |
3715// | RESTSubResp | |
3716// |<----------------| |
3717// | | SubReq |
3718// | |------------->|
3719// | | |
3720// | | |
3721// | | SubReq |
3722// | |------------->|
3723// | | |
3724// | | SubDelReq |
3725// | |------------->|
3726// | | |
3727// | | |
3728// | | SubDelReq |
3729// | |------------->|
3730// | | |
3731// | | |
3732// | | SubDelResp |
3733// | |<-------------|
3734// | RESTNotif | |
3735// | unsuccess | |
3736// |<----------------| |
3737// | | |
3738// | [SUBS DELETE] |
3739// | | |
3740//
3741//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03003742
archaggeafbf95f2021-04-14 08:54:05 +03003743func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
3744 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
3745
3746 // Init counter check
3747 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003748 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003749 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003750 Counter{cSubReqToE2, 1},
3751 Counter{cSubReReqToE2, 1},
3752 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003753 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003754 Counter{cSubDelReqToE2, 1},
3755 Counter{cSubDelRespFromE2, 1},
3756 })
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003757 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003758 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003759 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003760
3761 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003762 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003763
3764 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003765 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003766
3767 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003768 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003769 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03003770 xappConn1.WaitRESTNotification(t, restSubId)
3771
3772 // Wait that subs is cleaned
3773 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
3774
3775 mainCtrl.VerifyCounterValues(t)
3776}
3777
3778func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
3779 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
3780
3781 // Init counter check
3782 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003783 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003784 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003785 Counter{cSubReqToE2, 1},
3786 Counter{cSubReReqToE2, 1},
3787 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003788 Counter{cSubDelReReqToE2, 1},
3789 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003790 Counter{cSubDelReqToE2, 1},
3791 Counter{cSubDelReqTimerExpiry, 2},
3792 })
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003793 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003794 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003795 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003796
3797 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003798 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003799
3800 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003801 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003802
3803 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003804 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003805
Markku Virtanen55d2a282021-06-04 14:46:56 +03003806 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003807 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003808 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003809
3810 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3811
3812 waitSubsCleanup(t, e2SubsId, 10)
3813
3814 mainCtrl.VerifyCounterValues(t)
3815
3816}
3817
3818//-----------------------------------------------------------------------------
3819// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
3820//
3821// stub stub
3822// +-------+ +---------+ +---------+
3823// | xapp | | submgr | | e2term |
3824// +-------+ +---------+ +---------+
3825// | | |
3826// | RESTSubReq | |
3827// |---------------->| |
3828// | | |
3829// | RESTSubResp | |
3830// |<----------------| |
3831// | | SubReq |
3832// | |------------->|
3833// | | |
3834// | | |
3835// | | SubReq |
3836// | |------------->|
3837// | | |
3838// | | SubDelReq |
3839// | |------------->|
3840// | | |
3841// | | |
3842// | | SubDelReq |
3843// | |------------->|
3844// | | |
3845// | | |
3846// | | SubDelResp |
3847// | |<-------------|
3848// | RESTNotif | |
3849// | unsuccess | |
3850// |<----------------| |
3851// | | |
3852// | [SUBS DELETE] |
3853// | | |
3854//
3855//-----------------------------------------------------------------------------
3856func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
3857 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
3858
3859 // Init counter check
3860 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003861 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003862 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003863 Counter{cSubReqToE2, 1},
3864 Counter{cSubReReqToE2, 1},
3865 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003866 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003867 Counter{cSubDelReqToE2, 1},
3868 Counter{cSubDelReReqToE2, 1},
3869 Counter{cSubDelReqTimerExpiry, 2},
3870 })
3871
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003872 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003873 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003874 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003875
3876 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003877 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003878
3879 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003880 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003881
3882 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003883 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003884
Markku Virtanen55d2a282021-06-04 14:46:56 +03003885 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003886 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003887 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003888
3889 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3890
3891 waitSubsCleanup(t, e2SubsId, 10)
3892
3893 mainCtrl.VerifyCounterValues(t)
3894}
3895
3896//-----------------------------------------------------------------------------
3897// TestRESTSubReqSubFailRespInSubmgr
3898//
3899// stub stub
3900// +-------+ +---------+ +---------+
3901// | xapp | | submgr | | e2term |
3902// +-------+ +---------+ +---------+
3903// | | |
3904// | RESTSubReq | |
3905// |---------------->| |
3906// | | |
3907// | RESTSubResp | |
3908// |<----------------| |
3909// | | SubReq |
3910// | |------------->|
3911// | | |
3912// | | SubFail |
3913// | |<-------------|
3914// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003915// | RESTNotif | |
3916// | unsuccess | |
3917// |<----------------| |
3918// | | |
3919// | [SUBS DELETE] |
3920// | | |
3921//
3922//-----------------------------------------------------------------------------
3923func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
3924 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
3925
3926 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003927 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003928 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003929 Counter{cSubReqToE2, 1},
3930 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003931 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003932 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003933 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003934 })
3935
3936 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003937 const e2Timeout int64 = 2
3938 const e2RetryCount int64 = 1
3939 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03003940
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003941 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03003942 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03003943 restSubId := xappConn1.SendRESTSubsReq(t, params)
3944
3945 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3946 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3947 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02003948 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003949 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3950
archaggeafbf95f2021-04-14 08:54:05 +03003951 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003952 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003953
3954 // REST subscription sill there to be deleted
3955 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3956
3957 // Wait that subs is cleaned
3958 waitSubsCleanup(t, e2SubsId, 10)
3959
3960 mainCtrl.VerifyCounterValues(t)
3961
3962}
3963
3964//-----------------------------------------------------------------------------
3965// TestRESTSubDelReqRetryInSubmgr
3966//
3967// stub stub
3968// +-------+ +---------+ +---------+
3969// | xapp | | submgr | | e2term |
3970// +-------+ +---------+ +---------+
3971// | | |
3972// | [SUBS CREATE] |
3973// | | |
3974// | | |
3975// | RESTSubDelReq | |
3976// |---------------->| |
3977// | | |
3978// | RESTSubDelResp | |
3979// |<----------------| |
3980// | | SubDelReq |
3981// | |------------->|
3982// | | |
3983// | | SubDelReq |
3984// | |------------->|
3985// | | |
3986// | | SubDelResp |
3987// | |<-------------|
3988// | | |
3989//
3990//-----------------------------------------------------------------------------
3991func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3992 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3993
3994 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003995 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003996 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003997 Counter{cSubReqToE2, 1},
3998 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003999 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004000 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004001 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004002 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004003 Counter{cSubDelReReqToE2, 1},
4004 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004005 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004006 })
4007 // Req
4008 var params *teststube2ap.RESTSubsReqParams = nil
4009 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4010
4011 // Del
4012 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4013
4014 // E2t: Receive 1st SubsDelReq
4015 e2termConn1.RecvSubsDelReq(t)
4016
4017 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4018 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4019 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4020
4021 //Wait that subs is cleaned
4022 waitSubsCleanup(t, e2SubsId, 10)
4023
4024 mainCtrl.VerifyCounterValues(t)
4025}
4026
4027//-----------------------------------------------------------------------------
4028// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4029//
4030// stub stub
4031// +-------+ +---------+ +---------+
4032// | xapp | | submgr | | e2term |
4033// +-------+ +---------+ +---------+
4034// | | |
4035// | [SUBS CREATE] |
4036// | | |
4037// | | |
4038// | RESTSubDelReq | |
4039// |---------------->| |
4040// | | |
4041// | RESTSubDelResp | |
4042// |<----------------| |
4043// | | SubDelReq |
4044// | |------------->|
4045// | | |
4046// | | SubDelReq |
4047// | |------------->|
4048// | | |
4049// | | |
4050//
4051//-----------------------------------------------------------------------------
4052func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
4053 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
4054
4055 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004056 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004057 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004058 Counter{cSubReqToE2, 1},
4059 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004060 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004061 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004062 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004063 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004064 Counter{cSubDelReReqToE2, 1},
4065 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004066 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004067 })
4068
4069 // Req
4070 var params *teststube2ap.RESTSubsReqParams = nil
4071 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4072
4073 // Del
4074 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4075
4076 // E2t: Receive 1st SubsDelReq
4077 e2termConn1.RecvSubsDelReq(t)
4078
4079 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4080 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4081 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4082
4083 //Wait that subs is cleaned
4084 waitSubsCleanup(t, e2SubsId, 10)
4085
4086 mainCtrl.VerifyCounterValues(t)
4087}
4088
4089//-----------------------------------------------------------------------------
4090// TestRESTSubDelReqSubDelFailRespInSubmgr
4091//
4092// stub stub
4093// +-------+ +---------+ +---------+
4094// | xapp | | submgr | | e2term |
4095// +-------+ +---------+ +---------+
4096// | | |
4097// | [SUBS CREATE] |
4098// | | |
4099// | | |
4100// | RESTSubDelReq | |
4101// |---------------->| |
4102// | | |
4103// | RESTSubDelResp | |
4104// |<----------------| |
4105// | | SubDelReq |
4106// | |------------->|
4107// | | |
4108// | | SubDelFail |
4109// | |<-------------|
4110// | | |
4111//
4112//-----------------------------------------------------------------------------
4113func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
4114 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
4115
4116 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004117 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004118 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004119 Counter{cSubReqToE2, 1},
4120 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004121 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004122 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004123 Counter{cSubDelReqToE2, 1},
4124 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004125 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004126 })
4127
4128 // Req
4129 var params *teststube2ap.RESTSubsReqParams = nil
4130 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4131
4132 // Del
4133 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4134
4135 // E2t: Send receive SubsDelReq and send SubsDelFail
4136 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4137 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4138
4139 //Wait that subs is cleaned
4140 waitSubsCleanup(t, e2SubsId, 10)
4141
4142 mainCtrl.VerifyCounterValues(t)
4143}
4144
4145//-----------------------------------------------------------------------------
4146// TestRESTSubReqAndSubDelOkSameAction
4147//
4148// stub stub
4149// +-------+ +-------+ +---------+ +---------+
4150// | xapp2 | | xapp1 | | submgr | | e2term |
4151// +-------+ +-------+ +---------+ +---------+
4152// | | | |
4153// | | RESTSubReq1 | |
4154// | |---------------->| |
4155// | | | |
4156// | | RESTSubResp1 | |
4157// | |<----------------| |
4158// | | | |
4159// | | | SubReq1 |
4160// | | |------------->|
4161// | | | SubResp1 |
4162// | | |<-------------|
4163// | | RESTNotif1 | |
4164// | |<----------------| |
4165// | | | |
4166// | RESTSubReq2 | |
4167// |------------------------------>| |
4168// | | | |
4169// | RESTSubResp2 | |
4170// |<------------------------------| |
4171// | | | |
4172// | | RESTNotif2 | |
4173// |<------------------------------| |
4174// | | | |
4175// | | RESTSubDelReq1 | |
4176// | |---------------->| |
4177// | | | |
4178// | | RESTSubDelResp1 | |
4179// | |<----------------| |
4180// | | | |
4181// | RESTSubDelReq2 | |
4182// |------------------------------>| |
4183// | | | |
4184// | RESTSubDelResp2 | |
4185// |<------------------------------| |
4186// | | | |
4187// | | | SubDelReq2 |
4188// | | |------------->|
4189// | | | |
4190// | | | SubDelResp2 |
4191// | | |<-------------|
4192// | | | |
4193//
4194//-----------------------------------------------------------------------------
4195func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
4196 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
4197
4198 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004199 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004200 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004201 Counter{cSubReqToE2, 1},
4202 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004203 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004204 Counter{cMergedSubscriptions, 1},
4205 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004206 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004207 Counter{cSubDelReqToE2, 1},
4208 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004209 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004210 })
4211
4212 // Req1
4213 var params *teststube2ap.RESTSubsReqParams = nil
4214
4215 //Subs Create
4216 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4217 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4218
4219 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004220 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004221 params.SetMeid("RAN_NAME_1")
4222
4223 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004224 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004225 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004226 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004227 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004228 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004229 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004230 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004231
4232 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4233
4234 // Del1
4235 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4236
4237 // Del2
4238 deleteXapp2Subscription(t, &restSubId2)
4239
4240 //Wait that subs is cleaned
4241 waitSubsCleanup(t, e2SubsId2, 10)
4242
4243 mainCtrl.VerifyCounterValues(t)
4244}
4245
4246//-----------------------------------------------------------------------------
4247// TestSubReqAndSubDelOkSameActionParallel
4248//
4249// stub stub stub
4250// +-------+ +-------+ +---------+ +---------+
4251// | xapp2 | | xapp1 | | submgr | | e2term |
4252// +-------+ +-------+ +---------+ +---------+
4253// | | | |
4254// | | | |
4255// | | | |
4256// | | SubReq1 | |
4257// | |------------->| |
4258// | | | |
4259// | | | SubReq1 |
4260// | | |------------->|
4261// | SubReq2 | |
4262// |--------------------------->| |
4263// | | | SubResp1 |
4264// | | |<-------------|
4265// | | SubResp1 | |
4266// | |<-------------| |
4267// | | | SubReq2 |
4268// | | |------------->|
4269// | | | |
4270// | | | SubResp2 |
4271// | | |<-------------|
4272// | SubResp2 | |
4273// |<---------------------------| |
4274// | | | |
4275// | | SubDelReq 1 | |
4276// | |------------->| |
4277// | | | |
4278// | | SubDelResp 1 | |
4279// | |<-------------| |
4280// | | | |
4281// | SubDelReq 2 | |
4282// |--------------------------->| |
4283// | | | |
4284// | | | SubDelReq 2 |
4285// | | |------------->|
4286// | | | |
4287// | | | SubDelReq 2 |
4288// | | |------------->|
4289// | | | |
4290// | SubDelResp 2 | |
4291// |<---------------------------| |
4292//
4293func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
4294 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
4295
4296 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004297 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004298 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004299 Counter{cSubReqToE2, 2},
4300 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004301 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004302 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004303 Counter{cSubDelReqToE2, 2},
4304 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004305 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004306 })
4307
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004308 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004309 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4310 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4311
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004312 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004313 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4314
4315 xappConn1.ExpectRESTNotification(t, restSubId1)
4316 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4317 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4318
4319 xappConn2.ExpectRESTNotification(t, restSubId2)
4320 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4321 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4322 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4323
4324 // Del1
4325 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4326 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4327 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4328 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4329
4330 // Del2
4331 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4332 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4333 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4334
4335 waitSubsCleanup(t, e2SubsId2, 10)
4336
4337 mainCtrl.VerifyCounterValues(t)
4338}
4339
4340//-----------------------------------------------------------------------------
4341// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4342//
4343// stub stub stub
4344// +-------+ +-------+ +---------+ +---------+
4345// | xapp2 | | xapp1 | | submgr | | e2term |
4346// +-------+ +-------+ +---------+ +---------+
4347// | | | |
4348// | | | |
4349// | | | |
4350// | | RESTSubReq1 | |
4351// | |---------------->| |
4352// | | | |
4353// | | RESTSubResp1 | |
4354// | |<----------------| |
4355// | | | SubReq1 |
4356// | | |------------->|
4357// | RESTSubReq2 | |
4358// |------------------------------>| |
4359// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02004360// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03004361// |<------------------------------| |
4362// | | | SubReq1 |
4363// | | |------------->|
4364// | | | |
4365// | | | |
4366// | | | SubDelReq |
4367// | | |------------->|
4368// | | | |
4369// | | | SubDelResp |
4370// | | |<-------------|
4371// | | RESTNotif1 | |
4372// | | unsuccess | |
4373// | |<----------------| |
4374// | RESTNotif2 | |
4375// | | unsuccess | |
4376// |<------------------------------| |
4377// | | | |
4378// | | RESTSubDelReq1 | |
4379// | |---------------->| |
4380// | | | |
4381// | | RESTSubDelResp1 | |
4382// | |<----------------| |
4383// | | | |
4384// | RESTSubDelReq2 | |
4385// |------------------------------>| |
4386// | | | |
4387// | RESTSubDelResp2 | |
4388// |<------------------------------| |
4389//
4390//-----------------------------------------------------------------------------
4391func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
4392 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
4393
4394 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004395 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004396 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004397 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004398 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004399 Counter{cSubReqTimerExpiry, 2},
4400 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004401 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004402 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004403 Counter{cSubDelReqToE2, 1},
4404 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004405 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004406 })
archaggeafbf95f2021-04-14 08:54:05 +03004407 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004408
4409 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004410 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004411 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
4412 crereq1, _ := e2termConn1.RecvSubsReq(t)
4413
4414 // Req2
4415 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004416 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004417 params2.SetMeid("RAN_NAME_1")
4418 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4419 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4420
4421 //Req1 (retransmitted)
4422 e2termConn1.RecvSubsReq(t)
4423
4424 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004425
4426 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004427 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4428
Markku Virtanenda34eec2021-05-20 08:22:04 +00004429 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004430 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00004431 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004432 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004433
4434 // Del1
4435 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4436
4437 // Del2
4438 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4439
Markku Virtanenda34eec2021-05-20 08:22:04 +00004440 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
4441
archaggeafbf95f2021-04-14 08:54:05 +03004442 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00004443 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004444
4445 mainCtrl.VerifyCounterValues(t)
4446}
4447
4448//-----------------------------------------------------------------------------
4449// TestRESTSubReqAndSubDelNokSameActionParallel
4450//
4451// stub stub stub
4452// +-------+ +-------+ +---------+ +---------+
4453// | xapp2 | | xapp1 | | submgr | | e2term |
4454// +-------+ +-------+ +---------+ +---------+
4455// | | | |
4456// | | | |
4457// | | | |
4458// | | RESTSubReq1 | |
4459// | |---------------->| |
4460// | | | |
4461// | | RESTSubResp1 | |
4462// | |<----------------| |
4463// | | | SubReq1 |
4464// | | |------------->|
4465// | RESTSubReq2 | |
4466// |------------------------------>| |
4467// | | | |
4468// | RESTSubDelResp2 | |
4469// |<------------------------------| |
4470// | | | SubFail1 |
4471// | | |<-------------|
4472// | | | |
4473// | | RESTNotif1 | |
4474// | | unsuccess | |
4475// | |<----------------| |
4476// | RESTNotif2 | |
4477// | | unsuccess | |
4478// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03004479// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02004480// | | RESTSubDelReq1 | | There is no need for xApp to send delete for failed subscriptions but some xApp might do so.
archaggeafbf95f2021-04-14 08:54:05 +03004481// | |---------------->| |
4482// | | | |
4483// | | RESTSubDelResp1 | |
4484// | |<----------------| |
4485// | | | |
4486// | RESTSubDelReq2 | |
4487// |------------------------------>| |
4488// | | | |
4489// | RESTSubDelResp2 | |
4490// |<------------------------------| |
4491//
4492//-----------------------------------------------------------------------------
4493func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
4494 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
4495
4496 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004497 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004498 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004499 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004500 Counter{cSubReqToE2, 1},
4501 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004502 Counter{cRestSubFailNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004503 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004504 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004505 })
4506
4507 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004508
4509 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004510 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004511 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4512 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4513
4514 // Req2
4515 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004516 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004517 params2.SetMeid("RAN_NAME_1")
4518 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4519 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
4520
4521 // E2t: send SubsFail (first)
4522 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4523 fparams1.Set(crereq1)
4524 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4525
archaggeafbf95f2021-04-14 08:54:05 +03004526 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03004527 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004528 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004529 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004530 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004531
4532 // Del1
4533 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4534
4535 // Del2
4536 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4537
4538 //Wait that subs is cleaned
4539 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
4540 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4541
4542 mainCtrl.VerifyCounterValues(t)
4543}
4544
4545func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
4546 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4547
4548 // Init counter check
4549 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004550 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004551 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004552 Counter{cSubReqToE2, 1},
4553 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004554 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004555 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004556 Counter{cSubDelReqToE2, 1},
4557 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004558 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004559 })
4560
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004561 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004562 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004563 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004564
4565 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4566 xappConn1.ExpectRESTNotification(t, restSubId)
4567 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4568 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004569 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004570
4571 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4572 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4573 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4574
4575 // Wait that subs is cleaned
4576 waitSubsCleanup(t, e2SubsId, 10)
4577 mainCtrl.VerifyCounterValues(t)
4578}
4579
4580//-----------------------------------------------------------------------------
4581// TestRESTSubReqPolicyChangeAndSubDelOk
4582//
4583// stub stub
4584// +-------+ +---------+ +---------+
4585// | xapp | | submgr | | e2term |
4586// +-------+ +---------+ +---------+
4587// | | |
4588// | RESTSubReq | |
4589// |---------------->| |
4590// | | |
4591// | RESTSubResp | |
4592// |<----------------| |
4593// | | SubReq |
4594// | |------------->|
4595// | | |
4596// | | SubResp |
4597// | |<-------------|
4598// | | |
4599// | RESTNotif | |
4600// |<----------------| |
4601// | | |
4602// | RESTSubReq | |
4603// |---------------->| |
4604// | | |
4605// | RESTSubResp | |
4606// |<----------------| |
4607// | | SubReq |
4608// | |------------->|
4609// | | |
4610// | | SubResp |
4611// | |<-------------|
4612// | | |
4613// | RESTNotif | |
4614// |<----------------| |
4615// | | |
4616// | RESTSubDelReq | |
4617// |---------------->| |
4618// | | |
4619// | | SubDelReq |
4620// | |------------->|
4621// | | |
4622// | | SubDelResp |
4623// | |<-------------|
4624// | | |
4625// | RESTSubDelResp | |
4626// |<----------------| |
4627//
4628//-----------------------------------------------------------------------------
4629func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
4630 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
4631
4632 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004633 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004634 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004635 Counter{cSubReqToE2, 2},
4636 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004637 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004638 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004639 Counter{cSubDelReqToE2, 1},
4640 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004641 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004642 })
4643
4644 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004645 const e2Timeout int64 = 1
4646 const e2RetryCount int64 = 0
4647 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004648
4649 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004650 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004651 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004652 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4653
4654 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004655 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004656
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004657 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004658 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004659 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004660 params.SetTimeToWait("w200ms")
4661 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
4662
4663 // Del
4664 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4665
4666 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4667 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4668
4669 // Wait that subs is cleaned
4670 waitSubsCleanup(t, e2SubsId, 10)
4671 mainCtrl.VerifyCounterValues(t)
4672}
4673
4674//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004675// TestRESTSubReqPolicyChangeNOk
4676//
4677// stub stub
4678// +-------+ +---------+ +---------+
4679// | xapp | | submgr | | e2term |
4680// +-------+ +---------+ +---------+
4681// | | |
4682// | RESTSubReq | |
4683// |---------------->| |
4684// | | |
4685// | RESTSubResp | |
4686// |<----------------| |
4687// | | SubReq |
4688// | |------------->|
4689// | | |
4690// | | SubResp |
4691// | |<-------------|
4692// | | |
4693// | RESTNotif | |
4694// |<----------------| |
4695// | | |
4696// | RESTSubReq | |
4697// |---------------->| |
4698// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004699// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004700// | | |
4701// | RESTSubDelReq | |
4702// |---------------->| |
4703// | | |
4704// | | SubDelReq |
4705// | |------------->|
4706// | | |
4707// | | SubDelResp |
4708// | |<-------------|
4709// | | |
4710// | RESTSubDelResp | |
4711// |<----------------| |
4712//
4713//-----------------------------------------------------------------------------
4714func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
4715 CaseBegin("TestRESTSubReqPolicyChangeNOk")
4716
4717 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4718 Counter{cRestSubReqFromXapp, 2},
4719 Counter{cRestSubRespToXapp, 1},
4720 Counter{cSubReqToE2, 1},
4721 Counter{cSubRespFromE2, 1},
4722 Counter{cRestSubNotifToXapp, 1},
4723 Counter{cRestSubFailToXapp, 1},
4724 Counter{cRestSubDelReqFromXapp, 1},
4725 Counter{cSubDelReqToE2, 1},
4726 Counter{cSubDelRespFromE2, 1},
4727 Counter{cRestSubDelRespToXapp, 1},
4728 })
4729
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004730 // Req
4731 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4732 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4733
4734 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004735 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
4736
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004737 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00004738 params.SetSubscriptionID(&restSubIdUpd)
4739 params.SetTimeToWait("w200ms")
4740
4741 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
4742 assert.Equal(t, restSubId2, "")
4743
4744 // Del
4745 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4746
4747 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4748 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4749
4750 // Wait that subs is cleaned
4751 waitSubsCleanup(t, e2SubsId, 10)
4752 mainCtrl.VerifyCounterValues(t)
4753}
4754
4755//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004756// TestRESTSubReqAndSubDelOkTwoE2termParallel
4757//
4758// stub stub stub
4759// +-------+ +---------+ +---------+ +---------+
4760// | xapp | | submgr | | e2term1 | | e2term2 |
4761// +-------+ +---------+ +---------+ +---------+
4762// | | | |
4763// | | | |
4764// | | | |
4765// | RESTSubReq1 | | |
4766// |---------------->| | |
4767// | | | |
4768// | RESTSubResp1 | | |
4769// |<----------------| | |
4770// | | SubReq1 | |
4771// | |------------->| |
4772// | | | |
4773// | RESTSubReq2 | | |
4774// |---------------->| | |
4775// | | | |
4776// | RESTSubResp2 | | |
4777// |<----------------| | |
4778// | | SubReq2 | |
4779// | |---------------------------->|
4780// | | | |
4781// | | SubResp1 | |
4782// | |<-------------| |
4783// | RESTNotif1 | | |
4784// |<----------------| | |
4785// | | SubResp2 | |
4786// | |<----------------------------|
4787// | RESTNotif2 | | |
4788// |<----------------| | |
4789// | | | |
4790// | [SUBS 1 DELETE] | |
4791// | | | |
4792// | [SUBS 2 DELETE] | |
4793// | | | |
4794//
4795//-----------------------------------------------------------------------------
4796func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
4797 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
4798
4799 // Init counter check
4800 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004801 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004802 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004803 Counter{cSubReqToE2, 2},
4804 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004805 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004806 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004807 Counter{cSubDelReqToE2, 2},
4808 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004809 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004810 })
4811
4812 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004813
4814 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004815 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004816 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4817 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4818
4819 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004820 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004821 params.SetMeid("RAN_NAME_11")
4822 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
4823 // would not work as notification would not be received
4824 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4825 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
4826
4827 // Resp1
4828 xappConn1.ExpectRESTNotification(t, restSubId1)
4829 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4830 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004831 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004832
4833 // Resp2
4834 xappConn2.ExpectRESTNotification(t, restSubId2)
4835 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
4836 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004837 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004838
4839 // Delete1
4840 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4841 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4842 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4843
4844 // Wait that subs is cleaned
4845 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4846
4847 // Delete2
4848 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
4849 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
4850 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
4851
4852 // Wait that subs is cleaned
4853 waitSubsCleanup(t, e2SubsId2, 10)
4854
4855 mainCtrl.VerifyCounterValues(t)
4856}
4857
4858//-----------------------------------------------------------------------------
4859// TestRESTSubReqAsn1EncodeFail
4860//
4861// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
4862// stub stub
4863// +-------+ +---------+ +---------+
4864// | xapp | | submgr | | e2term |
4865// +-------+ +---------+ +---------+
4866// | | |
4867// | RESTSubReq | |
4868// |---------------->| |
4869// | | |
4870// | RESTSubResp | |
4871// |<----------------| |
4872// | RESTSubDelReq | |
4873// |---------------->| |
4874// | RESTSubDelResp | |
4875// | unsuccess | |
4876// |<----------------| |
4877// | | |
4878//
4879//-----------------------------------------------------------------------------
4880func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
4881 CaseBegin("TestRESTSubReqAsn1EncodeFail")
4882
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004883 xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
archaggeafbf95f2021-04-14 08:54:05 +03004884
4885}
4886
4887//-----------------------------------------------------------------------------
4888// TestRESTSubReqInsertAndSubDelOk
4889//
4890// stub stub
4891// +-------+ +---------+ +---------+
4892// | xapp | | submgr | | e2term |
4893// +-------+ +---------+ +---------+
4894// | | |
4895// | RestSubReq | |
4896// |---------------->| |
4897// | | |
4898// | RESTSubResp | |
4899// |<----------------| |
4900// | | |
4901// | | SubReq |
4902// | |------------->|
4903// | | |
4904// | | SubResp |
4905// | |<-------------|
4906// | RESTNotif | |
4907// |<----------------| |
4908// | ... | ... |
4909// | | |
4910// | RESTSubDelReq | |
4911// |---------------->| |
4912// | | |
4913// | | SubDelReq |
4914// | |------------->|
4915// | | |
4916// | | SubDelResp |
4917// | |<-------------|
4918// | | |
4919// | RESTSubDelResp| |
4920// |<----------------| |
4921//
4922//-----------------------------------------------------------------------------
4923func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
4924 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
4925
4926 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004927 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004928 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004929 Counter{cSubReqToE2, 1},
4930 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004931 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004932 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004933 Counter{cSubDelReqToE2, 1},
4934 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004935 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004936 })
4937
4938 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004939
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004940 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004941 params.SetSubActionTypes("insert")
4942
4943 // Req
4944 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4945
4946 // Del
4947 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4948
4949 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4950 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4951
4952 // Wait that subs is cleaned
4953 waitSubsCleanup(t, e2SubsId, 10)
4954 mainCtrl.VerifyCounterValues(t)
4955}
4956
4957//-----------------------------------------------------------------------------
4958// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
4959//
4960// stub stub
4961// +-------+ +---------+ +---------+
4962// | xapp | | submgr | | e2term |
4963// +-------+ +---------+ +---------+
4964// | | |
4965// | RESTSubReq | |
4966// |------------->| |
4967// | | |
4968// | | SubReq |
4969// | |------------->|
4970// | | |
4971// | | SubResp |
4972// | <----|
4973// | |
4974// | Submgr restart |
4975// | |
4976// | | |
4977// | | SubDelReq |
4978// | |------------->|
4979// | | |
4980// | | SubDelResp |
4981// | |<-------------|
4982// | | |
4983//
4984//-----------------------------------------------------------------------------
4985func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
4986 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
4987
4988 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004989 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004990 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004991 Counter{cSubReqToE2, 1},
4992 Counter{cSubDelReqFromXapp, 1},
4993 Counter{cSubDelReqToE2, 1},
4994 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004995 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004996 })
4997
4998 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004999
5000 // Remove possible existing subscription
5001 mainCtrl.removeExistingSubscriptions(t)
5002
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005003 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005004
5005 //Req
5006 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5007 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005008 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005009
5010 e2termConn1.RecvSubsReq(t)
5011
5012 mainCtrl.SetResetTestFlag(t, false)
5013
5014 mainCtrl.SimulateRestart(t)
5015 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5016
5017 //Del
5018 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5019 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5020
5021 xappConn1.TestMsgChanEmpty(t)
5022 xappConn2.TestMsgChanEmpty(t)
5023 e2termConn1.TestMsgChanEmpty(t)
5024 mainCtrl.wait_registry_empty(t, 10)
5025
5026 mainCtrl.VerifyCounterValues(t)
5027}
5028
5029//-----------------------------------------------------------------------------
5030// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5031//
5032// stub stub
5033// +-------+ +---------+ +---------+
5034// | xapp | | submgr | | e2term |
5035// +-------+ +---------+ +---------+
5036// | | |
5037// | RESTSubReq | |
5038// |---------------->| |
5039// | | |
5040// | RESTSubResp | |
5041// |<----------------| |
5042// | | SubReq |
5043// | |------------->|
5044// | | |
5045// | | SubResp |
5046// | |<-------------|
5047// | | |
5048// | RESTNotif | |
5049// |<----------------| |
5050// | | |
5051// | |
5052// | Submgr restart |
5053// | | |
5054// | RESTSubDelReq | |
5055// |---------------->| |
5056// | | |
5057// | | SubDelReq |
5058// | |------------->|
5059// | | |
5060// | | SubDelResp |
5061// | |<-------------|
5062// | | |
5063// | RESTSubDelResp | |
5064// |<----------------| |
5065//
5066//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005067
archaggeafbf95f2021-04-14 08:54:05 +03005068func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
5069 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
5070
5071 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005072 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005073 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005074 Counter{cSubReqToE2, 1},
5075 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005076 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005077 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005078 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005079 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005080 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005081 })
archaggeafbf95f2021-04-14 08:54:05 +03005082 // Remove possible existing subscription
5083 mainCtrl.removeExistingSubscriptions(t)
5084
5085 var params *teststube2ap.RESTSubsReqParams = nil
5086
5087 // Create subscription
5088 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005089 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005090
5091 // Check subscription
5092 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5093
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005094 mainCtrl.SimulateRestart(t)
5095 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005096
5097 // Check subscription
5098 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5099
5100 // Delete subscription
5101 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5102
5103 //Wait that subs is cleaned
5104 waitSubsCleanup(t, e2SubsId, 10)
5105
5106 mainCtrl.VerifyCounterValues(t)
5107}
5108
5109//-----------------------------------------------------------------------------
5110// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5111//
5112// stub stub
5113// +-------+ +-------+ +---------+ +---------+
5114// | xapp2 | | xapp1 | | submgr | | e2term |
5115// +-------+ +-------+ +---------+ +---------+
5116// | | | |
5117// | | RESTSubReq1 | |
5118// | |---------------->| |
5119// | | | |
5120// | | RESTSubResp1 | |
5121// | |<----------------| |
5122// | | | |
5123// | | | SubReq1 |
5124// | | |------------->|
5125// | | | SubResp1 |
5126// | | |<-------------|
5127// | | RESTNotif1 | |
5128// | |<----------------| |
5129// | | | |
5130// | RESTSubReq2 | |
5131// |------------------------------>| |
5132// | | | |
5133// | RESTSubResp2 | |
5134// |<------------------------------| |
5135// | | | |
5136// | | RESTNotif2 | |
5137// |<------------------------------| |
5138// | | | |
5139// | | Submgr restart |
5140// | | | |
5141// | | RESTSubDelReq1 | |
5142// | |---------------->| |
5143// | | | |
5144// | | RESTSubDelResp1 | |
5145// | |<----------------| |
5146// | | | |
5147// | | Submgr restart |
5148// | | | |
5149// | RESTSubDelReq2 | |
5150// |------------------------------>| |
5151// | | | |
5152// | RESTSubDelResp2 | |
5153// |<------------------------------| |
5154// | | | |
5155// | | | SubDelReq2 |
5156// | | |------------->|
5157// | | | |
5158// | | | SubDelResp2 |
5159// | | |<-------------|
5160// | | | |
5161//
5162//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005163
archaggeafbf95f2021-04-14 08:54:05 +03005164func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
5165 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
5166
5167 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005168 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005169 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005170 Counter{cSubReqToE2, 1},
5171 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005172 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005173 Counter{cMergedSubscriptions, 1},
5174 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005175 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005176 Counter{cSubDelReqToE2, 1},
5177 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005178 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005179 })
5180
5181 // Remove possible existing subscription
5182 mainCtrl.removeExistingSubscriptions(t)
5183
5184 var params *teststube2ap.RESTSubsReqParams = nil
5185
5186 // Create subscription 1
5187 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005188 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005189
5190 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005191 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005192 params.SetMeid("RAN_NAME_1")
5193 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005194 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005195 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005196 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005197 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005198 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005199
5200 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5201
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005202 mainCtrl.SimulateRestart(t)
5203 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005204
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005205 // Delete subscription 1, and wait until it has removed the first endpoint
5206 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005207 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005208 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005209
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005210 mainCtrl.SimulateRestart(t)
5211 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005212 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5213
5214 // Delete subscription 2
5215 deleteXapp2Subscription(t, &restSubId2)
5216
5217 //Wait that subs is cleaned
5218 waitSubsCleanup(t, e2SubsId2, 10)
5219
5220 mainCtrl.VerifyCounterValues(t)
5221}
5222
5223//-----------------------------------------------------------------------------
5224// TestRESTReportSubReqAndSubDelOk
5225//
5226// stub stub
5227// +-------+ +---------+ +---------+
5228// | xapp | | submgr | | e2term |
5229// +-------+ +---------+ +---------+
5230// | | |
5231// | RestSubReq | |
5232// |---------------->| |
5233// | | |
5234// | RESTSubResp | |
5235// |<----------------| |
5236// | | |
5237// | | SubReq |
5238// | |------------->|
5239// | | |
5240// | | SubResp |
5241// | |<-------------|
5242// | RESTNotif | |
5243// |<----------------| |
5244// | | SubReq |
5245// | |------------->|
5246// | | |
5247// | | SubResp |
5248// | |<-------------|
5249// | RESTNotif | |
5250// |<----------------| |
5251// | ... | ... |
5252// | | |
5253// | | |
5254// | RESTSubDelReq | |
5255// |---------------->| |
5256// | | |
5257// | | SubDelReq |
5258// | |------------->|
5259// | | |
5260// | | SubDelResp |
5261// | |<-------------|
5262// | | |
5263// | RESTSubDelResp| |
5264// |<----------------| |
5265//
5266//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005267
archaggeafbf95f2021-04-14 08:54:05 +03005268func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
5269 CaseBegin("TestRESTReportSubReqAndSubDelOk")
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005270 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005271 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005272 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005273}
5274
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005275func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005276 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005277
5278 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005279 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005280 restSubId := xappConn1.SendRESTSubsReq(t, params)
5281
5282 var e2SubsId []uint32
5283 for i := 0; i < subReqCount; i++ {
5284 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5285 xappConn1.ExpectRESTNotification(t, restSubId)
5286
5287 e2termConn1.SendSubsResp(t, crereq, cremsg)
5288 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005289 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005290 e2SubsId = append(e2SubsId, instanceId)
5291 resp, _ := xapp.Subscription.QuerySubscriptions()
5292 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5293 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5294 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5295
5296 }
5297
5298 // Del
5299 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5300
5301 for i := 0; i < subReqCount; i++ {
5302 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5303 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5304 }
5305
5306 // Wait that subs is cleaned
5307 for i := 0; i < subReqCount; i++ {
5308 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5309 }
5310
5311 xappConn1.TestMsgChanEmpty(t)
5312 e2termConn1.TestMsgChanEmpty(t)
5313 mainCtrl.wait_registry_empty(t, 10)
5314}
5315
5316/*
5317func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
5318 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
5319
5320 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005321 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005322 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005323
5324 subReqCount = 19
archaggeafbf95f2021-04-14 08:54:05 +03005325 testIndex = 2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005326 RESTPolicySubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005327}
5328*/
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005329func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005330 xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005331
5332 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005333 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005334 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03005335
5336 var e2SubsId []uint32
5337 for i := 0; i < subReqCount; i++ {
5338 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5339 xappConn1.ExpectRESTNotification(t, restSubId)
5340 e2termConn1.SendSubsResp(t, crereq, cremsg)
5341 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005342 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005343 e2SubsId = append(e2SubsId, instanceId)
5344 }
5345
5346 // Del
5347 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5348
5349 for i := 0; i < subReqCount; i++ {
5350 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5351 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5352 }
5353
5354 // Wait that subs is cleaned
5355 for i := 0; i < subReqCount; i++ {
5356 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
5357 }
5358 xappConn1.TestMsgChanEmpty(t)
5359 e2termConn1.TestMsgChanEmpty(t)
5360 mainCtrl.wait_registry_empty(t, 10)
5361}
5362
archaggeafbf95f2021-04-14 08:54:05 +03005363func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
5364
archaggeafbf95f2021-04-14 08:54:05 +03005365 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005366 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005367 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005368 Counter{cSubReqToE2, 2},
5369 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005370 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005371 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005372 Counter{cSubDelReqToE2, 2},
5373 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005374 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005375 })
5376
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005377 const subReqCount int = 2
5378
archaggeafbf95f2021-04-14 08:54:05 +03005379 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005380 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005381 restSubId := xappConn1.SendRESTSubsReq(t, params)
5382 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5383
5384 assert.Equal(t, len(e2SubsIds), 2)
5385
5386 // Del
5387 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5388 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5389
5390 xappConn1.TestMsgChanEmpty(t)
5391 e2termConn1.TestMsgChanEmpty(t)
5392 mainCtrl.wait_registry_empty(t, 10)
5393
5394 mainCtrl.VerifyCounterValues(t)
5395}
archaggeafbf95f2021-04-14 08:54:05 +03005396func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
5397
archaggeafbf95f2021-04-14 08:54:05 +03005398 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005399 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005400 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005401 Counter{cSubReqToE2, 19},
5402 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005403 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005404 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005405 Counter{cSubDelReqToE2, 19},
5406 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005407 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005408 })
5409
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005410 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03005411 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005412 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005413 restSubId := xappConn1.SendRESTSubsReq(t, params)
5414 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5415
5416 assert.Equal(t, len(e2SubsIds), 19)
5417
5418 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5419 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5420
5421 xappConn1.TestMsgChanEmpty(t)
5422 e2termConn1.TestMsgChanEmpty(t)
5423 mainCtrl.wait_registry_empty(t, 10)
5424
5425 mainCtrl.VerifyCounterValues(t)
5426}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005427
archaggeafbf95f2021-04-14 08:54:05 +03005428func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
5429
5430 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005431
5432 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005433 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005434 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005435 Counter{cSubReqToE2, uint64(subReqCount)},
5436 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005437 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005438 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005439 Counter{cSubDelReqToE2, uint64(subReqCount)},
5440 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005441 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005442 })
5443
5444 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005445 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005446 restSubId := xappConn1.SendRESTSubsReq(t, params)
5447 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5448
5449 assert.Equal(t, len(e2SubsIds), subReqCount)
5450
5451 // Del
5452 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5453 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5454
5455 xappConn1.TestMsgChanEmpty(t)
5456 e2termConn1.TestMsgChanEmpty(t)
5457 mainCtrl.wait_registry_empty(t, 10)
5458
5459 mainCtrl.VerifyCounterValues(t)
5460}
Markku Virtanenda34eec2021-05-20 08:22:04 +00005461
archaggeafbf95f2021-04-14 08:54:05 +03005462func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
5463
5464 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03005465
5466 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005467 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005468 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005469 Counter{cSubReqToE2, uint64(subReqCount)},
5470 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005471 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005472 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005473 Counter{cSubDelReqToE2, uint64(subReqCount)},
5474 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005475 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005476 })
5477
5478 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005479 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005480 restSubId := xappConn1.SendRESTSubsReq(t, params)
5481 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5482
5483 assert.Equal(t, len(e2SubsIds), subReqCount)
5484
5485 // Del
5486 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5487 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5488
5489 xappConn1.TestMsgChanEmpty(t)
5490 e2termConn1.TestMsgChanEmpty(t)
5491 mainCtrl.wait_registry_empty(t, 10)
5492
5493 mainCtrl.VerifyCounterValues(t)
5494}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005495
archaggeafbf95f2021-04-14 08:54:05 +03005496func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
5497
5498 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03005499
5500 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005501 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005502 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005503 Counter{cSubReqToE2, uint64(subReqCount)},
5504 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005505 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005506 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005507 Counter{cSubDelReqToE2, uint64(subReqCount)},
5508 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005509 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005510 })
5511
5512 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005513 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005514 restSubId := xappConn1.SendRESTSubsReq(t, params)
5515 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
5516
5517 assert.Equal(t, len(e2SubsIds), subReqCount)
5518
5519 // Del
5520 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5521 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
5522
5523 xappConn1.TestMsgChanEmpty(t)
5524 e2termConn1.TestMsgChanEmpty(t)
5525 mainCtrl.wait_registry_empty(t, 10)
5526
5527 mainCtrl.VerifyCounterValues(t)
5528}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005529
5530func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
5531 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
5532
5533 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005534 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005535 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005536 Counter{cSubReqToE2, 2},
5537 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005538 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005539 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005540 Counter{cSubDelReqToE2, 2},
5541 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005542 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005543 })
5544
5545 // Req1
5546 var params *teststube2ap.RESTSubsReqParams = nil
5547
5548 //Subs Create
5549 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005550 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005551
5552 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5553
5554 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005555 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005556 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005557 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005558 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
5559
5560 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005561 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005562 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5563 xappConn2.ExpectRESTNotification(t, restSubId2)
5564 e2termConn1.SendSubsResp(t, crereq, cremsg)
5565 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5566
5567 deleteXapp1Subscription(t, &restSubId1)
5568 deleteXapp2Subscription(t, &restSubId2)
5569
5570 waitSubsCleanup(t, e2SubsId1, 10)
5571 waitSubsCleanup(t, e2SubsId2, 10)
5572
5573 mainCtrl.VerifyCounterValues(t)
5574
5575}
5576
5577func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
5578 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
5579
5580 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005581 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005582 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005583 Counter{cSubReqToE2, 2},
5584 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005585 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005586 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005587 Counter{cSubDelReqToE2, 2},
5588 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005589 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005590 })
5591
5592 // Req1
5593 var params *teststube2ap.RESTSubsReqParams = nil
5594
5595 //Subs Create
5596 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005597 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005598
5599 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5600
5601 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005602 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005603 params.SetMeid("RAN_NAME_1")
5604
5605 actionId := int64(1)
5606 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005607 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005608 subsequestActionType := "continue"
5609 timeToWait := "w10ms"
5610 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
5611
5612 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005613 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005614 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5615 xappConn2.ExpectRESTNotification(t, restSubId2)
5616 e2termConn1.SendSubsResp(t, crereq, cremsg)
5617 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5618
5619 deleteXapp1Subscription(t, &restSubId1)
5620 deleteXapp2Subscription(t, &restSubId2)
5621
5622 waitSubsCleanup(t, e2SubsId1, 10)
5623 waitSubsCleanup(t, e2SubsId2, 10)
5624
5625 mainCtrl.VerifyCounterValues(t)
5626
5627}
5628
5629func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
5630 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
5631
5632 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005633 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005634 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005635 Counter{cSubReqToE2, 2},
5636 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005637 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005638 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005639 Counter{cSubDelReqToE2, 2},
5640 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005641 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005642 })
5643
5644 // Req1
5645 var params *teststube2ap.RESTSubsReqParams = nil
5646
5647 //Subs Create
5648 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005649 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005650
5651 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5652
5653 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005654 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005655 params.SetMeid("RAN_NAME_1")
5656 params.SetSubActionIDs(int64(2))
5657
5658 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005659 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005660 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5661 xappConn2.ExpectRESTNotification(t, restSubId2)
5662 e2termConn1.SendSubsResp(t, crereq, cremsg)
5663 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5664
5665 deleteXapp1Subscription(t, &restSubId1)
5666 deleteXapp2Subscription(t, &restSubId2)
5667
5668 waitSubsCleanup(t, e2SubsId1, 10)
5669 waitSubsCleanup(t, e2SubsId2, 10)
5670
5671 mainCtrl.VerifyCounterValues(t)
5672
5673}
5674
5675func TestRESTSubReqDiffActionType(t *testing.T) {
5676 CaseBegin("TestRESTSubReqDiffActionType")
5677
5678 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005679 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005680 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005681 Counter{cSubReqToE2, 2},
5682 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005683 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005684 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005685 Counter{cSubDelReqToE2, 2},
5686 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005687 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005688 })
5689
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005690 const e2Timeout int64 = 2
5691 const e2RetryCount int64 = 2
5692 const routingNeeded bool = true
5693
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005694 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005695 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005696 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005697
5698 //Subs Create
5699 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005700 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005701
5702 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5703
5704 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005705 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005706 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005707 params.SetMeid("RAN_NAME_1")
5708
5709 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005710 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005711 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5712 xappConn2.ExpectRESTNotification(t, restSubId2)
5713 e2termConn1.SendSubsResp(t, crereq, cremsg)
5714 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5715
5716 deleteXapp1Subscription(t, &restSubId1)
5717 deleteXapp2Subscription(t, &restSubId2)
5718
5719 waitSubsCleanup(t, e2SubsId1, 10)
5720 waitSubsCleanup(t, e2SubsId2, 10)
5721
5722 mainCtrl.VerifyCounterValues(t)
5723
5724}
5725
5726func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
5727 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
5728
5729 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005730 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005731 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005732 Counter{cSubReqToE2, 2},
5733 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005734 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005735 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005736 Counter{cSubDelReqToE2, 2},
5737 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005738 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005739 })
5740
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005741 const e2Timeout int64 = 2
5742 const e2RetryCount int64 = 2
5743 const routingNeeded bool = true
5744
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005745 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005746 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005747 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005748
5749 //Subs Create
5750 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005751 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005752
5753 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5754
5755 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005756 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005757 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005758 params.SetMeid("RAN_NAME_1")
5759
5760 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005761 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005762 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5763 xappConn2.ExpectRESTNotification(t, restSubId2)
5764 e2termConn1.SendSubsResp(t, crereq, cremsg)
5765 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5766
5767 deleteXapp1Subscription(t, &restSubId1)
5768 deleteXapp2Subscription(t, &restSubId2)
5769
5770 waitSubsCleanup(t, e2SubsId1, 10)
5771 waitSubsCleanup(t, e2SubsId2, 10)
5772
5773 mainCtrl.VerifyCounterValues(t)
5774
5775}
5776
5777func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
5778 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
5779
5780 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005781 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005782 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005783 Counter{cSubReqToE2, 2},
5784 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005785 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005786 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005787 Counter{cSubDelReqToE2, 2},
5788 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005789 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005790 })
5791
5792 // Req1
5793 var params *teststube2ap.RESTSubsReqParams = nil
5794
5795 //Subs Create
5796 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005797 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005798
5799 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5800
5801 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005802 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005803 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005804 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005805 params.SetSubActionDefinition(actionDefinition)
5806
5807 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005808 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005809 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5810 xappConn2.ExpectRESTNotification(t, restSubId2)
5811 e2termConn1.SendSubsResp(t, crereq, cremsg)
5812 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5813
5814 deleteXapp1Subscription(t, &restSubId1)
5815 deleteXapp2Subscription(t, &restSubId2)
5816
5817 waitSubsCleanup(t, e2SubsId1, 10)
5818 waitSubsCleanup(t, e2SubsId2, 10)
5819
5820 mainCtrl.VerifyCounterValues(t)
5821
5822}
5823
5824func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
5825 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
5826
5827 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005828 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005829 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005830 Counter{cSubReqToE2, 2},
5831 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005832 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005833 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005834 Counter{cSubDelReqToE2, 2},
5835 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005836 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005837 })
5838
5839 // Req1
5840 var params *teststube2ap.RESTSubsReqParams = nil
5841
5842 //Subs Create
5843 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005844 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005845
5846 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5847
5848 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005849 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005850 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00005851 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005852 params.SetSubActionDefinition(actionDefinition)
5853
5854 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005855 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005856 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5857 xappConn2.ExpectRESTNotification(t, restSubId2)
5858 e2termConn1.SendSubsResp(t, crereq, cremsg)
5859 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5860
5861 deleteXapp1Subscription(t, &restSubId1)
5862 deleteXapp2Subscription(t, &restSubId2)
5863
5864 waitSubsCleanup(t, e2SubsId1, 10)
5865 waitSubsCleanup(t, e2SubsId2, 10)
5866
5867 mainCtrl.VerifyCounterValues(t)
5868
5869}
5870
5871func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
5872 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
5873
5874 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005875 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005876 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005877 Counter{cSubReqToE2, 2},
5878 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005879 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005880 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005881 Counter{cSubDelReqToE2, 2},
5882 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005883 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005884 })
5885
5886 // Req1
5887 var params *teststube2ap.RESTSubsReqParams = nil
5888
5889 //Subs Create
5890 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005891 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005892
5893 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
5894
5895 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005896 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005897 params.SetMeid("RAN_NAME_1")
5898 params.SetTimeToWait("w200ms")
5899 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005900 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00005901 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5902 xappConn2.ExpectRESTNotification(t, restSubId2)
5903 e2termConn1.SendSubsResp(t, crereq, cremsg)
5904 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
5905
5906 deleteXapp1Subscription(t, &restSubId1)
5907 deleteXapp2Subscription(t, &restSubId2)
5908
5909 waitSubsCleanup(t, e2SubsId1, 10)
5910 waitSubsCleanup(t, e2SubsId2, 10)
5911
5912 mainCtrl.VerifyCounterValues(t)
5913
5914}
5915
Anssi Mannila51122392021-05-25 11:51:31 +03005916//-----------------------------------------------------------------------------
5917// TestRESTUnpackSubscriptionResponseDecodeFail
5918//
5919// stub stub
5920// +-------+ +---------+ +---------+
5921// | xapp | | submgr | | e2term |
5922// +-------+ +---------+ +---------+
5923// | | |
5924// | RestSubReq | |
5925// |---------------->| |
5926// | | |
5927// | RESTSubResp | |
5928// |<----------------| |
5929// | | |
5930// | | SubReq |
5931// | |------------->|
5932// | | |
5933// | | SubResp | ASN.1 decode fails
5934// | |<-------------|
5935// | | |
5936// | | SubReq |
5937// | |------------->|
5938// | | |
5939// | | SubFail | Duplicated action
5940// | |<-------------|
5941// | RESTNotif (fail)| |
5942// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03005943// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03005944//
5945//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005946
Anssi Mannila51122392021-05-25 11:51:31 +03005947func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005948 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
5949 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03005950
5951 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005952 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03005953 restSubId := xappConn1.SendRESTSubsReq(t, params)
5954
5955 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5956 // Decode of this response fails which will result resending original request
5957 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
5958
5959 _, cremsg = e2termConn1.RecvSubsReq(t)
5960
Markku Virtanen55d2a282021-06-04 14:46:56 +03005961 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03005962
5963 // Subscription already created in E2 Node.
5964 fparams := &teststube2ap.E2StubSubsFailParams{}
5965 fparams.Set(crereq)
5966 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5967 e2termConn1.SendSubsFail(t, fparams, cremsg)
5968
Anssi Mannila51122392021-05-25 11:51:31 +03005969 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005970 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03005971
5972 // Wait that subs is cleaned
5973 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5974
5975 xappConn1.TestMsgChanEmpty(t)
5976 e2termConn1.TestMsgChanEmpty(t)
5977 mainCtrl.wait_registry_empty(t, 10)
5978}
5979
5980//-----------------------------------------------------------------------------
5981// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5982//
5983// stub stub
5984// +-------+ +---------+ +---------+
5985// | xapp | | submgr | | e2term |
5986// +-------+ +---------+ +---------+
5987// | | |
5988// | RestSubReq | |
5989// |---------------->| |
5990// | | |
5991// | RESTSubResp | |
5992// |<----------------| |
5993// | | |
5994// | | SubReq |
5995// | |------------->|
5996// | | |
5997// | | SubResp | Unknown instanceId
5998// | |<-------------|
5999// | | |
6000// | | SubReq |
6001// | |------------->|
6002// | | |
6003// | | SubFail | Duplicated action
6004// | |<-------------|
6005// | RESTNotif (fail)| |
6006// |<----------------| |
6007// | | SubDelReq |
6008// | |------------->|
6009// | | |
6010// | | SubDelResp |
6011// | |<-------------|
6012//
6013//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00006014
Anssi Mannila51122392021-05-25 11:51:31 +03006015func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006016 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
6017 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006018
6019 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006020 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006021 restSubId := xappConn1.SendRESTSubsReq(t, params)
6022
6023 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6024
6025 // Unknown instanceId in this response which will result resending original request
6026 orgInstanceId := crereq.RequestId.InstanceId
6027 crereq.RequestId.InstanceId = 0
6028 e2termConn1.SendSubsResp(t, crereq, cremsg)
6029
6030 _, cremsg = e2termConn1.RecvSubsReq(t)
6031
Markku Virtanen55d2a282021-06-04 14:46:56 +03006032 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006033
6034 // Subscription already created in E2 Node.
6035 fparams := &teststube2ap.E2StubSubsFailParams{}
6036 fparams.Set(crereq)
6037 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6038 e2termConn1.SendSubsFail(t, fparams, cremsg)
6039
6040 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6041 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6042
6043 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006044 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006045
6046 // Wait that subs is cleaned
6047 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
6048
6049 xappConn1.TestMsgChanEmpty(t)
6050 e2termConn1.TestMsgChanEmpty(t)
6051 mainCtrl.wait_registry_empty(t, 10)
6052}
6053
6054//-----------------------------------------------------------------------------
6055// TestRESTUnpackSubscriptionResponseNoTransaction
6056//
6057// stub stub
6058// +-------+ +---------+ +---------+
6059// | xapp | | submgr | | e2term |
6060// +-------+ +---------+ +---------+
6061// | | |
6062// | RestSubReq | |
6063// |---------------->| |
6064// | | |
6065// | RESTSubResp | |
6066// |<----------------| |
6067// | | |
6068// | | SubReq |
6069// | |------------->|
6070// | | |
6071// | | SubResp | No transaction for the response
6072// | |<-------------|
6073// | | |
6074// | | SubReq |
6075// | |------------->|
6076// | | |
6077// | | SubFail | Duplicated action
6078// | |<-------------|
6079// | RESTNotif (fail)| |
6080// |<----------------| |
6081// | | SubDelReq |
6082// | |------------->|
6083// | | |
6084// | | SubDelResp |
6085// | |<-------------|
6086// | | |
6087// | | SubDelReq |
6088// | |------------->|
6089// | | |
6090// | | SubDelResp |
6091// | |<-------------|
6092//
6093//-----------------------------------------------------------------------------
6094func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006095 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
6096 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006097
6098 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006099 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006100 restSubId := xappConn1.SendRESTSubsReq(t, params)
6101
6102 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6103
6104 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6105 // No transaction exist for this response which will result resending original request
6106 e2termConn1.SendSubsResp(t, crereq, cremsg)
6107
6108 _, cremsg = e2termConn1.RecvSubsReq(t)
6109
Markku Virtanen55d2a282021-06-04 14:46:56 +03006110 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006111
6112 // Subscription already created in E2 Node.
6113 fparams := &teststube2ap.E2StubSubsFailParams{}
6114 fparams.Set(crereq)
6115 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6116 e2termConn1.SendSubsFail(t, fparams, cremsg)
6117
6118 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6119 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6120
6121 // Resending happens because there no transaction
6122 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6123 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6124
6125 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006126 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006127
6128 // Wait that subs is cleaned
6129 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6130
6131 xappConn1.TestMsgChanEmpty(t)
6132 e2termConn1.TestMsgChanEmpty(t)
6133 mainCtrl.wait_registry_empty(t, 10)
6134
6135}
6136
6137//-----------------------------------------------------------------------------
6138// TestRESTUnpackSubscriptionFailureDecodeFail
6139//
6140// stub stub
6141// +-------+ +---------+ +---------+
6142// | xapp | | submgr | | e2term |
6143// +-------+ +---------+ +---------+
6144// | | |
6145// | RestSubReq | |
6146// |---------------->| |
6147// | | |
6148// | RESTSubResp | |
6149// |<----------------| |
6150// | | |
6151// | | SubReq |
6152// | |------------->|
6153// | | |
6154// | | SubFail | ASN.1 decode fails
6155// | |<-------------|
6156// | | |
6157// | | SubReq |
6158// | |------------->|
6159// | | |
6160// | | SubFail | Duplicated action
6161// | |<-------------|
6162// | RESTNotif (fail)| |
6163// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03006164// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03006165//
6166//-----------------------------------------------------------------------------
6167func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006168 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
6169 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006170
6171 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006172 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006173 restSubId := xappConn1.SendRESTSubsReq(t, params)
6174
6175 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6176
6177 // Decode of this response fails which will result resending original request
6178 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
6179
6180 _, cremsg = e2termConn1.RecvSubsReq(t)
6181
Markku Virtanen55d2a282021-06-04 14:46:56 +03006182 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006183
6184 // Subscription already created in E2 Node.
6185 fparams := &teststube2ap.E2StubSubsFailParams{}
6186 fparams.Set(crereq)
6187 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6188 e2termConn1.SendSubsFail(t, fparams, cremsg)
6189
Anssi Mannila51122392021-05-25 11:51:31 +03006190 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006191 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006192
6193 // Wait that subs is cleaned
6194 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6195
6196 xappConn1.TestMsgChanEmpty(t)
6197 e2termConn1.TestMsgChanEmpty(t)
6198 mainCtrl.wait_registry_empty(t, 10)
6199}
6200
6201//-----------------------------------------------------------------------------
6202// TestRESTUnpackSubscriptionResponseUnknownInstanceId
6203//
6204// stub stub
6205// +-------+ +---------+ +---------+
6206// | xapp | | submgr | | e2term |
6207// +-------+ +---------+ +---------+
6208// | | |
6209// | RestSubReq | |
6210// |---------------->| |
6211// | | |
6212// | RESTSubResp | |
6213// |<----------------| |
6214// | | |
6215// | | SubReq |
6216// | |------------->|
6217// | | |
6218// | | SubFail | Unknown instanceId
6219// | |<-------------|
6220// | | |
6221// | | SubReq |
6222// | |------------->|
6223// | | |
6224// | | SubFail | Duplicated action
6225// | |<-------------|
6226// | RESTNotif (fail)| |
6227// |<----------------| |
6228// | | SubDelReq |
6229// | |------------->|
6230// | | |
6231// | | SubDelResp |
6232// | |<-------------|
6233//
6234//-----------------------------------------------------------------------------
6235func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006236 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
6237 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006238
6239 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006240 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006241 restSubId := xappConn1.SendRESTSubsReq(t, params)
6242
6243 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6244
6245 // Unknown instanceId in this response which will result resending original request
6246 fparams := &teststube2ap.E2StubSubsFailParams{}
6247 fparams.Set(crereq)
6248 fparams.Fail.RequestId.InstanceId = 0
6249 e2termConn1.SendSubsFail(t, fparams, cremsg)
6250
6251 _, cremsg = e2termConn1.RecvSubsReq(t)
6252
Markku Virtanen55d2a282021-06-04 14:46:56 +03006253 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006254
6255 // Subscription already created in E2 Node.
6256 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6257 e2termConn1.SendSubsFail(t, fparams, cremsg)
6258
6259 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6260 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6261
6262 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006263 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006264
6265 // Wait that subs is cleaned
6266 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6267
6268 xappConn1.TestMsgChanEmpty(t)
6269 e2termConn1.TestMsgChanEmpty(t)
6270 mainCtrl.wait_registry_empty(t, 10)
6271}
6272
6273//-----------------------------------------------------------------------------
6274// TestRESTUnpackSubscriptionFailureNoTransaction
6275//
6276// stub stub
6277// +-------+ +---------+ +---------+
6278// | xapp | | submgr | | e2term |
6279// +-------+ +---------+ +---------+
6280// | | |
6281// | RestSubReq | |
6282// |---------------->| |
6283// | | |
6284// | RESTSubResp | |
6285// |<----------------| |
6286// | | |
6287// | | SubReq |
6288// | |------------->|
6289// | | |
6290// | | SubFail | No transaction for the response
6291// | |<-------------|
6292// | | |
6293// | | SubReq |
6294// | |------------->|
6295// | | |
6296// | | SubFail | Duplicated action
6297// | |<-------------|
6298// | RESTNotif (fail)| |
6299// |<----------------| |
6300// | | SubDelReq |
6301// | |------------->|
6302// | | |
6303// | | SubDelResp |
6304// | |<-------------|
6305//
6306//-----------------------------------------------------------------------------
6307func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006308 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
6309 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03006310
6311 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006312 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03006313 restSubId := xappConn1.SendRESTSubsReq(t, params)
6314
6315 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6316
6317 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
6318
6319 // No transaction exist for this response which will result resending original request
6320 fparams := &teststube2ap.E2StubSubsFailParams{}
6321 fparams.Set(crereq)
6322 e2termConn1.SendSubsFail(t, fparams, cremsg)
6323
6324 _, cremsg = e2termConn1.RecvSubsReq(t)
6325
Markku Virtanen55d2a282021-06-04 14:46:56 +03006326 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006327
6328 // Subscription already created in E2 Node.
6329 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
6330 e2termConn1.SendSubsFail(t, fparams, cremsg)
6331
6332 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6333 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6334
6335 // Resending happens because there no transaction
6336 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6337 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6338
6339 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006340 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03006341
6342 // Wait that subs is cleaned
6343 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
6344
6345 xappConn1.TestMsgChanEmpty(t)
6346 e2termConn1.TestMsgChanEmpty(t)
6347 mainCtrl.wait_registry_empty(t, 10)
6348}
6349
6350//-----------------------------------------------------------------------------
6351// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
6352//
6353// stub stub
6354// +-------+ +---------+ +---------+
6355// | xapp | | submgr | | e2term |
6356// +-------+ +---------+ +---------+
6357// | | |
6358// | [SUBS CREATE] |
6359// | | |
6360// | | |
6361// | RESTSubDelReq | |
6362// |---------------->| |
6363// | | |
6364// | RESTSubDelResp | |
6365// |<----------------| |
6366// | | |
6367// | | SubDelReq |
6368// | |------------->|
6369// | | |
6370// | | SubDelResp | ASN.1 decode fails
6371// | |<-------------|
6372// | | |
6373// | | SubDelReq |
6374// | |------------->|
6375// | | |
6376// | | SubDelFail | Subscription does exist any more
6377// | |<-------------|
6378// | | |
6379//
6380//-----------------------------------------------------------------------------
6381func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006382 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006383
6384 // Req
6385 var params *teststube2ap.RESTSubsReqParams = nil
6386 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6387
6388 // Del
6389 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6390
6391 // E2t: Receive 1st SubsDelReq
6392 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6393
6394 // Decode of this response fails which will result resending original request
6395 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
6396
6397 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6398 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6399
6400 // Subscription does not exist in in E2 Node.
6401 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6402
6403 // Wait that subs is cleaned
6404 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6405
6406 xappConn1.TestMsgChanEmpty(t)
6407 e2termConn1.TestMsgChanEmpty(t)
6408 mainCtrl.wait_registry_empty(t, 10)
6409}
6410
6411//-----------------------------------------------------------------------------
6412// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
6413//
6414// stub stub
6415// +-------+ +---------+ +---------+
6416// | xapp | | submgr | | e2term |
6417// +-------+ +---------+ +---------+
6418// | | |
6419// | [SUBS CREATE] |
6420// | | |
6421// | | |
6422// | RESTSubDelReq | |
6423// |---------------->| |
6424// | | |
6425// | RESTSubDelResp | |
6426// |<----------------| |
6427// | | |
6428// | | SubDelReq |
6429// | |------------->|
6430// | | |
6431// | | SubDelResp | Unknown instanceId
6432// | |<-------------|
6433// | | |
6434// | | SubDelReq |
6435// | |------------->|
6436// | | |
6437// | | SubDelFail | Subscription does exist any more
6438// | |<-------------|
6439//
6440//-----------------------------------------------------------------------------
6441func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006442 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006443
6444 // Req
6445 var params *teststube2ap.RESTSubsReqParams = nil
6446 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6447
6448 // Del
6449 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6450
6451 // E2t: Receive 1st SubsDelReq
6452 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6453
6454 // Unknown instanceId in this response which will result resending original request
6455 delreq.RequestId.InstanceId = 0
6456 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6457
6458 // E2t: Receive 2nd SubsDelReq
6459 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6460
6461 // Subscription does not exist in in E2 Node.
6462 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6463
6464 // Wait that subs is cleaned
6465 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6466
6467 xappConn1.TestMsgChanEmpty(t)
6468 e2termConn1.TestMsgChanEmpty(t)
6469 mainCtrl.wait_registry_empty(t, 10)
6470}
6471
6472//-----------------------------------------------------------------------------
6473// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
6474//
6475// stub stub
6476// +-------+ +---------+ +---------+
6477// | xapp | | submgr | | e2term |
6478// +-------+ +---------+ +---------+
6479// | | |
6480// | [SUBS CREATE] |
6481// | | |
6482// | | |
6483// | RESTSubDelReq | |
6484// |---------------->| |
6485// | | |
6486// | RESTSubDelResp | |
6487// |<----------------| |
6488// | | |
6489// | | SubDelReq |
6490// | |------------->|
6491// | | |
6492// | | SubDelResp | No transaction for the response
6493// | |<-------------|
6494// | | |
6495// | | SubDelReq |
6496// | |------------->|
6497// | | |
6498// | | SubDelFail | Subscription does exist any more
6499// | |<-------------|
6500//
6501//-----------------------------------------------------------------------------
6502func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006503 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006504
6505 // Req
6506 var params *teststube2ap.RESTSubsReqParams = nil
6507 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6508
6509 // Del
6510 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6511
6512 // E2t: Receive 1st SubsDelReq
6513 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6514
6515 mainCtrl.MakeTransactionNil(t, e2SubsId)
6516
6517 // No transaction exist for this response which will result resending original request
6518 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6519
6520 // E2t: Receive 2nd SubsDelReq
6521 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6522
6523 // Subscription does not exist in in E2 Node.
6524 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6525
6526 // Wait that subs is cleaned
6527 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6528
6529 xappConn1.TestMsgChanEmpty(t)
6530 e2termConn1.TestMsgChanEmpty(t)
6531 mainCtrl.wait_registry_empty(t, 10)
6532}
6533
6534//-----------------------------------------------------------------------------
6535// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
6536//
6537// stub stub
6538// +-------+ +---------+ +---------+
6539// | xapp | | submgr | | e2term |
6540// +-------+ +---------+ +---------+
6541// | | |
6542// | [SUBS CREATE] |
6543// | | |
6544// | | |
6545// | RESTSubDelReq | |
6546// |---------------->| |
6547// | | |
6548// | RESTSubDelResp | |
6549// |<----------------| |
6550// | | |
6551// | | SubDelReq |
6552// | |------------->|
6553// | | |
6554// | | SubDelFail | ASN.1 decode fails
6555// | |<-------------|
6556// | | |
6557// | | SubDelReq |
6558// | |------------->|
6559// | | |
6560// | | SubDelFail | Subscription does exist any more
6561// | |<-------------|
6562//
6563//-----------------------------------------------------------------------------
6564func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006565 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
Anssi Mannila51122392021-05-25 11:51:31 +03006566
6567 // Req
6568 var params *teststube2ap.RESTSubsReqParams = nil
6569 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6570
6571 // Del
6572 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6573
6574 // E2t: Receive 1st SubsDelReq
6575 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6576
6577 // Decode of this response fails which will result resending original request
6578 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
6579
6580 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
6581 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6582
6583 // Subscription does not exist in in E2 Node.
6584 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6585
6586 // Wait that subs is cleaned
6587 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6588
6589 xappConn1.TestMsgChanEmpty(t)
6590 e2termConn1.TestMsgChanEmpty(t)
6591 mainCtrl.wait_registry_empty(t, 10)
6592}
6593
6594//-----------------------------------------------------------------------------
6595// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
6596//
6597// stub stub
6598// +-------+ +---------+ +---------+
6599// | xapp | | submgr | | e2term |
6600// +-------+ +---------+ +---------+
6601// | | |
6602// | [SUBS CREATE] |
6603// | | |
6604// | | |
6605// | RESTSubDelReq | |
6606// |---------------->| |
6607// | | |
6608// | RESTSubDelResp | |
6609// |<----------------| |
6610// | | |
6611// | | SubDelReq |
6612// | |------------->|
6613// | | |
6614// | | SubDelFail | Unknown instanceId
6615// | |<-------------|
6616// | | |
6617// | | SubDelReq |
6618// | |------------->|
6619// | | |
6620// | | SubDelFail | Subscription does exist any more
6621// | |<-------------|
6622//
6623//-----------------------------------------------------------------------------
6624func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006625 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
Anssi Mannila51122392021-05-25 11:51:31 +03006626
6627 // Req
6628 var params *teststube2ap.RESTSubsReqParams = nil
6629 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6630
6631 // Del
6632 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6633
6634 // E2t: Receive 1st SubsDelReq
6635 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6636
6637 // Unknown instanceId in this response which will result resending original request
6638 delreq.RequestId.InstanceId = 0
6639 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6640
6641 // E2t: Receive 2nd SubsDelReq
6642 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6643
6644 // Subscription does not exist in in E2 Node.
6645 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6646
6647 // Wait that subs is cleaned
6648 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6649
6650 xappConn1.TestMsgChanEmpty(t)
6651 e2termConn1.TestMsgChanEmpty(t)
6652 mainCtrl.wait_registry_empty(t, 10)
6653}
6654
6655//-----------------------------------------------------------------------------
6656// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
6657//
6658// stub stub
6659// +-------+ +---------+ +---------+
6660// | xapp | | submgr | | e2term |
6661// +-------+ +---------+ +---------+
6662// | | |
6663// | [SUBS CREATE] |
6664// | | |
6665// | | |
6666// | RESTSubDelReq | |
6667// |---------------->| |
6668// | | |
6669// | RESTSubDelResp | |
6670// |<----------------| |
6671// | | |
6672// | | SubDelReq |
6673// | |------------->|
6674// | | |
6675// | | SubDelFail | No transaction for the response
6676// | |<-------------|
6677// | | |
6678// | | SubDelReq |
6679// | |------------->|
6680// | | |
6681// | | SubDelFail | Subscription does exist any more
6682// | |<-------------|
6683//
6684//-----------------------------------------------------------------------------
6685func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006686 xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
Anssi Mannila51122392021-05-25 11:51:31 +03006687
6688 // Req
6689 var params *teststube2ap.RESTSubsReqParams = nil
6690 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
6691
6692 // Del
6693 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6694
6695 // E2t: Receive 1st SubsDelReq
6696 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6697
6698 mainCtrl.MakeTransactionNil(t, e2SubsId)
6699
6700 // No transaction exist for this response which will result resending original request
6701 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6702
6703 // E2t: Receive 2nd SubsDelReq
6704 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
6705
6706 // Subscription does not exist in in E2 Node.
6707 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
6708
6709 // Wait that subs is cleaned
6710 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
6711
6712 xappConn1.TestMsgChanEmpty(t)
6713 e2termConn1.TestMsgChanEmpty(t)
6714 mainCtrl.wait_registry_empty(t, 10)
6715}
6716
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006717//-----------------------------------------------------------------------------
6718// TestRESTSubReqFailAsn1PackSubReqError
6719//
6720// stub stub
6721// +-------+ +---------+ +---------+
6722// | xapp | | submgr | | e2term |
6723// +-------+ +---------+ +---------+
6724// | | |
6725// | RESTSubReq | |
6726// |---------------->| |
6727// | | |
6728// | RESTSubResp | |
6729// |<----------------| |
6730// | | |
6731// | ASN.1 encode fails |
6732// | | |
6733// | | SubDelReq |
6734// | |------------->|
6735// | | |
6736// | | SubDelFail |
6737// | |<-------------|
6738// | | |
6739// | RESTNotif | |
6740// | unsuccess | |
6741// |<----------------| |
6742// | | |
6743// | [SUBS DELETE] |
6744// | | |
6745//
6746//-----------------------------------------------------------------------------
6747func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
6748
6749 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006750 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006751 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006752 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006753 })
6754
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006755 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006756
6757 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006758 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006759 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
6760
6761 // Req
6762 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006763 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006764
6765 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03006766 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006767
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006768 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006769 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00006770
6771 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
6772 // Wait that subs is cleaned
6773 waitSubsCleanup(t, e2SubsId, 10)
6774 mainCtrl.VerifyCounterValues(t)
6775}
6776
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006777func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
6778 CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
6779
6780 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6781 Counter{cRestSubReqFromXapp, 2},
6782 Counter{cRestSubRespToXapp, 2},
6783 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006784 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006785 Counter{cSubRespFromE2, 1},
6786 Counter{cRestSubNotifToXapp, 1},
6787 Counter{cRestSubFailNotifToXapp, 1},
6788 Counter{cRestSubDelReqFromXapp, 1},
6789 Counter{cSubDelReqToE2, 1},
6790 Counter{cSubDelRespFromE2, 1},
6791 Counter{cRestSubDelRespToXapp, 1},
6792 })
6793
6794 const e2Timeout int64 = 1
6795 const e2RetryCount int64 = 0
6796 const routingNeeded bool = false
6797
6798 // Req1
6799 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6800 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6801
6802 // Subs Create
6803 restSubId := xappConn1.SendRESTSubsReq(t, params)
6804 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6805
6806 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6807 xappConn1.ExpectRESTNotification(t, restSubId)
6808 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6809 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6810 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6811
6812 // Policy change
6813 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6814 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6815 params.SetSubscriptionID(&restSubId)
6816 params.SetTimeToWait("w200ms")
6817 restSubId = xappConn1.SendRESTSubsReq(t, params)
6818 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6819
6820 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6821 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03006822 // SubsResp is missing, e2SubsId will be 0
6823 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6824 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006825
6826 // Del
6827 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6828 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6829 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6830
6831 waitSubsCleanup(t, e2SubsId, 10)
6832
6833 mainCtrl.VerifyCounterValues(t)
6834}
6835
6836//-----------------------------------------------------------------------------
6837// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
6838//
6839// stub stub
6840// +-------+ +---------+ +---------+
6841// | xapp | | submgr | | e2term |
6842// +-------+ +---------+ +---------+
6843// | | |
6844// | RESTSubReq | |
6845// |---------------->| |
6846// | | |
6847// | RESTSubResp | |
6848// |<----------------| |
6849// | | SubReq |
6850// | |------------->|
6851// | | |
6852// | | SubResp |
6853// | |<-------------|
6854// | | |
6855// | RESTNotif | |
6856// |<----------------| |
6857// | | |
6858// | RESTSubReq | |
6859// |---------------->| |
6860// | | |
6861// | RESTSubResp | |
6862// |<----------------| |
6863// | | SubReq |
6864// | |------------->|
6865// | |
6866// | Submgr restart |
6867// | | |
6868// | RESTSubDelReq | |
6869// |---------------->| |
6870// | | |
6871// | | SubDelReq |
6872// | |------------->|
6873// | | |
6874// | | SubDelResp |
6875// | |<-------------|
6876// | | |
6877// | RESTSubDelResp | |
6878// |<----------------| |
6879//
6880//-----------------------------------------------------------------------------
6881
6882func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
6883 CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
6884
6885 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
6886 Counter{cRestSubReqFromXapp, 2},
6887 Counter{cRestSubRespToXapp, 2},
6888 Counter{cSubReqToE2, 2},
6889 Counter{cSubRespFromE2, 1},
6890 Counter{cRestSubNotifToXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006891 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006892 Counter{cRestSubDelReqFromXapp, 1},
6893 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02006894 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006895 Counter{cRestSubDelRespToXapp, 1},
6896 })
6897
6898 // Remove possible existing subscription
6899 mainCtrl.removeExistingSubscriptions(t)
6900
6901 const e2Timeout int64 = 1
6902 const e2RetryCount int64 = 0
6903 const routingNeeded bool = false
6904
6905 // Req1
6906 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6907 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6908 // Create subscription
6909 restSubId := xappConn1.SendRESTSubsReq(t, params)
6910 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6911
6912 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6913 xappConn1.ExpectRESTNotification(t, restSubId)
6914 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6915 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
6916 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
6917
6918 // Check subscription
6919 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6920
6921 // Policy change
6922 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
6923 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
6924 params.SetSubscriptionID(&restSubId)
6925 params.SetTimeToWait("w200ms")
6926 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
6927 restSubId = xappConn1.SendRESTSubsReq(t, params)
6928 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
6929
6930 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
6931 mainCtrl.SetResetTestFlag(t, false)
6932
6933 // SubsResp is missing due to submgr restart
6934
6935 mainCtrl.SimulateRestart(t)
6936 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
6937
6938 // Check subscription
6939 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
6940
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006941 // Delete subscription
6942 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6943 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6944 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6945
6946 //Wait that subs is cleaned
6947 waitSubsCleanup(t, e2SubsId, 10)
6948
6949 mainCtrl.VerifyCounterValues(t)
6950}
6951
archaggeafbf95f2021-04-14 08:54:05 +03006952////////////////////////////////////////////////////////////////////////////////////
6953// Services for UT cases
6954////////////////////////////////////////////////////////////////////////////////////
6955const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03006956const host string = "localhost"
6957
6958func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
6959 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006960 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006961 }
6962 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006963 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006964
6965 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
6966 fromXappConn.ExpectRESTNotification(t, restSubId)
6967 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
6968 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006969 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006970
6971 return restSubId, e2SubsId
6972}
6973
6974func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
6975
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006976 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006977 if meid != "" {
6978 params.SetMeid(meid)
6979 }
6980 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
6981 restSubId := xappConn2.SendRESTSubsReq(t, params)
6982 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006983 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006984 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006985 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03006986
6987 return restSubId, e2SubsId
6988}
6989
6990func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006991
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006992 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006993 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006994 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03006995
6996 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
6997 xappConn1.ExpectRESTNotification(t, restSubId)
6998 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
6999 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007000 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007001
7002 return restSubId, e2SubsId
7003}
7004
7005func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007006 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03007007 restSubId := xappConn1.SendRESTSubsReq(t, params)
7008
7009 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
7010 fparams1 := &teststube2ap.E2StubSubsFailParams{}
7011 fparams1.Set(crereq1)
7012 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
7013
7014 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
7015 xappConn1.ExpectRESTNotification(t, restSubId)
7016 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
7017 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007018 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03007019
7020 return restSubId, e2SubsId
7021}
7022
7023func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
7024 fromXappConn.SendRESTSubsDelReq(t, restSubId)
7025 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7026 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7027}
7028
7029func deleteXapp1Subscription(t *testing.T, restSubId *string) {
7030 xappConn1.SendRESTSubsDelReq(t, restSubId)
7031 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7032 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7033}
7034
7035func deleteXapp2Subscription(t *testing.T, restSubId *string) {
7036 xappConn2.SendRESTSubsDelReq(t, restSubId)
7037 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7038 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7039}
7040
7041func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
7042 resp, _ := xapp.Subscription.QuerySubscriptions()
7043 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
7044 assert.Equal(t, resp[0].Meid, meid)
7045 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
7046}
7047
7048func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
7049 //Wait that subs is cleaned
7050 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
7051
7052 xappConn1.TestMsgChanEmpty(t)
7053 xappConn2.TestMsgChanEmpty(t)
7054 e2termConn1.TestMsgChanEmpty(t)
7055 mainCtrl.wait_registry_empty(t, timeout)
7056}
7057
7058func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
7059
7060 var e2SubsId []uint32
7061
7062 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007063 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007064 crereq, cremsg := toE2termConn.RecvSubsReq(t)
7065 fromXappConn.ExpectRESTNotification(t, restSubId)
7066 toE2termConn.SendSubsResp(t, crereq, cremsg)
7067 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
7068 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007069 xapp.Logger.Debug("TEST: %v", e2SubsId)
7070 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007071 <-time.After(100 * time.Millisecond)
7072 }
7073 return e2SubsId
7074}
7075
7076func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
7077
7078 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007079 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007080 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
7081 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
7082 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007083 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03007084 <-time.After(100 * time.Millisecond)
7085 }
7086
7087 // Wait that subs is cleaned
7088 for i := 0; i < len(e2SubsIds); i++ {
7089 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
7090 }
7091
7092}