blob: 3e9a51bcb6abc7182bf665de39ab0f75a3e68b91 [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 Mannila92c38552021-12-29 09:59:24 +020023 "encoding/json"
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
Anssi Mannila27385172021-12-22 09:41:54 +020036// In below test cases there is done only one retry for E2 messages
37// In Helm chart retry count is currently 2 By default. Retry count
38// used in test cases is defined in submgr-config.yaml file.
39
Markku Virtanenac8bde42021-05-25 09:54:42 +000040func TestSuiteSetup(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030041 // The effect of this call shall endure though the UT suite!
42 // If this causes any issues, the previous interface can be restored
Markku Virtanenac8bde42021-05-25 09:54:42 +000043 // like this:git log
Markku Virtanenfa39fed2021-05-25 08:18:43 +000044 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
45
Anssi Mannila3d80b722021-11-12 13:17:15 +020046 mainCtrl.InitAllCounterMap()
Markku Virtanenfa39fed2021-05-25 08:18:43 +000047 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
Anssi Mannila3cdd2e02021-10-14 12:35:41 +030048 mainCtrl.c.restDuplicateCtrl.Init()
Markku Virtanenb642a192021-06-09 09:08:14 +000049
Markku Virtanenac8bde42021-05-25 09:54:42 +000050}
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030051func TestRanStatusChangeViaSDLNotification(t *testing.T) {
52
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020053 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
54 Counter{cE2StateChangedToUp, 3},
55 })
56
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030057 // Current UT test cases use these ran names
58 xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
59 xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
60 xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
61
62 mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
63 mainCtrl.c.e2IfState.SubscribeChannels()
64
65 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
66 mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
67 mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020068
69 mainCtrl.VerifyCounterValues(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030070}
71
72//-----------------------------------------------------------------------------
73// TestRESTSubReqAfterE2ConnBreak
74//
75// stub stub
76// +-------+ +---------+ +---------+
77// | xapp | | submgr | | e2term |
78// +-------+ +---------+ +---------+
79// | | |
80// | [E2 Conn. DOWN] |
81// | | |
82// | RESTSubReq | |
83// |---------------->| |
84// | RESTSubFail | |
85// |<----------------| |
86// | | |
87//
88//-----------------------------------------------------------------------------
89
90func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030091
92 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
93 Counter{cRestSubReqFromXapp, 1},
94 Counter{cRestReqRejDueE2Down, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +020095 Counter{cE2StateChangedToDown, 1},
96 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +030097 })
98
99 // E2 disconnect after E2term has received response
100 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
101 // Req
102 const subReqCount int = 1
103 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
104 xappConn1.SendRESTSubsReq(t, params)
105
106 // Restore E2 connection for following test cases
107 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
108
Anssi Mannilab43397e2021-11-16 12:06:16 +0200109 mainCtrl.VerifyAllClean(t)
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200110 mainCtrl.VerifyCounterValues(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300111}
112
113//-----------------------------------------------------------------------------
114// TestRESTSubReqE2ConnBreak
115//
116// stub stub
117// +-------+ +---------+ +---------+
118// | xapp | | submgr | | e2term |
119// +-------+ +---------+ +---------+
120// | | |
121// | RESTSubReq | |
122// |---------------->| |
123// | RESTSubResp | |
124// |<----------------| |
125// | | SubReq |
126// | |------------->|
127// | | SubResp |
128// | |<-------------|
129// | | |
130// | [E2 Conn. DOWN] |
131// | [Int. SUBS DELETE] |
132// | | |
133// | RESTNotif(unsuccessful) |
134// |<----------------| |
135// | | |
136// | | |
137//
138//-----------------------------------------------------------------------------
139func TestRESTSubReqE2ConnBreak(t *testing.T) {
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300140
141 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
142 Counter{cRestSubReqFromXapp, 1},
143 Counter{cRestSubRespToXapp, 1},
144 Counter{cSubReqToE2, 1},
145 Counter{cSubRespFromE2, 1},
146 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200147 Counter{cE2StateChangedToDown, 1},
148 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300149 })
150
151 // Req
152 const subReqCount int = 1
153 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
154 restSubId := xappConn1.SendRESTSubsReq(t, params)
155
156 crereq, cremsg := e2termConn1.RecvSubsReq(t)
157 xappConn1.ExpectRESTNotification(t, restSubId)
158
159 // E2 disconnect after E2term has received response
160 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
161
162 e2termConn1.SendSubsResp(t, crereq, cremsg)
163 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
164
165 <-time.After(time.Second * 1)
166 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
167 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
168
169 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
170 if err != nil {
171 xapp.Logger.Error("%v", err)
172 } else {
173 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
174 assert.Equal(t, 0, len(register))
175 }
176
177 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
178 if err != nil {
179 xapp.Logger.Error("%v", err)
180 } else {
181 assert.Equal(t, 0, len(restSubscriptions))
182 }
183
184 // Restore E2 connection for following test cases
185 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
186
187 // Wait that subs is cleaned
188 waitSubsCleanup(t, e2SubsId, 10)
189 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200190 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300191}
192
193//-----------------------------------------------------------------------------
194// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
195//
196// stub stub
197// +-------+ +---------+ +---------+
198// | xapp | | submgr | | e2term |
199// +-------+ +---------+ +---------+
200// | | |
201// | [SUBS CREATE] |
202// | | |
203// | [E2 Conn. DOWN] |
204// | | |
205// | RESTSubDelReq | |
206// |---------------->| |
207// | | |
208// | RESTSubDelResp | |
209// |<----------------| |
210// | | |
211// | [No valid subscription found] |
212// | | |
213//
214//-----------------------------------------------------------------------------
215func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
216 xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak")
217
218 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
219 Counter{cRestSubReqFromXapp, 1},
220 Counter{cRestSubRespToXapp, 1},
221 Counter{cSubReqToE2, 1},
222 Counter{cSubRespFromE2, 1},
223 Counter{cRestSubNotifToXapp, 1},
224 Counter{cRestSubDelReqFromXapp, 1},
225 Counter{cRestSubDelRespToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200226 Counter{cE2StateChangedToDown, 1},
227 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300228 })
229
230 // Req
231 var params *teststube2ap.RESTSubsReqParams = nil
232 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
233
234 // E2 disconnect after E2term has received response
235 mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
236
237 // Del
238 xappConn1.SendRESTSubsDelReq(t, &restSubId)
239
240 <-time.After(time.Second * 1)
241 assert.Equal(t, 0, len(mainCtrl.c.registry.register))
242 assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
243
244 subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
245 if err != nil {
246 xapp.Logger.Error("%v", err)
247 } else {
248 assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
249 assert.Equal(t, 0, len(register))
250 }
251
252 restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
253 if err != nil {
254 xapp.Logger.Error("%v", err)
255 } else {
256 assert.Equal(t, 0, len(restSubscriptions))
257 }
258
259 // Restore E2 connection for following test cases
260 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
261
262 // Wait that subs is cleaned
263 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
264
265 xappConn1.TestMsgChanEmpty(t)
266 e2termConn1.TestMsgChanEmpty(t)
267 mainCtrl.wait_registry_empty(t, 10)
268 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200269 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300270}
271
272//-----------------------------------------------------------------------------
273// TestRESTOtherE2ConnectionChanges
274//
275
276// stub stub
277// +-------+ +---------+ +---------+
278// | xapp | | submgr | | e2term |
279// +-------+ +---------+ +---------+
280// | | |
281// | [SUBS CREATE] |
282// | | |
283// | [E2 CONNECTED_SETUP_FAILED] |
284// | [E2 CONNECTING] |
285// | [E2 SHUTTING_DOWN] |
286// | [E2 SHUT_DOWN] |
287// | | |
288// | [SUBS DELETE] |
289// | | |
290//
291//-----------------------------------------------------------------------------
292func TestRESTOtherE2ConnectionChanges(t *testing.T) {
293 xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges")
294
295 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
296 Counter{cRestSubReqFromXapp, 1},
297 Counter{cRestSubRespToXapp, 1},
298 Counter{cSubReqToE2, 1},
299 Counter{cSubRespFromE2, 1},
300 Counter{cRestSubNotifToXapp, 1},
301 Counter{cRestSubDelReqFromXapp, 1},
302 Counter{cSubDelReqToE2, 1},
303 Counter{cSubDelRespFromE2, 1},
304 Counter{cRestSubDelRespToXapp, 1},
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200305 Counter{cE2StateChangedToUp, 1},
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300306 })
307
308 // Req
309 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
310 restSubId := xappConn1.SendRESTSubsReq(t, params)
311
312 crereq, cremsg := e2termConn1.RecvSubsReq(t)
313 xappConn1.ExpectRESTNotification(t, restSubId)
314 e2termConn1.SendSubsResp(t, crereq, cremsg)
315 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
316
Anssi Mannila4b1ff2c2021-12-17 12:45:25 +0200317 // Submgr should not react to any other connection state changes than CONNECTED and DISCONNECTED
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300318 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
319 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
320 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
321 mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
322
323 // Del
324 xappConn1.SendRESTSubsDelReq(t, &restSubId)
325 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
326 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
327
328 // Restore E2 connection for following test cases
329 mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
330
331 // Wait that subs is cleaned
332 waitSubsCleanup(t, e2SubsId, 10)
333 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200334 mainCtrl.VerifyAllClean(t)
Anssi Mannilac7da4ee2021-10-22 09:52:02 +0300335}
Markku Virtanenac8bde42021-05-25 09:54:42 +0000336
337//-----------------------------------------------------------------------------
338// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
339//
340// stub stub stub
341// +-------+ +---------+ +---------+ +---------+
342// | xapp | | submgr | | e2term | | rtmgr |
343// +-------+ +---------+ +---------+ +---------+
344// | | | |
345// | RESTSubReq | | |
346// |---------------->| | |
347// | | RouteCreate | |
348// | |--------------------------->| // The order of these events may vary
349// | | | |
350// | RESTSubResp | | | // The order of these events may vary
351// |<----------------| | |
352// | | RouteResponse| |
353// | |<---------------------------| // The order of these events may vary
354// | | | |
355// | | SubReq | |
356// | |------------->| | // The order of these events may vary
357// | | | |
358// | | SubResp | |
359// | |<-------------| |
360// | RESTNotif1 | | |
361// |<----------------| | |
362// | | | |
363// | RESTSubDelReq | | |
364// |---------------->| | |
365// | | SubDelReq | |
366// | |------------->| |
367// | | | |
368// | RESTSubDelResp| | |
369// |<----------------| | |
370// | | | |
371// | | SubDelResp | |
372// | |<-------------| |
373// | | | |
374// | | | |
375//
376//-----------------------------------------------------------------------------
377func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000378
379 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
380
381 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
382
383 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200384 mainCtrl.VerifyAllClean(t)
Markku Virtanenfa39fed2021-05-25 08:18:43 +0000385}
386
Juha Hyttinenfa015662020-01-24 10:05:18 +0200387//-----------------------------------------------------------------------------
Markku Virtanenac8bde42021-05-25 09:54:42 +0000388// TestRESTSubReqAndE1apDeleteReqPackingError
389//
390// stub stub stub
391// +-------+ +---------+ +---------+ +---------+
392// | xapp | | submgr | | e2term | | rtmgr |
393// +-------+ +---------+ +---------+ +---------+
394// | | | |
395// | RESTSubReq | | |
396// |---------------->| | |
397// | | RouteCreate | |
398// | |--------------------------->| // The order of these events may vary
399// | | | |
400// | RESTSubResp | | | // The order of these events may vary
401// |<----------------| | |
402// | | RouteResponse| |
403// | |<---------------------------| // The order of these events may vary
404// | | | |
405// | | SubReq | |
406// | |------------->| | // The order of these events may vary
407// | | | |
408// | | SubResp | |
409// | |<-------------| |
410// | RESTNotif1 | | |
411// |<----------------| | |
412// | | | |
413// | RESTSubDelReq | | |
414// |---------------->| | |
415// | | | |
416// | RESTSubDelResp| | |
417// |<----------------| | |
418// | | | |
419// | | | |
420//
421//-----------------------------------------------------------------------------
422func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) {
423
424 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
425
426 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false)
427 xappConn1.SendRESTSubsDelReq(t, &restSubId)
428 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
429
430 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200431 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000432}
433
434//-----------------------------------------------------------------------------
435// TestRESTSubReqAndE1apDeleteRespUnpackingError
436//
437// stub stub stub
438// +-------+ +---------+ +---------+ +---------+
439// | xapp | | submgr | | e2term | | rtmgr |
440// +-------+ +---------+ +---------+ +---------+
441// | | | |
442// | RESTSubReq | | |
443// |---------------->| | |
444// | | RouteCreate | |
445// | |--------------------------->| // The order of these events may vary
446// | | | |
447// | RESTSubResp | | | // The order of these events may vary
448// |<----------------| | |
449// | | RouteResponse| |
450// | |<---------------------------| // The order of these events may vary
451// | | | |
452// | | SubReq | |
453// | |------------->| | // The order of these events may vary
454// | | | |
455// | | SubResp | |
456// | |<-------------| |
457// | RESTNotif1 | | |
458// |<----------------| | |
459// | | | |
460// | RESTSubDelReq | | |
461// |---------------->| | |
462// | | SubDelReq | |
463// | |------------->| |
464// | | | |
465// | RESTSubDelResp| | |
466// |<----------------| | | // The order of these events may vary
467// | | | |
468// | | SubDelResp | |
469// | |<-------------| | // 1.st NOK
470// | | | |
471// | | SubDelReq | |
472// | |------------->| |
473// | | | |
474// | | SubDelResp | |
475// | |<-------------| | // 2.nd NOK
476//
477//-----------------------------------------------------------------------------
478
479func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) {
480
481 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
482
483 xappConn1.SendRESTSubsDelReq(t, &restSubId)
484 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false)
485 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
486 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
487
488 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
489 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
490
491 defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
492
493 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +0200494 mainCtrl.VerifyAllClean(t)
Markku Virtanenac8bde42021-05-25 09:54:42 +0000495}
496
497//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200498// TestSubReqAndRouteNok
499//
500// stub stub
501// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +0200502// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200503// +-------+ +---------+ +---------+
504// | | |
505// | SubReq | |
506// |------------->| |
507// | | |
508// | | RouteCreate |
509// | |------------->|
510// | | |
511// | | RouteCreate |
512// | | status:400 |
513// | |<-------------|
514// | | |
515// | [SUBS INT DELETE] |
516// | | |
517//
518//-----------------------------------------------------------------------------
519
520func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200521 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200522
Anssi Mannila4abf1802021-01-28 13:06:46 +0200523 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200524 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
525 Counter{cSubReqFromXapp, 1},
526 Counter{cRouteCreateFail, 1},
527 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200528
Juha Hyttinenfa015662020-01-24 10:05:18 +0200529 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +0300530 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200531 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200532 waiter.WaitResult(t)
533
534 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +0200535 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200536
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200537 xappConn1.TestMsgChanEmpty(t)
538 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200539 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200540 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200541
542 <-time.After(1 * time.Second)
543 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200544}
545
546//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +0200547// TestSubReqAndRouteUpdateNok
548
549// stub stub
550// +-------+ +-------+ +---------+ +---------+
551// | xapp2 | | xapp1 | | submgr | | rtmgr |
552// +-------+ +-------+ +---------+ +---------+
553// | | | |
554// | [SUBS CREATE] | |
555// | | | |
556// | | | |
557// | | | |
558// | SubReq (mergeable) | |
559// |--------------------------->| | |
560// | | | |
561// | | | RouteUpdate |
562// | | |------------->|
563// | | | |
564// | | | RouteUpdate |
565// | | | status:400 |
566// | | |<-------------|
567// | | | |
568// | [SUBS INT DELETE] | |
569// | | | |
570// | | | |
571// | [SUBS DELETE] | |
572// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300573
Anssi Mannila4abf1802021-01-28 13:06:46 +0200574func TestSubReqAndRouteUpdateNok(t *testing.T) {
575 CaseBegin("TestSubReqAndRouteUpdateNok")
576
577 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200578 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
579 Counter{cSubReqFromXapp, 2},
580 Counter{cSubReqToE2, 1},
581 Counter{cSubRespFromE2, 1},
582 Counter{cSubRespToXapp, 1},
583 Counter{cRouteCreateUpdateFail, 1},
584 Counter{cSubDelReqFromXapp, 1},
585 Counter{cSubDelReqToE2, 1},
586 Counter{cSubDelRespFromE2, 1},
587 Counter{cSubDelRespToXapp, 1},
588 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200589
590 cretrans := xappConn1.SendSubsReq(t, nil, nil)
591 crereq, cremsg := e2termConn1.RecvSubsReq(t)
592 e2termConn1.SendSubsResp(t, crereq, cremsg)
593 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
594
595 resp, _ := xapp.Subscription.QuerySubscriptions()
596 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
597 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300598 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200599
600 waiter := rtmgrHttp.AllocNextEvent(false)
601 newSubsId := mainCtrl.get_registry_next_subid(t)
602 xappConn2.SendSubsReq(t, nil, nil)
603 waiter.WaitResult(t)
604
605 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
606 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
607
608 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
609 xappConn1.RecvSubsDelResp(t, deltrans)
610
611 //Wait that subs is cleaned
612 mainCtrl.wait_subs_clean(t, newSubsId, 10)
613 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
614
615 xappConn1.TestMsgChanEmpty(t)
616 xappConn2.TestMsgChanEmpty(t)
617 e2termConn1.TestMsgChanEmpty(t)
618 mainCtrl.wait_registry_empty(t, 10)
619
620 mainCtrl.VerifyCounterValues(t)
621}
622
623//-----------------------------------------------------------------------------
624// TestSubDelReqAndRouteDeleteNok
625//
626// stub stub
627// +-------+ +---------+ +---------+ +---------+
628// | xapp | | submgr | | e2term | | rtmgr |
629// +-------+ +---------+ +---------+ +---------+
630// | | | |
631// | [SUBS CREATE] | |
632// | | | |
633// | | | |
634// | | | |
635// | SubDelReq | | |
636// |------------->| | |
637// | | SubDelReq | |
638// | |------------->| |
639// | | SubDelRsp | |
640// | |<-------------| |
641// | SubDelRsp | | |
642// |<-------------| | |
643// | | RouteDelete | |
644// | |---------------------------->|
645// | | | |
646// | | RouteDelete | |
647// | | status:400 | |
648// | |<----------------------------|
649// | | | |
650func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
651 CaseBegin("TestSubDelReqAndRouteDeleteNok")
652
653 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200654 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
655 Counter{cSubReqFromXapp, 1},
656 Counter{cSubReqToE2, 1},
657 Counter{cSubRespFromE2, 1},
658 Counter{cSubRespToXapp, 1},
659 Counter{cSubDelReqFromXapp, 1},
660 Counter{cRouteDeleteFail, 1},
661 Counter{cSubDelReqToE2, 1},
662 Counter{cSubDelRespFromE2, 1},
663 Counter{cSubDelRespToXapp, 1},
664 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200665
666 cretrans := xappConn1.SendSubsReq(t, nil, nil)
667 crereq, cremsg := e2termConn1.RecvSubsReq(t)
668 e2termConn1.SendSubsResp(t, crereq, cremsg)
669 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
670
671 resp, _ := xapp.Subscription.QuerySubscriptions()
672 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
673 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300674 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200675
676 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
677 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
678
679 waiter := rtmgrHttp.AllocNextEvent(false)
680 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
681 waiter.WaitResult(t)
682
683 xappConn1.RecvSubsDelResp(t, deltrans)
684
685 //Wait that subs is cleaned
686 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
687
688 xappConn1.TestMsgChanEmpty(t)
689 xappConn2.TestMsgChanEmpty(t)
690 e2termConn1.TestMsgChanEmpty(t)
691 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200692 mainCtrl.VerifyCounterValues(t)
693}
694
695//-----------------------------------------------------------------------------
696// TestSubMergeDelAndRouteUpdateNok
697// stub stub
698// +-------+ +-------+ +---------+ +---------+
699// | xapp2 | | xapp1 | | submgr | | e2term |
700// +-------+ +-------+ +---------+ +---------+
701// | | | |
702// | | | |
703// | | | |
704// | | SubReq1 | |
705// | |------------->| |
706// | | | |
707// | | | SubReq1 |
708// | | |------------->|
709// | | | SubResp1 |
710// | | |<-------------|
711// | | SubResp1 | |
712// | |<-------------| |
713// | | | |
714// | SubReq2 | |
715// |--------------------------->| |
716// | | | |
717// | SubResp2 | |
718// |<---------------------------| |
719// | | | |
720// | | SubDelReq 1 | |
721// | |------------->| |
722// | | | RouteUpdate |
723// | | |-----> rtmgr |
724// | | | |
725// | | | RouteUpdate |
726// | | | status:400 |
727// | | |<----- rtmgr |
728// | | | |
729// | | SubDelResp 1 | |
730// | |<-------------| |
731// | | | |
732// | SubDelReq 2 | |
733// |--------------------------->| |
734// | | | |
735// | | | SubDelReq 2 |
736// | | |------------->|
737// | | | |
738// | | | SubDelReq 2 |
739// | | |------------->|
740// | | | |
741// | SubDelResp 2 | |
742// |<---------------------------| |
743//
744//-----------------------------------------------------------------------------
745func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
746 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
747
748 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200749 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
750 Counter{cSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200751 Counter{cMergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200752 Counter{cSubReqToE2, 1},
753 Counter{cSubRespFromE2, 1},
754 Counter{cSubRespToXapp, 2},
755 Counter{cSubDelReqFromXapp, 2},
756 Counter{cRouteDeleteUpdateFail, 1},
757 Counter{cSubDelReqToE2, 1},
758 Counter{cSubDelRespFromE2, 1},
759 Counter{cSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +0200760 Counter{cUnmergedSubscriptions, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200761 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200762
763 //Req1
764 rparams1 := &teststube2ap.E2StubSubsReqParams{}
765 rparams1.Init()
766 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
767 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
768 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
769 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
770
771 //Req2
772 rparams2 := &teststube2ap.E2StubSubsReqParams{}
773 rparams2.Init()
774 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
775 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
776
777 resp, _ := xapp.Subscription.QuerySubscriptions()
778 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
779 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300780 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200781
782 //Del1
783 waiter := rtmgrHttp.AllocNextEvent(false)
784 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
785 waiter.WaitResult(t)
786
787 xappConn1.RecvSubsDelResp(t, deltrans1)
788
789 //Del2
790 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
791 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
792 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
793 xappConn2.RecvSubsDelResp(t, deltrans2)
794 //Wait that subs is cleaned
795 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
796
797 xappConn1.TestMsgChanEmpty(t)
798 xappConn2.TestMsgChanEmpty(t)
799 e2termConn1.TestMsgChanEmpty(t)
800 mainCtrl.wait_registry_empty(t, 10)
801
802 mainCtrl.VerifyCounterValues(t)
803}
804
805//-----------------------------------------------------------------------------
806
807//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200808// TestSubReqAndSubDelOk
809//
810// stub stub
811// +-------+ +---------+ +---------+
812// | xapp | | submgr | | e2term |
813// +-------+ +---------+ +---------+
814// | | |
815// | SubReq | |
816// |------------->| |
817// | | |
818// | | SubReq |
819// | |------------->|
820// | | |
821// | | SubResp |
822// | |<-------------|
823// | | |
824// | SubResp | |
825// |<-------------| |
826// | | |
827// | | |
828// | SubDelReq | |
829// |------------->| |
830// | | |
831// | | SubDelReq |
832// | |------------->|
833// | | |
834// | | SubDelResp |
835// | |<-------------|
836// | | |
837// | SubDelResp | |
838// |<-------------| |
839//
840//-----------------------------------------------------------------------------
841func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200842 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200843
Anssi Mannila4abf1802021-01-28 13:06:46 +0200844 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200845 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
846 Counter{cSubReqFromXapp, 1},
847 Counter{cSubReqToE2, 1},
848 Counter{cSubRespFromE2, 1},
849 Counter{cSubRespToXapp, 1},
850 Counter{cSubDelReqFromXapp, 1},
851 Counter{cSubDelReqToE2, 1},
852 Counter{cSubDelRespFromE2, 1},
853 Counter{cSubDelRespToXapp, 1},
854 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200855
856 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200857 crereq, cremsg := e2termConn1.RecvSubsReq(t)
858 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200859 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200860
861 resp, _ := xapp.Subscription.QuerySubscriptions()
862 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
863 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300864 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200865
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200866 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200867 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200868
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200869 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200870 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200871
872 //Wait that subs is cleaned
873 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
874
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200875 xappConn1.TestMsgChanEmpty(t)
876 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200877 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200878 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200879
880 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200881}
882
883//-----------------------------------------------------------------------------
884// TestSubReqRetransmission
885//
886// stub stub
887// +-------+ +---------+ +---------+
888// | xapp | | submgr | | e2term |
889// +-------+ +---------+ +---------+
890// | | |
891// | SubReq | |
892// |------------->| |
893// | | |
894// | | SubReq |
895// | |------------->|
896// | | |
897// | SubReq | |
898// | (retrans) | |
899// |------------->| |
900// | | |
901// | | SubResp |
902// | |<-------------|
903// | | |
904// | SubResp | |
905// |<-------------| |
906// | | |
907// | [SUBS DELETE] |
908// | | |
909//
910//-----------------------------------------------------------------------------
911func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200912 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200913
914 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200915 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200916 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200917
918 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200919 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200920 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
921
Juha Hyttinen1683f912020-04-17 10:39:57 +0300922 // hack as there is no real way to see has message be handled.
923 // Previuos counter check just tells that is has been received by submgr
924 // --> artificial delay
925 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200926 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200927 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200928
929 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200930 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200931 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
932 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200933 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200934
935 //Wait that subs is cleaned
936 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
937
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200938 xappConn1.TestMsgChanEmpty(t)
939 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200940 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200941 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200942}
943
944//-----------------------------------------------------------------------------
945// TestSubDelReqRetransmission
946//
947// stub stub
948// +-------+ +---------+ +---------+
949// | xapp | | submgr | | e2term |
950// +-------+ +---------+ +---------+
951// | | |
952// | [SUBS CREATE] |
953// | | |
954// | | |
955// | SubDelReq | |
956// |------------->| |
957// | | |
958// | | SubDelReq |
959// | |------------->|
960// | | |
961// | SubDelReq | |
962// | (same sub) | |
963// | (same xid) | |
964// |------------->| |
965// | | |
966// | | SubDelResp |
967// | |<-------------|
968// | | |
969// | SubDelResp | |
970// |<-------------| |
971//
972//-----------------------------------------------------------------------------
973func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200974 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200975
976 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200977 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200978 crereq, cremsg := e2termConn1.RecvSubsReq(t)
979 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200980 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200981
982 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200983 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200984 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200985
986 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200987 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200988 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
989
Juha Hyttinen1683f912020-04-17 10:39:57 +0300990 // hack as there is no real way to see has message be handled.
991 // Previuos counter check just tells that is has been received by submgr
992 // --> artificial delay
993 <-time.After(1 * time.Second)
994
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200995 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200996 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200997
998 //Wait that subs is cleaned
999 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1000
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001001 xappConn1.TestMsgChanEmpty(t)
1002 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001003 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001004 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001005}
1006
1007//-----------------------------------------------------------------------------
1008// TestSubDelReqCollision
1009//
1010// stub stub
1011// +-------+ +---------+ +---------+
1012// | xapp | | submgr | | e2term |
1013// +-------+ +---------+ +---------+
1014// | | |
1015// | [SUBS CREATE] |
1016// | | |
1017// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001018// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001019// |------------->| |
1020// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001021// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001022// | |------------->|
1023// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001024// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001025// | (same sub) | |
1026// | (diff xid) | |
1027// |------------->| |
1028// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001029// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001030// | |<-------------|
1031// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001032// | SubDelResp 1 | |
1033// |<-------------| |
1034// | | |
1035// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001036// |<-------------| |
1037//
1038//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +02001039
Juha Hyttinenfa015662020-01-24 10:05:18 +02001040func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001041 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001042
1043 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001044 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001045 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1046 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001047 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001048
1049 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001050 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001051 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001052
Juha Hyttinen3944a222020-01-24 11:51:46 +02001053 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +02001054 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001055 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1056 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +02001057 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
1058
Juha Hyttinen1683f912020-04-17 10:39:57 +03001059 // hack as there is no real way to see has message be handled.
1060 // Previuos counter check just tells that is has been received by submgr
1061 // --> artificial delay
1062 <-time.After(1 * time.Second)
1063
Juha Hyttinen3944a222020-01-24 11:51:46 +02001064 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001065 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001066
1067 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001068 xappConn1.RecvSubsDelResp(t, nil)
1069 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001070
1071 //Wait that subs is cleaned
1072 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1073
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001074 xappConn1.TestMsgChanEmpty(t)
1075 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001076 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001077 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001078}
1079
1080//-----------------------------------------------------------------------------
1081// TestSubReqAndSubDelOkTwoParallel
1082//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001083// stub stub stub
1084// +-------+ +-------+ +---------+ +---------+
1085// | xapp | | xapp | | submgr | | e2term |
1086// +-------+ +-------+ +---------+ +---------+
1087// | | | |
1088// | | | |
1089// | | | |
1090// | | SubReq1 | |
1091// | |------------->| |
1092// | | | |
1093// | | | SubReq1 |
1094// | | |------------->|
1095// | | | |
1096// | SubReq2 | |
1097// |------------------------>| |
1098// | | | |
1099// | | | SubReq2 |
1100// | | |------------->|
1101// | | | |
1102// | | | SubResp1 |
1103// | | |<-------------|
1104// | | SubResp1 | |
1105// | |<-------------| |
1106// | | | |
1107// | | | SubResp2 |
1108// | | |<-------------|
1109// | SubResp2 | |
1110// |<------------------------| |
1111// | | | |
1112// | | [SUBS 1 DELETE] |
1113// | | | |
1114// | | [SUBS 2 DELETE] |
1115// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001116//
1117//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03001118
Juha Hyttinenfa015662020-01-24 10:05:18 +02001119func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001120 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001121
1122 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001123 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001124 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001125 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001126 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001127
1128 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001129 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001130 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +03001131
1132 rparams2.Req.EventTriggerDefinition.Data.Length = 1
1133 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
1134 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
1135
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001136 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001137 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001138
1139 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001140 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001141 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001142
1143 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001144 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001145 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001146
1147 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001148 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001149 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1150 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001151 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001152 //Wait that subs is cleaned
1153 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1154
1155 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001156 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001157 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1158 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001159 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001160 //Wait that subs is cleaned
1161 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1162
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001163 xappConn1.TestMsgChanEmpty(t)
1164 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001165 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001166 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001167}
1168
1169//-----------------------------------------------------------------------------
1170// TestSameSubsDiffRan
1171// Same subscription to different RANs
1172//
1173// stub stub
1174// +-------+ +---------+ +---------+
1175// | xapp | | submgr | | e2term |
1176// +-------+ +---------+ +---------+
1177// | | |
1178// | | |
1179// | | |
1180// | SubReq(r1) | |
1181// |------------->| |
1182// | | |
1183// | | SubReq(r1) |
1184// | |------------->|
1185// | | |
1186// | | SubResp(r1) |
1187// | |<-------------|
1188// | | |
1189// | SubResp(r1) | |
1190// |<-------------| |
1191// | | |
1192// | SubReq(r2) | |
1193// |------------->| |
1194// | | |
1195// | | SubReq(r2) |
1196// | |------------->|
1197// | | |
1198// | | SubResp(r2) |
1199// | |<-------------|
1200// | | |
1201// | SubResp(r2) | |
1202// |<-------------| |
1203// | | |
1204// | [SUBS r1 DELETE] |
1205// | | |
1206// | [SUBS r2 DELETE] |
1207// | | |
1208//
1209//-----------------------------------------------------------------------------
1210func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001211 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001212
1213 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001214 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1215 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001216 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1217 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001218 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001219
1220 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001221 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1222 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001223 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1224 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001225 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001226
1227 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001228 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1229 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001230 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1231 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001232 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001233 //Wait that subs is cleaned
1234 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1235
1236 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001237 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
1238 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001239 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1240 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001241 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001242 //Wait that subs is cleaned
1243 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1244
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001245 xappConn1.TestMsgChanEmpty(t)
1246 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001247 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001248 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001249}
1250
1251//-----------------------------------------------------------------------------
1252// TestSubReqRetryInSubmgr
1253//
1254// stub stub
1255// +-------+ +---------+ +---------+
1256// | xapp | | submgr | | e2term |
1257// +-------+ +---------+ +---------+
1258// | | |
1259// | SubReq | |
1260// |------------->| |
1261// | | |
1262// | | SubReq |
1263// | |------------->|
1264// | | |
1265// | | |
1266// | | SubReq |
1267// | |------------->|
1268// | | |
1269// | | SubResp |
1270// | |<-------------|
1271// | | |
1272// | SubResp | |
1273// |<-------------| |
1274// | | |
1275// | [SUBS DELETE] |
1276// | | |
1277//
1278//-----------------------------------------------------------------------------
1279
1280func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001281 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001282
1283 // Init counter check
1284 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1285 Counter{cSubReqFromXapp, 1},
1286 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02001287 Counter{cSubReqTimerExpiry, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001288 Counter{cSubReReqToE2, 1},
1289 Counter{cSubRespFromE2, 1},
1290 Counter{cSubRespToXapp, 1},
1291 Counter{cSubDelReqFromXapp, 1},
1292 Counter{cSubDelReqToE2, 1},
1293 Counter{cSubDelRespFromE2, 1},
1294 Counter{cSubDelRespToXapp, 1},
1295 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001296
1297 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001298 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001299
1300 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001301 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001302
1303 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001304 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1305 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001306
1307 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001308 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001309
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001310 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001311 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1312 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001313 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001314
1315 // Wait that subs is cleaned
1316 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1317
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001318 xappConn1.TestMsgChanEmpty(t)
1319 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001320 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001321 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001322
1323 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001324}
1325
1326//-----------------------------------------------------------------------------
1327// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
1328//
1329// stub stub
1330// +-------+ +---------+ +---------+
1331// | xapp | | submgr | | e2term |
1332// +-------+ +---------+ +---------+
1333// | | |
1334// | SubReq | |
1335// |------------->| |
1336// | | |
1337// | | SubReq |
1338// | |------------->|
1339// | | |
1340// | | |
1341// | | SubReq |
1342// | |------------->|
1343// | | |
1344// | | SubDelReq |
1345// | |------------->|
1346// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001347// | | SubDelResp |
1348// | |<-------------|
1349// | | |
1350//
1351//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001352func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001353 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001354
1355 // Init counter check
1356 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1357 Counter{cSubReqFromXapp, 1},
1358 Counter{cSubReqToE2, 1},
1359 Counter{cSubReReqToE2, 1},
1360 Counter{cSubReqTimerExpiry, 2},
1361 Counter{cSubDelReqToE2, 1},
1362 Counter{cSubDelRespFromE2, 1},
1363 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001364
1365 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001366 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001367
1368 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001369 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001370
1371 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001372 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001373
1374 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001375 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1376 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001377
1378 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001379 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001380
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001381 xappConn1.TestMsgChanEmpty(t)
1382 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001383 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001384 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001385
1386 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001387}
1388
1389//-----------------------------------------------------------------------------
1390// TestSubReqTwoRetriesNoRespAtAllInSubmgr
1391//
1392// stub stub
1393// +-------+ +---------+ +---------+
1394// | xapp | | submgr | | e2term |
1395// +-------+ +---------+ +---------+
1396// | | |
1397// | SubReq | |
1398// |------------->| |
1399// | | |
1400// | | SubReq |
1401// | |------------->|
1402// | | |
1403// | | |
1404// | | SubReq |
1405// | |------------->|
1406// | | |
1407// | | SubDelReq |
1408// | |------------->|
1409// | | |
1410// | | |
1411// | | SubDelReq |
1412// | |------------->|
1413// | | |
1414// | | |
1415//
1416//-----------------------------------------------------------------------------
1417
1418func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001419 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001420
1421 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1422 Counter{cSubReqFromXapp, 1},
1423 Counter{cSubReqToE2, 1},
1424 Counter{cSubReReqToE2, 1},
1425 Counter{cSubReqTimerExpiry, 2},
1426 Counter{cSubDelReqToE2, 1},
1427 Counter{cSubDelReReqToE2, 1},
1428 Counter{cSubDelReqTimerExpiry, 2},
1429 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001430
1431 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001432 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001433
1434 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001435 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001436
1437 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001438 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001439
1440 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001441 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001442
1443 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001444 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001445
1446 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001447 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001448
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001449 xappConn1.TestMsgChanEmpty(t)
1450 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001451 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001452 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001453
1454 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001455}
1456
1457//-----------------------------------------------------------------------------
1458// TestSubReqSubFailRespInSubmgr
1459//
1460// stub stub
1461// +-------+ +---------+ +---------+
1462// | xapp | | submgr | | e2term |
1463// +-------+ +---------+ +---------+
1464// | | |
1465// | SubReq | |
1466// |------------->| |
1467// | | |
1468// | | SubReq |
1469// | |------------->|
1470// | | |
1471// | | SubFail |
1472// | |<-------------|
1473// | | |
1474// | SubFail | |
1475// |<-------------| |
1476// | | |
1477//
1478//-----------------------------------------------------------------------------
1479
1480func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001481 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001482
1483 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1484 Counter{cSubReqFromXapp, 1},
1485 Counter{cSubReqToE2, 1},
1486 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001487 Counter{cSubFailToXapp, 1},
1488 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001489
1490 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001491 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001492
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001493 // E2t: Receive SubsReq and send SubsFail (first)
1494 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1495 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1496 fparams1.Set(crereq1)
1497 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1498
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001499 // Xapp: Receive SubsFail
1500 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1501
1502 // Wait that subs is cleaned
1503 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1504
1505 xappConn1.TestMsgChanEmpty(t)
1506 xappConn2.TestMsgChanEmpty(t)
1507 e2termConn1.TestMsgChanEmpty(t)
1508 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001509
1510 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001511}
1512
1513//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001514// TestSubDelReqRetryInSubmgr
1515//
1516// stub stub
1517// +-------+ +---------+ +---------+
1518// | xapp | | submgr | | e2term |
1519// +-------+ +---------+ +---------+
1520// | | |
1521// | [SUBS CREATE] |
1522// | | |
1523// | | |
1524// | SubDelReq | |
1525// |------------->| |
1526// | | |
1527// | | SubDelReq |
1528// | |------------->|
1529// | | |
1530// | | SubDelReq |
1531// | |------------->|
1532// | | |
1533// | | SubDelResp |
1534// | |<-------------|
1535// | | |
1536// | SubDelResp | |
1537// |<-------------| |
1538//
1539//-----------------------------------------------------------------------------
1540
1541func TestSubDelReqRetryInSubmgr(t *testing.T) {
1542
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001543 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001544
1545 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001546 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001547 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1548 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001549 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001550
1551 // Subs Delete
1552 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001553 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001554
1555 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001556 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001557
1558 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001559 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1560 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001561
1562 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001563 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001564
1565 // Wait that subs is cleaned
1566 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1567
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001568 xappConn1.TestMsgChanEmpty(t)
1569 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001570 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001571 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001572}
1573
1574//-----------------------------------------------------------------------------
1575// TestSubDelReqTwoRetriesNoRespInSubmgr
1576//
1577// stub stub
1578// +-------+ +---------+ +---------+
1579// | xapp | | submgr | | e2term |
1580// +-------+ +---------+ +---------+
1581// | | |
1582// | [SUBS CREATE] |
1583// | | |
1584// | | |
1585// | SubDelReq | |
1586// |------------->| |
1587// | | |
1588// | | SubDelReq |
1589// | |------------->|
1590// | | |
1591// | | SubDelReq |
1592// | |------------->|
1593// | | |
1594// | | |
1595// | SubDelResp | |
1596// |<-------------| |
1597//
1598//-----------------------------------------------------------------------------
1599
1600func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1601
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001602 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001603
1604 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001605 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001606 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1607 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001608 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001609
1610 // Subs Delete
1611 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001612 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001613
1614 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001615 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001616
1617 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001618 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001619
1620 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001621 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001622
1623 // Wait that subs is cleaned
1624 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1625
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001626 xappConn1.TestMsgChanEmpty(t)
1627 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001628 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001629 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001630}
1631
1632//-----------------------------------------------------------------------------
1633// TestSubDelReqSubDelFailRespInSubmgr
1634//
1635// stub stub
1636// +-------+ +---------+ +---------+
1637// | xapp | | submgr | | e2term |
1638// +-------+ +---------+ +---------+
1639// | | |
1640// | [SUBS CREATE] |
1641// | | |
1642// | | |
1643// | SubDelReq | |
1644// |------------->| |
1645// | | |
1646// | | SubDelReq |
1647// | |------------->|
1648// | | |
1649// | | SubDelFail |
1650// | |<-------------|
1651// | | |
1652// | SubDelResp | |
1653// |<-------------| |
1654// | | |
1655//
1656//-----------------------------------------------------------------------------
1657
1658func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001659 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001660
1661 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1662 Counter{cSubReqFromXapp, 1},
1663 Counter{cSubReqToE2, 1},
1664 Counter{cSubRespFromE2, 1},
1665 Counter{cSubRespToXapp, 1},
1666 Counter{cSubDelReqFromXapp, 1},
1667 Counter{cSubDelReqToE2, 1},
1668 Counter{cSubDelFailFromE2, 1},
1669 Counter{cSubDelRespToXapp, 1},
1670 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001671
1672 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001673 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001674 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1675 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001676 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001677
1678 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001679 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001680
1681 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001682 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1683 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001684
1685 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001686 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001687
1688 // Wait that subs is cleaned
1689 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1690
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001691 xappConn1.TestMsgChanEmpty(t)
1692 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001693 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001694 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001695
1696 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001697}
1698
1699//-----------------------------------------------------------------------------
1700// TestSubReqAndSubDelOkSameAction
1701//
1702// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001703// +-------+ +-------+ +---------+ +---------+
1704// | xapp2 | | xapp1 | | submgr | | e2term |
1705// +-------+ +-------+ +---------+ +---------+
1706// | | | |
1707// | | | |
1708// | | | |
1709// | | SubReq1 | |
1710// | |------------->| |
1711// | | | |
1712// | | | SubReq1 |
1713// | | |------------->|
1714// | | | SubResp1 |
1715// | | |<-------------|
1716// | | SubResp1 | |
1717// | |<-------------| |
1718// | | | |
1719// | SubReq2 | |
1720// |--------------------------->| |
1721// | | | |
1722// | SubResp2 | |
1723// |<---------------------------| |
1724// | | | |
1725// | | SubDelReq 1 | |
1726// | |------------->| |
1727// | | | |
1728// | | SubDelResp 1 | |
1729// | |<-------------| |
1730// | | | |
1731// | SubDelReq 2 | |
1732// |--------------------------->| |
1733// | | | |
1734// | | | SubDelReq 2 |
1735// | | |------------->|
1736// | | | |
1737// | | | SubDelReq 2 |
1738// | | |------------->|
1739// | | | |
1740// | SubDelResp 2 | |
1741// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001742//
1743//-----------------------------------------------------------------------------
1744func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001745 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001746
Anssi Mannila4abf1802021-01-28 13:06:46 +02001747 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001748 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1749 Counter{cSubReqFromXapp, 2},
1750 Counter{cSubReqToE2, 1},
1751 Counter{cSubRespFromE2, 1},
1752 Counter{cSubRespToXapp, 2},
1753 Counter{cMergedSubscriptions, 1},
1754 Counter{cUnmergedSubscriptions, 1},
1755 Counter{cSubDelReqFromXapp, 2},
1756 Counter{cSubDelReqToE2, 1},
1757 Counter{cSubDelRespFromE2, 1},
1758 Counter{cSubDelRespToXapp, 2},
1759 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001760
Juha Hyttinen3944a222020-01-24 11:51:46 +02001761 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001762 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001763 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001764 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001765 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1766 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001767 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001768
1769 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001770 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001771 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001772 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001773 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001774
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001775 resp, _ := xapp.Subscription.QuerySubscriptions()
1776 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1777 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001778 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001779
Juha Hyttinen3944a222020-01-24 11:51:46 +02001780 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001781 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001782 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001783
1784 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001785 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001786 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1787 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001788 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001789 //Wait that subs is cleaned
1790 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1791
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001792 xappConn1.TestMsgChanEmpty(t)
1793 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001794 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001795 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001796
1797 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001798}
1799
1800//-----------------------------------------------------------------------------
1801// TestSubReqAndSubDelOkSameActionParallel
1802//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001803// stub stub stub
1804// +-------+ +-------+ +---------+ +---------+
1805// | xapp2 | | xapp1 | | submgr | | e2term |
1806// +-------+ +-------+ +---------+ +---------+
1807// | | | |
1808// | | | |
1809// | | | |
1810// | | SubReq1 | |
1811// | |------------->| |
1812// | | | |
1813// | | | SubReq1 |
1814// | | |------------->|
1815// | SubReq2 | |
1816// |--------------------------->| |
1817// | | | SubResp1 |
1818// | | |<-------------|
1819// | | SubResp1 | |
1820// | |<-------------| |
1821// | | | |
1822// | SubResp2 | |
1823// |<---------------------------| |
1824// | | | |
1825// | | SubDelReq 1 | |
1826// | |------------->| |
1827// | | | |
1828// | | SubDelResp 1 | |
1829// | |<-------------| |
1830// | | | |
1831// | SubDelReq 2 | |
1832// |--------------------------->| |
1833// | | | |
1834// | | | SubDelReq 2 |
1835// | | |------------->|
1836// | | | |
1837// | | | SubDelReq 2 |
1838// | | |------------->|
1839// | | | |
1840// | SubDelResp 2 | |
1841// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001842//
1843//-----------------------------------------------------------------------------
1844func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001845 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001846
1847 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001848 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001849 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001850 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001851 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001852
1853 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001854 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001855 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001856 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001857
1858 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001859 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001860 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001861
1862 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001863 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001864
1865 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001866 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1867 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001868
1869 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001870 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001871 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1872 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001873 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001874
1875 //Wait that subs is cleaned
1876 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1877
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001878 xappConn1.TestMsgChanEmpty(t)
1879 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001880 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001881 mainCtrl.wait_registry_empty(t, 10)
1882}
1883
1884//-----------------------------------------------------------------------------
1885// TestSubReqAndSubDelNokSameActionParallel
1886//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001887// stub stub stub
1888// +-------+ +-------+ +---------+ +---------+
1889// | xapp2 | | xapp1 | | submgr | | e2term |
1890// +-------+ +-------+ +---------+ +---------+
1891// | | | |
1892// | | | |
1893// | | | |
1894// | | SubReq1 | |
1895// | |------------->| |
1896// | | | |
1897// | | | SubReq1 |
1898// | | |------------->|
1899// | SubReq2 | |
1900// |--------------------------->| |
1901// | | | SubFail1 |
1902// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001903// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001904// | | SubFail1 | |
1905// | |<-------------| |
1906// | | | |
1907// | SubFail2 | |
1908// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001909//
1910//-----------------------------------------------------------------------------
1911func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001912 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001913
1914 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001915 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001916 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001917 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001918
1919 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001920 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001921
1922 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001923 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001924 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001925 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001926 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001927 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001928
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001929 // E2t: send SubsFail (first)
1930 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1931 fparams1.Set(crereq1)
1932 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1933
Juha Hyttinen3944a222020-01-24 11:51:46 +02001934 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001935 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001936 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001937 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001938
1939 //Wait that subs is cleaned
1940 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1941
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001942 xappConn1.TestMsgChanEmpty(t)
1943 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001944 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001945 mainCtrl.wait_registry_empty(t, 10)
1946}
1947
1948//-----------------------------------------------------------------------------
1949// TestSubReqAndSubDelNoAnswerSameActionParallel
1950//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001951// stub stub stub
1952// +-------+ +-------+ +---------+ +---------+
1953// | xapp2 | | xapp1 | | submgr | | e2term |
1954// +-------+ +-------+ +---------+ +---------+
1955// | | | |
1956// | | | |
1957// | | | |
1958// | | SubReq1 | |
1959// | |------------->| |
1960// | | | |
1961// | | | SubReq1 |
1962// | | |------------->|
1963// | | SubReq2 | |
1964// |--------------------------->| |
1965// | | | |
1966// | | | SubReq1 |
1967// | | |------------->|
1968// | | | |
1969// | | | |
1970// | | | SubDelReq |
1971// | | |------------->|
1972// | | | |
1973// | | | SubDelResp |
1974// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001975//
1976//-----------------------------------------------------------------------------
1977func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001978 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001979
1980 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001981 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001982 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001983 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001984
Juha Hyttinen1683f912020-04-17 10:39:57 +03001985 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001986
1987 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001988 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001989 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001990 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001991 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001992 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001993
1994 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001995 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001996
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001997 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1998 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001999
2000 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03002001 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002002
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02002003 xappConn1.TestMsgChanEmpty(t)
2004 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002005 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02002006 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02002007}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002008
2009//----------------------------- Policy cases ---------------------------------
2010//-----------------------------------------------------------------------------
2011// TestSubReqPolicyAndSubDelOk
2012//
2013// stub stub
2014// +-------+ +---------+ +---------+
2015// | xapp | | submgr | | e2term |
2016// +-------+ +---------+ +---------+
2017// | | |
2018// | SubReq | |
2019// |------------->| |
2020// | | |
2021// | | SubReq |
2022// | |------------->|
2023// | | |
2024// | | SubResp |
2025// | |<-------------|
2026// | | |
2027// | SubResp | |
2028// |<-------------| |
2029// | | |
2030// | | |
2031// | SubDelReq | |
2032// |------------->| |
2033// | | |
2034// | | SubDelReq |
2035// | |------------->|
2036// | | |
2037// | | SubDelResp |
2038// | |<-------------|
2039// | | |
2040// | SubDelResp | |
2041// |<-------------| |
2042//
2043//-----------------------------------------------------------------------------
2044func TestSubReqPolicyAndSubDelOk(t *testing.T) {
2045 CaseBegin("TestSubReqAndSubDelOk")
2046
2047 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2048 rparams1.Init()
2049 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2050 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2051
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002052 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2053 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002054 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2055 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002056 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002057
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002058 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002059 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002060
2061 //Wait that subs is cleaned
2062 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2063
2064 xappConn1.TestMsgChanEmpty(t)
2065 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002066 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002067 mainCtrl.wait_registry_empty(t, 10)
2068}
2069
2070//-----------------------------------------------------------------------------
2071// TestSubReqPolicyChangeAndSubDelOk
2072//
2073// stub stub
2074// +-------+ +---------+ +---------+
2075// | xapp | | submgr | | e2term |
2076// +-------+ +---------+ +---------+
2077// | | |
2078// | SubReq | |
2079// |------------->| |
2080// | | |
2081// | | SubReq |
2082// | |------------->|
2083// | | |
2084// | | SubResp |
2085// | |<-------------|
2086// | | |
2087// | SubResp | |
2088// |<-------------| |
2089// | | |
2090// | SubReq | |
2091// |------------->| |
2092// | | |
2093// | | SubReq |
2094// | |------------->|
2095// | | |
2096// | | SubResp |
2097// | |<-------------|
2098// | | |
2099// | SubResp | |
2100// |<-------------| |
2101// | | |
2102// | SubDelReq | |
2103// |------------->| |
2104// | | |
2105// | | SubDelReq |
2106// | |------------->|
2107// | | |
2108// | | SubDelResp |
2109// | |<-------------|
2110// | | |
2111// | SubDelResp | |
2112// |<-------------| |
2113//
2114//-----------------------------------------------------------------------------
2115
2116func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
2117 CaseBegin("TestSubReqAndSubDelOk")
2118
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002119 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2120 rparams1.Init()
2121 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
2122 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002123
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002124 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2125 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002126 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2127
2128 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03002129 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002130 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
2131 xappConn1.SendSubsReq(t, rparams1, cretrans)
2132
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002133 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2134 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002135 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2136 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002137 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002138
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002139 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002140 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002141
2142 //Wait that subs is cleaned
2143 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2144
2145 xappConn1.TestMsgChanEmpty(t)
2146 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02002147 e2termConn1.TestMsgChanEmpty(t)
2148 mainCtrl.wait_registry_empty(t, 10)
2149}
2150
2151//-----------------------------------------------------------------------------
2152// TestSubReqAndSubDelOkTwoE2termParallel
2153//
2154// stub stub stub
2155// +-------+ +---------+ +---------+ +---------+
2156// | xapp | | submgr | | e2term1 | | e2term2 |
2157// +-------+ +---------+ +---------+ +---------+
2158// | | | |
2159// | | | |
2160// | | | |
2161// | SubReq1 | | |
2162// |------------->| | |
2163// | | | |
2164// | | SubReq1 | |
2165// | |------------->| |
2166// | | | |
2167// | SubReq2 | | |
2168// |------------->| | |
2169// | | | |
2170// | | SubReq2 | |
2171// | |---------------------------->|
2172// | | | |
2173// | | SubResp1 | |
2174// | |<-------------| |
2175// | SubResp1 | | |
2176// |<-------------| | |
2177// | | SubResp2 | |
2178// | |<----------------------------|
2179// | SubResp2 | | |
2180// |<-------------| | |
2181// | | | |
2182// | [SUBS 1 DELETE] | |
2183// | | | |
2184// | [SUBS 2 DELETE] | |
2185// | | | |
2186//
2187//-----------------------------------------------------------------------------
2188func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
2189 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
2190
2191 //Req1
2192 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
2193 xappConn1.SendSubsReq(t, nil, cretrans1)
2194 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2195
2196 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
2197 xappConn1.SendSubsReq(t, nil, cretrans2)
2198 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
2199
2200 //Resp1
2201 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2202 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2203
2204 //Resp2
2205 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
2206 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
2207
2208 //Del1
2209 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2210 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2211 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2212 xappConn1.RecvSubsDelResp(t, deltrans1)
2213 //Wait that subs is cleaned
2214 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2215
2216 //Del2
2217 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
2218 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
2219 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
2220 xappConn1.RecvSubsDelResp(t, deltrans2)
2221 //Wait that subs is cleaned
2222 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2223
2224 xappConn1.TestMsgChanEmpty(t)
2225 xappConn2.TestMsgChanEmpty(t)
2226 e2termConn1.TestMsgChanEmpty(t)
2227 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02002228 mainCtrl.wait_registry_empty(t, 10)
2229}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03002230
2231//-----------------------------------------------------------------------------
2232// TestSubReqInsertAndSubDelOk
2233//
2234// stub stub
2235// +-------+ +---------+ +---------+
2236// | xapp | | submgr | | e2term |
2237// +-------+ +---------+ +---------+
2238// | | |
2239// | SubReq | |
2240// |------------->| |
2241// | | |
2242// | | SubReq |
2243// | |------------->|
2244// | | |
2245// | | SubResp |
2246// | |<-------------|
2247// | | |
2248// | SubResp | |
2249// |<-------------| |
2250// | | |
2251// | | |
2252// | SubDelReq | |
2253// |------------->| |
2254// | | |
2255// | | SubDelReq |
2256// | |------------->|
2257// | | |
2258// | | SubDelResp |
2259// | |<-------------|
2260// | | |
2261// | SubDelResp | |
2262// |<-------------| |
2263//
2264//-----------------------------------------------------------------------------
2265func TestSubReqInsertAndSubDelOk(t *testing.T) {
2266 CaseBegin("TestInsertSubReqAndSubDelOk")
2267
2268 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2269 rparams1.Init()
2270 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
2271 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
2272
2273 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2274 e2termConn1.SendSubsResp(t, crereq, cremsg)
2275 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2276 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2277 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2278
2279 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2280 xappConn1.RecvSubsDelResp(t, deltrans)
2281
2282 //Wait that subs is cleaned
2283 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2284
2285 xappConn1.TestMsgChanEmpty(t)
2286 xappConn2.TestMsgChanEmpty(t)
2287 e2termConn1.TestMsgChanEmpty(t)
2288 mainCtrl.wait_registry_empty(t, 10)
2289}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02002290
2291//-----------------------------------------------------------------------------
2292// TestSubReqRetransmissionWithSameSubIdDiffXid
2293//
2294// This case simulates case where xApp restarts and starts sending same
2295// subscription requests which have already subscribed successfully
2296
2297// stub stub
2298// +-------+ +---------+ +---------+
2299// | xapp | | submgr | | e2term |
2300// +-------+ +---------+ +---------+
2301// | | |
2302// | SubReq | |
2303// |------------->| |
2304// | | |
2305// | | SubReq |
2306// | |------------->|
2307// | | |
2308// | | SubResp |
2309// | |<-------------|
2310// | | |
2311// | SubResp | |
2312// |<-------------| |
2313// | | |
2314// | xApp restart | |
2315// | | |
2316// | SubReq | |
2317// | (retrans with same xApp generated subid but diff xid)
2318// |------------->| |
2319// | | |
2320// | SubResp | |
2321// |<-------------| |
2322// | | |
2323// | [SUBS DELETE] |
2324// | | |
2325//
2326//-----------------------------------------------------------------------------
2327func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
2328 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
2329
2330 //Subs Create
2331 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2332 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2333 e2termConn1.SendSubsResp(t, crereq, cremsg)
2334 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2335
2336 // xApp restart here
2337 // --> artificial delay
2338 <-time.After(1 * time.Second)
2339
2340 //Subs Create
2341 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
2342 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
2343
2344 //Subs Delete
2345 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2346 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2347 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2348 xappConn1.RecvSubsDelResp(t, deltrans)
2349
2350 //Wait that subs is cleaned
2351 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2352
2353 xappConn1.TestMsgChanEmpty(t)
2354 xappConn2.TestMsgChanEmpty(t)
2355 e2termConn1.TestMsgChanEmpty(t)
2356 mainCtrl.wait_registry_empty(t, 10)
2357}
Anssi Mannilac92b4212020-12-07 14:59:34 +02002358
2359//-----------------------------------------------------------------------------
2360// TestSubReqNokAndSubDelOkWithRestartInMiddle
2361//
2362// stub stub
2363// +-------+ +---------+ +---------+
2364// | xapp | | submgr | | e2term |
2365// +-------+ +---------+ +---------+
2366// | | |
2367// | SubReq | |
2368// |------------->| |
2369// | | |
2370// | | SubReq |
2371// | |------------->|
2372// | | |
2373// | | SubResp |
2374// | <----|
2375// | |
2376// | Submgr restart |
2377// | |
2378// | | |
2379// | | SubDelReq |
2380// | |------------->|
2381// | | |
2382// | | SubDelResp |
2383// | |<-------------|
2384// | | |
2385//
2386//-----------------------------------------------------------------------------
2387
2388func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
2389 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
2390
Anssi Mannilac92b4212020-12-07 14:59:34 +02002391 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
2392 xappConn1.SendSubsReq(t, nil, nil)
2393 e2termConn1.RecvSubsReq(t)
2394 mainCtrl.SetResetTestFlag(t, false)
2395
2396 resp, _ := xapp.Subscription.QuerySubscriptions()
2397 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002398 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002399 e2SubsId := uint32(resp[0].SubscriptionID)
2400 t.Logf("e2SubsId = %v", e2SubsId)
2401
archaggeafbf95f2021-04-14 08:54:05 +03002402 mainCtrl.SimulateRestart(t)
2403 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002404
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002405 // Submgr send delete for uncompleted subscription
Anssi Mannilac92b4212020-12-07 14:59:34 +02002406 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2407 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2408
2409 // Wait that subs is cleaned
2410 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2411
2412 xappConn1.TestMsgChanEmpty(t)
2413 xappConn2.TestMsgChanEmpty(t)
2414 e2termConn1.TestMsgChanEmpty(t)
2415 mainCtrl.wait_registry_empty(t, 10)
2416}
2417
2418//-----------------------------------------------------------------------------
2419// TestSubReqAndSubDelOkWithRestartInMiddle
2420//
2421// stub stub
2422// +-------+ +---------+ +---------+
2423// | xapp | | submgr | | e2term |
2424// +-------+ +---------+ +---------+
2425// | | |
2426// | SubReq | |
2427// |------------->| |
2428// | | |
2429// | | SubReq |
2430// | |------------->|
2431// | | |
2432// | | SubResp |
2433// | |<-------------|
2434// | | |
2435// | SubResp | |
2436// |<-------------| |
2437// | | |
2438// | |
2439// | Submgr restart |
2440// | |
2441// | SubDelReq | |
2442// |------------->| |
2443// | | |
2444// | | SubDelReq |
2445// | |------------->|
2446// | | |
2447// | | SubDelResp |
2448// | |<-------------|
2449// | | |
2450// | SubDelResp | |
2451// |<-------------| |
2452//
2453//-----------------------------------------------------------------------------
2454
2455func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2456 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2457
2458 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2459 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2460 e2termConn1.SendSubsResp(t, crereq, cremsg)
2461 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2462
2463 // Check subscription
2464 resp, _ := xapp.Subscription.QuerySubscriptions()
2465 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2466 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002467 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002468
2469 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002470 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002471
Anssi Mannila54838ed2021-11-19 11:25:01 +02002472 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2473 // That needs to be completed before successful subscription query is possible
2474 <-time.After(time.Second * 1)
2475
Anssi Mannilac92b4212020-12-07 14:59:34 +02002476 // Check that subscription is restored correctly after restart
2477 resp, _ = xapp.Subscription.QuerySubscriptions()
2478 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2479 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002480 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002481
2482 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2483 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2484 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2485 xappConn1.RecvSubsDelResp(t, deltrans)
2486
2487 //Wait that subs is cleaned
2488 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2489
2490 xappConn1.TestMsgChanEmpty(t)
2491 xappConn2.TestMsgChanEmpty(t)
2492 e2termConn1.TestMsgChanEmpty(t)
2493 mainCtrl.wait_registry_empty(t, 10)
2494}
2495
2496//-----------------------------------------------------------------------------
2497// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2498//
2499// stub stub
2500// +-------+ +-------+ +---------+ +---------+
2501// | xapp2 | | xapp1 | | submgr | | e2term |
2502// +-------+ +-------+ +---------+ +---------+
2503// | | | |
2504// | | | |
2505// | | | |
2506// | | SubReq1 | |
2507// | |------------->| |
2508// | | | |
2509// | | | SubReq1 |
2510// | | |------------->|
2511// | | | SubResp1 |
2512// | | |<-------------|
2513// | | SubResp1 | |
2514// | |<-------------| |
2515// | | | |
2516// | |
2517// | submgr restart |
2518// | |
2519// | | | |
2520// | | | |
2521// | SubReq2 | |
2522// |--------------------------->| |
2523// | | | |
2524// | SubResp2 | |
2525// |<---------------------------| |
2526// | | | |
2527// | | SubDelReq 1 | |
2528// | |------------->| |
2529// | | | |
2530// | | SubDelResp 1 | |
2531// | |<-------------| |
2532// | | | |
2533// | | | |
2534// | |
2535// | submgr restart |
2536// | |
2537// | | | |
2538// | SubDelReq 2 | |
2539// |--------------------------->| |
2540// | | | |
2541// | | | SubDelReq 2 |
2542// | | |------------->|
2543// | | | |
2544// | | | SubDelReq 2 |
2545// | | |------------->|
2546// | | | |
2547// | SubDelResp 2 | |
2548// |<---------------------------| |
2549//
2550//-----------------------------------------------------------------------------
2551
2552func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2553 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2554
2555 //Req1
2556 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2557 rparams1.Init()
2558 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2559 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2560 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2561 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2562
2563 //Req2
2564 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2565 rparams2.Init()
2566 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2567 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2568
2569 // Check subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02002570 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannilac92b4212020-12-07 14:59:34 +02002571 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2572 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002573 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002574
2575 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002576 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002577
Anssi Mannila54838ed2021-11-19 11:25:01 +02002578 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2579 // That needs to be completed before successful subscription query is possible
2580 <-time.After(time.Second * 1)
2581
Anssi Mannilac92b4212020-12-07 14:59:34 +02002582 // Check that subscription is restored correctly after restart
2583 resp, _ = xapp.Subscription.QuerySubscriptions()
2584 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2585 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002586 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002587
2588 //Del1
2589 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2590 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2591 xappConn1.RecvSubsDelResp(t, deltrans1)
2592 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2593
2594 mainCtrl.SimulateRestart(t)
2595 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2596
Anssi Mannila54838ed2021-11-19 11:25:01 +02002597 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
2598 // Submgr need be ready before successful subscription deletion is possible
2599 <-time.After(time.Second * 1)
2600
Anssi Mannilac92b4212020-12-07 14:59:34 +02002601 //Del2
2602 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2603 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2604
2605 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2606 xappConn2.RecvSubsDelResp(t, deltrans2)
2607
2608 //Wait that subs is cleaned
2609 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2610
2611 xappConn1.TestMsgChanEmpty(t)
2612 xappConn2.TestMsgChanEmpty(t)
2613 e2termConn1.TestMsgChanEmpty(t)
2614 mainCtrl.wait_registry_empty(t, 10)
2615}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002616
archaggeafbf95f2021-04-14 08:54:05 +03002617//*****************************************************************************
2618// REST interface test cases
2619//*****************************************************************************
2620
Anssi Mannila47518ae2021-04-16 09:27:07 +03002621//-----------------------------------------------------------------------------
2622// Test debug GET and POST requests
2623//
2624// curl
2625// +-------+ +---------+
2626// | user | | submgr |
2627// +-------+ +---------+
2628// | |
2629// | GET/POST Req |
2630// |------------->|
2631// | Resp |
2632// |<-------------|
2633// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002634func TestGetSubscriptions(t *testing.T) {
2635
Anssi Mannila92c38552021-12-29 09:59:24 +02002636 mainCtrl.SendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002637}
2638
2639func TestGetSymptomData(t *testing.T) {
2640
Anssi Mannila92c38552021-12-29 09:59:24 +02002641 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002642}
2643
2644func TestPostdeleteSubId(t *testing.T) {
2645
Anssi Mannila92c38552021-12-29 09:59:24 +02002646 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002647}
2648
2649func TestPostEmptyDb(t *testing.T) {
2650
Anssi Mannila92c38552021-12-29 09:59:24 +02002651 mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
Anssi Mannila47518ae2021-04-16 09:27:07 +03002652}
archaggeafbf95f2021-04-14 08:54:05 +03002653
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002654func TestGetRestSubscriptions(t *testing.T) {
2655
Anssi Mannila92c38552021-12-29 09:59:24 +02002656 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions")
2657}
2658
2659//-----------------------------------------------------------------------------
2660// TestDelAllE2nodeSubsViaDebugIf
2661//
2662// stub stub stub
2663// +-------+ +---------+ +---------+ +---------+
2664// | xapp | | submgr | | e2term | | rtmgr |
2665// +-------+ +---------+ +---------+ +---------+
2666// | | | |
2667// | RESTSubReq | | |
2668// |---------------->| | |
2669// | RESTSubResp | | |
2670// |<----------------| | |
2671// | | RouteCreate | |
2672// | |--------------------------->|
2673// | | RouteResponse| |
2674// | |<---------------------------|
2675// | | SubReq | |
2676// | |------------->| |
2677// | | SubResp | |
2678// | |<-------------| |
2679// | RESTNotif1 | | |
2680// |<----------------| | |
2681// | | | |
2682// | REST get_all_e2nodes | |
2683// |---------------->| | |
2684// | OK 200 | | |
2685// |<----------------| | |
2686// | REST delete_all_e2node_subscriptions | ranName = RAN_NAME_1
2687// |---------------->| | |
2688// | OK 200 | | |
2689// |<----------------| | |
2690// | | SubDelReq | |
2691// | |------------->| |
2692// | | SubDelResp | |
2693// | |<-------------| |
2694// | | | |
2695// | | RouteDelete | |
2696// | |--------------------------->|
2697// | | RouteResponse| |
2698// | |<---------------------------|
2699//
2700//-----------------------------------------------------------------------------
2701
2702func TestDelAllE2nodeSubsViaDebugIf(t *testing.T) {
2703
2704 // Init counter check
2705 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2706 Counter{cRestSubReqFromXapp, 1},
2707 Counter{cRestSubRespToXapp, 1},
2708 Counter{cSubReqToE2, 1},
2709 Counter{cSubRespFromE2, 1},
2710 Counter{cRestSubNotifToXapp, 1},
2711 Counter{cRestSubDelReqFromXapp, 1},
2712 Counter{cSubDelReqToE2, 1},
2713 Counter{cSubDelRespFromE2, 1},
2714 Counter{cRestSubDelRespToXapp, 1},
2715 })
2716
2717 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2718 restSubId := xappConn1.SendRESTSubsReq(t, params)
2719 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2720
2721 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2722 xappConn1.ExpectRESTNotification(t, restSubId)
2723 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2724 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2725 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2726
2727 e2nodesJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_e2nodes")
2728
2729 var e2nodesList []string
2730 err := json.Unmarshal(e2nodesJson, &e2nodesList)
2731 if err != nil {
2732 t.Errorf("Unmarshal error: %s", err)
2733 }
2734 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("RAN_NAME_1", e2nodesList))
2735
2736 e2RestSubsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2node_rest_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
2737 var e2RestSubsMap map[string]RESTSubscription
2738 err = json.Unmarshal(e2RestSubsJson, &e2RestSubsMap)
2739 if err != nil {
2740 t.Errorf("Unmarshal error: %s", err)
2741 }
2742
2743 if len(e2RestSubsMap) != 1 {
2744 t.Errorf("Incorrect e2RestSubsMap length %v", len(e2RestSubsMap))
2745 }
2746
2747 // Simulate deletion through REST test and debug interface
2748 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/delete_all_e2node_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName
2749 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2750 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2751
2752 // Wait that subs is cleaned
2753 waitSubsCleanup(t, e2SubsId, 10)
2754 mainCtrl.VerifyCounterValues(t)
2755 mainCtrl.VerifyAllClean(t)
2756}
2757
2758//-----------------------------------------------------------------------------
2759// TestDelAllxAppSubsViaDebugIf
2760//
2761// stub stub stub
2762// +-------+ +---------+ +---------+ +---------+
2763// | xapp | | submgr | | e2term | | rtmgr |
2764// +-------+ +---------+ +---------+ +---------+
2765// | | | |
2766// | RESTSubReq | | |
2767// |---------------->| | |
2768// | RESTSubResp | | |
2769// |<----------------| | |
2770// | | RouteCreate | |
2771// | |--------------------------->|
2772// | | RouteResponse| |
2773// | |<---------------------------|
2774// | | SubReq | |
2775// | |------------->| |
2776// | | SubResp | |
2777// | |<-------------| |
2778// | RESTNotif1 | | |
2779// |<----------------| | |
2780// | | | |
2781// | REST get_all_xapps | |
2782// |---------------->| | |
2783// | OK 200 | | |
2784// |<----------------| | |
2785// | REST delete_all_xapp_subscriptions | xappServiceName = localhost
2786// |---------------->| | |
2787// | OK 200 | | |
2788// |<----------------| | |
2789// | | SubDelReq | |
2790// | |------------->| |
2791// | | SubDelResp | |
2792// | |<-------------| |
2793// | | | |
2794// | | RouteDelete | |
2795// | |--------------------------->|
2796// | | RouteResponse| |
2797// | |<---------------------------|
2798//
2799//-----------------------------------------------------------------------------
2800
2801func TestDelAllxAppSubsViaDebugIf(t *testing.T) {
2802
2803 // Init counter check
2804 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2805 Counter{cRestSubReqFromXapp, 1},
2806 Counter{cRestSubRespToXapp, 1},
2807 Counter{cSubReqToE2, 1},
2808 Counter{cSubRespFromE2, 1},
2809 Counter{cRestSubNotifToXapp, 1},
2810 Counter{cRestSubDelReqFromXapp, 1},
2811 Counter{cSubDelReqToE2, 1},
2812 Counter{cSubDelRespFromE2, 1},
2813 Counter{cRestSubDelRespToXapp, 1},
2814 })
2815
2816 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2817 restSubId := xappConn1.SendRESTSubsReq(t, params)
2818 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2819
2820 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2821 xappConn1.ExpectRESTNotification(t, restSubId)
2822 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2823 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2824 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2825
2826 xappsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_xapps")
2827
2828 var xappList []string
2829 err := json.Unmarshal(xappsJson, &xappList)
2830 if err != nil {
2831 t.Errorf("Unmarshal error: %s", err)
2832 }
2833 assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("localhost", xappList))
2834
2835 // Simulate deletion through REST test and debug interface
2836 mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/delete_all_xapp_subscriptions/localhost") // localhost = xappServiceName
2837 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2838 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2839
2840 // Wait that subs is cleaned
2841 waitSubsCleanup(t, e2SubsId, 10)
2842 mainCtrl.VerifyCounterValues(t)
2843 mainCtrl.VerifyAllClean(t)
2844}
2845
2846//-----------------------------------------------------------------------------
2847// TestDelViaxAppSubsIf
2848//
2849// stub stub stub
2850// +-------+ +---------+ +---------+ +---------+
2851// | xapp | | submgr | | e2term | | rtmgr |
2852// +-------+ +---------+ +---------+ +---------+
2853// | | | |
2854// | RESTSubReq | | |
2855// |---------------->| | |
2856// | RESTSubResp | | |
2857// |<----------------| | |
2858// | | RouteCreate | |
2859// | |--------------------------->|
2860// | | RouteResponse| |
2861// | |<---------------------------|
2862// | | SubReq | |
2863// | |------------->| |
2864// | | SubResp | |
2865// | |<-------------| |
2866// | RESTNotif1 | | |
2867// |<----------------| | |
2868// | | | |
2869// | REST get_xapp_rest_restsubscriptions |
2870// |---------------->| | |
2871// | OK 200 | | |
2872// |<----------------| | |
2873// | RESTSudDel | | |
2874// |---------------->| | | Via user curl command (port 8088)
2875// | RESTSudDel | | |
2876// |<----------------| | |
2877// | | SubDelReq | |
2878// | |------------->| |
2879// | | SubDelResp | |
2880// | |<-------------| |
2881// | | | |
2882// | | RouteDelete | |
2883// | |--------------------------->|
2884// | | RouteResponse| |
2885// | |<---------------------------|
2886//
2887//-----------------------------------------------------------------------------
2888
2889func TestDelViaxAppSubsIf(t *testing.T) {
2890
2891 // Init counter check
2892 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2893 Counter{cRestSubReqFromXapp, 1},
2894 Counter{cRestSubRespToXapp, 1},
2895 Counter{cSubReqToE2, 1},
2896 Counter{cSubRespFromE2, 1},
2897 Counter{cRestSubNotifToXapp, 1},
2898 Counter{cRestSubDelReqFromXapp, 1},
2899 Counter{cSubDelReqToE2, 1},
2900 Counter{cSubDelRespFromE2, 1},
2901 Counter{cRestSubDelRespToXapp, 1},
2902 })
2903
2904 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
2905 restSubId := xappConn1.SendRESTSubsReq(t, params)
2906 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
2907
2908 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2909 xappConn1.ExpectRESTNotification(t, restSubId)
2910 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2911 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2912 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
2913
2914 restSubsListJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_xapp_rest_restsubscriptions/localhost") // localhost = xappServiceName
2915
2916 var restSubsMap map[string]RESTSubscription
2917 err := json.Unmarshal(restSubsListJson, &restSubsMap)
2918 if err != nil {
2919 t.Errorf("Unmarshal error: %s", err)
2920 }
2921 _, ok := restSubsMap[restSubId]
2922 if !ok {
2923 t.Errorf("REST subscription not found. restSubId=%s", restSubId)
2924 }
2925
2926 var e2Subscriptions []Subscription
2927 e2SubscriptionsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2subscriptions/"+restSubId)
2928 err = json.Unmarshal(e2SubscriptionsJson, &e2Subscriptions)
2929 if err != nil {
2930 t.Errorf("Unmarshal error: %s", err)
2931 }
2932 if len(e2Subscriptions) != 1 {
2933 t.Errorf("Incorrect e2Subscriptions length %v", len(e2Subscriptions))
2934 }
2935
2936 // Simulate deletion through xapp REST test interface
2937 mainCtrl.SendDeleteRequest(t, "localhost:8088", "/ric/v1/subscriptions/"+restSubId)
2938 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2939 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2940
2941 // Wait that subs is cleaned
2942 waitSubsCleanup(t, e2SubsId, 10)
2943 mainCtrl.VerifyCounterValues(t)
2944 mainCtrl.VerifyAllClean(t)
Anssi Mannilab73e7cd2021-08-03 11:57:11 +03002945}
2946
archaggeafbf95f2021-04-14 08:54:05 +03002947//-----------------------------------------------------------------------------
2948// TestRESTSubReqAndRouteNok
2949//
2950// stub stub
2951// +-------+ +---------+ +---------+
2952// | xapp | | submgr | | rtmgr |
2953// +-------+ +---------+ +---------+
2954// | | |
2955// | RESTSubReq | |
2956// |---------------->| |
2957// | | |
2958// | RESTSubResp | |
2959// |<----------------| |
2960// | | RouteCreate |
2961// | |------------->|
archaggeafbf95f2021-04-14 08:54:05 +03002962// | | RouteCreate |
2963// | | status:400 |
2964// | |(Bad request) |
2965// | |<-------------|
2966// | RESTNotif | |
2967// |<----------------| |
2968// | | |
2969// | [SUBS INT DELETE] |
2970// | | |
2971// | RESTSubDelReq | |
2972// |---------------->| |
2973// | RESTSubDelResp | |
2974// |<----------------| |
2975//
2976//-----------------------------------------------------------------------------
2977func TestRESTSubReqAndRouteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03002978
2979 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002980 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002981 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002982 Counter{cRouteCreateFail, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03002983 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00002984 Counter{cRestSubDelReqFromXapp, 1},
2985 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03002986 })
2987
2988 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03002989
Markku Virtanenda34eec2021-05-20 08:22:04 +00002990 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2991 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002992 newSubsId := mainCtrl.get_registry_next_subid(t)
2993
2994 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00002995 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03002996 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanen55d2a282021-06-04 14:46:56 +03002997 xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
archaggeafbf95f2021-04-14 08:54:05 +03002998 waiter.WaitResult(t)
2999
archaggeafbf95f2021-04-14 08:54:05 +03003000 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003001 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003002
3003 // Del
3004 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3005
3006 // Wait that subs is cleaned
3007 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3008 waitSubsCleanup(t, e2SubsId, 10)
3009 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003010 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003011}
3012
Anssi Mannila27385172021-12-22 09:41:54 +02003013//-----------------------------------------------------------------------------
3014// TestRESTSubReqAndRouteUpdateNok
3015//
3016// stub stub stub stub
3017// +-------+ +-------+ +---------+ +---------+ +---------+
3018// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3019// +-------+ +-------+ +---------+ +---------+ +---------+
3020// | | | | |
3021// | RESTSubReq1 | | |
3022// |------------------------>| | |
3023// | RESTSubResp2 | | |
3024// |<------------------------| | |
3025// | | | | |
3026// | | | RouteCreate | |
3027// | | |------------->| |
3028// | | | CreateResp | |
3029// | | |<-------------| |
3030// | | | SubReq | |
3031// | | |---------------------------->|
3032// | | | SubResp | |
3033// | | |<----------------------------|
3034// | RESTNotif1 | | |
3035// |<------------------------| | |
3036// | | | | |
3037// | | RESTSubReq2 | | |
3038// | |------------>| | |
3039// | | RESTSubResp2| | |
3040// | |<------------| | |
3041// | | | RouteUpdate | |
3042// | | |------------->| |
3043// | | | RouteUpdate | |
3044// | | | status:400 | |
3045// | | |(Bad request) | |
3046// | | |<-------------| |
3047// | | RESTNotif2(unsuccessful) | |
3048// | |<------------| | |
3049// | | | | |
3050// | [SUBS INT DELETE] | |
3051// | | | | |
3052// | RESTSubDelReq1 | | |
3053// |------------------------>| | |
3054// | RESTSubDelResp1 | | |
3055// |<------------------------| | |
3056// | | | | |
3057// | | | [SUBS DELETE] |
3058//
3059//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03003060func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003061
3062 //Init counter check
3063 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003064 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003065 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003066 Counter{cSubReqToE2, 1},
3067 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003068 Counter{cRestSubNotifToXapp, 1},
3069 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003070 Counter{cRouteCreateUpdateFail, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003071 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003072 Counter{cSubDelReqToE2, 1},
3073 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02003074 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003075 })
3076
3077 var params *teststube2ap.RESTSubsReqParams = nil
3078
Anssi Mannila27385172021-12-22 09:41:54 +02003079 // Subs create for xapp1
archaggeafbf95f2021-04-14 08:54:05 +03003080 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3081
3082 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3083
3084 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
3085 waiter := rtmgrHttp.AllocNextEvent(false)
3086 newSubsId := mainCtrl.get_registry_next_subid(t)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003087 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03003088 params.SetMeid("RAN_NAME_1")
3089 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03003090 xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
Markku Virtanen55d2a282021-06-04 14:46:56 +03003091 xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03003092 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003093 xappConn2.WaitRESTNotification(t, restSubId2)
3094
3095 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3096
3097 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003098 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03003099
3100 mainCtrl.wait_subs_clean(t, newSubsId, 10)
3101 //Wait that subs is cleaned
3102 waitSubsCleanup(t, e2SubsId, 10)
3103
3104 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003105 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003106}
3107
Anssi Mannila27385172021-12-22 09:41:54 +02003108//-----------------------------------------------------------------------------
3109// TestRESTSubDelReqAndRouteDeleteNok
3110//
3111// stub stub stub
3112// +-------+ +---------+ +---------+ +---------+
3113// | xapp | | submgr | | rtmgr | | e2term |
3114// +-------+ +---------+ +---------+ +---------+
3115// | | | |
3116// | RESTSubReq | | |
3117// |---------------->| | |
3118// | | | |
3119// | RESTSubResp | | |
3120// |<----------------| | |
3121// | | SubReq | |
3122// | |---------------------------->|
3123// | | SubResp | |
3124// | |<----------------------------|
3125// | RESTNotif | | |
3126// |<----------------| | |
3127// | | | |
3128// | | | |
3129// | RESTSubDelReq | | |
3130// |---------------->| | |
3131// | RESTSubDelResp | | |
3132// |<----------------| | |
3133// | | SubSelReq | |
3134// | |---------------------------->|
3135// | | SubSelResp | |
3136// | |<----------------------------|
3137// | | RouteDelete | |
3138// | |------------->| |
3139// | | Routedelete | |
3140// | | status:400 | |
3141// | |(Bad request) | |
3142// | |<-------------| |
3143//
3144//-----------------------------------------------------------------------------
3145
archaggeafbf95f2021-04-14 08:54:05 +03003146func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003147
3148 // Init counter check
3149 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003150 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003151 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003152 Counter{cSubReqToE2, 1},
3153 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003154 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003155 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003156 Counter{cRouteDeleteFail, 1},
3157 Counter{cSubDelReqToE2, 1},
3158 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003159 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003160 })
3161
3162 var params *teststube2ap.RESTSubsReqParams = nil
3163
3164 //Subs Create
3165 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3166
3167 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3168
3169 waiter := rtmgrHttp.AllocNextEvent(false)
3170 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3171 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3172 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3173 waiter.WaitResult(t)
3174
3175 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003176 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003177 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003178}
3179
Anssi Mannila27385172021-12-22 09:41:54 +02003180//-----------------------------------------------------------------------------
3181// TestRESTSubMergeDelAndRouteUpdateNok
3182//
3183// stub stub stub stub
3184// +-------+ +-------+ +---------+ +---------+ +---------+
3185// | xapp1 | | xapp2 | | submgr | | rtmgr | | e2term |
3186// +-------+ +-------+ +---------+ +---------+ +---------+
3187// | | | | |
3188// | RESTSubReq1 | | |
3189// |------------------------>| | |
3190// | RESTSubResp2 | | |
3191// |<------------------------| | |
3192// | | | | |
3193// | | | RouteCreate | |
3194// | | |------------->| |
3195// | | | CreateResp | |
3196// | | |<-------------| |
3197// | | | SubReq | |
3198// | | |---------------------------->|
3199// | | | SubResp | |
3200// | | |<----------------------------|
3201// | RESTNotif1 | | |
3202// |<------------------------| | |
3203// | | | | |
3204// | | RESTSubReq2 | | |
3205// | |------------>| | |
3206// | | RESTSubResp2| | |
3207// | |<------------| | |
3208// | | | RouteCreate | |
3209// | | |------------->| |
3210// | | | CreateResp | |
3211// | | |<-------------| |
3212// | | | SubReq | |
3213// | | |---------------------------->|
3214// | | | SubResp | |
3215// | | |<----------------------------|
3216// | | RESTNotif2 | | |
3217// | |<------------| | |
3218// | | | | |
3219// | [SUBS INT DELETE] | |
3220// | | | | |
3221// | RESTSubDelReq1 | | |
3222// |------------------------>| | |
3223// | RESTSubDelResp1 | | |
3224// |<------------------------| | |
3225// | | | SubDelReq | |
3226// | | |---------------------------->|
3227// | | | SubDelResp | |
3228// | | |<----------------------------|
3229// | | | RouteUpdate | |
3230// | | |------------->| |
3231// | | | RouteUpdate | |
3232// | | | status:400 | |
3233// | | |(Bad request) | |
3234// | | |<-------------| |
3235// | | | | |
3236// | | RESTSubDelReq2 | |
3237// | |------------>| | |
3238// | | RESTSubDelResp2 | |
3239// | |<------------| | |
3240// | | | SubDelReq | |
3241// | | |---------------------------->|
3242// | | | SubdelResp | |
3243// | | |<----------------------------|
3244// | | | RouteDelete | |
3245// | | |------------->| |
3246// | | | Deleteresp | |
3247// | | |<-------------| |
3248
3249//-----------------------------------------------------------------------------
3250
archaggeafbf95f2021-04-14 08:54:05 +03003251func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003252
3253 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003254 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003255 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003256 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003257 Counter{cSubReqToE2, 1},
3258 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003259 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003260 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003261 Counter{cRouteDeleteUpdateFail, 1},
3262 Counter{cSubDelReqToE2, 1},
3263 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003264 Counter{cRestSubDelRespToXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003265 Counter{cUnmergedSubscriptions, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003266 })
3267
3268 var params *teststube2ap.RESTSubsReqParams = nil
3269
3270 //Subs Create
3271 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3272
3273 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3274 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
3275
3276 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3277
3278 //Del1, this shall fail on rtmgr side
3279 waiter := rtmgrHttp.AllocNextEvent(false)
3280 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3281 waiter.WaitResult(t)
3282
3283 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
3284
3285 //Del2
3286 deleteXapp2Subscription(t, &restSubId2)
3287
3288 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003289 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003290 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003291}
3292
3293//-----------------------------------------------------------------------------
3294// TestRESTSubReqRetransmission
3295//
3296// stub stub
3297// +-------+ +---------+ +---------+
3298// | xapp | | submgr | | e2term |
3299// +-------+ +---------+ +---------+
3300// | | |
3301// | RESTSubReq1 | |
3302// |---------------->| |
3303// | | |
3304// | RESTSubResp | |
3305// |<----------------| |
3306// | | SubReq1 |
3307// | |------------->|
3308// | | |
3309// | RESTSubReq2 | |
3310// | (retrans) | |
3311// |---------------->| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003312// | RESTSubResp(201)| |
archaggeafbf95f2021-04-14 08:54:05 +03003313// |<----------------| |
Markku Virtanenb642a192021-06-09 09:08:14 +00003314// | | |
archaggeafbf95f2021-04-14 08:54:05 +03003315// | | SubResp1 |
3316// | |<-------------|
3317// | RESTNotif1 | |
3318// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03003319// | | |
3320// | [SUBS DELETE] |
3321// | | |
3322//
3323//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00003324
archaggeafbf95f2021-04-14 08:54:05 +03003325func TestRESTSubReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003326
3327 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003328 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003329 Counter{cRestSubRespToXapp, 2},
Markku Virtanenb642a192021-06-09 09:08:14 +00003330 Counter{cSubReqToE2, 1},
3331 Counter{cSubRespFromE2, 1},
3332 Counter{cRestSubNotifToXapp, 1},
3333 Counter{cRestSubDelReqFromXapp, 1},
3334 Counter{cSubDelReqToE2, 1},
3335 Counter{cSubDelRespFromE2, 1},
3336 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003337 })
Markku Virtanen42723e22021-06-15 10:09:23 +03003338 // Retry/duplicate will get the same way as the first request.
archaggeafbf95f2021-04-14 08:54:05 +03003339 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
3340 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
3341
3342 // Subs Create
3343 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03003344
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00003345 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003346 restSubId := xappConn1.SendRESTSubsReq(t, params)
archaggeafbf95f2021-04-14 08:54:05 +03003347
Anssi Mannilab43397e2021-11-16 12:06:16 +02003348 xappConn1.SendRESTSubsReq(t, params)
3349 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03003350
Anssi Mannilab43397e2021-11-16 12:06:16 +02003351 xappConn1.WaitListedRestNotifications(t, []string{restSubId})
archaggeafbf95f2021-04-14 08:54:05 +03003352
3353 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
Anssi Mannilab43397e2021-11-16 12:06:16 +02003354 // the order is not significant here.
archaggeafbf95f2021-04-14 08:54:05 +03003355 crereq, cremsg := e2termConn1.RecvSubsReq(t)
3356 e2termConn1.SendSubsResp(t, crereq, cremsg)
archaggeafbf95f2021-04-14 08:54:05 +03003357
Anssi Mannilab43397e2021-11-16 12:06:16 +02003358 e2SubsId := <-xappConn1.ListedRESTNotifications
3359
3360 xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03003361
3362 // Del1
Anssi Mannilab43397e2021-11-16 12:06:16 +02003363 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03003364 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3365 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3366
Anssi Mannilab43397e2021-11-16 12:06:16 +02003367 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003368
3369 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003370 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003371}
Markku Virtanenda34eec2021-05-20 08:22:04 +00003372
Markku Virtanen42723e22021-06-15 10:09:23 +03003373//-----------------------------------------------------------------------------
3374// stub stub stub
3375// +-------+ +---------+ +---------+ +---------+
3376// | xapp | | submgr | | e2term | | rtmgr |
3377// +-------+ +---------+ +---------+ +---------+
3378// | | | |
3379// | RESTSubReq | | |
3380// |---------------->| | |
3381// | RESTSubResp | | |
3382// |<----------------| | |
3383// | | RouteCreate | |
3384// | |--------------------------->|
3385// | | RouteResponse| |
3386// | |<---------------------------| // The order of these events may vary
3387// | | SubReq | |
3388// | |------------->| | // The order of these events may vary
3389// | | SubResp | |
3390// | |<-------------| |
3391// | RESTNotif1 | | |
3392// |<----------------| | |
3393// | RESTSubReq | | |
3394// | [RETRANS1] | | |
3395// |---------------->| | |
3396// | RESTNotif1 | | |
3397// |<----------------| | |
3398// | RESTSubReq | | |
3399// | [RETRANS2] | | |
3400// |---------------->| | |
3401// | RESTNotif1 | | |
3402// |<----------------| | |
3403// | RESTSubDelReq | | |
3404// |---------------->| | |
3405// | | SubDelReq | |
3406// | |------------->| |
3407// | RESTSubDelResp| | |
3408// |<----------------| | |
3409// | | SubDelResp | |
3410// | |<-------------| |
3411// | | | |
3412//
3413//-----------------------------------------------------------------------------
3414
3415func TestRESTSubReqRetransmissionV2(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003416
3417 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3418 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003419 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003420 Counter{cRestSubRespToXapp, 3},
3421 Counter{cSubReqToE2, 1},
3422 Counter{cSubRespFromE2, 1},
3423 Counter{cRestSubNotifToXapp, 3},
3424 Counter{cRestSubDelReqFromXapp, 1},
3425 Counter{cSubDelReqToE2, 1},
3426 Counter{cSubDelRespFromE2, 1},
3427 Counter{cRestSubDelRespToXapp, 1},
3428 })
3429
3430 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3431
3432 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3433
3434 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3435
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003436 mainCtrl.WaitOngoingRequestMapEmpty()
3437
Markku Virtanen42723e22021-06-15 10:09:23 +03003438 //1.st resend
3439 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3440
3441 assert.Equal(t, restSubId_resend, restSubId)
3442
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003443 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003444
3445 //2.nd resend
3446 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3447
3448 assert.Equal(t, restSubId_resend2, restSubId)
3449
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003450 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003451
3452 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3453
3454 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003455 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003456 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003457}
3458
3459//-----------------------------------------------------------------------------
3460// stub stub stub
3461// +-------+ +---------+ +---------+ +---------+
3462// | xapp | | submgr | | e2term | | rtmgr |
3463// +-------+ +---------+ +---------+ +---------+
3464// | | | |
3465// | RESTSubReq | | |
3466// |---------------->| | |
3467// | RESTSubResp | | |
3468// |<----------------| | |
3469// | | RouteCreate | |
3470// | |--------------------------->|
3471// | | RouteResponse| |
3472// | |<---------------------------| // The order of these events may vary
3473// | | SubReq | |
3474// | |------------->| | // The order of these events may vary
3475// | | SubResp | |
3476// | |<-------------| |
3477// | RESTNotif1 | | |
3478// |<----------------| | |
3479// | RESTSubReq | | |
3480// | [RETRANS, with RESTsubsId] | |
3481// |---------------->| | |
3482// | RESTNotif1 | | |
3483// |<----------------| | |
3484// | RESTSubReq | | |
3485// | [RETRANS, without RESTsubsId] | |
3486// |---------------->| | |
3487// | RESTNotif1 | | |
3488// |<----------------| | |
3489// | RESTSubDelReq | | |
3490// |---------------->| | |
3491// | | SubDelReq | |
3492// | |------------->| |
3493// | RESTSubDelResp| | |
3494// |<----------------| | |
3495// | | SubDelResp | |
3496// | |<-------------| |
3497// | | | |
3498//
3499//-----------------------------------------------------------------------------
3500func TestRESTSubReqRetransmissionV3(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003501
3502 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3503 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003504 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003505 Counter{cRestSubRespToXapp, 3},
3506 Counter{cSubReqToE2, 1},
3507 Counter{cSubRespFromE2, 1},
3508 Counter{cRestSubNotifToXapp, 3},
3509 Counter{cRestSubDelReqFromXapp, 1},
3510 Counter{cSubDelReqToE2, 1},
3511 Counter{cSubDelRespFromE2, 1},
3512 Counter{cRestSubDelRespToXapp, 1},
3513 })
3514
3515 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3516
3517 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3518
3519 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3520
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003521 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003522
3523 //1.st resend with subscription ID
3524 params.SetSubscriptionID(&restSubId)
3525 restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
3526
3527 assert.Equal(t, restSubId_resend, restSubId)
3528
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003529 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003530
3531 //2.nd resend without subscription ID (faking app restart)
3532 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3533 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3534
3535 assert.Equal(t, restSubId_resend2, restSubId)
3536
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003537 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003538
3539 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3540
3541 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003542 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003543 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003544}
3545
3546//-----------------------------------------------------------------------------
3547// stub stub stub
3548// +-------+ +---------+ +---------+ +---------+
3549// | xapp | | submgr | | e2term | | rtmgr |
3550// +-------+ +---------+ +---------+ +---------+
3551// | | | |
3552// | RESTSubReq | | |
3553// |---------------->| | |
3554// | RESTSubResp | | |
3555// |<----------------| | |
3556// | | RouteCreate | |
3557// | |--------------------------->|
3558// | | RouteResponse| |
3559// | |<---------------------------|
3560// | | SubReq | |
3561// | |------------->| |
3562// | | SubResp | |
3563// | |<-------------| |
3564// | RESTNotif1 | | |
3565// |<----------------| | |
3566// | RESTSubReq | | |
3567// | [with RestSUbsId + one additional e2 subDetail]
3568// |---------------->| | |
3569// | RESTNotif1 | | |
3570// | [for initial e2 subDetail] | |
3571// |<----------------| | |
3572// | | RouteCreate | |
3573// | |--------------------------->|
3574// | | RouteResponse| |
3575// | |<---------------------------|
3576// | | SubReq | |
3577// | |------------->| |
3578// | | SubResp | |
3579// | |<-------------| |
3580// | RESTNotif1 | | |
3581// |<----------------| | |
3582// | RESTSubReq | | |
3583// | [with RESTsubsId initial request] |
3584// |---------------->| | |
3585// | RESTNotif1 | | |
3586// |<----------------| | |
3587// | RESTSubDelReq | | |
3588// |---------------->| | |
3589// | RESTSubDelResp| | |
3590// |<----------------| | |
3591// | | SubDelReq | |
3592// | |------------->| |
3593// | | SubDelResp | |
3594// | |<-------------| |
3595// | | SubDelReq | |
3596// | |------------->| |
3597// | | SubDelResp | |
3598// | |<-------------| |
3599// | | | |
3600//
3601//-----------------------------------------------------------------------------
3602
3603func TestRESTSubReqRetransmissionV4(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003604
3605 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3606 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003607 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003608 Counter{cRestSubRespToXapp, 3},
3609 Counter{cSubReqToE2, 2},
3610 Counter{cSubRespFromE2, 2},
3611 Counter{cRestSubNotifToXapp, 4},
3612 Counter{cRestSubDelReqFromXapp, 1},
3613 Counter{cSubDelReqToE2, 2},
3614 Counter{cSubDelRespFromE2, 2},
3615 Counter{cRestSubDelRespToXapp, 1},
3616 })
3617
3618 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3619
3620 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3621
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003622 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003623
3624 // Send modified requst, this time with e2 subscriptions.
3625 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3626 params2.SetSubscriptionID(&restSubId)
3627
3628 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003629 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003630 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3631 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003632 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3633 assert.Equal(t, e2SubsId, e2SubsId1)
Markku Virtanen42723e22021-06-15 10:09:23 +03003634
3635 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3636
Markku Virtanen2b512b62021-07-30 12:04:00 +00003637 xappConn1.DecrementRequestCount()
Markku Virtanen42723e22021-06-15 10:09:23 +03003638 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3639 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3640 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3641 assert.NotEqual(t, e2SubsId2, 0)
3642
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003643 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003644
3645 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3646 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
3647 params.SetSubscriptionID(&restSubId)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003648 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003649 // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
3650 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3651 assert.Equal(t, restSubId_resend, restSubId_resend2)
3652
Markku Virtanen2b512b62021-07-30 12:04:00 +00003653 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3654 assert.Equal(t, e2SubsId, e2SubsId1)
3655
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003656 mainCtrl.WaitOngoingRequestMapEmpty()
3657
Markku Virtanen42723e22021-06-15 10:09:23 +03003658 // Delete both e2 subscriptions
3659 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3660 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3661 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3662
3663 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003664 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003665 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003666}
3667
3668//-----------------------------------------------------------------------------
3669// stub stub stub
3670// +-------+ +---------+ +---------+ +---------+
3671// | xapp | | submgr | | e2term | | rtmgr |
3672// +-------+ +---------+ +---------+ +---------+
3673// | | | |
3674// | RESTSubReq | | |
3675// |---------------->| | |
3676// | RESTSubResp | | |
3677// |<----------------| | |
3678// | | RouteCreate | |
3679// | |--------------------------->|
3680// | | RouteResponse| |
3681// | |<---------------------------|
3682// | | SubReq | |
3683// | |------------->| |
3684// | | SubResp | |
3685// | |<-------------| |
3686// | RESTNotif1 | | |
3687// |<----------------| | |
3688// | RESTSubReq | | |
3689// | [with RestSUbsId + one additional e2 subDetail]
3690// |---------------->| | |
3691// | RESTNotif1 | | |
3692// | [for initial e2 subDetail] | |
3693// |<----------------| | |
3694// | | RouteCreate | |
3695// | |--------------------------->|
3696// | | RouteResponse| |
3697// | |<---------------------------|
3698// | | SubReq | |
3699// | |------------->| |
3700// | | SubResp | |
3701// | |<-------------| |
3702// | RESTNotif1 | | |
3703// |<----------------| | |
3704// | RESTSubReq | | |
3705// | [without RESTsubsId initial request] |
3706// |---------------->| | |
3707// | RESTNotif1 | | |
3708// |<----------------| | |
3709// | RESTSubDelReq | | |
3710// |---------------->| | |
3711// | RESTSubDelResp| | |
3712// |<----------------| | |
3713// | | SubDelReq | |
3714// | |------------->| |
3715// | | SubDelResp | |
3716// | |<-------------| |
3717// | | SubDelReq | |
3718// | |------------->| |
3719// | | SubDelResp | |
3720// | |<-------------| |
3721// | | | |
3722//
3723//-----------------------------------------------------------------------------
3724
3725func TestRESTSubReqRetransmissionV5(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003726
3727 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3728 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003729 Counter{cDuplicateE2SubReq, 2},
Markku Virtanen42723e22021-06-15 10:09:23 +03003730 Counter{cRestSubRespToXapp, 3},
3731 Counter{cSubReqToE2, 2},
3732 Counter{cSubRespFromE2, 2},
3733 Counter{cRestSubNotifToXapp, 4},
3734 Counter{cRestSubDelReqFromXapp, 1},
3735 Counter{cSubDelReqToE2, 2},
3736 Counter{cSubDelRespFromE2, 2},
3737 Counter{cRestSubDelRespToXapp, 1},
3738 })
3739
3740 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3741
3742 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3743
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003744 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003745
Anssi Mannila21782182021-12-10 10:56:02 +02003746 // Send modified request, this time with e2 subscriptions.
Markku Virtanen42723e22021-06-15 10:09:23 +03003747 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3748 params2.SetSubscriptionID(&restSubId)
3749
3750 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003751 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003752 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3753 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3754
Markku Virtanen2b512b62021-07-30 12:04:00 +00003755 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3756 assert.Equal(t, e2SubsId, e2SubsId1)
3757 // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
3758 xappConn1.DecrementRequestCount()
3759
Markku Virtanen42723e22021-06-15 10:09:23 +03003760 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3761
3762 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3763 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3764 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3765 assert.NotEqual(t, e2SubsId2, 0)
3766
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003767 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003768
3769 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
3770 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003771 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003772 // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
3773 // md5sum shall find the original request
3774 restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
3775 assert.Equal(t, restSubId_resend, restSubId_resend2)
3776
Markku Virtanen2b512b62021-07-30 12:04:00 +00003777 e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
3778 assert.Equal(t, e2SubsId, e2SubsId1)
3779
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003780 mainCtrl.WaitOngoingRequestMapEmpty()
3781
Markku Virtanen42723e22021-06-15 10:09:23 +03003782 // Delete both e2 subscriptions
3783 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3784 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3785 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3786
3787 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003788 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003789 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003790}
3791
3792//-----------------------------------------------------------------------------
3793// stub stub stub
3794// +-------+ +---------+ +---------+ +---------+
3795// | xapp | | submgr | | e2term | | rtmgr |
3796// +-------+ +---------+ +---------+ +---------+
3797// | | | |
3798// | RESTSubReq | | |
3799// |---------------->| | |
3800// | RESTSubResp | | |
3801// |<----------------| | |
3802// | | RouteCreate | |
3803// | |--------------------------->|
3804// | | RouteResponse| |
3805// | |<---------------------------|
3806// | | SubReq | |
3807// | |------------->| |
3808// | | SubResp | |
3809// | |<-------------| |
3810// | RESTNotif1 | | |
3811// |<----------------| | |
3812// | RESTSubReq | | |
3813// | [with RestSUbsId + one additional e2 subDetail]
3814// |---------------->| | |
3815// | RESTNotif1 | | |
3816// | [for initial e2 subDetail] | |
3817// |<----------------| | |
3818// | | RouteCreate | |
3819// | |--------------------------->|
3820// | | RouteResponse| |
3821// | |<---------------------------|
3822// | | SubReq | |
3823// | |------------->| |
3824// | | SubResp | |
3825// | |<-------------| |
3826// | RESTNotif1 | | |
3827// |<----------------| | |
3828// | RESTSubDelReq | | |
3829// |---------------->| | |
3830// | RESTSubDelResp| | |
3831// |<----------------| | |
3832// | | SubDelReq | |
3833// | |------------->| |
3834// | | SubDelResp | |
3835// | |<-------------| |
3836// | | SubDelReq | |
3837// | |------------->| |
3838// | | SubDelResp | |
3839// | |<-------------| |
3840// | RESTSubReq | | |
3841// | [with RESTsubsId initial request] |
3842// |---------------->| | |
3843// | RESTSubResp | | |
3844// |<----------------| | |
3845// | | RouteCreate | |
3846// | |--------------------------->|
3847// | | RouteResponse| |
3848// | |<---------------------------|
3849// | | SubReq | |
3850// | |------------->| |
3851// | | SubResp | |
3852// | |<-------------| |
3853// | RESTNotif1 | | |
3854// |<----------------| | |
3855// | | | |
3856//
3857//-----------------------------------------------------------------------------
3858func TestRESTSubReqRetransmissionV6(t *testing.T) {
Markku Virtanen42723e22021-06-15 10:09:23 +03003859
3860 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3861 Counter{cRestSubReqFromXapp, 3},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003862 Counter{cDuplicateE2SubReq, 1},
Markku Virtanen42723e22021-06-15 10:09:23 +03003863 Counter{cRestSubRespToXapp, 3},
3864 Counter{cSubReqToE2, 3},
3865 Counter{cSubRespFromE2, 3},
3866 Counter{cRestSubNotifToXapp, 4},
3867 Counter{cRestSubDelReqFromXapp, 2},
3868 Counter{cSubDelReqToE2, 3},
3869 Counter{cSubDelRespFromE2, 3},
3870 Counter{cRestSubDelRespToXapp, 2},
3871 })
3872
3873 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
3874
3875 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3876
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003877 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003878
3879 // Send modified requst, this time with e2 subscriptions.
3880 params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
3881 params2.SetSubscriptionID(&restSubId)
3882
3883 xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00003884 xappConn1.ExpectAnyNotification(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003885 // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
3886 restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
3887
Markku Virtanen2b512b62021-07-30 12:04:00 +00003888 e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
3889 assert.Equal(t, e2SubsId, e2SubsId1)
3890
Markku Virtanen42723e22021-06-15 10:09:23 +03003891 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3892
3893 xappConn1.ExpectRESTNotification(t, restSubId_resend)
3894 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3895 e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
3896 assert.NotEqual(t, e2SubsId2, 0)
3897
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003898 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003899
3900 // Delete both e2 subscriptions
3901 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3902 e2SubsIds := []uint32{e2SubsId, e2SubsId2}
3903 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
3904
3905 waitSubsCleanup(t, e2SubsId, 10)
3906
3907 // Resend the original request, we shall find it's previous md5sum/restsubs
3908 // but the restsubscription has been already removed. This shall trigger a
3909 // fresh create.
3910 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3911
Anssi Mannilae5fdcd22021-12-13 14:18:24 +02003912 mainCtrl.WaitOngoingRequestMapEmpty()
Markku Virtanen42723e22021-06-15 10:09:23 +03003913
3914 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
3915
3916 waitSubsCleanup(t, e2SubsId, 10)
Markku Virtanen42723e22021-06-15 10:09:23 +03003917 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003918 mainCtrl.VerifyAllClean(t)
Markku Virtanen42723e22021-06-15 10:09:23 +03003919}
3920
Anssi Mannila27385172021-12-22 09:41:54 +02003921//-----------------------------------------------------------------------------
3922// TestRESTSubDelReqRetransmission
3923//
3924// stub stub
3925// +-------+ +---------+ +---------+
3926// | xapp | | submgr | | e2term |
3927// +-------+ +---------+ +---------+
3928// | | |
3929// | RESTSubReq | |
3930// |---------------->| |
3931// | | |
3932// | RESTSubResp | |
3933// |<----------------| |
3934// | | SubReq |
3935// | |------------->|
3936// | | SubResp |
3937// | |<-------------|
3938// | RESTNotif1 | |
3939// |<----------------| |
3940// | | |
3941// | RESTSubDelReq | |
3942// |---------------->| |
3943// | RESTSubDelResp | |
3944// |<----------------| |
3945// | | SubDelReq |
3946// | |------------->|
3947// | RESTSubDelReq | |
3948// |---------------->| |
3949// | RESTSubDelResp | |
3950// |<----------------| |
3951// | | SubDelResp |
3952// | |<-------------|
3953// | | |
3954//
3955//-----------------------------------------------------------------------------
3956
archaggeafbf95f2021-04-14 08:54:05 +03003957func TestRESTSubDelReqRetransmission(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03003958
3959 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003960 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003961 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03003962 Counter{cSubReqToE2, 1},
3963 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03003964 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00003965 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003966 Counter{cSubDelReqToE2, 1},
3967 Counter{cSubDelRespFromE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02003968 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03003969 })
3970
3971 var params *teststube2ap.RESTSubsReqParams = nil
3972
3973 //Subs Create
3974 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3975
3976 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
3977
3978 //Subs Delete
3979 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3980 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3981
Anssi Mannila27385172021-12-22 09:41:54 +02003982 //Resend delete req
archaggeafbf95f2021-04-14 08:54:05 +03003983 seqBef := mainCtrl.get_msgcounter(t)
3984 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3985 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
3986
Anssi Mannila27385172021-12-22 09:41:54 +02003987 // Del resp
archaggeafbf95f2021-04-14 08:54:05 +03003988 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3989
3990 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003991 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02003992 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03003993}
3994
3995//-----------------------------------------------------------------------------
3996// TestRESTSubReqDelReq
3997//
3998// stub stub
3999// +-------+ +---------+ +---------+
4000// | xapp | | submgr | | e2term |
4001// +-------+ +---------+ +---------+
4002// | | |
4003// | RESTSubReq | |
4004// |---------------->| |
4005// | | |
4006// | RESTSubResp | |
4007// |<----------------| |
4008// | | SubReq |
4009// | |------------->|
4010// | RESTSubDelReq | |
4011// |---------------->| |
4012// | RESTSubDelResp | |
4013// | unsuccess | |
4014// |<----------------| |
4015// | | SubResp |
4016// | |<-------------|
4017// | RESTNotif1 | |
4018// |<----------------| |
4019// | | |
4020// | [SUBS DELETE] |
4021// | | |
4022//
4023//-----------------------------------------------------------------------------
4024func TestRESTSubReqDelReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004025
4026 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004027 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004028 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004029 Counter{cSubReqToE2, 1},
4030 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004031 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004032 Counter{cRestSubDelReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004033 Counter{cRestSubDelFailToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004034 Counter{cSubDelReqToE2, 1},
4035 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004036 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004037 })
4038
4039 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03004040
4041 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004042 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004043 restSubId := xappConn1.SendRESTSubsReq(t, params)
4044
4045 // Del. This will fail as processing of the subscription
4046 // is still ongoing in submgr. Deletion is not allowed before
4047 // subscription creation has been completed.
4048 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4049 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4050 xappConn1.ExpectRESTNotification(t, restSubId)
4051 e2termConn1.SendSubsResp(t, crereq, cremsg)
4052 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4053
4054 // Retry del
4055 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4056
4057 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4058 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4059
4060 // Wait that subs is cleaned
4061 waitSubsCleanup(t, e2SubsId, 10)
4062 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004063 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004064}
4065
Anssi Mannila27385172021-12-22 09:41:54 +02004066//-----------------------------------------------------------------------------
4067// TestRESTSubReqAndSubDelOkTwoParallel
4068//
4069// stub stub stub
4070// +-------+ +-------+ +---------+ +---------+
4071// | xapp2 | | xapp1 | | submgr | | e2term |
4072// +-------+ +-------+ +---------+ +---------+
4073// | | | |
4074// | | RESTSubReq1 | |
4075// | |------------->| |
4076// | | RESTSubResp1 | |
4077// | |<-------------| |
4078// | | | |
4079// | | | SubReq1 |
4080// | | |------------->|
4081// | | | |
4082// | RESTSubReq2 | |
4083// |------------------------>| |
4084// | RESTSubResp2 | |
4085// |<------------------------| |
4086// | | | |
4087// | | | SubReq2 |
4088// | | |------------->|
4089// | | | |
4090// | | | SubResp1 |
4091// | | |<-------------|
4092// | | RESTNotif1 | |
4093// | |<-------------| |
4094// | | | |
4095// | | | SubResp2 |
4096// | | |<-------------|
4097// | RESTNotif2 | |
4098// |<------------------------| |
4099// | | | |
4100// | | [SUBS 1 DELETE] |
4101// | | | |
4102// | | [SUBS 2 DELETE] |
4103// | | | |
4104//
4105//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03004106
4107func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004108
4109 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004110 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004111 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004112 Counter{cSubReqToE2, 2},
4113 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004114 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004115 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004116 Counter{cSubDelReqToE2, 2},
4117 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004118 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004119 })
4120
4121 //Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004122 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004123 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004124 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004125
4126 //Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004127 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004128 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004129 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004130
4131 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4132 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4133
4134 //XappConn1 receives both of the responses
4135 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
4136
4137 //Resp1
4138 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4139 //Resp2
4140 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4141
4142 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004143 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03004144 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004145 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03004146
4147 //Del1
4148 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4149 //Del2
4150 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
4151
4152 //Wait that subs is cleaned
4153 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
4154 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
4155
4156 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004157 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004158}
4159
Anssi Mannila27385172021-12-22 09:41:54 +02004160//-----------------------------------------------------------------------------
4161// TestRESTSameSubsDiffRan
4162// Same subscription to different RANs
4163//
4164// stub stub
4165// +-------+ +---------+ +---------+
4166// | xapp | | submgr | | e2term |
4167// +-------+ +---------+ +---------+
4168// | | |
4169// | RESTSubReq(r1) | |
4170// |---------------->| |
4171// | RESTSubResp(r1) | |
4172// |<----------------| |
4173// | | |
4174// | | SubReq(r1) |
4175// | |------------->|
4176// | | |
4177// | | SubResp(r1) |
4178// | |<-------------|
4179// | | |
4180// | RESTNotif(r1) | |
4181// |<----------------| |
4182// | | |
4183// | RESTSubReq(r2) | |
4184// |---------------->| |
4185// | | |
4186// | RESTSubResp(r2) | |
4187// |<----------------| |
4188// | | SubReq(r2) |
4189// | |------------->|
4190// | | |
4191// | | SubResp(r2) |
4192// | |<-------------|
4193// | | |
4194// | RESTNotif(r2) | |
4195// |<----------------| |
4196// | | |
4197// | [SUBS r1 DELETE] |
4198// | | |
4199// | [SUBS r2 DELETE] |
4200// | | |
4201//
4202//-----------------------------------------------------------------------------
4203
archaggeafbf95f2021-04-14 08:54:05 +03004204func TestRESTSameSubsDiffRan(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004205
4206 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004207 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004208 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004209 Counter{cSubReqToE2, 2},
4210 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004211 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004212 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004213 Counter{cSubDelReqToE2, 2},
4214 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004215 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004216 })
4217
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004218 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004219 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004220 xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03004221
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004222 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004223 params.SetMeid("RAN_NAME_2")
4224 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004225 xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
archaggeafbf95f2021-04-14 08:54:05 +03004226
4227 //Del1
4228 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
4229 //Del2
4230 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
4231
4232 //Wait that subs is cleaned
4233 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4234 waitSubsCleanup(t, e2SubsId2, 10)
4235
4236 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004237 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004238}
4239
Anssi Mannila27385172021-12-22 09:41:54 +02004240//-----------------------------------------------------------------------------
4241// TestRESTSubReqRetryInSubmgr
4242//
4243// stub stub
4244// +-------+ +---------+ +---------+
4245// | xapp | | submgr | | e2term |
4246// +-------+ +---------+ +---------+
4247// | | |
4248// | RESTSubReq | |
4249// |---------------->| |
4250// | RESTSubResp | |
4251// |<----------------| |
4252// | | SubReq |
Anssi Mannila92c38552021-12-29 09:59:24 +02004253// | |------------->|
Anssi Mannila27385172021-12-22 09:41:54 +02004254// | | |
4255// | | |
4256// | | SubReq |
4257// | |------------->|
4258// | | SubResp |
4259// | |<-------------|
4260// | | |
4261// | RESTNotif | |
4262// |<----------------| |
4263// | | |
4264// | [SUBS DELETE] |
4265// | | |
4266//
4267//-----------------------------------------------------------------------------
4268
archaggeafbf95f2021-04-14 08:54:05 +03004269func TestRESTSubReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004270
4271 // Init counter check
4272 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004273 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004274 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004275 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004276 Counter{cSubReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004277 Counter{cSubReReqToE2, 1},
4278 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004279 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004280 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004281 Counter{cSubDelReqToE2, 1},
4282 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004283 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004284 })
4285
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004286 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004287 restSubId := xappConn1.SendRESTSubsReq(t, params)
4288
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004289 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004290
4291 // Catch the first message and ignore it
4292 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004293 xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004294
4295 // The second request is being handled normally
4296 crereq, cremsg = e2termConn1.RecvSubsReq(t)
4297 xappConn1.ExpectRESTNotification(t, restSubId)
4298 e2termConn1.SendSubsResp(t, crereq, cremsg)
4299 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4300
4301 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4302
Anssi Mannila27385172021-12-22 09:41:54 +02004303 // Del
archaggeafbf95f2021-04-14 08:54:05 +03004304 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4305
4306 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
4307 //Wait that subs is cleaned
4308 waitSubsCleanup(t, e2SubsId, 10)
4309
4310 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004311 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004312}
4313
4314//-----------------------------------------------------------------------------
4315// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4316//
4317// stub stub
4318// +-------+ +---------+ +---------+
4319// | xapp | | submgr | | e2term |
4320// +-------+ +---------+ +---------+
4321// | | |
4322// | RESTSubReq | |
4323// |---------------->| |
4324// | | |
4325// | RESTSubResp | |
4326// |<----------------| |
4327// | | SubReq |
4328// | |------------->|
4329// | | |
4330// | | |
4331// | | SubReq |
4332// | |------------->|
4333// | | |
4334// | | SubDelReq |
4335// | |------------->|
4336// | | |
4337// | | |
4338// | | SubDelReq |
4339// | |------------->|
4340// | | |
4341// | | |
4342// | | SubDelResp |
4343// | |<-------------|
4344// | RESTNotif | |
4345// | unsuccess | |
4346// |<----------------| |
4347// | | |
4348// | [SUBS DELETE] |
4349// | | |
4350//
4351//-----------------------------------------------------------------------------
Markku Virtanen55d2a282021-06-04 14:46:56 +03004352
archaggeafbf95f2021-04-14 08:54:05 +03004353func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004354
4355 // Init counter check
4356 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004357 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004358 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004359 Counter{cSubReqToE2, 1},
4360 Counter{cSubReReqToE2, 1},
4361 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004362 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004363 Counter{cSubDelReqToE2, 1},
4364 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004365 Counter{cRestSubDelReqFromXapp, 1},
4366 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004367 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004368
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004369 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004370 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004371 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004372
4373 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004374 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004375
4376 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004377 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004378
4379 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Markku Virtanen55d2a282021-06-04 14:46:56 +03004380 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004381 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
archaggeafbf95f2021-04-14 08:54:05 +03004382 xappConn1.WaitRESTNotification(t, restSubId)
4383
Anssi Mannilab43397e2021-11-16 12:06:16 +02004384 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4385
archaggeafbf95f2021-04-14 08:54:05 +03004386 // Wait that subs is cleaned
4387 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004388 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004389 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004390}
4391
Anssi Mannila27385172021-12-22 09:41:54 +02004392//-----------------------------------------------------------------------------
4393// TestREST2eTermNotRespondingToSubReq
4394//
4395// stub stub
4396// +-------+ +---------+ +---------+
4397// | xapp | | submgr | | e2term |
4398// +-------+ +---------+ +---------+
4399// | | |
4400// | RESTSubReq | |
4401// |---------------->| |
4402// | RESTSubResp | |
4403// |<----------------| |
4404// | | SubReq |
4405// | |------------->|
4406// | | |
4407// | | SubReq |
4408// | |------------->|
4409// | | |
4410// | | SubDelReq |
4411// | |------------->|
4412// | | |
4413// | | SubDelReq |
4414// | |------------->|
4415// | RESTNotif(Unsuccessful) |
4416// |<----------------| |
4417// | | |
4418// | RESTSubDelReq | |
4419// |---------------->| |
4420// | RESTSubDelResp | |
4421// |<----------------| |
4422// | | |
4423//
4424//-----------------------------------------------------------------------------
4425
archaggeafbf95f2021-04-14 08:54:05 +03004426func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004427
4428 // Init counter check
4429 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004430 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004431 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004432 Counter{cSubReqToE2, 1},
4433 Counter{cSubReReqToE2, 1},
4434 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004435 Counter{cSubDelReReqToE2, 1},
4436 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004437 Counter{cSubDelReqToE2, 1},
4438 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004439 Counter{cRestSubDelReqFromXapp, 1},
4440 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004441 })
Anssi Mannilab43397e2021-11-16 12:06:16 +02004442
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004443 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004444 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004445 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004446
4447 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004448 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004449
4450 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004451 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004452
4453 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004454 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004455
Markku Virtanen55d2a282021-06-04 14:46:56 +03004456 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004457 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004458 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004459
4460 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4461
Anssi Mannilab43397e2021-11-16 12:06:16 +02004462 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004463
Anssi Mannilab43397e2021-11-16 12:06:16 +02004464 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004465 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004466 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004467}
4468
4469//-----------------------------------------------------------------------------
4470// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
4471//
4472// stub stub
4473// +-------+ +---------+ +---------+
4474// | xapp | | submgr | | e2term |
4475// +-------+ +---------+ +---------+
4476// | | |
4477// | RESTSubReq | |
4478// |---------------->| |
4479// | | |
4480// | RESTSubResp | |
4481// |<----------------| |
4482// | | SubReq |
4483// | |------------->|
4484// | | |
4485// | | |
4486// | | SubReq |
4487// | |------------->|
4488// | | |
4489// | | SubDelReq |
4490// | |------------->|
4491// | | |
4492// | | |
4493// | | SubDelReq |
4494// | |------------->|
4495// | | |
4496// | | |
4497// | | SubDelResp |
4498// | |<-------------|
4499// | RESTNotif | |
4500// | unsuccess | |
4501// |<----------------| |
4502// | | |
4503// | [SUBS DELETE] |
4504// | | |
4505//
4506//-----------------------------------------------------------------------------
4507func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004508
4509 // Init counter check
4510 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004511 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004512 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004513 Counter{cSubReqToE2, 1},
4514 Counter{cSubReReqToE2, 1},
4515 Counter{cSubReqTimerExpiry, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004516 Counter{cRestSubFailNotifToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004517 Counter{cSubDelReqToE2, 1},
4518 Counter{cSubDelReReqToE2, 1},
4519 Counter{cSubDelReqTimerExpiry, 2},
Anssi Mannilab43397e2021-11-16 12:06:16 +02004520 Counter{cRestSubDelReqFromXapp, 1},
4521 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004522 })
4523
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004524 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004525 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004526 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004527
4528 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004529 xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004530
4531 e2termConn1.RecvSubsReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004532 xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004533
4534 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004535 xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004536
Markku Virtanen55d2a282021-06-04 14:46:56 +03004537 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004538 e2termConn1.RecvSubsDelReq(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004539 xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004540
4541 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
4542
Anssi Mannilab43397e2021-11-16 12:06:16 +02004543 xappConn1.SendRESTSubsDelReq(t, &restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03004544
Anssi Mannilab43397e2021-11-16 12:06:16 +02004545 waitSubsCleanup(t, e2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004546 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004547 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004548}
4549
4550//-----------------------------------------------------------------------------
4551// TestRESTSubReqSubFailRespInSubmgr
4552//
4553// stub stub
4554// +-------+ +---------+ +---------+
4555// | xapp | | submgr | | e2term |
4556// +-------+ +---------+ +---------+
4557// | | |
4558// | RESTSubReq | |
4559// |---------------->| |
4560// | | |
4561// | RESTSubResp | |
4562// |<----------------| |
4563// | | SubReq |
4564// | |------------->|
4565// | | |
4566// | | SubFail |
4567// | |<-------------|
4568// | | |
archaggeafbf95f2021-04-14 08:54:05 +03004569// | RESTNotif | |
4570// | unsuccess | |
4571// |<----------------| |
4572// | | |
4573// | [SUBS DELETE] |
4574// | | |
4575//
4576//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004577
archaggeafbf95f2021-04-14 08:54:05 +03004578func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004579
4580 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004581 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004582 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004583 Counter{cSubReqToE2, 1},
4584 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004585 Counter{cRestSubFailNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004586 Counter{cRestSubDelReqFromXapp, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004587 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004588 })
4589
4590 const subReqCount int = 1
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004591 const e2Timeout int64 = 2
4592 const e2RetryCount int64 = 1
4593 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03004594
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004595 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilacb7dd492021-10-01 11:10:26 +03004596 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03004597 restSubId := xappConn1.SendRESTSubsReq(t, params)
4598
4599 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4600 fparams1 := &teststube2ap.E2StubSubsFailParams{}
4601 fparams1.Set(crereq1)
Anssi Mannila3e55f472021-11-05 09:58:04 +02004602 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
archaggeafbf95f2021-04-14 08:54:05 +03004603 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
4604
archaggeafbf95f2021-04-14 08:54:05 +03004605 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004606 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03004607
4608 // REST subscription sill there to be deleted
4609 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4610
4611 // Wait that subs is cleaned
4612 waitSubsCleanup(t, e2SubsId, 10)
4613
4614 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004615 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004616}
4617
4618//-----------------------------------------------------------------------------
4619// TestRESTSubDelReqRetryInSubmgr
4620//
4621// stub stub
4622// +-------+ +---------+ +---------+
4623// | xapp | | submgr | | e2term |
4624// +-------+ +---------+ +---------+
4625// | | |
4626// | [SUBS CREATE] |
4627// | | |
4628// | | |
4629// | RESTSubDelReq | |
4630// |---------------->| |
4631// | | |
4632// | RESTSubDelResp | |
4633// |<----------------| |
4634// | | SubDelReq |
4635// | |------------->|
4636// | | |
4637// | | SubDelReq |
4638// | |------------->|
4639// | | |
4640// | | SubDelResp |
4641// | |<-------------|
4642// | | |
4643//
4644//-----------------------------------------------------------------------------
4645func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004646
4647 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004648 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004649 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004650 Counter{cSubReqToE2, 1},
4651 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004652 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004653 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004654 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004655 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004656 Counter{cSubDelReReqToE2, 1},
4657 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004658 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004659 })
4660 // Req
4661 var params *teststube2ap.RESTSubsReqParams = nil
4662 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4663
4664 // Del
4665 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4666
4667 // E2t: Receive 1st SubsDelReq
4668 e2termConn1.RecvSubsDelReq(t)
4669
4670 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4671 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4672 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4673
4674 //Wait that subs is cleaned
4675 waitSubsCleanup(t, e2SubsId, 10)
4676
4677 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004678 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004679}
4680
4681//-----------------------------------------------------------------------------
4682// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
4683//
4684// stub stub
4685// +-------+ +---------+ +---------+
4686// | xapp | | submgr | | e2term |
4687// +-------+ +---------+ +---------+
4688// | | |
4689// | [SUBS CREATE] |
4690// | | |
4691// | | |
4692// | RESTSubDelReq | |
4693// |---------------->| |
4694// | | |
4695// | RESTSubDelResp | |
4696// |<----------------| |
4697// | | SubDelReq |
4698// | |------------->|
4699// | | |
4700// | | SubDelReq |
4701// | |------------->|
4702// | | |
4703// | | |
4704//
4705//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004706
archaggeafbf95f2021-04-14 08:54:05 +03004707func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004708
4709 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004710 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004711 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004712 Counter{cSubReqToE2, 1},
4713 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004714 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004715 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004716 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02004717 Counter{cSubDelReqTimerExpiry, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004718 Counter{cSubDelReReqToE2, 1},
4719 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004720 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004721 })
4722
4723 // Req
4724 var params *teststube2ap.RESTSubsReqParams = nil
4725 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4726
4727 // Del
4728 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4729
4730 // E2t: Receive 1st SubsDelReq
4731 e2termConn1.RecvSubsDelReq(t)
4732
4733 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
4734 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4735 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4736
4737 //Wait that subs is cleaned
4738 waitSubsCleanup(t, e2SubsId, 10)
4739
4740 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004741 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004742}
4743
4744//-----------------------------------------------------------------------------
4745// TestRESTSubDelReqSubDelFailRespInSubmgr
4746//
4747// stub stub
4748// +-------+ +---------+ +---------+
4749// | xapp | | submgr | | e2term |
4750// +-------+ +---------+ +---------+
4751// | | |
4752// | [SUBS CREATE] |
4753// | | |
4754// | | |
4755// | RESTSubDelReq | |
4756// |---------------->| |
4757// | | |
4758// | RESTSubDelResp | |
4759// |<----------------| |
4760// | | SubDelReq |
4761// | |------------->|
4762// | | |
4763// | | SubDelFail |
4764// | |<-------------|
4765// | | |
4766//
4767//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004768
archaggeafbf95f2021-04-14 08:54:05 +03004769func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004770
4771 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004772 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004773 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004774 Counter{cSubReqToE2, 1},
4775 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004776 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004777 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004778 Counter{cSubDelReqToE2, 1},
4779 Counter{cSubDelFailFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004780 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03004781 })
4782
4783 // Req
4784 var params *teststube2ap.RESTSubsReqParams = nil
4785 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4786
4787 // Del
4788 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4789
4790 // E2t: Send receive SubsDelReq and send SubsDelFail
4791 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4792 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
4793
4794 //Wait that subs is cleaned
4795 waitSubsCleanup(t, e2SubsId, 10)
4796
4797 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004798 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004799}
4800
4801//-----------------------------------------------------------------------------
4802// TestRESTSubReqAndSubDelOkSameAction
4803//
4804// stub stub
4805// +-------+ +-------+ +---------+ +---------+
4806// | xapp2 | | xapp1 | | submgr | | e2term |
4807// +-------+ +-------+ +---------+ +---------+
4808// | | | |
4809// | | RESTSubReq1 | |
4810// | |---------------->| |
4811// | | | |
4812// | | RESTSubResp1 | |
4813// | |<----------------| |
4814// | | | |
4815// | | | SubReq1 |
4816// | | |------------->|
4817// | | | SubResp1 |
4818// | | |<-------------|
4819// | | RESTNotif1 | |
4820// | |<----------------| |
4821// | | | |
4822// | RESTSubReq2 | |
4823// |------------------------------>| |
4824// | | | |
4825// | RESTSubResp2 | |
4826// |<------------------------------| |
4827// | | | |
4828// | | RESTNotif2 | |
4829// |<------------------------------| |
4830// | | | |
4831// | | RESTSubDelReq1 | |
4832// | |---------------->| |
4833// | | | |
4834// | | RESTSubDelResp1 | |
4835// | |<----------------| |
4836// | | | |
4837// | RESTSubDelReq2 | |
4838// |------------------------------>| |
4839// | | | |
4840// | RESTSubDelResp2 | |
4841// |<------------------------------| |
4842// | | | |
4843// | | | SubDelReq2 |
4844// | | |------------->|
4845// | | | |
4846// | | | SubDelResp2 |
4847// | | |<-------------|
4848// | | | |
4849//
4850//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02004851
archaggeafbf95f2021-04-14 08:54:05 +03004852func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004853
4854 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004855 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004856 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004857 Counter{cSubReqToE2, 1},
4858 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004859 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004860 Counter{cMergedSubscriptions, 1},
4861 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004862 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004863 Counter{cSubDelReqToE2, 1},
4864 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004865 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004866 })
4867
4868 // Req1
4869 var params *teststube2ap.RESTSubsReqParams = nil
4870
4871 //Subs Create
4872 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4873 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4874
4875 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004876 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004877 params.SetMeid("RAN_NAME_1")
4878
4879 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004880 xappConn2.ExpectAnyNotification(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004881 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03004882 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00004883 waiter.WaitResult(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004884 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00004885 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03004886 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03004887
4888 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4889
4890 // Del1
4891 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4892
4893 // Del2
4894 deleteXapp2Subscription(t, &restSubId2)
4895
4896 //Wait that subs is cleaned
4897 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004898 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004899 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004900}
4901
4902//-----------------------------------------------------------------------------
4903// TestSubReqAndSubDelOkSameActionParallel
4904//
4905// stub stub stub
4906// +-------+ +-------+ +---------+ +---------+
4907// | xapp2 | | xapp1 | | submgr | | e2term |
4908// +-------+ +-------+ +---------+ +---------+
4909// | | | |
4910// | | | |
4911// | | | |
4912// | | SubReq1 | |
4913// | |------------->| |
4914// | | | |
4915// | | | SubReq1 |
4916// | | |------------->|
4917// | SubReq2 | |
4918// |--------------------------->| |
4919// | | | SubResp1 |
4920// | | |<-------------|
4921// | | SubResp1 | |
4922// | |<-------------| |
4923// | | | SubReq2 |
4924// | | |------------->|
4925// | | | |
4926// | | | SubResp2 |
4927// | | |<-------------|
4928// | SubResp2 | |
4929// |<---------------------------| |
4930// | | | |
4931// | | SubDelReq 1 | |
4932// | |------------->| |
4933// | | | |
4934// | | SubDelResp 1 | |
4935// | |<-------------| |
4936// | | | |
4937// | SubDelReq 2 | |
4938// |--------------------------->| |
4939// | | | |
4940// | | | SubDelReq 2 |
4941// | | |------------->|
4942// | | | |
4943// | | | SubDelReq 2 |
4944// | | |------------->|
4945// | | | |
4946// | SubDelResp 2 | |
4947// |<---------------------------| |
4948//
4949func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03004950
4951 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004952 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004953 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004954 Counter{cSubReqToE2, 2},
4955 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03004956 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004957 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004958 Counter{cSubDelReqToE2, 2},
4959 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00004960 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03004961 })
4962
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004963 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004964 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
4965 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
4966
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00004967 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03004968 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
4969
4970 xappConn1.ExpectRESTNotification(t, restSubId1)
4971 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
4972 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
4973
4974 xappConn2.ExpectRESTNotification(t, restSubId2)
4975 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
4976 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
4977 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4978
4979 // Del1
4980 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
4981 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
4982 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
4983 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
4984
4985 // Del2
4986 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
4987 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
4988 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
4989
4990 waitSubsCleanup(t, e2SubsId2, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004991 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02004992 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03004993}
4994
4995//-----------------------------------------------------------------------------
4996// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
4997//
4998// stub stub stub
4999// +-------+ +-------+ +---------+ +---------+
5000// | xapp2 | | xapp1 | | submgr | | e2term |
5001// +-------+ +-------+ +---------+ +---------+
5002// | | | |
5003// | | | |
5004// | | | |
5005// | | RESTSubReq1 | |
5006// | |---------------->| |
5007// | | | |
5008// | | RESTSubResp1 | |
5009// | |<----------------| |
5010// | | | SubReq1 |
5011// | | |------------->|
5012// | RESTSubReq2 | |
5013// |------------------------------>| |
5014// | | | |
Anssi Mannila3d80b722021-11-12 13:17:15 +02005015// | RESTSubResp2 | |
archaggeafbf95f2021-04-14 08:54:05 +03005016// |<------------------------------| |
5017// | | | SubReq1 |
5018// | | |------------->|
5019// | | | |
5020// | | | |
5021// | | | SubDelReq |
5022// | | |------------->|
5023// | | | |
5024// | | | SubDelResp |
5025// | | |<-------------|
5026// | | RESTNotif1 | |
5027// | | unsuccess | |
5028// | |<----------------| |
5029// | RESTNotif2 | |
5030// | | unsuccess | |
5031// |<------------------------------| |
5032// | | | |
5033// | | RESTSubDelReq1 | |
5034// | |---------------->| |
5035// | | | |
5036// | | RESTSubDelResp1 | |
5037// | |<----------------| |
5038// | | | |
5039// | RESTSubDelReq2 | |
5040// |------------------------------>| |
5041// | | | |
5042// | RESTSubDelResp2 | |
5043// |<------------------------------| |
5044//
5045//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005046
archaggeafbf95f2021-04-14 08:54:05 +03005047func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005048
5049 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005050 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005051 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005052 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005053 Counter{cSubReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005054 Counter{cSubReqTimerExpiry, 2},
5055 Counter{cSubReReqToE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005056 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005057 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005058 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005059 Counter{cSubDelReqToE2, 1},
5060 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005061 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005062 })
archaggeafbf95f2021-04-14 08:54:05 +03005063 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005064
5065 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005066 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005067 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
5068 crereq1, _ := e2termConn1.RecvSubsReq(t)
5069
5070 // Req2
5071 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005072 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005073 params2.SetMeid("RAN_NAME_1")
5074 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5075 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5076
5077 //Req1 (retransmitted)
5078 e2termConn1.RecvSubsReq(t)
5079
5080 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005081
5082 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005083 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5084
Markku Virtanenda34eec2021-05-20 08:22:04 +00005085 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005086 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
Markku Virtanenda34eec2021-05-20 08:22:04 +00005087 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005088 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005089
5090 // Del1
5091 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5092
5093 // Del2
5094 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5095
Markku Virtanenda34eec2021-05-20 08:22:04 +00005096 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
5097
archaggeafbf95f2021-04-14 08:54:05 +03005098 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00005099 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005100 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005101 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005102}
5103
5104//-----------------------------------------------------------------------------
5105// TestRESTSubReqAndSubDelNokSameActionParallel
5106//
5107// stub stub stub
5108// +-------+ +-------+ +---------+ +---------+
5109// | xapp2 | | xapp1 | | submgr | | e2term |
5110// +-------+ +-------+ +---------+ +---------+
5111// | | | |
5112// | | | |
5113// | | | |
5114// | | RESTSubReq1 | |
5115// | |---------------->| |
5116// | | | |
5117// | | RESTSubResp1 | |
5118// | |<----------------| |
5119// | | | SubReq1 |
5120// | | |------------->|
5121// | RESTSubReq2 | |
5122// |------------------------------>| |
5123// | | | |
5124// | RESTSubDelResp2 | |
5125// |<------------------------------| |
5126// | | | SubFail1 |
5127// | | |<-------------|
5128// | | | |
5129// | | RESTNotif1 | |
5130// | | unsuccess | |
5131// | |<----------------| |
5132// | RESTNotif2 | |
5133// | | unsuccess | |
5134// |<------------------------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005135// | | | |
Anssi Mannila3e55f472021-11-05 09:58:04 +02005136// | | 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 +03005137// | |---------------->| |
5138// | | | |
5139// | | RESTSubDelResp1 | |
5140// | |<----------------| |
5141// | | | |
5142// | RESTSubDelReq2 | |
5143// |------------------------------>| |
5144// | | | |
5145// | RESTSubDelResp2 | |
5146// |<------------------------------| |
5147//
5148//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005149
archaggeafbf95f2021-04-14 08:54:05 +03005150func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005151
5152 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005153 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005154 Counter{cMergedSubscriptions, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005155 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005156 Counter{cSubReqToE2, 1},
5157 Counter{cSubFailFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005158 Counter{cRestSubFailNotifToXapp, 2},
Anssi Mannila54838ed2021-11-19 11:25:01 +02005159 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005160 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005161 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005162 })
5163
5164 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005165
5166 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005167 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005168 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5169 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5170
5171 // Req2
5172 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005173 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005174 params2.SetMeid("RAN_NAME_1")
5175 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
5176 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
5177
5178 // E2t: send SubsFail (first)
5179 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5180 fparams1.Set(crereq1)
5181 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5182
archaggeafbf95f2021-04-14 08:54:05 +03005183 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03005184 e2SubsIdA := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005185 xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
archaggeafbf95f2021-04-14 08:54:05 +03005186 e2SubsIdB := <-xappConn1.ListedRESTNotifications
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005187 xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03005188
5189 // Del1
5190 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5191
5192 // Del2
5193 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
5194
5195 //Wait that subs is cleaned
5196 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
5197 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03005198 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005199 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005200}
Anssi Mannila54838ed2021-11-19 11:25:01 +02005201
Anssi Mannila27385172021-12-22 09:41:54 +02005202//-----------------------------------------------------------------------------
5203// TestRESTSubReqPolicyAndSubDelOk
5204//
5205// stub stub
5206// +-------+ +---------+ +---------+
5207// | xapp | | submgr | | e2term |
5208// +-------+ +---------+ +---------+
5209// | | |
5210// | RESTSubReq | |
5211// |--------------->| |
5212// | RESTSubResp | |
5213// |<---------------| |
5214// | | |
5215// | | SubReq |
5216// | |------------->|
5217// | | |
5218// | | SubResp |
5219// | |<-------------|
5220// | | |
5221// | RESTNotif | |
5222// |<---------------| |
5223// | | |
5224// | | |
5225// | RESTSubDelReq | |
5226// |--------------->| |
5227// | RESTSubDelResp | |
5228// |<---------------| |
5229// | | |
5230// | | SubDelReq |
5231// | |------------->|
5232// | | |
5233// | | SubDelResp |
5234// | |<-------------|
5235// | | |
5236//
5237//-----------------------------------------------------------------------------
5238
archaggeafbf95f2021-04-14 08:54:05 +03005239func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005240
5241 // Init counter check
5242 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005243 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005244 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005245 Counter{cSubReqToE2, 1},
5246 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005247 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005248 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005249 Counter{cSubDelReqToE2, 1},
5250 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005251 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005252 })
5253
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005254 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005255 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005256 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005257
5258 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5259 xappConn1.ExpectRESTNotification(t, restSubId)
5260 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5261 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005262 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03005263
5264 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5265 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5266 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5267
5268 // Wait that subs is cleaned
5269 waitSubsCleanup(t, e2SubsId, 10)
5270 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005271 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005272}
5273
5274//-----------------------------------------------------------------------------
5275// TestRESTSubReqPolicyChangeAndSubDelOk
5276//
5277// stub stub
5278// +-------+ +---------+ +---------+
5279// | xapp | | submgr | | e2term |
5280// +-------+ +---------+ +---------+
5281// | | |
5282// | RESTSubReq | |
5283// |---------------->| |
5284// | | |
5285// | RESTSubResp | |
5286// |<----------------| |
5287// | | SubReq |
5288// | |------------->|
5289// | | |
5290// | | SubResp |
5291// | |<-------------|
5292// | | |
5293// | RESTNotif | |
5294// |<----------------| |
5295// | | |
5296// | RESTSubReq | |
5297// |---------------->| |
5298// | | |
5299// | RESTSubResp | |
5300// |<----------------| |
5301// | | SubReq |
5302// | |------------->|
5303// | | |
5304// | | SubResp |
5305// | |<-------------|
5306// | | |
5307// | RESTNotif | |
5308// |<----------------| |
5309// | | |
5310// | RESTSubDelReq | |
5311// |---------------->| |
5312// | | |
5313// | | SubDelReq |
5314// | |------------->|
5315// | | |
5316// | | SubDelResp |
5317// | |<-------------|
5318// | | |
5319// | RESTSubDelResp | |
5320// |<----------------| |
5321//
5322//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005323
archaggeafbf95f2021-04-14 08:54:05 +03005324func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005325
5326 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005327 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005328 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005329 Counter{cSubReqToE2, 2},
5330 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005331 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005332 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005333 Counter{cSubDelReqToE2, 1},
5334 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005335 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005336 })
5337
5338 const subReqCount int = 1
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005339 const e2Timeout int64 = 1
5340 const e2RetryCount int64 = 0
5341 const routingNeeded bool = true
archaggeafbf95f2021-04-14 08:54:05 +03005342
5343 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005344 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005345 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
archaggeafbf95f2021-04-14 08:54:05 +03005346 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5347
5348 // Policy change
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005349 // GetRESTSubsReqPolicyParams sets some counters on tc side.
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005350
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005351 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005352 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005353 params.SetSubscriptionID(&restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005354 params.SetTimeToWait("w200ms")
5355 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
5356
5357 // Del
5358 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5359
5360 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5361 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5362
5363 // Wait that subs is cleaned
5364 waitSubsCleanup(t, e2SubsId, 10)
5365 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005366 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005367}
5368
5369//-----------------------------------------------------------------------------
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005370// TestRESTSubReqPolicyChangeNOk
5371//
5372// stub stub
5373// +-------+ +---------+ +---------+
5374// | xapp | | submgr | | e2term |
5375// +-------+ +---------+ +---------+
5376// | | |
5377// | RESTSubReq | |
5378// |---------------->| |
5379// | | |
5380// | RESTSubResp | |
5381// |<----------------| |
5382// | | SubReq |
5383// | |------------->|
5384// | | |
5385// | | SubResp |
5386// | |<-------------|
5387// | | |
5388// | RESTNotif | |
5389// |<----------------| |
5390// | | |
5391// | RESTSubReq | |
5392// |---------------->| |
5393// | | |
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005394// | RESTSubUpdateFail(400 Bad request)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005395// | | |
5396// | RESTSubDelReq | |
5397// |---------------->| |
5398// | | |
5399// | | SubDelReq |
5400// | |------------->|
5401// | | |
5402// | | SubDelResp |
5403// | |<-------------|
5404// | | |
5405// | RESTSubDelResp | |
5406// |<----------------| |
5407//
5408//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005409
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005410func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005411
5412 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5413 Counter{cRestSubReqFromXapp, 2},
5414 Counter{cRestSubRespToXapp, 1},
5415 Counter{cSubReqToE2, 1},
5416 Counter{cSubRespFromE2, 1},
5417 Counter{cRestSubNotifToXapp, 1},
5418 Counter{cRestSubFailToXapp, 1},
5419 Counter{cRestSubDelReqFromXapp, 1},
5420 Counter{cSubDelReqToE2, 1},
5421 Counter{cSubDelRespFromE2, 1},
5422 Counter{cRestSubDelRespToXapp, 1},
5423 })
5424
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005425 // Req
5426 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5427 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5428
5429 // Policy change
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005430 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
5431
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005432 restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005433 params.SetSubscriptionID(&restSubIdUpd)
5434 params.SetTimeToWait("w200ms")
5435
5436 restSubId2 := xappConn1.SendRESTSubsReq(t, params)
5437 assert.Equal(t, restSubId2, "")
5438
5439 // Del
5440 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5441
5442 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5443 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5444
5445 // Wait that subs is cleaned
5446 waitSubsCleanup(t, e2SubsId, 10)
5447 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005448 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelofe93b00f2021-06-03 10:00:19 +00005449}
5450
5451//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005452// TestRESTSubReqAndSubDelOkTwoE2termParallel
5453//
5454// stub stub stub
5455// +-------+ +---------+ +---------+ +---------+
5456// | xapp | | submgr | | e2term1 | | e2term2 |
5457// +-------+ +---------+ +---------+ +---------+
5458// | | | |
5459// | | | |
5460// | | | |
5461// | RESTSubReq1 | | |
5462// |---------------->| | |
5463// | | | |
5464// | RESTSubResp1 | | |
5465// |<----------------| | |
5466// | | SubReq1 | |
5467// | |------------->| |
5468// | | | |
5469// | RESTSubReq2 | | |
5470// |---------------->| | |
5471// | | | |
5472// | RESTSubResp2 | | |
5473// |<----------------| | |
5474// | | SubReq2 | |
5475// | |---------------------------->|
5476// | | | |
5477// | | SubResp1 | |
5478// | |<-------------| |
5479// | RESTNotif1 | | |
5480// |<----------------| | |
5481// | | SubResp2 | |
5482// | |<----------------------------|
5483// | RESTNotif2 | | |
5484// |<----------------| | |
5485// | | | |
5486// | [SUBS 1 DELETE] | |
5487// | | | |
5488// | [SUBS 2 DELETE] | |
5489// | | | |
5490//
5491//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005492
archaggeafbf95f2021-04-14 08:54:05 +03005493func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005494
5495 // Init counter check
5496 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005497 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005498 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005499 Counter{cSubReqToE2, 2},
5500 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005501 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005502 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005503 Counter{cSubDelReqToE2, 2},
5504 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005505 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005506 })
5507
5508 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005509
5510 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005511 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005512 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
5513 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5514
5515 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005516 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005517 params.SetMeid("RAN_NAME_11")
5518 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
5519 // would not work as notification would not be received
5520 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
5521 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
5522
5523 // Resp1
5524 xappConn1.ExpectRESTNotification(t, restSubId1)
5525 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5526 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005527 xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03005528
5529 // Resp2
5530 xappConn2.ExpectRESTNotification(t, restSubId2)
5531 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
5532 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005533 xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005534
5535 // Delete1
5536 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
5537 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5538 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5539
5540 // Wait that subs is cleaned
5541 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
5542
5543 // Delete2
5544 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
5545 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
5546 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
5547
5548 // Wait that subs is cleaned
5549 waitSubsCleanup(t, e2SubsId2, 10)
5550
5551 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005552 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005553}
5554
5555//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03005556// TestRESTSubReqInsertAndSubDelOk
5557//
5558// stub stub
5559// +-------+ +---------+ +---------+
5560// | xapp | | submgr | | e2term |
5561// +-------+ +---------+ +---------+
5562// | | |
5563// | RestSubReq | |
5564// |---------------->| |
5565// | | |
5566// | RESTSubResp | |
5567// |<----------------| |
5568// | | |
5569// | | SubReq |
5570// | |------------->|
5571// | | |
5572// | | SubResp |
5573// | |<-------------|
5574// | RESTNotif | |
5575// |<----------------| |
5576// | ... | ... |
5577// | | |
5578// | RESTSubDelReq | |
5579// |---------------->| |
5580// | | |
5581// | | SubDelReq |
5582// | |------------->|
5583// | | |
5584// | | SubDelResp |
5585// | |<-------------|
5586// | | |
5587// | RESTSubDelResp| |
5588// |<----------------| |
5589//
5590//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005591
archaggeafbf95f2021-04-14 08:54:05 +03005592func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005593
5594 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005595 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005596 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005597 Counter{cSubReqToE2, 1},
5598 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005599 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005600 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005601 Counter{cSubDelReqToE2, 1},
5602 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005603 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005604 })
5605
5606 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005607
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005608 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005609 params.SetSubActionTypes("insert")
5610
5611 // Req
5612 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5613
5614 // Del
5615 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5616
5617 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5618 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5619
5620 // Wait that subs is cleaned
5621 waitSubsCleanup(t, e2SubsId, 10)
5622 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005623 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005624}
5625
5626//-----------------------------------------------------------------------------
5627// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
5628//
5629// stub stub
5630// +-------+ +---------+ +---------+
5631// | xapp | | submgr | | e2term |
5632// +-------+ +---------+ +---------+
5633// | | |
5634// | RESTSubReq | |
5635// |------------->| |
5636// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005637// | RESTSubResp | |
5638// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005639// | | SubReq |
5640// | |------------->|
5641// | | |
5642// | | SubResp |
5643// | <----|
5644// | |
5645// | Submgr restart |
5646// | |
5647// | | |
5648// | | SubDelReq |
5649// | |------------->|
5650// | | |
5651// | | SubDelResp |
5652// | |<-------------|
5653// | | |
Anssi Mannilab43397e2021-11-16 12:06:16 +02005654// | RESTNotif | |
5655// | unsuccess | |
5656// |<-------------| |
5657// | | |
5658// | RESTSubDelReq| |
5659// |------------->| |
5660// | | |
5661// |RESTSubDelResp| |
5662// |<-------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005663//
5664//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02005665
archaggeafbf95f2021-04-14 08:54:05 +03005666func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005667
5668 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005669 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005670 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005671 Counter{cSubReqToE2, 1},
5672 Counter{cSubDelReqFromXapp, 1},
5673 Counter{cSubDelReqToE2, 1},
5674 Counter{cSubDelRespFromE2, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02005675 Counter{cRestSubDelReqFromXapp, 1},
5676 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005677 })
5678
5679 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005680
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005681 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005682
5683 //Req
5684 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
5685 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005686 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005687
5688 e2termConn1.RecvSubsReq(t)
5689
5690 mainCtrl.SetResetTestFlag(t, false)
5691
5692 mainCtrl.SimulateRestart(t)
5693 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
5694
Anssi Mannilab43397e2021-11-16 12:06:16 +02005695 // Deleletion of uncompleted subscription
archaggeafbf95f2021-04-14 08:54:05 +03005696 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5697 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5698
Anssi Mannilab43397e2021-11-16 12:06:16 +02005699 //Del
5700 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5701
archaggeafbf95f2021-04-14 08:54:05 +03005702 xappConn1.TestMsgChanEmpty(t)
archaggeafbf95f2021-04-14 08:54:05 +03005703 e2termConn1.TestMsgChanEmpty(t)
5704 mainCtrl.wait_registry_empty(t, 10)
5705
5706 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005707 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005708}
5709
5710//-----------------------------------------------------------------------------
5711// TestRESTSubReqAndSubDelOkWithRestartInMiddle
5712//
5713// stub stub
5714// +-------+ +---------+ +---------+
5715// | xapp | | submgr | | e2term |
5716// +-------+ +---------+ +---------+
5717// | | |
5718// | RESTSubReq | |
5719// |---------------->| |
5720// | | |
5721// | RESTSubResp | |
5722// |<----------------| |
5723// | | SubReq |
5724// | |------------->|
5725// | | |
5726// | | SubResp |
5727// | |<-------------|
5728// | | |
5729// | RESTNotif | |
5730// |<----------------| |
5731// | | |
5732// | |
5733// | Submgr restart |
5734// | | |
5735// | RESTSubDelReq | |
5736// |---------------->| |
5737// | | |
5738// | | SubDelReq |
5739// | |------------->|
5740// | | |
5741// | | SubDelResp |
5742// | |<-------------|
5743// | | |
5744// | RESTSubDelResp | |
5745// |<----------------| |
5746//
5747//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005748
archaggeafbf95f2021-04-14 08:54:05 +03005749func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005750
5751 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005752 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005753 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005754 Counter{cSubReqToE2, 1},
5755 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005756 Counter{cRestSubNotifToXapp, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005757 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005758 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02005759 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005760 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03005761 })
archaggeafbf95f2021-04-14 08:54:05 +03005762
5763 // Create subscription
Anssi Mannila54838ed2021-11-19 11:25:01 +02005764 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005765 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005766 xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03005767
5768 // Check subscription
5769 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5770
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005771 mainCtrl.SimulateRestart(t)
5772 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03005773
Anssi Mannila54838ed2021-11-19 11:25:01 +02005774 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5775 // That needs to be completed before successful subscription query is possible
5776 <-time.After(time.Second * 1)
5777
archaggeafbf95f2021-04-14 08:54:05 +03005778 // Check subscription
5779 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
5780
5781 // Delete subscription
5782 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
5783
5784 //Wait that subs is cleaned
5785 waitSubsCleanup(t, e2SubsId, 10)
5786
5787 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005788 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005789}
5790
5791//-----------------------------------------------------------------------------
5792// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
5793//
5794// stub stub
5795// +-------+ +-------+ +---------+ +---------+
5796// | xapp2 | | xapp1 | | submgr | | e2term |
5797// +-------+ +-------+ +---------+ +---------+
5798// | | | |
5799// | | RESTSubReq1 | |
5800// | |---------------->| |
5801// | | | |
5802// | | RESTSubResp1 | |
5803// | |<----------------| |
5804// | | | |
5805// | | | SubReq1 |
5806// | | |------------->|
5807// | | | SubResp1 |
5808// | | |<-------------|
5809// | | RESTNotif1 | |
5810// | |<----------------| |
5811// | | | |
5812// | RESTSubReq2 | |
5813// |------------------------------>| |
5814// | | | |
5815// | RESTSubResp2 | |
5816// |<------------------------------| |
5817// | | | |
5818// | | RESTNotif2 | |
5819// |<------------------------------| |
5820// | | | |
5821// | | Submgr restart |
5822// | | | |
5823// | | RESTSubDelReq1 | |
5824// | |---------------->| |
5825// | | | |
5826// | | RESTSubDelResp1 | |
5827// | |<----------------| |
5828// | | | |
5829// | | Submgr restart |
5830// | | | |
5831// | RESTSubDelReq2 | |
5832// |------------------------------>| |
5833// | | | |
5834// | RESTSubDelResp2 | |
5835// |<------------------------------| |
5836// | | | |
5837// | | | SubDelReq2 |
5838// | | |------------->|
5839// | | | |
5840// | | | SubDelResp2 |
5841// | | |<-------------|
5842// | | | |
5843//
5844//-----------------------------------------------------------------------------
5845func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03005846
5847 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005848 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005849 Counter{cRestSubRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005850 Counter{cSubReqToE2, 1},
5851 Counter{cSubRespFromE2, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03005852 Counter{cRestSubNotifToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005853 Counter{cMergedSubscriptions, 1},
5854 Counter{cUnmergedSubscriptions, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005855 Counter{cRestSubDelReqFromXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005856 Counter{cSubDelReqToE2, 1},
5857 Counter{cSubDelRespFromE2, 1},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00005858 Counter{cRestSubDelRespToXapp, 2},
archaggeafbf95f2021-04-14 08:54:05 +03005859 })
5860
archaggeafbf95f2021-04-14 08:54:05 +03005861 // Create subscription 1
Anssi Mannila54838ed2021-11-19 11:25:01 +02005862 var params *teststube2ap.RESTSubsReqParams = nil
archaggeafbf95f2021-04-14 08:54:05 +03005863 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005864 xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
archaggeafbf95f2021-04-14 08:54:05 +03005865
5866 // Create subscription 2 with same action
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005867 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005868 params.SetMeid("RAN_NAME_1")
5869 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005870 xappConn2.ExpectAnyNotification(t)
archaggeafbf95f2021-04-14 08:54:05 +03005871 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005872 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Markku Virtanen2b512b62021-07-30 12:04:00 +00005873 e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005874 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
archaggeafbf95f2021-04-14 08:54:05 +03005875
5876 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
5877
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005878 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005879 xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
5880
5881 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5882 // That needs to be completed before successful subscription delete is possible
5883 <-time.After(time.Second * 1)
archaggeafbf95f2021-04-14 08:54:05 +03005884
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00005885 // Delete subscription 1, and wait until it has removed the first endpoint
archaggeafbf95f2021-04-14 08:54:05 +03005886 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Anssi Mannilafc20a5c2021-12-14 10:28:20 +02005887 mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005888 // Above wait does not work correctly anymore as this delay makes this test case work
Anssi Mannila54838ed2021-11-19 11:25:01 +02005889
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005890 mainCtrl.SimulateRestart(t)
Anssi Mannila54838ed2021-11-19 11:25:01 +02005891 xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
5892
5893 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
5894 // That needs to be completed before successful subscription query is possible
5895 <-time.After(time.Second * 1)
5896
archaggeafbf95f2021-04-14 08:54:05 +03005897 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
5898
5899 // Delete subscription 2
5900 deleteXapp2Subscription(t, &restSubId2)
5901
5902 //Wait that subs is cleaned
5903 waitSubsCleanup(t, e2SubsId2, 10)
5904
5905 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02005906 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03005907}
5908
5909//-----------------------------------------------------------------------------
5910// TestRESTReportSubReqAndSubDelOk
5911//
5912// stub stub
5913// +-------+ +---------+ +---------+
5914// | xapp | | submgr | | e2term |
5915// +-------+ +---------+ +---------+
5916// | | |
5917// | RestSubReq | |
5918// |---------------->| |
5919// | | |
5920// | RESTSubResp | |
5921// |<----------------| |
5922// | | |
5923// | | SubReq |
5924// | |------------->|
5925// | | |
5926// | | SubResp |
5927// | |<-------------|
5928// | RESTNotif | |
5929// |<----------------| |
Anssi Mannila27385172021-12-22 09:41:54 +02005930// | | SubReq | // Only one request sent in the teat case
archaggeafbf95f2021-04-14 08:54:05 +03005931// | |------------->|
5932// | | |
5933// | | SubResp |
5934// | |<-------------|
5935// | RESTNotif | |
5936// |<----------------| |
5937// | ... | ... |
5938// | | |
5939// | | |
5940// | RESTSubDelReq | |
5941// |---------------->| |
5942// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02005943// | RESTSubDelResp| |
5944// |<----------------| |
archaggeafbf95f2021-04-14 08:54:05 +03005945// | | SubDelReq |
5946// | |------------->|
5947// | | |
5948// | | SubDelResp |
5949// | |<-------------|
5950// | | |
archaggeafbf95f2021-04-14 08:54:05 +03005951//
5952//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00005953
archaggeafbf95f2021-04-14 08:54:05 +03005954func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005955 const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03005956 testIndex := 1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005957 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005958}
5959
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005960func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005961 xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
archaggeafbf95f2021-04-14 08:54:05 +03005962
Anssi Mannila21782182021-12-10 10:56:02 +02005963 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5964 Counter{cRestSubReqFromXapp, 1},
5965 Counter{cRestSubRespToXapp, 1},
5966 Counter{cSubReqToE2, uint64(subReqCount)},
5967 Counter{cSubRespFromE2, uint64(subReqCount)},
5968 Counter{cRestSubNotifToXapp, 1},
5969 Counter{cRestSubDelReqFromXapp, 1},
5970 Counter{cRestSubDelRespToXapp, 1},
5971 Counter{cSubDelReqToE2, uint64(subReqCount)},
5972 Counter{cSubDelRespFromE2, uint64(subReqCount)},
5973 })
5974
archaggeafbf95f2021-04-14 08:54:05 +03005975 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00005976 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03005977 restSubId := xappConn1.SendRESTSubsReq(t, params)
5978
5979 var e2SubsId []uint32
5980 for i := 0; i < subReqCount; i++ {
5981 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5982 xappConn1.ExpectRESTNotification(t, restSubId)
5983
5984 e2termConn1.SendSubsResp(t, crereq, cremsg)
5985 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03005986 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
archaggeafbf95f2021-04-14 08:54:05 +03005987 e2SubsId = append(e2SubsId, instanceId)
5988 resp, _ := xapp.Subscription.QuerySubscriptions()
5989 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
5990 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
5991 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
5992
5993 }
5994
5995 // Del
5996 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5997
5998 for i := 0; i < subReqCount; i++ {
5999 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
6000 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
6001 }
6002
6003 // Wait that subs is cleaned
6004 for i := 0; i < subReqCount; i++ {
6005 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
6006 }
6007
6008 xappConn1.TestMsgChanEmpty(t)
6009 e2termConn1.TestMsgChanEmpty(t)
6010 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006011 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02006012 mainCtrl.VerifyCounterValues(t)
archaggeafbf95f2021-04-14 08:54:05 +03006013}
6014
Anssi Mannila27385172021-12-22 09:41:54 +02006015//-----------------------------------------------------------------------------
6016// TestRESTTwoPolicySubReqAndSubDelOk
6017//
6018// stub stub
6019// +-------+ +---------+ +---------+
6020// | xapp | | submgr | | e2term |
6021// +-------+ +---------+ +---------+
6022// | | |
6023// | RestSubReq | |
6024// |---------------->| |
6025// | | |
6026// | RESTSubResp | |
6027// |<----------------| |
6028// | | |
6029// | | SubReq |
6030// | |------------->|
6031// | | |
6032// | | SubResp |
6033// | |<-------------|
6034// | RESTNotif | |
6035// |<----------------| |
6036// | | SubReq |
6037// | |------------->|
6038// | | |
6039// | | SubResp |
6040// | |<-------------|
6041// | RESTNotif | |
6042// |<----------------| |
6043// | | |
6044// | RESTSubDelReq | |
6045// |---------------->| |
6046// | | |
6047// | RESTSubDelResp| |
6048// |<----------------| |
6049// | | SubDelReq |
6050// | |------------->|
6051// | | |
6052// | | SubDelResp |
6053// | |<-------------|
6054// | | |
6055// | | SubDelReq |
6056// | |------------->|
6057// | | |
6058// | | SubDelResp |
6059// | |<-------------|
6060// | | |
6061//
6062//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +03006063
archaggeafbf95f2021-04-14 08:54:05 +03006064func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
6065
archaggeafbf95f2021-04-14 08:54:05 +03006066 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006067 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006068 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006069 Counter{cSubReqToE2, 2},
6070 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006071 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006072 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006073 Counter{cSubDelReqToE2, 2},
6074 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006075 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006076 })
6077
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006078 const subReqCount int = 2
6079
archaggeafbf95f2021-04-14 08:54:05 +03006080 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006081 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006082 restSubId := xappConn1.SendRESTSubsReq(t, params)
6083 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6084
6085 assert.Equal(t, len(e2SubsIds), 2)
6086
6087 // Del
6088 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6089 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6090
6091 xappConn1.TestMsgChanEmpty(t)
6092 e2termConn1.TestMsgChanEmpty(t)
6093 mainCtrl.wait_registry_empty(t, 10)
6094
6095 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006096 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006097}
Anssi Mannila27385172021-12-22 09:41:54 +02006098
6099//-----------------------------------------------------------------------------
6100// TestRESTPolicySubReqAndSubDelOk19E2Subs
6101//
6102// stub stub
6103// +-------+ +---------+ +---------+
6104// | xapp | | submgr | | e2term |
6105// +-------+ +---------+ +---------+
6106// | | |
6107// | RestSubReq | |
6108// |---------------->| |
6109// | | |
6110// | RESTSubResp | |
6111// |<----------------| |
6112// | | | ------
6113// | | SubReq |
6114// | |------------->|
6115// | | | E2 subscription x 19
6116// | | SubResp |
6117// | |<-------------|
6118// | RESTNotif | |
6119// |<----------------| |
6120// | | | ------
6121// | RESTSubDelReq | |
6122// |---------------->| |
6123// | | |
6124// | RESTSubDelResp| |
6125// |<----------------| |
6126// | | SubDelReq | ------
6127// | |------------->|
6128// | | | E2 subscription delete x 19
6129// | | SubDelResp |
6130// | |<-------------|
6131// | | | ------
6132// | | |
6133//
6134//-----------------------------------------------------------------------------
6135
6136func TestRESTPolicySubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006137
archaggeafbf95f2021-04-14 08:54:05 +03006138 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006139 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006140 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006141 Counter{cSubReqToE2, 19},
6142 Counter{cSubRespFromE2, 19},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006143 Counter{cRestSubNotifToXapp, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006144 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006145 Counter{cSubDelReqToE2, 19},
6146 Counter{cSubDelRespFromE2, 19},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006147 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006148 })
6149
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006150 const subReqCount int = 19
archaggeafbf95f2021-04-14 08:54:05 +03006151 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006152 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006153 restSubId := xappConn1.SendRESTSubsReq(t, params)
6154 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6155
6156 assert.Equal(t, len(e2SubsIds), 19)
6157
6158 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6159 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6160
6161 xappConn1.TestMsgChanEmpty(t)
6162 e2termConn1.TestMsgChanEmpty(t)
6163 mainCtrl.wait_registry_empty(t, 10)
6164
6165 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006166 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006167}
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006168
Anssi Mannila27385172021-12-22 09:41:54 +02006169//-----------------------------------------------------------------------------
6170// TestRESTTwoPolicySubReqAndSubDelOk
6171//
6172// stub stub
6173// +-------+ +---------+ +---------+
6174// | xapp | | submgr | | e2term |
6175// +-------+ +---------+ +---------+
6176// | | |
6177// | RestSubReq | |
6178// |---------------->| |
6179// | | |
6180// | RESTSubResp | |
6181// |<----------------| |
6182// | | |
6183// | | SubReq |
6184// | |------------->|
6185// | | |
6186// | | SubResp |
6187// | |<-------------|
6188// | RESTNotif | |
6189// |<----------------| |
6190// | | SubReq |
6191// | |------------->|
6192// | | |
6193// | | SubResp |
6194// | |<-------------|
6195// | RESTNotif | |
6196// |<----------------| |
6197// | | |
6198// | RESTSubDelReq | |
6199// |---------------->| |
6200// | | |
6201// | RESTSubDelResp| |
6202// |<----------------| |
6203// | | SubDelReq |
6204// | |------------->|
6205// | | |
6206// | | SubDelResp |
6207// | |<-------------|
6208// | | |
6209// | | SubDelReq |
6210// | |------------->|
6211// | | |
6212// | | SubDelResp |
6213// | |<-------------|
6214// | | |
6215//
6216//-----------------------------------------------------------------------------
6217
archaggeafbf95f2021-04-14 08:54:05 +03006218func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
6219
6220 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006221
6222 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006223 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006224 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006225 Counter{cSubReqToE2, uint64(subReqCount)},
6226 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006227 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006228 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006229 Counter{cSubDelReqToE2, uint64(subReqCount)},
6230 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006231 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006232 })
6233
6234 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006235 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006236 restSubId := xappConn1.SendRESTSubsReq(t, params)
6237 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6238
6239 assert.Equal(t, len(e2SubsIds), subReqCount)
6240
6241 // Del
6242 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6243 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6244
6245 xappConn1.TestMsgChanEmpty(t)
6246 e2termConn1.TestMsgChanEmpty(t)
6247 mainCtrl.wait_registry_empty(t, 10)
6248
6249 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006250 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006251}
Markku Virtanenda34eec2021-05-20 08:22:04 +00006252
Anssi Mannila27385172021-12-22 09:41:54 +02006253//-----------------------------------------------------------------------------
6254// TestRESTTwoReportSubReqAndSubDelOkNoActParams
6255//
6256// stub stub
6257// +-------+ +---------+ +---------+
6258// | xapp | | submgr | | e2term |
6259// +-------+ +---------+ +---------+
6260// | | |
6261// | RestSubReq | |
6262// |---------------->| |
6263// | | |
6264// | RESTSubResp | |
6265// |<----------------| |
6266// | | |
6267// | | SubReq |
6268// | |------------->|
6269// | | |
6270// | | SubResp |
6271// | |<-------------|
6272// | RESTNotif | |
6273// |<----------------| |
6274// | | SubReq |
6275// | |------------->|
6276// | | |
6277// | | SubResp |
6278// | |<-------------|
6279// | RESTNotif | |
6280// |<----------------| |
6281// | | |
6282// | RESTSubDelReq | |
6283// |---------------->| |
6284// | | |
6285// | RESTSubDelResp| |
6286// |<----------------| |
6287// | | SubDelReq |
6288// | |------------->|
6289// | | |
6290// | | SubDelResp |
6291// | |<-------------|
6292// | | |
6293// | | SubDelReq |
6294// | |------------->|
6295// | | |
6296// | | SubDelResp |
6297// | |<-------------|
6298// | | |
6299//
6300//-----------------------------------------------------------------------------
6301
archaggeafbf95f2021-04-14 08:54:05 +03006302func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
6303
6304 subReqCount := 2
archaggeafbf95f2021-04-14 08:54:05 +03006305
6306 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006307 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006308 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006309 Counter{cSubReqToE2, uint64(subReqCount)},
6310 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006311 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006312 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006313 Counter{cSubDelReqToE2, uint64(subReqCount)},
6314 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006315 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006316 })
6317
6318 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006319 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006320 restSubId := xappConn1.SendRESTSubsReq(t, params)
6321 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6322
6323 assert.Equal(t, len(e2SubsIds), subReqCount)
6324
6325 // Del
6326 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6327 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6328
6329 xappConn1.TestMsgChanEmpty(t)
6330 e2termConn1.TestMsgChanEmpty(t)
6331 mainCtrl.wait_registry_empty(t, 10)
6332
6333 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006334 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006335}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00006336
Anssi Mannila27385172021-12-22 09:41:54 +02006337//-----------------------------------------------------------------------------
6338// TestRESTReportSubReqAndSubDelOk19E2Subs
6339//
6340// stub stub
6341// +-------+ +---------+ +---------+
6342// | xapp | | submgr | | e2term |
6343// +-------+ +---------+ +---------+
6344// | | |
6345// | RestSubReq | |
6346// |---------------->| |
6347// | | |
6348// | RESTSubResp | |
6349// |<----------------| |
6350// | | | ------
6351// | | SubReq |
6352// | |------------->|
6353// | | | E2 subscription x 19
6354// | | SubResp |
6355// | |<-------------|
6356// | RESTNotif | |
6357// |<----------------| |
6358// | | | ------
6359// | RESTSubDelReq | |
6360// |---------------->| |
6361// | | |
6362// | RESTSubDelResp| |
6363// |<----------------| |
6364// | | SubDelReq | ------
6365// | |------------->|
6366// | | | E2 subscription delete x 19
6367// | | SubDelResp |
6368// | |<-------------|
6369// | | | ------
6370// | | |
6371//
6372//-----------------------------------------------------------------------------
6373
6374func TestRESTReportSubReqAndSubDelOk19E2Subs(t *testing.T) {
archaggeafbf95f2021-04-14 08:54:05 +03006375
6376 subReqCount := 19
archaggeafbf95f2021-04-14 08:54:05 +03006377
6378 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006379 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006380 Counter{cRestSubRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006381 Counter{cSubReqToE2, uint64(subReqCount)},
6382 Counter{cSubRespFromE2, uint64(subReqCount)},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006383 Counter{cRestSubNotifToXapp, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006384 Counter{cRestSubDelReqFromXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006385 Counter{cSubDelReqToE2, uint64(subReqCount)},
6386 Counter{cSubDelRespFromE2, uint64(subReqCount)},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006387 Counter{cRestSubDelRespToXapp, 1},
archaggeafbf95f2021-04-14 08:54:05 +03006388 })
6389
6390 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006391 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03006392 restSubId := xappConn1.SendRESTSubsReq(t, params)
6393 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
6394
6395 assert.Equal(t, len(e2SubsIds), subReqCount)
6396
6397 // Del
6398 xappConn1.SendRESTSubsDelReq(t, &restSubId)
6399 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
6400
6401 xappConn1.TestMsgChanEmpty(t)
6402 e2termConn1.TestMsgChanEmpty(t)
6403 mainCtrl.wait_registry_empty(t, 10)
6404
6405 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006406 mainCtrl.VerifyAllClean(t)
archaggeafbf95f2021-04-14 08:54:05 +03006407}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006408
Anssi Mannila27385172021-12-22 09:41:54 +02006409//-----------------------------------------------------------------------------
6410// TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen
6411//
6412// stub stub stub
6413// +-------+ +-------+ +---------+ +---------+
6414// | xapp2 | | xapp1 | | submgr | | e2term |
6415// +-------+ +-------+ +---------+ +---------+
6416// | | | |
6417// | | RESTSubReq1 | |
6418// | |------------->| |
6419// | | RESTSubResp1 | |
6420// | |<-------------| |
6421// | | | |
6422// | | | SubReq1 |
6423// | | |------------->|
6424// | | | |
6425// | RESTSubReq2 | |
6426// |------------------------>| |
6427// | RESTSubResp2 | |
6428// |<------------------------| |
6429// | | | |
6430// | | | SubReq2 |
6431// | | |------------->|
6432// | | | |
6433// | | | SubResp1 |
6434// | | |<-------------|
6435// | | RESTNotif1 | |
6436// | |<-------------| |
6437// | | | |
6438// | | | SubResp2 |
6439// | | |<-------------|
6440// | RESTNotif2 | |
6441// |<------------------------| |
6442// | | | |
6443// | | [SUBS 1 DELETE] |
6444// | | | |
6445// | | [SUBS 2 DELETE] |
6446// | | | |
6447//
6448//-----------------------------------------------------------------------------
6449
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006450func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006451
6452 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006453 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006454 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006455 Counter{cSubReqToE2, 2},
6456 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006457 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006458 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006459 Counter{cSubDelReqToE2, 2},
6460 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006461 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006462 })
6463
6464 // Req1
6465 var params *teststube2ap.RESTSubsReqParams = nil
6466
6467 //Subs Create
6468 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006469 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006470
6471 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6472
6473 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006474 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006475 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006476 eventTriggerDefinition := []int64{1234, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006477 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
6478
6479 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006480 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006481 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6482 xappConn2.ExpectRESTNotification(t, restSubId2)
6483 e2termConn1.SendSubsResp(t, crereq, cremsg)
6484 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6485
6486 deleteXapp1Subscription(t, &restSubId1)
6487 deleteXapp2Subscription(t, &restSubId2)
6488
6489 waitSubsCleanup(t, e2SubsId1, 10)
6490 waitSubsCleanup(t, e2SubsId2, 10)
6491
6492 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006493 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006494}
6495
Anssi Mannila27385172021-12-22 09:41:54 +02006496//-----------------------------------------------------------------------------
6497// TestRESTSubReqReportSameActionDiffActionListLen
6498//
6499// stub stub stub
6500// +-------+ +-------+ +---------+ +---------+
6501// | xapp2 | | xapp1 | | submgr | | e2term |
6502// +-------+ +-------+ +---------+ +---------+
6503// | | | |
6504// | | RESTSubReq1 | |
6505// | |------------->| |
6506// | | RESTSubResp1 | |
6507// | |<-------------| |
6508// | | | |
6509// | | | SubReq1 |
6510// | | |------------->|
6511// | | | |
6512// | RESTSubReq2 | |
6513// |------------------------>| |
6514// | RESTSubResp2 | |
6515// |<------------------------| |
6516// | | | |
6517// | | | SubReq2 |
6518// | | |------------->|
6519// | | | |
6520// | | | SubResp1 |
6521// | | |<-------------|
6522// | | RESTNotif1 | |
6523// | |<-------------| |
6524// | | | |
6525// | | | SubResp2 |
6526// | | |<-------------|
6527// | RESTNotif2 | |
6528// |<------------------------| |
6529// | | | |
6530// | | [SUBS 1 DELETE] |
6531// | | | |
6532// | | [SUBS 2 DELETE] |
6533// | | | |
6534//
6535//-----------------------------------------------------------------------------
6536
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006537func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006538
6539 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006540 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006541 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006542 Counter{cSubReqToE2, 2},
6543 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006544 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006545 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006546 Counter{cSubDelReqToE2, 2},
6547 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006548 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006549 })
6550
6551 // Req1
6552 var params *teststube2ap.RESTSubsReqParams = nil
6553
6554 //Subs Create
6555 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006556 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006557
6558 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6559
6560 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006561 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006562 params.SetMeid("RAN_NAME_1")
6563
6564 actionId := int64(1)
6565 actionType := "report"
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006566 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006567 subsequestActionType := "continue"
6568 timeToWait := "w10ms"
6569 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
6570
6571 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006572 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006573 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6574 xappConn2.ExpectRESTNotification(t, restSubId2)
6575 e2termConn1.SendSubsResp(t, crereq, cremsg)
6576 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6577
6578 deleteXapp1Subscription(t, &restSubId1)
6579 deleteXapp2Subscription(t, &restSubId2)
6580
6581 waitSubsCleanup(t, e2SubsId1, 10)
6582 waitSubsCleanup(t, e2SubsId2, 10)
6583
6584 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006585 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006586}
6587
Anssi Mannila27385172021-12-22 09:41:54 +02006588//-----------------------------------------------------------------------------
6589// TestRESTSubReqReportSameActionDiffActionID
6590//
6591// stub stub stub
6592// +-------+ +-------+ +---------+ +---------+
6593// | xapp2 | | xapp1 | | submgr | | e2term |
6594// +-------+ +-------+ +---------+ +---------+
6595// | | | |
6596// | | RESTSubReq1 | |
6597// | |------------->| |
6598// | | RESTSubResp1 | |
6599// | |<-------------| |
6600// | | | |
6601// | | | SubReq1 |
6602// | | |------------->|
6603// | | | |
6604// | RESTSubReq2 | |
6605// |------------------------>| |
6606// | RESTSubResp2 | |
6607// |<------------------------| |
6608// | | | |
6609// | | | SubReq2 |
6610// | | |------------->|
6611// | | | |
6612// | | | SubResp1 |
6613// | | |<-------------|
6614// | | RESTNotif1 | |
6615// | |<-------------| |
6616// | | | |
6617// | | | SubResp2 |
6618// | | |<-------------|
6619// | RESTNotif2 | |
6620// |<------------------------| |
6621// | | | |
6622// | | [SUBS 1 DELETE] |
6623// | | | |
6624// | | [SUBS 2 DELETE] |
6625// | | | |
6626//
6627//-----------------------------------------------------------------------------
6628
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006629func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006630
6631 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006632 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006633 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006634 Counter{cSubReqToE2, 2},
6635 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006636 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006637 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006638 Counter{cSubDelReqToE2, 2},
6639 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006640 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006641 })
6642
6643 // Req1
6644 var params *teststube2ap.RESTSubsReqParams = nil
6645
6646 //Subs Create
6647 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006648 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006649
6650 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6651
6652 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006653 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006654 params.SetMeid("RAN_NAME_1")
6655 params.SetSubActionIDs(int64(2))
6656
6657 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006658 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006659 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6660 xappConn2.ExpectRESTNotification(t, restSubId2)
6661 e2termConn1.SendSubsResp(t, crereq, cremsg)
6662 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6663
6664 deleteXapp1Subscription(t, &restSubId1)
6665 deleteXapp2Subscription(t, &restSubId2)
6666
6667 waitSubsCleanup(t, e2SubsId1, 10)
6668 waitSubsCleanup(t, e2SubsId2, 10)
6669
6670 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006671 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006672}
6673
Anssi Mannila27385172021-12-22 09:41:54 +02006674//-----------------------------------------------------------------------------
6675// TestRESTSubReqDiffActionType
6676//
6677// stub stub stub
6678// +-------+ +-------+ +---------+ +---------+
6679// | xapp2 | | xapp1 | | submgr | | e2term |
6680// +-------+ +-------+ +---------+ +---------+
6681// | | | |
6682// | | RESTSubReq1 | |
6683// | |------------->| |
6684// | | RESTSubResp1 | |
6685// | |<-------------| |
6686// | | | |
6687// | | | SubReq1 |
6688// | | |------------->|
6689// | | | |
6690// | RESTSubReq2 | |
6691// |------------------------>| |
6692// | RESTSubResp2 | |
6693// |<------------------------| |
6694// | | | |
6695// | | | SubReq2 |
6696// | | |------------->|
6697// | | | |
6698// | | | SubResp1 |
6699// | | |<-------------|
6700// | | RESTNotif1 | |
6701// | |<-------------| |
6702// | | | |
6703// | | | SubResp2 |
6704// | | |<-------------|
6705// | RESTNotif2 | |
6706// |<------------------------| |
6707// | | | |
6708// | | [SUBS 1 DELETE] |
6709// | | | |
6710// | | [SUBS 2 DELETE] |
6711// | | | |
6712//
6713//-----------------------------------------------------------------------------
6714
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006715func TestRESTSubReqDiffActionType(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006716
6717 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006718 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006719 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006720 Counter{cSubReqToE2, 2},
6721 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006722 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006723 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006724 Counter{cSubDelReqToE2, 2},
6725 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006726 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006727 })
6728
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006729 const e2Timeout int64 = 2
6730 const e2RetryCount int64 = 2
6731 const routingNeeded bool = true
6732
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006733 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006734 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006735 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006736
6737 //Subs Create
6738 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006739 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006740
6741 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6742
6743 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006744 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006745 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006746 params.SetMeid("RAN_NAME_1")
6747
6748 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006749 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006750 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6751 xappConn2.ExpectRESTNotification(t, restSubId2)
6752 e2termConn1.SendSubsResp(t, crereq, cremsg)
6753 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6754
6755 deleteXapp1Subscription(t, &restSubId1)
6756 deleteXapp2Subscription(t, &restSubId2)
6757
6758 waitSubsCleanup(t, e2SubsId1, 10)
6759 waitSubsCleanup(t, e2SubsId2, 10)
6760
6761 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006762 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006763}
6764
Anssi Mannila27385172021-12-22 09:41:54 +02006765//-----------------------------------------------------------------------------
6766// TestRESTSubReqPolicyAndSubDelOkSameAction
6767//
6768// stub stub stub
6769// +-------+ +-------+ +---------+ +---------+
6770// | xapp2 | | xapp1 | | submgr | | e2term |
6771// +-------+ +-------+ +---------+ +---------+
6772// | | | |
6773// | | RESTSubReq1 | |
6774// | |------------->| |
6775// | | RESTSubResp1 | |
6776// | |<-------------| |
6777// | | | |
6778// | | | SubReq1 |
6779// | | |------------->|
6780// | | | |
6781// | RESTSubReq2 | |
6782// |------------------------>| |
6783// | RESTSubResp2 | |
6784// |<------------------------| |
6785// | | | |
6786// | | | SubReq2 |
6787// | | |------------->|
6788// | | | |
6789// | | | SubResp1 |
6790// | | |<-------------|
6791// | | RESTNotif1 | |
6792// | |<-------------| |
6793// | | | |
6794// | | | SubResp2 |
6795// | | |<-------------|
6796// | RESTNotif2 | |
6797// |<------------------------| |
6798// | | | |
6799// | | [SUBS 1 DELETE] |
6800// | | | |
6801// | | [SUBS 2 DELETE] |
6802// | | | |
6803//
6804//-----------------------------------------------------------------------------
6805
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006806func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006807
6808 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006809 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006810 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006811 Counter{cSubReqToE2, 2},
6812 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006813 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006814 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006815 Counter{cSubDelReqToE2, 2},
6816 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006817 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006818 })
6819
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006820 const e2Timeout int64 = 2
6821 const e2RetryCount int64 = 2
6822 const routingNeeded bool = true
6823
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006824 // Req1
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006825 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006826 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006827
6828 //Subs Create
6829 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006830 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006831
6832 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6833
6834 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006835 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006836 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006837 params.SetMeid("RAN_NAME_1")
6838
6839 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006840 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006841 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6842 xappConn2.ExpectRESTNotification(t, restSubId2)
6843 e2termConn1.SendSubsResp(t, crereq, cremsg)
6844 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6845
6846 deleteXapp1Subscription(t, &restSubId1)
6847 deleteXapp2Subscription(t, &restSubId2)
6848
6849 waitSubsCleanup(t, e2SubsId1, 10)
6850 waitSubsCleanup(t, e2SubsId2, 10)
6851
6852 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006853 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006854}
6855
Anssi Mannila27385172021-12-22 09:41:54 +02006856//-----------------------------------------------------------------------------
6857// TestRESTSubReqReportSameActionDiffActionDefinitionLen
6858//
6859// stub stub stub
6860// +-------+ +-------+ +---------+ +---------+
6861// | xapp2 | | xapp1 | | submgr | | e2term |
6862// +-------+ +-------+ +---------+ +---------+
6863// | | | |
6864// | | RESTSubReq1 | |
6865// | |------------->| |
6866// | | RESTSubResp1 | |
6867// | |<-------------| |
6868// | | | |
6869// | | | SubReq1 |
6870// | | |------------->|
6871// | | | |
6872// | RESTSubReq2 | |
6873// |------------------------>| |
6874// | RESTSubResp2 | |
6875// |<------------------------| |
6876// | | | |
6877// | | | SubReq2 |
6878// | | |------------->|
6879// | | | |
6880// | | | SubResp1 |
6881// | | |<-------------|
6882// | | RESTNotif1 | |
6883// | |<-------------| |
6884// | | | |
6885// | | | SubResp2 |
6886// | | |<-------------|
6887// | RESTNotif2 | |
6888// |<------------------------| |
6889// | | | |
6890// | | [SUBS 1 DELETE] |
6891// | | | |
6892// | | [SUBS 2 DELETE] |
6893// | | | |
6894//
6895//-----------------------------------------------------------------------------
6896
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006897func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006898
6899 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006900 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006901 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006902 Counter{cSubReqToE2, 2},
6903 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006904 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006905 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006906 Counter{cSubDelReqToE2, 2},
6907 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006908 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006909 })
6910
6911 // Req1
6912 var params *teststube2ap.RESTSubsReqParams = nil
6913
6914 //Subs Create
6915 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006916 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006917
6918 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
6919
6920 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00006921 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006922 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00006923 actionDefinition := []int64{5678, 1}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006924 params.SetSubActionDefinition(actionDefinition)
6925
6926 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03006927 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006928 crereq, cremsg := e2termConn1.RecvSubsReq(t)
6929 xappConn2.ExpectRESTNotification(t, restSubId2)
6930 e2termConn1.SendSubsResp(t, crereq, cremsg)
6931 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
6932
6933 deleteXapp1Subscription(t, &restSubId1)
6934 deleteXapp2Subscription(t, &restSubId2)
6935
6936 waitSubsCleanup(t, e2SubsId1, 10)
6937 waitSubsCleanup(t, e2SubsId2, 10)
6938
6939 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02006940 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006941}
6942
Anssi Mannila27385172021-12-22 09:41:54 +02006943//-----------------------------------------------------------------------------
6944// TestRESTSubReqReportSameActionDiffActionDefinitionContents
6945//
6946// stub stub stub
6947// +-------+ +-------+ +---------+ +---------+
6948// | xapp2 | | xapp1 | | submgr | | e2term |
6949// +-------+ +-------+ +---------+ +---------+
6950// | | | |
6951// | | RESTSubReq1 | |
6952// | |------------->| |
6953// | | RESTSubResp1 | |
6954// | |<-------------| |
6955// | | | |
6956// | | | SubReq1 |
6957// | | |------------->|
6958// | | | |
6959// | RESTSubReq2 | |
6960// |------------------------>| |
6961// | RESTSubResp2 | |
6962// |<------------------------| |
6963// | | | |
6964// | | | SubReq2 |
6965// | | |------------->|
6966// | | | |
6967// | | | SubResp1 |
6968// | | |<-------------|
6969// | | RESTNotif1 | |
6970// | |<-------------| |
6971// | | | |
6972// | | | SubResp2 |
6973// | | |<-------------|
6974// | RESTNotif2 | |
6975// |<------------------------| |
6976// | | | |
6977// | | [SUBS 1 DELETE] |
6978// | | | |
6979// | | [SUBS 2 DELETE] |
6980// | | | |
6981//
6982//-----------------------------------------------------------------------------
6983
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006984func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006985
6986 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006987 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006988 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006989 Counter{cSubReqToE2, 2},
6990 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03006991 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006992 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006993 Counter{cSubDelReqToE2, 2},
6994 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00006995 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00006996 })
6997
6998 // Req1
6999 var params *teststube2ap.RESTSubsReqParams = nil
7000
7001 //Subs Create
7002 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007003 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007004
7005 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7006
7007 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007008 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007009 params.SetMeid("RAN_NAME_1")
Konstantinos Archangelofbd9c98e2021-06-07 17:32:10 +00007010 actionDefinition := []int64{56782}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007011 params.SetSubActionDefinition(actionDefinition)
7012
7013 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007014 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007015 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7016 xappConn2.ExpectRESTNotification(t, restSubId2)
7017 e2termConn1.SendSubsResp(t, crereq, cremsg)
7018 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7019
7020 deleteXapp1Subscription(t, &restSubId1)
7021 deleteXapp2Subscription(t, &restSubId2)
7022
7023 waitSubsCleanup(t, e2SubsId1, 10)
7024 waitSubsCleanup(t, e2SubsId2, 10)
7025
7026 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007027 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007028}
7029
Anssi Mannila27385172021-12-22 09:41:54 +02007030//-----------------------------------------------------------------------------
7031// TestRESTSubReqReportSameActionDiffSubsAction
7032//
7033// stub stub stub
7034// +-------+ +-------+ +---------+ +---------+
7035// | xapp2 | | xapp1 | | submgr | | e2term |
7036// +-------+ +-------+ +---------+ +---------+
7037// | | | |
7038// | | RESTSubReq1 | |
7039// | |------------->| |
7040// | | RESTSubResp1 | |
7041// | |<-------------| |
7042// | | | |
7043// | | | SubReq1 |
7044// | | |------------->|
7045// | | | |
7046// | RESTSubReq2 | |
7047// |------------------------>| |
7048// | RESTSubResp2 | |
7049// |<------------------------| |
7050// | | | |
7051// | | | SubReq2 |
7052// | | |------------->|
7053// | | | |
7054// | | | SubResp1 |
7055// | | |<-------------|
7056// | | RESTNotif1 | |
7057// | |<-------------| |
7058// | | | |
7059// | | | SubResp2 |
7060// | | |<-------------|
7061// | RESTNotif2 | |
7062// |<------------------------| |
7063// | | | |
7064// | | [SUBS 1 DELETE] |
7065// | | | |
7066// | | [SUBS 2 DELETE] |
7067// | | | |
7068//
7069//-----------------------------------------------------------------------------
7070
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007071func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007072
7073 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007074 Counter{cRestSubReqFromXapp, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007075 Counter{cRestSubRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007076 Counter{cSubReqToE2, 2},
7077 Counter{cSubRespFromE2, 2},
Anssi Mannila316d8a12021-06-02 11:08:54 +03007078 Counter{cRestSubNotifToXapp, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007079 Counter{cRestSubDelReqFromXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007080 Counter{cSubDelReqToE2, 2},
7081 Counter{cSubDelRespFromE2, 2},
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00007082 Counter{cRestSubDelRespToXapp, 2},
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007083 })
7084
7085 // Req1
7086 var params *teststube2ap.RESTSubsReqParams = nil
7087
7088 //Subs Create
7089 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007090 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007091
7092 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
7093
7094 // Req2
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007095 params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007096 params.SetMeid("RAN_NAME_1")
7097 params.SetTimeToWait("w200ms")
7098 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007099 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007100 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7101 xappConn2.ExpectRESTNotification(t, restSubId2)
7102 e2termConn1.SendSubsResp(t, crereq, cremsg)
7103 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
7104
7105 deleteXapp1Subscription(t, &restSubId1)
7106 deleteXapp2Subscription(t, &restSubId2)
7107
7108 waitSubsCleanup(t, e2SubsId1, 10)
7109 waitSubsCleanup(t, e2SubsId2, 10)
7110
7111 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007112 mainCtrl.VerifyAllClean(t)
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00007113}
7114
Anssi Mannila51122392021-05-25 11:51:31 +03007115//-----------------------------------------------------------------------------
7116// TestRESTUnpackSubscriptionResponseDecodeFail
7117//
7118// stub stub
7119// +-------+ +---------+ +---------+
7120// | xapp | | submgr | | e2term |
7121// +-------+ +---------+ +---------+
7122// | | |
7123// | RestSubReq | |
7124// |---------------->| |
7125// | | |
7126// | RESTSubResp | |
7127// |<----------------| |
7128// | | |
7129// | | SubReq |
7130// | |------------->|
7131// | | |
7132// | | SubResp | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007133// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007134// | | |
7135// | | SubReq |
7136// | |------------->|
7137// | | |
7138// | | SubFail | Duplicated action
7139// | |<-------------|
7140// | RESTNotif (fail)| |
7141// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007142// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007143// | [SUBS DELETE] |
7144// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007145//
7146//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007147
Anssi Mannila51122392021-05-25 11:51:31 +03007148func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007149
7150 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7151 Counter{cRestSubReqFromXapp, 1},
7152 Counter{cRestSubRespToXapp, 1},
7153 Counter{cSubReqToE2, 1},
7154 Counter{cSubReqTimerExpiry, 1},
7155 Counter{cSubReReqToE2, 1},
7156 Counter{cSubRespFromE2, 1},
7157 Counter{cSubFailFromE2, 1},
7158 Counter{cRestSubFailNotifToXapp, 1},
7159 Counter{cRestSubDelReqFromXapp, 1},
7160 Counter{cRestSubDelRespToXapp, 1},
7161 })
7162
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007163 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007164
7165 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007166 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007167 restSubId := xappConn1.SendRESTSubsReq(t, params)
7168
7169 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7170 // Decode of this response fails which will result resending original request
7171 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
7172
7173 _, cremsg = e2termConn1.RecvSubsReq(t)
7174
Markku Virtanen55d2a282021-06-04 14:46:56 +03007175 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007176
7177 // Subscription already created in E2 Node.
7178 fparams := &teststube2ap.E2StubSubsFailParams{}
7179 fparams.Set(crereq)
7180 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7181 e2termConn1.SendSubsFail(t, fparams, cremsg)
7182
Anssi Mannila51122392021-05-25 11:51:31 +03007183 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007184 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007185
Anssi Mannilab43397e2021-11-16 12:06:16 +02007186 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7187
Anssi Mannila51122392021-05-25 11:51:31 +03007188 // Wait that subs is cleaned
7189 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7190
7191 xappConn1.TestMsgChanEmpty(t)
7192 e2termConn1.TestMsgChanEmpty(t)
7193 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007194 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007195 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007196}
7197
7198//-----------------------------------------------------------------------------
7199// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7200//
7201// stub stub
7202// +-------+ +---------+ +---------+
7203// | xapp | | submgr | | e2term |
7204// +-------+ +---------+ +---------+
7205// | | |
7206// | RestSubReq | |
7207// |---------------->| |
7208// | | |
7209// | RESTSubResp | |
7210// |<----------------| |
7211// | | |
7212// | | SubReq |
7213// | |------------->|
7214// | | |
7215// | | SubResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007216// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007217// | | |
7218// | | SubReq |
7219// | |------------->|
7220// | | |
7221// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007222// | |<-------------| No valid subscription found with subIds [0]
Anssi Mannila51122392021-05-25 11:51:31 +03007223// | RESTNotif (fail)| |
7224// |<----------------| |
7225// | | SubDelReq |
7226// | |------------->|
7227// | | |
7228// | | SubDelResp |
7229// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007230// | | |
7231// | [SUBS DELETE] |
7232// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007233//
7234//-----------------------------------------------------------------------------
Markku Virtanenb642a192021-06-09 09:08:14 +00007235
Anssi Mannila51122392021-05-25 11:51:31 +03007236func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007237
7238 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7239 Counter{cRestSubReqFromXapp, 1},
7240 Counter{cRestSubRespToXapp, 1},
7241 Counter{cSubReqToE2, 1},
7242 Counter{cSubReqTimerExpiry, 2},
7243 Counter{cSubReReqToE2, 1},
7244 Counter{cSubRespFromE2, 1},
7245 Counter{cSubFailFromE2, 1},
7246 Counter{cRestSubFailNotifToXapp, 1},
7247 Counter{cRestSubDelReqFromXapp, 1},
7248 Counter{cRestSubDelRespToXapp, 1},
7249 Counter{cSubDelReqToE2, 1},
7250 Counter{cSubDelRespFromE2, 1},
7251 })
7252
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007253 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007254
7255 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007256 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007257 restSubId := xappConn1.SendRESTSubsReq(t, params)
7258
7259 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7260
Anssi Mannila21782182021-12-10 10:56:02 +02007261 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007262 orgInstanceId := crereq.RequestId.InstanceId
7263 crereq.RequestId.InstanceId = 0
7264 e2termConn1.SendSubsResp(t, crereq, cremsg)
7265
7266 _, cremsg = e2termConn1.RecvSubsReq(t)
7267
Markku Virtanen55d2a282021-06-04 14:46:56 +03007268 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007269
Anssi Mannila21782182021-12-10 10:56:02 +02007270 // Subscription already created in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0
Anssi Mannila51122392021-05-25 11:51:31 +03007271 fparams := &teststube2ap.E2StubSubsFailParams{}
7272 fparams.Set(crereq)
7273 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7274 e2termConn1.SendSubsFail(t, fparams, cremsg)
7275
7276 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7277 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7278
7279 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007280 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007281
Anssi Mannilab43397e2021-11-16 12:06:16 +02007282 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7283
Anssi Mannila51122392021-05-25 11:51:31 +03007284 // Wait that subs is cleaned
7285 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
7286
7287 xappConn1.TestMsgChanEmpty(t)
7288 e2termConn1.TestMsgChanEmpty(t)
7289 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007290 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007291 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007292}
7293
7294//-----------------------------------------------------------------------------
7295// TestRESTUnpackSubscriptionResponseNoTransaction
7296//
7297// stub stub
7298// +-------+ +---------+ +---------+
7299// | xapp | | submgr | | e2term |
7300// +-------+ +---------+ +---------+
7301// | | |
7302// | RestSubReq | |
7303// |---------------->| |
7304// | | |
7305// | RESTSubResp | |
7306// |<----------------| |
7307// | | |
7308// | | SubReq |
7309// | |------------->|
7310// | | |
7311// | | SubResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007312// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007313// | | |
7314// | | SubReq |
7315// | |------------->|
7316// | | |
7317// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007318// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007319// | RESTNotif (fail)| |
7320// |<----------------| |
7321// | | SubDelReq |
7322// | |------------->|
7323// | | |
7324// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007325// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007326// | | |
7327// | | SubDelReq |
7328// | |------------->|
7329// | | |
7330// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007331// | |<-------------| Ongoing transaction not found.
7332// | | |
7333// | [SUBS DELETE] |
7334// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007335//
7336//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007337
Anssi Mannila51122392021-05-25 11:51:31 +03007338func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007339
7340 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7341 Counter{cRestSubReqFromXapp, 1},
7342 Counter{cRestSubRespToXapp, 1},
7343 Counter{cSubReqToE2, 1},
7344 Counter{cSubReqTimerExpiry, 2},
7345 Counter{cSubReReqToE2, 1},
7346 Counter{cSubRespFromE2, 1},
7347 Counter{cSubFailFromE2, 1},
7348 Counter{cRestSubFailNotifToXapp, 1},
7349 Counter{cRestSubDelReqFromXapp, 1},
7350 Counter{cRestSubDelRespToXapp, 1},
7351 Counter{cSubDelReqToE2, 1},
7352 Counter{cSubDelReqTimerExpiry, 2},
7353 Counter{cSubDelReReqToE2, 1},
7354 Counter{cSubDelRespFromE2, 2},
7355 })
7356
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007357 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007358
7359 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007360 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007361 restSubId := xappConn1.SendRESTSubsReq(t, params)
7362
7363 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7364
7365 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7366 // No transaction exist for this response which will result resending original request
7367 e2termConn1.SendSubsResp(t, crereq, cremsg)
7368
7369 _, cremsg = e2termConn1.RecvSubsReq(t)
7370
Markku Virtanen55d2a282021-06-04 14:46:56 +03007371 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007372
7373 // Subscription already created in E2 Node.
7374 fparams := &teststube2ap.E2StubSubsFailParams{}
7375 fparams.Set(crereq)
7376 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7377 e2termConn1.SendSubsFail(t, fparams, cremsg)
7378
7379 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7380 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7381
7382 // Resending happens because there no transaction
7383 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7384 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7385
7386 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007387 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007388
Anssi Mannilab43397e2021-11-16 12:06:16 +02007389 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7390
Anssi Mannila51122392021-05-25 11:51:31 +03007391 // Wait that subs is cleaned
7392 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7393
7394 xappConn1.TestMsgChanEmpty(t)
7395 e2termConn1.TestMsgChanEmpty(t)
7396 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007397 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007398 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007399}
7400
7401//-----------------------------------------------------------------------------
7402// TestRESTUnpackSubscriptionFailureDecodeFail
7403//
7404// stub stub
7405// +-------+ +---------+ +---------+
7406// | xapp | | submgr | | e2term |
7407// +-------+ +---------+ +---------+
7408// | | |
7409// | RestSubReq | |
7410// |---------------->| |
7411// | | |
7412// | RESTSubResp | |
7413// |<----------------| |
7414// | | |
7415// | | SubReq |
7416// | |------------->|
7417// | | |
7418// | | SubFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007419// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007420// | | |
7421// | | SubReq |
7422// | |------------->|
7423// | | |
7424// | | SubFail | Duplicated action
7425// | |<-------------|
7426// | RESTNotif (fail)| |
7427// |<----------------| |
Anssi Mannila51122392021-05-25 11:51:31 +03007428// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007429// | [SUBS DELETE] |
7430// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007431//
7432//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007433
Anssi Mannila51122392021-05-25 11:51:31 +03007434func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
Anssi Mannila21782182021-12-10 10:56:02 +02007435
7436 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7437 Counter{cRestSubReqFromXapp, 1},
7438 Counter{cRestSubRespToXapp, 1},
7439 Counter{cSubReqToE2, 1},
7440 Counter{cSubReqTimerExpiry, 1},
7441 Counter{cSubReReqToE2, 1},
7442 Counter{cSubFailFromE2, 2},
7443 Counter{cRestSubFailNotifToXapp, 1},
7444 Counter{cRestSubDelReqFromXapp, 1},
7445 Counter{cRestSubDelRespToXapp, 1},
7446 })
7447
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007448 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007449
7450 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007451 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007452 restSubId := xappConn1.SendRESTSubsReq(t, params)
7453
7454 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7455
7456 // Decode of this response fails which will result resending original request
7457 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
7458
7459 _, cremsg = e2termConn1.RecvSubsReq(t)
7460
Markku Virtanen55d2a282021-06-04 14:46:56 +03007461 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007462
7463 // Subscription already created in E2 Node.
7464 fparams := &teststube2ap.E2StubSubsFailParams{}
7465 fparams.Set(crereq)
7466 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7467 e2termConn1.SendSubsFail(t, fparams, cremsg)
7468
Anssi Mannila51122392021-05-25 11:51:31 +03007469 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007470 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007471
Anssi Mannilab43397e2021-11-16 12:06:16 +02007472 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7473
Anssi Mannila51122392021-05-25 11:51:31 +03007474 // Wait that subs is cleaned
7475 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7476
7477 xappConn1.TestMsgChanEmpty(t)
7478 e2termConn1.TestMsgChanEmpty(t)
7479 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007480 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007481 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007482}
7483
7484//-----------------------------------------------------------------------------
7485// TestRESTUnpackSubscriptionResponseUnknownInstanceId
7486//
7487// stub stub
7488// +-------+ +---------+ +---------+
7489// | xapp | | submgr | | e2term |
7490// +-------+ +---------+ +---------+
7491// | | |
7492// | RestSubReq | |
7493// |---------------->| |
7494// | | |
7495// | RESTSubResp | |
7496// |<----------------| |
7497// | | |
7498// | | SubReq |
7499// | |------------->|
7500// | | |
7501// | | SubFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007502// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007503// | | |
7504// | | SubReq |
7505// | |------------->|
7506// | | |
7507// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007508// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007509// | RESTNotif (fail)| |
7510// |<----------------| |
7511// | | SubDelReq |
7512// | |------------->|
7513// | | |
7514// | | SubDelResp |
7515// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007516// | | |
7517// | [SUBS DELETE] |
7518// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007519//
7520//-----------------------------------------------------------------------------
7521func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007522
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007523 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007524
Anssi Mannila21782182021-12-10 10:56:02 +02007525 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7526 Counter{cRestSubReqFromXapp, 1},
7527 Counter{cRestSubRespToXapp, 1},
7528 Counter{cSubReqToE2, 1},
7529 Counter{cSubReqTimerExpiry, 2},
7530 Counter{cSubReReqToE2, 1},
7531 Counter{cSubFailFromE2, 2},
7532 Counter{cRestSubFailNotifToXapp, 1},
7533 Counter{cRestSubDelReqFromXapp, 1},
7534 Counter{cRestSubDelRespToXapp, 1},
7535 Counter{cSubDelReqToE2, 1},
7536 Counter{cSubDelRespFromE2, 1},
7537 })
7538
Anssi Mannila51122392021-05-25 11:51:31 +03007539 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007540 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007541 restSubId := xappConn1.SendRESTSubsReq(t, params)
7542
7543 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7544
Anssi Mannila21782182021-12-10 10:56:02 +02007545 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03007546 fparams := &teststube2ap.E2StubSubsFailParams{}
7547 fparams.Set(crereq)
7548 fparams.Fail.RequestId.InstanceId = 0
7549 e2termConn1.SendSubsFail(t, fparams, cremsg)
7550
7551 _, cremsg = e2termConn1.RecvSubsReq(t)
7552
Markku Virtanen55d2a282021-06-04 14:46:56 +03007553 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007554
Anssi Mannila21782182021-12-10 10:56:02 +02007555 // Subscription already created in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0
Anssi Mannila51122392021-05-25 11:51:31 +03007556 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7557 e2termConn1.SendSubsFail(t, fparams, cremsg)
7558
7559 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7560 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7561
7562 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007563 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007564
Anssi Mannilab43397e2021-11-16 12:06:16 +02007565 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7566
Anssi Mannila51122392021-05-25 11:51:31 +03007567 // Wait that subs is cleaned
7568 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7569
7570 xappConn1.TestMsgChanEmpty(t)
7571 e2termConn1.TestMsgChanEmpty(t)
7572 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007573 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007574 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007575}
7576
7577//-----------------------------------------------------------------------------
7578// TestRESTUnpackSubscriptionFailureNoTransaction
7579//
7580// stub stub
7581// +-------+ +---------+ +---------+
7582// | xapp | | submgr | | e2term |
7583// +-------+ +---------+ +---------+
7584// | | |
7585// | RestSubReq | |
7586// |---------------->| |
7587// | | |
7588// | RESTSubResp | |
7589// |<----------------| |
7590// | | |
7591// | | SubReq |
7592// | |------------->|
7593// | | |
7594// | | SubFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007595// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007596// | | |
7597// | | SubReq |
7598// | |------------->|
7599// | | |
7600// | | SubFail | Duplicated action
Anssi Mannila21782182021-12-10 10:56:02 +02007601// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete
Anssi Mannila51122392021-05-25 11:51:31 +03007602// | RESTNotif (fail)| |
7603// |<----------------| |
7604// | | SubDelReq |
7605// | |------------->|
7606// | | |
7607// | | SubDelResp |
Anssi Mannila21782182021-12-10 10:56:02 +02007608// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
7609// | | |
7610// | | SubDelReq |
7611// | |------------->|
7612// | | |
7613// | | SubDelResp |
7614// | |<-------------| Ongoing transaction not found.
7615// | | |
7616// | [SUBS DELETE] |
7617// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007618//
7619//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007620
Anssi Mannila51122392021-05-25 11:51:31 +03007621func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
Anssi Mannila27385172021-12-22 09:41:54 +02007622
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007623 const subReqCount int = 1
Anssi Mannila51122392021-05-25 11:51:31 +03007624
Anssi Mannila21782182021-12-10 10:56:02 +02007625 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7626 Counter{cRestSubReqFromXapp, 1},
7627 Counter{cRestSubRespToXapp, 1},
7628 Counter{cSubReqToE2, 1},
7629 Counter{cSubReqTimerExpiry, 2},
7630 Counter{cSubReReqToE2, 1},
7631 Counter{cSubFailFromE2, 2},
7632 Counter{cRestSubFailNotifToXapp, 1},
7633 Counter{cRestSubDelReqFromXapp, 1},
7634 Counter{cRestSubDelRespToXapp, 1},
7635 Counter{cSubDelReqToE2, 1},
7636 Counter{cSubDelReqTimerExpiry, 2},
7637 Counter{cSubDelReReqToE2, 1},
7638 Counter{cSubDelRespFromE2, 2},
7639 })
7640
Anssi Mannila51122392021-05-25 11:51:31 +03007641 // Req
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00007642 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
Anssi Mannila51122392021-05-25 11:51:31 +03007643 restSubId := xappConn1.SendRESTSubsReq(t, params)
7644
7645 crereq, cremsg := e2termConn1.RecvSubsReq(t)
7646
7647 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
7648
7649 // No transaction exist for this response which will result resending original request
7650 fparams := &teststube2ap.E2StubSubsFailParams{}
7651 fparams.Set(crereq)
7652 e2termConn1.SendSubsFail(t, fparams, cremsg)
7653
7654 _, cremsg = e2termConn1.RecvSubsReq(t)
7655
Markku Virtanen55d2a282021-06-04 14:46:56 +03007656 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Anssi Mannila51122392021-05-25 11:51:31 +03007657
7658 // Subscription already created in E2 Node.
7659 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
7660 e2termConn1.SendSubsFail(t, fparams, cremsg)
7661
7662 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7663 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7664
7665 // Resending happens because there no transaction
7666 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7667 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7668
7669 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03007670 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
Anssi Mannila51122392021-05-25 11:51:31 +03007671
Anssi Mannilab43397e2021-11-16 12:06:16 +02007672 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7673
Anssi Mannila51122392021-05-25 11:51:31 +03007674 // Wait that subs is cleaned
7675 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
7676
7677 xappConn1.TestMsgChanEmpty(t)
7678 e2termConn1.TestMsgChanEmpty(t)
7679 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007680 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007681 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007682}
7683
7684//-----------------------------------------------------------------------------
7685// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
7686//
7687// stub stub
7688// +-------+ +---------+ +---------+
7689// | xapp | | submgr | | e2term |
7690// +-------+ +---------+ +---------+
7691// | | |
7692// | [SUBS CREATE] |
7693// | | |
7694// | | |
7695// | RESTSubDelReq | |
7696// |---------------->| |
7697// | | |
7698// | RESTSubDelResp | |
7699// |<----------------| |
7700// | | |
7701// | | SubDelReq |
7702// | |------------->|
7703// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007704// | | SubDelResp | ASN.1 decode fails.
7705// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007706// | | |
7707// | | SubDelReq |
7708// | |------------->|
7709// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007710// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007711// | |<-------------|
7712// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007713// | [SUBS DELETE] |
7714// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007715//
7716//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007717
Anssi Mannila51122392021-05-25 11:51:31 +03007718func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007719
Anssi Mannila21782182021-12-10 10:56:02 +02007720 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7721 Counter{cRestSubReqFromXapp, 1},
7722 Counter{cRestSubRespToXapp, 1},
7723 Counter{cSubReqToE2, 1},
7724 Counter{cSubRespFromE2, 1},
7725 Counter{cRestSubNotifToXapp, 1},
7726 Counter{cRestSubDelReqFromXapp, 1},
7727 Counter{cRestSubDelRespToXapp, 1},
7728 Counter{cSubDelReqToE2, 1},
7729 Counter{cSubDelReqTimerExpiry, 1},
7730 Counter{cSubDelReReqToE2, 1},
7731 Counter{cSubDelFailFromE2, 1},
7732 Counter{cSubDelRespFromE2, 1},
7733 })
7734
Anssi Mannila51122392021-05-25 11:51:31 +03007735 // Req
7736 var params *teststube2ap.RESTSubsReqParams = nil
7737 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7738
7739 // Del
7740 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7741
7742 // E2t: Receive 1st SubsDelReq
7743 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7744
7745 // Decode of this response fails which will result resending original request
Anssi Mannila21782182021-12-10 10:56:02 +02007746 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP)
Anssi Mannila51122392021-05-25 11:51:31 +03007747
7748 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
7749 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7750
7751 // Subscription does not exist in in E2 Node.
7752 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7753
7754 // Wait that subs is cleaned
7755 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7756
7757 xappConn1.TestMsgChanEmpty(t)
7758 e2termConn1.TestMsgChanEmpty(t)
7759 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007760 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007761 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007762}
7763
7764//-----------------------------------------------------------------------------
7765// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
7766//
7767// stub stub
7768// +-------+ +---------+ +---------+
7769// | xapp | | submgr | | e2term |
7770// +-------+ +---------+ +---------+
7771// | | |
7772// | [SUBS CREATE] |
7773// | | |
7774// | | |
7775// | RESTSubDelReq | |
7776// |---------------->| |
7777// | | |
7778// | RESTSubDelResp | |
7779// |<----------------| |
7780// | | |
7781// | | SubDelReq |
7782// | |------------->|
7783// | | |
7784// | | SubDelResp | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02007785// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007786// | | |
7787// | | SubDelReq |
7788// | |------------->|
7789// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007790// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007791// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007792// | | |
7793// | [SUBS DELETE] |
7794// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007795//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007796
Anssi Mannila51122392021-05-25 11:51:31 +03007797func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007798
Anssi Mannila21782182021-12-10 10:56:02 +02007799 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7800 Counter{cRestSubReqFromXapp, 1},
7801 Counter{cRestSubRespToXapp, 1},
7802 Counter{cSubReqToE2, 1},
7803 Counter{cSubRespFromE2, 1},
7804 Counter{cRestSubNotifToXapp, 1},
7805 Counter{cRestSubDelReqFromXapp, 1},
7806 Counter{cRestSubDelRespToXapp, 1},
7807 Counter{cSubDelReqToE2, 1},
7808 Counter{cSubDelReqTimerExpiry, 1},
7809 Counter{cSubDelReReqToE2, 1},
7810 Counter{cSubDelRespFromE2, 1},
7811 Counter{cSubDelFailFromE2, 1},
7812 })
7813
Anssi Mannila51122392021-05-25 11:51:31 +03007814 // Req
7815 var params *teststube2ap.RESTSubsReqParams = nil
7816 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7817
7818 // Del
7819 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7820
7821 // E2t: Receive 1st SubsDelReq
7822 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7823
7824 // Unknown instanceId in this response which will result resending original request
7825 delreq.RequestId.InstanceId = 0
7826 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7827
7828 // E2t: Receive 2nd SubsDelReq
7829 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7830
7831 // Subscription does not exist in in E2 Node.
7832 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7833
7834 // Wait that subs is cleaned
7835 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7836
7837 xappConn1.TestMsgChanEmpty(t)
7838 e2termConn1.TestMsgChanEmpty(t)
7839 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007840 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007841 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007842}
7843
7844//-----------------------------------------------------------------------------
7845// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
7846//
7847// stub stub
7848// +-------+ +---------+ +---------+
7849// | xapp | | submgr | | e2term |
7850// +-------+ +---------+ +---------+
7851// | | |
7852// | [SUBS CREATE] |
7853// | | |
7854// | | |
7855// | RESTSubDelReq | |
7856// |---------------->| |
7857// | | |
7858// | RESTSubDelResp | |
7859// |<----------------| |
7860// | | |
7861// | | SubDelReq |
7862// | |------------->|
7863// | | |
7864// | | SubDelResp | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02007865// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007866// | | |
7867// | | SubDelReq |
7868// | |------------->|
7869// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007870// | | SubDelFail | Subscription does exist any more in E2 node
7871// | |<-------------| Ongoing transaction not found. This will result timer expiry
7872// | | |
7873// | [SUBS DELETE] |
7874// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007875//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007876
Anssi Mannila51122392021-05-25 11:51:31 +03007877func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007878
Anssi Mannila21782182021-12-10 10:56:02 +02007879 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7880 Counter{cRestSubReqFromXapp, 1},
7881 Counter{cRestSubRespToXapp, 1},
7882 Counter{cSubReqToE2, 1},
7883 Counter{cSubRespFromE2, 1},
7884 Counter{cRestSubNotifToXapp, 1},
7885 Counter{cRestSubDelReqFromXapp, 1},
7886 Counter{cRestSubDelRespToXapp, 1},
7887 Counter{cSubDelReqToE2, 1},
7888 Counter{cSubDelReqTimerExpiry, 2},
7889 Counter{cSubDelReReqToE2, 1},
7890 Counter{cSubDelRespFromE2, 1},
7891 Counter{cSubDelFailFromE2, 1},
7892 })
7893
Anssi Mannila51122392021-05-25 11:51:31 +03007894 // Req
7895 var params *teststube2ap.RESTSubsReqParams = nil
7896 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7897
7898 // Del
7899 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7900
7901 // E2t: Receive 1st SubsDelReq
7902 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7903
7904 mainCtrl.MakeTransactionNil(t, e2SubsId)
7905
7906 // No transaction exist for this response which will result resending original request
7907 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
7908
7909 // E2t: Receive 2nd SubsDelReq
7910 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7911
7912 // Subscription does not exist in in E2 Node.
7913 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7914
7915 // Wait that subs is cleaned
7916 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7917
7918 xappConn1.TestMsgChanEmpty(t)
7919 e2termConn1.TestMsgChanEmpty(t)
7920 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007921 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02007922 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03007923}
7924
7925//-----------------------------------------------------------------------------
7926// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
7927//
7928// stub stub
7929// +-------+ +---------+ +---------+
7930// | xapp | | submgr | | e2term |
7931// +-------+ +---------+ +---------+
7932// | | |
7933// | [SUBS CREATE] |
7934// | | |
7935// | | |
7936// | RESTSubDelReq | |
7937// |---------------->| |
7938// | | |
7939// | RESTSubDelResp | |
7940// |<----------------| |
7941// | | |
7942// | | SubDelReq |
7943// | |------------->|
7944// | | |
7945// | | SubDelFail | ASN.1 decode fails
Anssi Mannila21782182021-12-10 10:56:02 +02007946// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03007947// | | |
7948// | | SubDelReq |
7949// | |------------->|
7950// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02007951// | | SubDelFail | Subscription does exist any more in E2 node
Anssi Mannila51122392021-05-25 11:51:31 +03007952// | |<-------------|
Anssi Mannila21782182021-12-10 10:56:02 +02007953// | | |
7954// | [SUBS DELETE] |
7955// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03007956//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02007957
Anssi Mannila51122392021-05-25 11:51:31 +03007958func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03007959
Anssi Mannila21782182021-12-10 10:56:02 +02007960 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
7961 Counter{cRestSubReqFromXapp, 1},
7962 Counter{cRestSubRespToXapp, 1},
7963 Counter{cSubReqToE2, 1},
7964 Counter{cSubRespFromE2, 1},
7965 Counter{cRestSubNotifToXapp, 1},
7966 Counter{cRestSubDelReqFromXapp, 1},
7967 Counter{cRestSubDelRespToXapp, 1},
7968 Counter{cSubDelReqToE2, 1},
7969 Counter{cSubDelReqTimerExpiry, 1},
7970 Counter{cSubDelReReqToE2, 1},
7971 Counter{cSubDelFailFromE2, 2},
7972 })
7973
Anssi Mannila51122392021-05-25 11:51:31 +03007974 // Req
7975 var params *teststube2ap.RESTSubsReqParams = nil
7976 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
7977
7978 // Del
7979 xappConn1.SendRESTSubsDelReq(t, &restSubId)
7980
7981 // E2t: Receive 1st SubsDelReq
7982 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
7983
7984 // Decode of this response fails which will result resending original request
7985 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
7986
7987 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
7988 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
7989
7990 // Subscription does not exist in in E2 Node.
7991 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
7992
7993 // Wait that subs is cleaned
7994 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
7995
7996 xappConn1.TestMsgChanEmpty(t)
7997 e2termConn1.TestMsgChanEmpty(t)
7998 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02007999 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008000 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008001}
8002
8003//-----------------------------------------------------------------------------
8004// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
8005//
8006// stub stub
8007// +-------+ +---------+ +---------+
8008// | xapp | | submgr | | e2term |
8009// +-------+ +---------+ +---------+
8010// | | |
8011// | [SUBS CREATE] |
8012// | | |
8013// | | |
8014// | RESTSubDelReq | |
8015// |---------------->| |
8016// | | |
8017// | RESTSubDelResp | |
8018// |<----------------| |
8019// | | |
8020// | | SubDelReq |
8021// | |------------->|
8022// | | |
8023// | | SubDelFail | Unknown instanceId
Anssi Mannila21782182021-12-10 10:56:02 +02008024// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008025// | | |
8026// | | SubDelReq |
8027// | |------------->|
8028// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008029// | | SubDelFail | Subscription does exist any more in E2 node
8030// | |<-------------| No valid subscription found with subIds [0].
8031// | | |
8032// | [SUBS DELETE] |
8033// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008034//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008035
Anssi Mannila51122392021-05-25 11:51:31 +03008036func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008037
Anssi Mannila21782182021-12-10 10:56:02 +02008038 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8039 Counter{cRestSubReqFromXapp, 1},
8040 Counter{cRestSubRespToXapp, 1},
8041 Counter{cSubReqToE2, 1},
8042 Counter{cSubRespFromE2, 1},
8043 Counter{cRestSubNotifToXapp, 1},
8044 Counter{cRestSubDelReqFromXapp, 1},
8045 Counter{cRestSubDelRespToXapp, 1},
8046 Counter{cSubDelReqToE2, 1},
8047 Counter{cSubDelReqTimerExpiry, 1},
8048 Counter{cSubDelReReqToE2, 1},
8049 Counter{cSubDelFailFromE2, 2},
8050 })
8051
Anssi Mannila51122392021-05-25 11:51:31 +03008052 // Req
8053 var params *teststube2ap.RESTSubsReqParams = nil
8054 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8055
8056 // Del
8057 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8058
8059 // E2t: Receive 1st SubsDelReq
8060 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8061
Anssi Mannila21782182021-12-10 10:56:02 +02008062 // Unknown instanceId 0 in this response which will result resending original request
Anssi Mannila51122392021-05-25 11:51:31 +03008063 delreq.RequestId.InstanceId = 0
8064 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8065
8066 // E2t: Receive 2nd SubsDelReq
8067 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8068
Anssi Mannila21782182021-12-10 10:56:02 +02008069 // Subscription does not exist in in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0
Anssi Mannila51122392021-05-25 11:51:31 +03008070 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8071
8072 // Wait that subs is cleaned
8073 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8074
8075 xappConn1.TestMsgChanEmpty(t)
8076 e2termConn1.TestMsgChanEmpty(t)
8077 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008078 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008079 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008080}
8081
8082//-----------------------------------------------------------------------------
8083// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
8084//
8085// stub stub
8086// +-------+ +---------+ +---------+
8087// | xapp | | submgr | | e2term |
8088// +-------+ +---------+ +---------+
8089// | | |
8090// | [SUBS CREATE] |
8091// | | |
8092// | | |
8093// | RESTSubDelReq | |
8094// |---------------->| |
8095// | | |
8096// | RESTSubDelResp | |
8097// |<----------------| |
8098// | | |
8099// | | SubDelReq |
8100// | |------------->|
8101// | | |
8102// | | SubDelFail | No transaction for the response
Anssi Mannila21782182021-12-10 10:56:02 +02008103// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
Anssi Mannila51122392021-05-25 11:51:31 +03008104// | | |
8105// | | SubDelReq |
8106// | |------------->|
8107// | | |
Anssi Mannila21782182021-12-10 10:56:02 +02008108// | | SubDelFail | Subscription does exist any more in E2 node
8109// | |<-------------| Ongoing transaction not found. This will result timer expiry
8110// | | |
8111// | [SUBS DELETE] |
8112// | | |
Anssi Mannila51122392021-05-25 11:51:31 +03008113//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008114
Anssi Mannila51122392021-05-25 11:51:31 +03008115func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
Anssi Mannila51122392021-05-25 11:51:31 +03008116
Anssi Mannila21782182021-12-10 10:56:02 +02008117 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8118 Counter{cRestSubReqFromXapp, 1},
8119 Counter{cRestSubRespToXapp, 1},
8120 Counter{cSubReqToE2, 1},
8121 Counter{cSubRespFromE2, 1},
8122 Counter{cRestSubNotifToXapp, 1},
8123 Counter{cRestSubDelReqFromXapp, 1},
8124 Counter{cRestSubDelRespToXapp, 1},
8125 Counter{cSubDelReqToE2, 1},
8126 Counter{cSubDelReqTimerExpiry, 2},
8127 Counter{cSubDelReReqToE2, 1},
8128 Counter{cSubDelFailFromE2, 2},
8129 })
8130
Anssi Mannila51122392021-05-25 11:51:31 +03008131 // Req
8132 var params *teststube2ap.RESTSubsReqParams = nil
8133 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
8134
8135 // Del
8136 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8137
8138 // E2t: Receive 1st SubsDelReq
8139 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8140
8141 mainCtrl.MakeTransactionNil(t, e2SubsId)
8142
8143 // No transaction exist for this response which will result resending original request
8144 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8145
8146 // E2t: Receive 2nd SubsDelReq
8147 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
8148
8149 // Subscription does not exist in in E2 Node.
8150 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
8151
8152 // Wait that subs is cleaned
8153 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
8154
8155 xappConn1.TestMsgChanEmpty(t)
8156 e2termConn1.TestMsgChanEmpty(t)
8157 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008158 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008159 mainCtrl.VerifyCounterValues(t)
Anssi Mannila51122392021-05-25 11:51:31 +03008160}
8161
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008162//-----------------------------------------------------------------------------
8163// TestRESTSubReqFailAsn1PackSubReqError
8164//
8165// stub stub
8166// +-------+ +---------+ +---------+
8167// | xapp | | submgr | | e2term |
8168// +-------+ +---------+ +---------+
8169// | | |
8170// | RESTSubReq | |
8171// |---------------->| |
8172// | | |
8173// | RESTSubResp | |
8174// |<----------------| |
8175// | | |
8176// | ASN.1 encode fails |
8177// | | |
8178// | | SubDelReq |
8179// | |------------->|
8180// | | |
8181// | | SubDelFail |
8182// | |<-------------|
8183// | | |
8184// | RESTNotif | |
8185// | unsuccess | |
8186// |<----------------| |
8187// | | |
8188// | [SUBS DELETE] |
8189// | | |
8190//
8191//-----------------------------------------------------------------------------
Anssi Mannila27385172021-12-22 09:41:54 +02008192
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008193func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
8194
8195 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Konstantinos Archangelof27433e72021-05-31 08:30:35 +00008196 Counter{cRestSubReqFromXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008197 Counter{cRestSubRespToXapp, 1},
Anssi Mannila316d8a12021-06-02 11:08:54 +03008198 Counter{cRestSubFailNotifToXapp, 1},
Anssi Mannilab43397e2021-11-16 12:06:16 +02008199 Counter{cRestSubDelReqFromXapp, 1},
8200 Counter{cRestSubDelRespToXapp, 1},
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008201 })
8202
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008203 const subReqCount int = 1
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008204
8205 var params *teststube2ap.RESTSubsReqParams = nil
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008206 params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008207 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
8208
8209 // Req
8210 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008211 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008212
8213 // E2t: Receive SubsDelReq
Markku Virtanen55d2a282021-06-04 14:46:56 +03008214 xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008215
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008216 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008217 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008218
8219 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008220
8221 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8222
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008223 // Wait that subs is cleaned
8224 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008225 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008226 mainCtrl.VerifyCounterValues(t)
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00008227}
8228
Anssi Mannila27385172021-12-22 09:41:54 +02008229//-----------------------------------------------------------------------------
8230// TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction
8231//
8232// stub stub
8233// +-------+ +---------+ +---------+
8234// | xapp | | submgr | | e2term |
8235// +-------+ +---------+ +---------+
8236// | | |
8237// | RESTSubReq | |
8238// |---------------->| |
8239// | | |
8240// | RESTSubResp | |
8241// |<----------------| |
8242// | | SubReq |
8243// | |------------->|
8244// | | |
8245// | | SubResp |
8246// | |<-------------|
8247// | | |
8248// | RESTNotif | |
8249// |<----------------| |
8250// | | |
8251// | RESTSubReq | | Policy modification
8252// |---------------->| |
8253// | | |
8254// | RESTSubResp | |
8255// |<----------------| |
8256// | | SubReq |
8257// | |------------->|
8258// | | |
8259// | | |
8260// | RESTNotif(Unsuccessful) | E2 timeout
8261// |<----------------| |
8262// | | |
8263// | RESTSubDelReq | |
8264// |---------------->| |
8265// | | |
8266// | | SubDelReq |
8267// | |------------->|
8268// | | |
8269// | | SubDelResp |
8270// | |<-------------|
8271// | | |
8272// | RESTSubDelResp | |
8273// |<----------------| |
8274//
8275//-----------------------------------------------------------------------------
8276
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008277func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008278
8279 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8280 Counter{cRestSubReqFromXapp, 2},
8281 Counter{cRestSubRespToXapp, 2},
8282 Counter{cSubReqToE2, 2},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008283 Counter{cSubReqTimerExpiry, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008284 Counter{cSubRespFromE2, 1},
8285 Counter{cRestSubNotifToXapp, 1},
8286 Counter{cRestSubFailNotifToXapp, 1},
8287 Counter{cRestSubDelReqFromXapp, 1},
8288 Counter{cSubDelReqToE2, 1},
8289 Counter{cSubDelRespFromE2, 1},
8290 Counter{cRestSubDelRespToXapp, 1},
8291 })
8292
8293 const e2Timeout int64 = 1
8294 const e2RetryCount int64 = 0
8295 const routingNeeded bool = false
8296
8297 // Req1
8298 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8299 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8300
8301 // Subs Create
8302 restSubId := xappConn1.SendRESTSubsReq(t, params)
8303 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8304
8305 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8306 xappConn1.ExpectRESTNotification(t, restSubId)
8307 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8308 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8309 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8310
8311 // Policy change
8312 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8313 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8314 params.SetSubscriptionID(&restSubId)
8315 params.SetTimeToWait("w200ms")
8316 restSubId = xappConn1.SendRESTSubsReq(t, params)
8317 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8318
8319 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8320 xappConn1.ExpectRESTNotification(t, restSubId)
Anssi Mannila53dbe7e2021-10-06 14:21:48 +03008321 // SubsResp is missing, e2SubsId will be 0
8322 zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8323 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008324
8325 // Del
8326 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8327 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8328 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8329
8330 waitSubsCleanup(t, e2SubsId, 10)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008331 mainCtrl.VerifyAllClean(t)
Anssi Mannila21782182021-12-10 10:56:02 +02008332 mainCtrl.VerifyCounterValues(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008333}
8334
8335//-----------------------------------------------------------------------------
8336// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
8337//
8338// stub stub
8339// +-------+ +---------+ +---------+
8340// | xapp | | submgr | | e2term |
8341// +-------+ +---------+ +---------+
8342// | | |
8343// | RESTSubReq | |
8344// |---------------->| |
8345// | | |
8346// | RESTSubResp | |
8347// |<----------------| |
8348// | | SubReq |
8349// | |------------->|
8350// | | |
8351// | | SubResp |
8352// | |<-------------|
8353// | | |
8354// | RESTNotif | |
8355// |<----------------| |
8356// | | |
8357// | RESTSubReq | |
8358// |---------------->| |
8359// | | |
8360// | RESTSubResp | |
8361// |<----------------| |
8362// | | SubReq |
8363// | |------------->|
8364// | |
8365// | Submgr restart |
8366// | | |
8367// | RESTSubDelReq | |
8368// |---------------->| |
8369// | | |
8370// | | SubDelReq |
8371// | |------------->|
8372// | | |
8373// | | SubDelResp |
8374// | |<-------------|
8375// | | |
8376// | RESTSubDelResp | |
8377// |<----------------| |
8378//
8379//-----------------------------------------------------------------------------
8380
8381func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008382
8383 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
8384 Counter{cRestSubReqFromXapp, 2},
8385 Counter{cRestSubRespToXapp, 2},
8386 Counter{cSubReqToE2, 2},
8387 Counter{cSubRespFromE2, 1},
8388 Counter{cRestSubNotifToXapp, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008389 Counter{cRestSubDelReqFromXapp, 1},
8390 Counter{cSubDelReqToE2, 1},
Anssi Mannila3d80b722021-11-12 13:17:15 +02008391 Counter{cSubDelRespFromE2, 1},
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008392 Counter{cRestSubDelRespToXapp, 1},
8393 })
8394
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008395 const e2Timeout int64 = 1
8396 const e2RetryCount int64 = 0
8397 const routingNeeded bool = false
8398
8399 // Req1
8400 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8401 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8402 // Create subscription
8403 restSubId := xappConn1.SendRESTSubsReq(t, params)
8404 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8405
8406 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8407 xappConn1.ExpectRESTNotification(t, restSubId)
8408 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8409 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
8410 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
8411
8412 // Check subscription
8413 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8414
8415 // Policy change
8416 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
8417 params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
8418 params.SetSubscriptionID(&restSubId)
8419 params.SetTimeToWait("w200ms")
8420 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
8421 restSubId = xappConn1.SendRESTSubsReq(t, params)
8422 xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
8423
8424 crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
8425 mainCtrl.SetResetTestFlag(t, false)
8426
8427 // SubsResp is missing due to submgr restart
8428
8429 mainCtrl.SimulateRestart(t)
8430 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
8431
Anssi Mannila54838ed2021-11-19 11:25:01 +02008432 // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
8433 // That needs to be completed before successful subscription query is possible
8434 <-time.After(time.Second * 1)
8435
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008436 // Check subscription
8437 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
8438
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008439 // Delete subscription
8440 xappConn1.SendRESTSubsDelReq(t, &restSubId)
8441 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8442 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8443
8444 //Wait that subs is cleaned
8445 waitSubsCleanup(t, e2SubsId, 10)
8446
8447 mainCtrl.VerifyCounterValues(t)
Anssi Mannilab43397e2021-11-16 12:06:16 +02008448 mainCtrl.VerifyAllClean(t)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008449}
8450
archaggeafbf95f2021-04-14 08:54:05 +03008451////////////////////////////////////////////////////////////////////////////////////
8452// Services for UT cases
8453////////////////////////////////////////////////////////////////////////////////////
8454const subReqCount int = 1
archaggeafbf95f2021-04-14 08:54:05 +03008455const host string = "localhost"
8456
8457func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
8458 if params == nil {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008459 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008460 }
8461 restSubId := fromXappConn.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008462 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008463
8464 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
8465 fromXappConn.ExpectRESTNotification(t, restSubId)
8466 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
8467 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008468 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008469
8470 return restSubId, e2SubsId
8471}
8472
8473func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
8474
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008475 params := xappConn2.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008476 if meid != "" {
8477 params.SetMeid(meid)
8478 }
8479 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
8480 restSubId := xappConn2.SendRESTSubsReq(t, params)
8481 xappConn2.ExpectRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008482 xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008483 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008484 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008485
8486 return restSubId, e2SubsId
8487}
8488
8489func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008490
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008491 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008492 restSubId := xappConn1.SendRESTSubsReq(t, params)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008493 xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03008494
8495 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8496 xappConn1.ExpectRESTNotification(t, restSubId)
8497 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
8498 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008499 xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008500
8501 return restSubId, e2SubsId
8502}
8503
8504func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
Konstantinos Archangelofc9ef0ba2021-05-26 09:52:25 +00008505 params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
archaggeafbf95f2021-04-14 08:54:05 +03008506 restSubId := xappConn1.SendRESTSubsReq(t, params)
8507
8508 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
8509 fparams1 := &teststube2ap.E2StubSubsFailParams{}
8510 fparams1.Set(crereq1)
8511 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
8512
8513 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
8514 xappConn1.ExpectRESTNotification(t, restSubId)
8515 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
8516 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008517 xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
archaggeafbf95f2021-04-14 08:54:05 +03008518
8519 return restSubId, e2SubsId
8520}
8521
8522func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
8523 fromXappConn.SendRESTSubsDelReq(t, restSubId)
8524 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8525 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8526}
8527
8528func deleteXapp1Subscription(t *testing.T, restSubId *string) {
8529 xappConn1.SendRESTSubsDelReq(t, restSubId)
8530 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8531 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8532}
8533
8534func deleteXapp2Subscription(t *testing.T, restSubId *string) {
8535 xappConn2.SendRESTSubsDelReq(t, restSubId)
8536 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
8537 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
8538}
8539
8540func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
8541 resp, _ := xapp.Subscription.QuerySubscriptions()
Anssi Mannila54838ed2021-11-19 11:25:01 +02008542 assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
8543 assert.Equal(t, meid, resp[0].Meid)
8544 assert.Equal(t, endpoint, resp[0].ClientEndpoint)
archaggeafbf95f2021-04-14 08:54:05 +03008545}
8546
8547func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
8548 //Wait that subs is cleaned
8549 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
8550
8551 xappConn1.TestMsgChanEmpty(t)
8552 xappConn2.TestMsgChanEmpty(t)
8553 e2termConn1.TestMsgChanEmpty(t)
8554 mainCtrl.wait_registry_empty(t, timeout)
8555}
8556
8557func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
8558
8559 var e2SubsId []uint32
8560
8561 for i := 0; i < count; i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008562 xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008563 crereq, cremsg := toE2termConn.RecvSubsReq(t)
8564 fromXappConn.ExpectRESTNotification(t, restSubId)
8565 toE2termConn.SendSubsResp(t, crereq, cremsg)
8566 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
8567 e2SubsId = append(e2SubsId, instanceId)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008568 xapp.Logger.Debug("TEST: %v", e2SubsId)
8569 xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008570 <-time.After(100 * time.Millisecond)
8571 }
8572 return e2SubsId
8573}
8574
8575func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
8576
8577 for i := 0; i < len(e2SubsIds); i++ {
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008578 xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008579 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
8580 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
8581 <-time.After(1 * time.Second)
Anssi Mannilaf682ace2021-09-28 13:11:25 +03008582 xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
archaggeafbf95f2021-04-14 08:54:05 +03008583 <-time.After(100 * time.Millisecond)
8584 }
8585
8586 // Wait that subs is cleaned
8587 for i := 0; i < len(e2SubsIds); i++ {
8588 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
8589 }
8590
8591}